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

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

[nongnu] elpa/edit-indirect 7d9bcfced3 06/28: Extract buffer-local value


From: ELPA Syncer
Subject: [nongnu] elpa/edit-indirect 7d9bcfced3 06/28: Extract buffer-local value handling into a macro.
Date: Thu, 7 Jul 2022 11:59:13 -0400 (EDT)

branch: elpa/edit-indirect
commit 7d9bcfced30f7b7d40cd5bf3ab0c62d0615fccc7
Author: Fanael Linithien <fanael4@gmail.com>
Commit: Fanael Linithien <fanael4@gmail.com>

    Extract buffer-local value handling into a macro.
---
 edit-indirect.el | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/edit-indirect.el b/edit-indirect.el
index 0aa51085ff..a6d5d98e2d 100644
--- a/edit-indirect.el
+++ b/edit-indirect.el
@@ -222,6 +222,16 @@ nil."
         (throw 'done overlay)))
     nil))
 
+(defmacro edit-indirect--buffer-local-value (buffer variable)
+  "Get the BUFFER local value of VARIABLE.
+VARIABLE shall be a symbol."
+  (unless (symbolp variable)
+    (signal 'wrong-type-argument (list #'symbolp variable)))
+  ;; `with-current-buffer' is used instead of `buffer-local-value' because
+  ;; the latter doesn't give warnings about free variables when
+  ;; byte-compiled.
+  `(with-current-buffer ,buffer ,variable))
+
 (defun edit-indirect--create-indirect-buffer (beg end overlay)
   "Create an edit-indirect buffer and return it.
 
@@ -237,15 +247,12 @@ OVERLAY is the overlay, see `edit-indirect--overlay'."
       ;; Use the buffer-local values from the parent buffer. Don't retrieve the
       ;; values before actual uses in case these variables are changed by some
       ;; of the many possible hooks.
-      ;; `with-current-buffer' is used instead of `buffer-local-value' because
-      ;; the latter doesn't give warnings about free variables when
-      ;; byte-compiled.
-      (funcall (with-current-buffer parent-buffer
-                 edit-indirect-guess-mode-function)
+      (funcall (edit-indirect--buffer-local-value
+                parent-buffer edit-indirect-guess-mode-function)
                parent-buffer beg end)
       (let ((edit-indirect-after-creation-hook
-             (with-current-buffer parent-buffer
-               edit-indirect-after-creation-hook)))
+             (edit-indirect--buffer-local-value
+              parent-buffer edit-indirect-after-creation-hook)))
         (run-hooks 'edit-indirect-after-creation-hook)))
     buffer))
 



reply via email to

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