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

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

[elpa] externals/lentic 8cc0df3b4c 022/333: Some batch manipulation func


From: ELPA Syncer
Subject: [elpa] externals/lentic 8cc0df3b4c 022/333: Some batch manipulation functions added.
Date: Tue, 27 Feb 2024 12:59:56 -0500 (EST)

branch: externals/lentic
commit 8cc0df3b4cd24bc6a34b1130cae31343911cc1d0
Author: Phillip Lord <phillord@haughton.ncl.ac.uk>
Commit: Phillip Lord <phillord@haughton.ncl.ac.uk>

    Some batch manipulation functions added.
---
 linked-buffer.el | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/linked-buffer.el b/linked-buffer.el
index 2b49e11a4d..c3310e9fc2 100644
--- a/linked-buffer.el
+++ b/linked-buffer.el
@@ -326,6 +326,11 @@ A and B are the buffers."
                                linked-buffer-config)))
     (funcall linked-buffer-init)))
 
+(defun linked-buffer-init-create ()
+  "Create the linked-buffer for current-buffer."
+  (linked-buffer-ensure-init)
+  (linked-buffer-create linked-buffer-config))
+
 (defun linked-buffer-split-window-below ()
   "Create a linked buffer in a new window below."
   (interactive)
@@ -416,9 +421,38 @@ same top-left location. Update details depend on CONF."
 ;;
 ;; Test functions!
 ;;
-(defun linked-buffer-batch-clone (file)
+(defun linked-buffer-batch-clone (filename)
   "Open FILE, clone and save."
-  )
+  (with-current-buffer
+      (find-file-noselect filename)
+    (with-current-buffer
+        (linked-buffer-init-create)
+      (save-buffer)
+      (kill-buffer))
+    (kill-buffer)))
+
+(defun linked-buffer-batch-clone-with-config
+  (filename init)
+  "Open FILENAME, set INIT function, then clone and save.
+This function does potentially evil things if the file or the
+linked-buffer is open already.
+
+Return the linked-buffer contents without properties."
+  (let ((retn nil))
+    (with-current-buffer
+        (find-file-noselect filename)
+      (setq linked-buffer-init init)
+      (with-current-buffer
+          (linked-buffer-init-create)
+        (setq retn
+              (buffer-substring-no-properties
+               (point-min)
+               (point-max)))
+        (set-buffer-modified-p nil)
+        (kill-buffer))
+      (set-buffer-modified-p nil)
+      (kill-buffer))
+    retn))
 
 (defun linked-buffer-test-after-change-function ()
   "Run the change functions out of the command loop.



reply via email to

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