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

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

[elpa] externals/org-real 639ee73 069/160: Using save-excursion when app


From: ELPA Syncer
Subject: [elpa] externals/org-real 639ee73 069/160: Using save-excursion when applying changes
Date: Wed, 6 Oct 2021 16:58:17 -0400 (EDT)

branch: externals/org-real
commit 639ee7376d981eab924233dba88c035b1764ef47
Author: Tyler Grinn <tylergrinn@gmail.com>
Commit: Tyler Grinn <tylergrinn@gmail.com>

    Using save-excursion when applying changes
---
 org-real.el | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/org-real.el b/org-real.el
index b778d48..3d7d208 100644
--- a/org-real.el
+++ b/org-real.el
@@ -304,8 +304,7 @@ ORIG is `org-insert-link', ARGS are the arguments passed to 
it."
                               (replace-link (org-real--to-link
                                              (reverse
                                               (append (cl-subseq 
old-containers 0 old-index)
-                                                      new-containers))))
-                              (old-desc ""))
+                                                      new-containers)))))
                     (when (catch 'conflict
                             (if (not (= (length new-containers) (- (length 
old-containers) old-index)))
                                 (throw 'conflict t))
@@ -318,15 +317,19 @@ ORIG is `org-insert-link', ARGS are the arguments passed 
to it."
                               (setq new-index (+ 1 new-index))
                               (setq old-index (+ 1 old-index)))
                             nil)
-                      (goto-char begin)
-                      (if (org-in-regexp org-link-bracket-re 1)
-                          (setq old-desc (when (match-end 2) 
(match-string-no-properties 2))))
-                      (push
-                       `(lambda ()
-                          (delete-region ,begin ,end)
-                          (goto-char ,begin)
-                          (insert (org-real--link-make-string ,replace-link 
,old-desc)))
-                       changes))))))
+                      (let* ((old-desc (save-excursion
+                                         (and (goto-char begin)
+                                              (org-in-regexp 
org-link-bracket-re 1)
+                                              (match-end 2)
+                                              (match-string-no-properties 2))))
+                             (new-link (org-real--link-make-string 
replace-link old-desc)))
+                        (push
+                         `(lambda ()
+                            (save-excursion
+                              (delete-region ,begin ,end)
+                              (goto-char ,begin)
+                              (insert ,new-link)))
+                         changes)))))))
             (when (and changes
                        (or replace-all (let ((response
                                               (read-char-choice



reply via email to

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