emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org-remark 41f90c53a8 59/67: refactor: Add 'org-remark-


From: ELPA Syncer
Subject: [elpa] externals/org-remark 41f90c53a8 59/67: refactor: Add 'org-remark-string=' for highlight-adjust-positions
Date: Sat, 22 Jul 2023 06:59:04 -0400 (EDT)

branch: externals/org-remark
commit 41f90c53a8ad177cad27296ffaf40b55b02a7340
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>

    refactor: Add 'org-remark-string=' for highlight-adjust-positions
---
 org-remark.el | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/org-remark.el b/org-remark.el
index 7aa0692829..33070306d9 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: 14 July 2023
+;; Last modified: 15 July 2023
 ;; Package-Requires: ((emacs "27.1") (org "9.4"))
 ;; Keywords: org-mode, annotation, note-taking, marginal-notes, wp,
 
@@ -1085,13 +1085,7 @@ It searches for TEXT, which should be the original text 
of the highlight."
          (end (overlay-end highlight))
          (paragraph-beg)(paragraph-end))
     (org-with-wide-buffer
-     (unless (string=
-              ;; Cater to the case when the text is divided by a newline
-              ;; character \n. Remove all spaces and newline chars
-              ;; before comparing the strings.
-              (replace-regexp-in-string "[\n ]" ""
-                                        (buffer-substring beg end))
-              (replace-regexp-in-string "[\n ]" "" text))
+     (unless (org-remark-string= (buffer-substring-no-properties beg end) text)
        ;; Look at one paragraph ahead as it is possible that the
        ;; position has been displaced across a paragraph
        (goto-char beg) (backward-paragraph 2) (setq paragraph-beg (point))
@@ -1534,9 +1528,10 @@ extensions."
       ;; it is different to the current
       ;; TODO fix the highlight comparision logic
       (when (and highlight-text
-                 (not (string= highlight-text
-                               (buffer-substring-no-properties
-                                (overlay-start ov) (overlay-end ov)))))
+                 (not (org-remark-string=
+                       highlight-text
+                       (buffer-substring-no-properties
+                        (overlay-start ov) (overlay-end ov)))))
         (org-remark-highlight-adjust-position-after-load
          ov highlight-text)))))
 
@@ -1601,6 +1596,15 @@ function extends the behavior and looks for the word at 
point"
           (list beg end))
       (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."
+  (string=
+   ;; Cater to the case when the text is divided by a newline
+   ;; character \n. Remove all spaces and newline chars
+   ;; before comparing the strings.
+   (replace-regexp-in-string "[\n ]" "" s1)
+   (replace-regexp-in-string "[\n ]" "" s2)))
+
 
 ;;;; Footer
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]