[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark 6ef0b47bd2 12/16: fix: revert-buffer duplica
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark 6ef0b47bd2 12/16: fix: revert-buffer duplicates highlights |
Date: |
Sat, 29 Jul 2023 18:58:48 -0400 (EDT) |
branch: externals/org-remark
commit 6ef0b47bd2ac7426fdf89d55b3e6680ffccf5bf7
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
fix: revert-buffer duplicates highlights
Before this change, `revert-buffer` would duplicate the highlights in
the buffer -- visibly duplicating the icons. Now this is fixed.
---
org-remark.el | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/org-remark.el b/org-remark.el
index 78404fc880..67529efa9c 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -6,7 +6,7 @@
;; URL: https://github.com/nobiot/org-remark
;; Version: 1.1.0
;; Created: 22 December 2020
-;; Last modified: 21 July 2023
+;; Last modified: 29 July 2023
;; Package-Requires: ((emacs "27.1") (org "9.4"))
;; Keywords: org-mode, annotation, note-taking, marginal-notes, wp,
@@ -327,7 +327,8 @@ recommended to turn it on as part of Emacs initialization.
(org-remark-highlights-load)
(add-hook 'after-save-hook #'org-remark-save nil t)
(add-hook 'org-remark-highlight-link-to-source-functions
- #'org-remark-highlight-link-to-source-default 80))
+ #'org-remark-highlight-link-to-source-default 80)
+ (add-hook 'after-revert-hook #'org-remark-highlights-load))
(t
;; Deactivate
(when org-remark-highlights
@@ -336,7 +337,8 @@ recommended to turn it on as part of Emacs initialization.
(setq org-remark-highlights nil)
(remove-hook 'after-save-hook #'org-remark-save t)
(remove-hook 'org-remark-highlight-link-to-source-functions
- #'org-remark-highlight-link-to-source-default))))
+ #'org-remark-highlight-link-to-source-default)
+ (remove-hook 'after-revert-hook #'org-remark-highlights-load))))
;;;; Org-remark Menu
@@ -1385,12 +1387,11 @@ process."
;; "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
+
+ ;; In order to update the highlight overlays, 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))
+ (org-remark-highlights-clear)
;; Loop highlights and add them to the current buffer
(let (overlays) ;; highlight overlays
(when-let* ((notes-filename (org-remark-notes-get-file-name))
@@ -1412,6 +1413,16 @@ process."
;; if there is no overlays loaded, return nil
nil)))))
+(defun org-remark-highlights-clear ()
+ "Delete all highlights in the buffer.
+
+This function also set `org-remark-highlights' to nil."
+ (setq org-remark-highlights nil)
+ (org-with-wide-buffer
+ (dolist (ov (overlays-in (point-min) (point-max)))
+ (when (overlay-get ov 'org-remark-id)
+ (delete-overlay ov)))))
+
(defun org-remark-highlights-get-positions (&optional reverse)
"Return list of the beginning point of all visible highlights in this buffer.
By default, the list is in ascending order. If REVERSE is
@@ -1624,7 +1635,8 @@ function extends the behavior and looks for the word at
point"
(user-error "No region selected and the cursor is not on a word"))))
(defun org-remark-string= (s1 s2)
- "Like `string=' but remove newlines and spaces before compare."
+ "Like `string=' but remove newlines and spaces before compare.
+Return t if S1 and S2 are an identical string."
(string=
;; Cater to the case when the text is divided by a newline
;; character \n. Remove all spaces and newline chars
- [elpa] externals/org-remark 05d280b5fa 05/16: fix(legacy): compilation warning #66, (continued)
- [elpa] externals/org-remark 05d280b5fa 05/16: fix(legacy): compilation warning #66, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark ef14f4e600 02/16: Merge branch 'dev/nov.el' into dev/1.2.0, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark 6333938f12 11/16: feat: Allow function to render icons, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark efe2c4d504 13/16: refactor: logic to add an icon, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark 346fe9cf69 15/16: refactor: separate org-remark-icon into its own feature/file, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark ec693af64a 01/16: feat: org-remark-info-mode to support Info-mode #65, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark 87404b78d3 14/16: Merge branch 'main' into dev/1.2.0, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark b44092e6cf 06/16: style: make org-remark-highlight-save obsolete and add alias, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark a0624e2ebc 04/16: fix: make sure new top-level headline is appended, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark c6941579e3 09/16: refactor(nov): nov can defer loading org-remark, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark 6ef0b47bd2 12/16: fix: revert-buffer duplicates highlights,
ELPA Syncer <=
- [elpa] externals/org-remark c701d9ceaa 07/16: style: silence compiler warning, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark 8ae3c426e0 08/16: fix: default highlighter color for dark theme, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark 0e05580760 10/16: feat(info): Advice to support rendering Info nodes in same buffer, ELPA Syncer, 2023/07/29
- [elpa] externals/org-remark d73c72cfc3 16/16: docs(info): Add copyright and commentary to source header, ELPA Syncer, 2023/07/29