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

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

[elpa] externals/m-buffer 1ab361ed32 053/115: with-markers and with-curr


From: ELPA Syncer
Subject: [elpa] externals/m-buffer 1ab361ed32 053/115: with-markers and with-current-location added.
Date: Tue, 19 Jul 2022 15:58:48 -0400 (EDT)

branch: externals/m-buffer
commit 1ab361ed3275c417ac3f178af192d9adc0a89eec
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>

    with-markers and with-current-location added.
    
    Two new macros one of which works like let, but auto nils markers, and
    the other which runs the body in a given buffer and location.
---
 m-buffer.el | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/m-buffer.el b/m-buffer.el
index a94e557426..90866a91ff 100644
--- a/m-buffer.el
+++ b/m-buffer.el
@@ -45,6 +45,41 @@
 ;;; Code:
 (require 'dash)
 
+;;
+;; Macro Support
+;;
+(defmacro m-buffer-with-markers (varlist &rest body)
+  "Bind variables after VARLIST then eval BODY.
+All variables should contain markers or collections of markers.
+All markers are niled after BODY."
+  ;; indent let part specially.
+  (declare (indent 1)(debug let))
+  ;; so, create a rtn var with make-symbol (for hygene)
+  (let* ((rtn-var (make-symbol "rtn-var"))
+         (marker-vars
+          (mapcar 'car varlist))
+         (full-varlist
+          (append
+           varlist
+           `((,rtn-var
+              (progn
+                ,@body))))))
+    `(let* ,full-varlist
+       (m-buffer-nil-marker
+        (list ,@marker-vars))
+       ,rtn-var)))
+
+(defmacro m-buffer-with-current-location
+  (buffer location &rest body)
+  "Run BODY in BUFFER at LOCATION."
+  (declare (indent 2)
+           (debug t))
+  `(with-current-buffer
+       ,buffer
+     (save-excursion
+       (goto-char ,location)
+      ,@body)))
+
 ;;
 ;; Regexp matching
 ;;



reply via email to

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