[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark 6ebbce9239 37/67: fix(load): clear obsolete
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark 6ebbce9239 37/67: fix(load): clear obsolete highlight overlays before loading |
Date: |
Sat, 22 Jul 2023 06:59:02 -0400 (EDT) |
branch: externals/org-remark
commit 6ebbce9239265d2a562dd3f9953a164e6dda959b
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
fix(load): clear obsolete highlight overlays before loading
Some major modes such as nov.el reuse the buffer for a different "file".
In this case, obsolete highlight overlays linger when you switch from
one file to another. Thus, we need to begin loading by clearing the
highlight overlays first.
---
org-remark.el | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/org-remark.el b/org-remark.el
index 9dec7a440c..3945550e0d 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -60,9 +60,9 @@
(defface org-remark-highlighter-warning
'((((class color) (min-colors 88) (background light))
- :background "#fff3da")
+ :foreground "#604000" :background "#fff29a")
(((class color) (min-colors 88) (background dark))
- :background "#fff3da")
+ :foreground: "#e2d980" :background "#693200")
(t
:inherit warning))
"Face for highlighter warning.
@@ -1030,7 +1030,8 @@ Assume the current buffer is the source buffer."
(overlay-put highlight '*org-remark-note-body
(plist-get plist :body))
(when (plist-get plist :body)
- (overlay-put highlight 'after-string (propertize "📔" 'face
'org-remark-highlighter)))
+ (let ((face (overlay-get highlight 'face)))
+ (overlay-put highlight 'after-string (propertize "⁽*⁾" 'face face))))
(overlay-put highlight '*org-remark-original-text
(plist-get plist :original-text)))
@@ -1069,8 +1070,10 @@ Adjustment is done by TEXT, which should be the original
text of the highlight."
(when (re-search-forward text paragraph-end :noerror)
(move-overlay highlight (match-beginning 0) (match-end 0))))
;; Even if the new location could not be found, indicate that it is
different to the original
- (overlay-put highlight 'after-string
- (propertize "!?" 'face 'org-remark-highlighter-warning)))))
+ (let ((afterstring (overlay-get highlight 'after-string)))
+ (overlay-put highlight 'after-string
+ (concat afterstring
+ (propertize "⁽ᵟ⁾" 'face
'org-remark-highlighter-warning)))))))
(defun org-remark-highlight-link-to-source-default (filename point)
"Return Org link string for the source when adding a highlight.
@@ -1332,6 +1335,16 @@ configuration. It automatically turns on
`org-remark-mode'.
Otherwise, do not forget to turn on `org-remark-mode' manually to
load the highlights"
+ ;; Some major modes such as nov.el reuse the buffer for a different
+ ;; "file". In this case, obsolete highlight overlays linger when you
+ ;; switch from one file to another. Thus, we need to begin loading by
+ ;; clearing the highlight overlays first.
+ ;;(org-remark-highlights-housekeep)
+ ;; In order to update the overlay, it is first gets deleted
+ ;; and newly loaded. This way, we avoid duplicate of the same
+ ;; highlight.
+ (dolist (ov org-remark-highlights)
+ (org-remark-highlight-clear ov))
;; Loop highlights and add them to the current buffer
(let (overlays) ;; highlight overlays
(when-let* ((notes-filename (org-remark-notes-get-file-name))
@@ -1343,18 +1356,7 @@ load the highlights"
(let* ((location (plist-get highlight :location))
(beg (car location))
(end (cdr location))
- (id (plist-get highlight :id))
- (ov (org-remark-find-overlay-in beg end id)))
- ;; In order to update the overlay, it is first gets deleted
- ;; and newly loaded. This way, we avoid duplicate of the same
- ;; highlight.
-
- ;; FIXME Currently the when clause is used to guard against
- ;; the case where a highlight overlay is not found. It should
- ;; be an edge case but the highlight could have moved to a
- ;; completely new location where the old location does not
- ;; overlap with the new location at all.
- (when ov (org-remark-highlight-clear ov))
+ (id (plist-get highlight :id)))
(push (org-remark-highlight-load highlight) overlays)))
(unless update (org-remark-notes-setup notes-buf source-buf))
(if overlays
- [elpa] externals/org-remark e4c42d7fd4 56/67: docs: Fix footnote (remove), (continued)
- [elpa] externals/org-remark e4c42d7fd4 56/67: docs: Fix footnote (remove), ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 536c2cca1e 63/67: fix: add-headline. Location of new highlight notes was wrong, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 883f948bbf 66/67: style: make org-remark-highlight-save obsolete and add alias, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 3216d951fc 09/67: feat: nov.el title and nov-file-name in H1 of the notes, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 81bc062482 10/67: refactor(nov): highlight-save-book-entry, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark eed28d7b8d 26/67: Merge branch 'main' into dev/nov.el, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark e5de684b67 33/67: fix: adjust location of highlight, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 5b76fa930a 49/67: refactor(load): make load process robust., ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark b50d0f7688 52/67: refactor: rename highlights-after-load-hook to -functions, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 07f5838c40 61/67: fix: Add headlines in the correct order and in the correct headline, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 6ebbce9239 37/67: fix(load): clear obsolete highlight overlays before loading,
ELPA Syncer <=
- [elpa] externals/org-remark 0ec9d2f1c2 41/67: refactor(headline-add): WIP, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 1c2f9ed822 46/67: feat: toggle icons, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 36df818752 55/67: docs: Update user manaul, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 642d4b489f 13/67: docs: updated NEWS, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 2a10b3d75a 17/67: refactor: adjust-positions, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 09d95e7519 20/67: Merge branch 'main' into dev/nov.el, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 52bc575bb9 28/67: docs: comments and docstring, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark e10a00b426 35/67: feat: add icon for highlights with annotation body text #64, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 41f90c53a8 59/67: refactor: Add 'org-remark-string=' for highlight-adjust-positions, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 2bd53de493 60/67: refactor: Set fn to hook org-remark-highlights-after-load-functions, ELPA Syncer, 2023/07/22