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

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

[elpa] externals/org-remark 2a10b3d75a 17/67: refactor: adjust-positions


From: ELPA Syncer
Subject: [elpa] externals/org-remark 2a10b3d75a 17/67: refactor: adjust-positions
Date: Sat, 22 Jul 2023 06:59:00 -0400 (EDT)

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

    refactor: adjust-positions
    
    Simplified logic
---
 adjust-highlights.el | 14 +++++++++++---
 org-remark-nov.el    |  2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/adjust-highlights.el b/adjust-highlights.el
index 3f55b5ccae..1cad144627 100644
--- a/adjust-highlights.el
+++ b/adjust-highlights.el
@@ -1,3 +1,6 @@
+;; Load works. but need one for sync. Need to re-think
+;; ' and ’ are different in regex of course.
+
 ;; This is probably not very good for text that you change; and change the 
highlights.
 ;; if you change it, this will bring it back to the "original".
 (defun test/move-highlight (highlight text)
@@ -9,9 +12,14 @@
          (text (replace-regexp-in-string " " "\[ \n\]" text)))
     (org-with-wide-buffer
      (unless (string= (buffer-substring 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))
        (goto-char beg) (forward-paragraph 2) (setq paragraph-end (point))
-       (goto-char (point-min))
-       (when (or (re-search-forward text paragraph-end :noerror)
-                 (re-search-backward text paragraph-beg :noerror))
+       (goto-char paragraph-beg)
+       ;; Search from the beginning of the previous paragraph to the end
+       ;; of next paragraph relative to the begining of the highlight
+       ;; overlay; this way, you don't need to look forward and backward
+       ;; separately.
+       (when (re-search-forward text paragraph-end :noerror)
          (move-overlay highlight (match-beginning 0) (match-end 0)))))))
diff --git a/org-remark-nov.el b/org-remark-nov.el
index 322a13ed90..0455944bdc 100644
--- a/org-remark-nov.el
+++ b/org-remark-nov.el
@@ -2,7 +2,7 @@
 
 ;; URL: https://github.com/nobiot/org-remark
 ;; Created: 9 January 2023
-;; Last modified: 12 January 2023
+;; Last modified: 13 January 2023
 
 ;;; Commentary:
 



reply via email to

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