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

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

[elpa] externals/lentic e567b169c9 185/333: Kill lentic buffer when crea


From: ELPA Syncer
Subject: [elpa] externals/lentic e567b169c9 185/333: Kill lentic buffer when creator buffer is killed.
Date: Tue, 27 Feb 2024 13:00:33 -0500 (EST)

branch: externals/lentic
commit e567b169c9b8d0c76866e5aaafb088df5bd9b1b5
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>

    Kill lentic buffer when creator buffer is killed.
    
    Removing the lentic makes sense because any change that is saved is
    likely to later get deleted. This mimics the behaviour of indirect
    buffers.
---
 lentic.el | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/lentic.el b/lentic.el
index eee5b204ab..a2eb428d99 100644
--- a/lentic.el
+++ b/lentic.el
@@ -212,6 +212,11 @@ of mode in the current buffer.")
     :initarg :this-buffer)
    (that-buffer
     :initarg :that-buffer)
+   (creator
+    :initarg :creator
+    :initform nil
+    :documentation
+    "Non-nil if this lentic-configuration was used to create a lentic view.")
    (sync-point
     :initarg :sync-point
     :initform t)
@@ -289,6 +294,7 @@ created."
                     this-buffer))))
          (sec-mode (oref conf :lentic-mode))
          (sec-file (oref conf :lentic-file)))
+    (oset conf :creator t)
     ;; make sure this-buffer knows about that-buffer
     (oset conf :that-buffer that-buffer)
     ;; insert the contents
@@ -399,7 +405,9 @@ see `lentic-init' for details."
   (add-hook 'before-change-functions
             'lentic-before-change-function)
   (add-hook 'after-save-hook
-            'lentic-after-save-hook))
+            'lentic-after-save-hook)
+  (add-hook 'kill-buffer-hook
+            'lentic-kill-buffer-hook))
 
 (defvar lentic-log t)
 (defmacro lentic-log (&rest rest)
@@ -467,6 +475,12 @@ repeated errors.")
          (when (buffer-file-name)
            (save-buffer)))))))
 
+(defun lentic-kill-buffer-hook ()
+  (lentic-when-lentic
+   (when (oref lentic-config :creator)
+     (kill-buffer
+      (lentic-that lentic-config)))))
+
 (defun lentic-post-command-hook ()
   "Update point according to config, with error handling."
   ;;(message "Entering post-command-hook")



reply via email to

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