branch: externals/bufferlo
commit 0044b70214fff282ca3c76ba5e60ab378019f9a2
Author: shipmints <shipmi...@gmail.com>
Commit: shipmints <shipmi...@gmail.com>

    Simplify bufferlo--clone-undelete-frame-advice  
bufferlo--tab-bar-undo-close-tab-advice
    
    Replace bufferlo-bookmark-frame-clone-policy with
    bufferlo-bookmark-frame-duplicate-policy
    
    Change bufferlo--clone-undelete-frame-advice so quit deletes the
    unneeded frame.
    
    Change bufferlo--tab-bar-undo-close-tab-advice so quit deletes the
    unneeded tab.
    
    Updated docs.
---
 README.org  |   6 ----
 bufferlo.el | 105 +++++++++++++++++++++++++++++-------------------------------
 2 files changed, 51 insertions(+), 60 deletions(-)

diff --git a/README.org b/README.org
index 8232e01a03..fdf736a510 100644
--- a/README.org
+++ b/README.org
@@ -579,11 +579,6 @@ settings.
   (setq bufferlo-bookmark-frame-duplicate-policy 'raise) ; do not load, raise 
the existing frame
 #+end_src
 Note: 'raise is considered to act as 'clear by bookmark set loading.
-#+begin_src emacs-lisp
-  ;; retain the bookmark when cloning a bookmarked frame via `clone-frame' or 
C-x 5 c
-  (setq bufferlo-bookmark-frame-clone-policy 'prompt) ; default
-  (setq bufferlo-bookmark-frame-clone-policy 'allow) ; old default behavior
-#+end_src
 
 *** Tab bookmark options
 
@@ -1102,7 +1097,6 @@ remain in force until they are saved if this policy is 
set to t.
     (setq bufferlo-bookmark-frame-load-make-frame 'restore-geometry)
     (setq bufferlo-bookmark-frame-load-policy 'prompt)
     (setq bufferlo-bookmark-frame-duplicate-policy 'prompt)
-    (setq bufferlo-bookmark-frame-clone-policy 'prompt)
     (setq bufferlo-bookmark-tab-replace-policy 'new)
     (setq bufferlo-bookmark-tab-duplicate-policy 'prompt)
     (setq bufferlo-bookmark-tab-in-bookmarked-frame-policy 'prompt)
diff --git a/bufferlo.el b/bufferlo.el
index d0dda5de2b..c7bc090afd 100644
--- a/bufferlo.el
+++ b/bufferlo.el
@@ -282,21 +282,6 @@ Note: \\='raise is considered \\='clear during 
bookmark-set loading."
                 (const :tag "Clear (with message)" clear-warn)
                 (const :tag "Raise" raise)))
 
-(defcustom bufferlo-bookmark-frame-clone-policy 'prompt
-  "Control bookmark duplication on cloned and undeleted frames.
-Duplicate active bookmarks cause potentially confusing race
-conditions.
-
-\\='prompt allows you to select a policy interactively.
-
-\\='allow allows duplicates.
-
-\\='disassociate will clear the bookmark on the newly cloned or
-undeleted frame."
-  :type '(radio (const :tag "Prompt" prompt)
-                (const :tag "Allow" allow)
-                (const :tag "Disassociate" disassociate)))
-
 (defcustom bufferlo-bookmarks-load-tabs-make-frame nil
   "If non-nil, make a new frame for tabs loaded by `bufferlo-bookmarks-load'.
 If nil, tab bookmarks are loaded into the current frame."
@@ -1264,27 +1249,36 @@ the advised functions."
 (defun bufferlo--clone-undelete-frame-advice (oldfn &rest args)
   "Activate the advice for `clone-frame' and `undelete-frame'.
 OLDFN is the original function.  ARGS is for compatibility with
-the advised functions. Honors `bufferlo-bookmark-frame-clone-policy'."
+the advised functions. Honors `bufferlo-bookmark-frame-duplicate-policy'."
   (let ((bufferlo--desktop-advice-active t)
         (bufferlo--desktop-advice-active-force t))
     (apply oldfn args))
-  (let ((fbm (frame-parameter nil 'bufferlo-bookmark-frame-name))
-        (clone-policy bufferlo-bookmark-frame-clone-policy))
-    (when fbm
-      (when (eq clone-policy 'prompt)
-        (pcase (let ((read-answer-short t))
-                 (with-local-quit
-                   (read-answer "Disassociate cloned/undeleted frame bookmark: 
Allow, Disassociate "
-                                '(("allow" ?a "Allow bookmark")
-                                  ("disassociate" ?d "Disassociate bookmark")
-                                  ("help" ?h "Help")
-                                  ("quit" ?q "Quit--retains the bookmark")))))
-          ("disassociate" (setq clone-policy 'disassociate))
-          (_ (setq clone-policy 'allow)))) ; allow, quit cases
-      (pcase clone-policy
-        ('allow)
-        ('disassociate
-         (set-frame-parameter nil 'bufferlo-bookmark-frame-name nil))))))
+  (when-let* ((bookmark-name (frame-parameter nil 
'bufferlo-bookmark-frame-name))
+              (abm (assoc bookmark-name (bufferlo--active-bookmarks))))
+    (let* ((msg nil)
+           (msg-append (lambda (s) (setq msg (concat msg "; " s)))))
+      (catch :raise
+        (when
+            (catch :abort
+              (let ((duplicate-policy (bufferlo--bookmark-get-duplicate-policy
+                                       bookmark-name "frame" 
bufferlo-bookmark-frame-duplicate-policy 'undelete)))
+                (pcase duplicate-policy
+                  ('allow)
+                  ('clear
+                   (setq bookmark-name nil))
+                  ('clear-warn
+                   (setq bookmark-name nil)
+                   (funcall msg-append "cleared frame bookmark"))
+                  ('raise
+                   (delete-frame)
+                   (bufferlo--bookmark-raise abm)
+                   (throw :raise t)))
+                (set-frame-parameter nil 'bufferlo-bookmark-frame-name 
bookmark-name))
+              (when msg
+                (message "Undelete frame bufferlo bookmark%s%s"
+                         (if bookmark-name (format ": %s" bookmark-name) "")
+                         (or msg ""))))
+          (delete-frame))))))
 
 (defun bufferlo--tab-bar-undo-close-tab-advice (oldfn &rest args)
   "Activate the advice for `tab-bar-undo-close-tab'.
@@ -1296,27 +1290,30 @@ the advised functions. Honors 
`bufferlo-bookmark-tab-duplicate-policy'."
   (when-let* ((current-tab (bufferlo--current-tab))
               (bookmark-name (alist-get 'bufferlo-bookmark-tab-name 
current-tab))
               (abm (assoc bookmark-name (bufferlo--active-bookmarks))))
-    (let ((msg)
-          (msg-append (lambda (s) (setq msg (concat msg "; " s)))))
-      (catch :abort
-        (let ((duplicate-policy (bufferlo--bookmark-get-duplicate-policy
-                                 bookmark-name "tab" 
bufferlo-bookmark-tab-duplicate-policy 'undelete)))
-          (pcase duplicate-policy
-            ('allow)
-            ('clear
-             (setq bookmark-name nil))
-            ('clear-warn
-             (setq bookmark-name nil)
-             (funcall msg-append "cleared tab bookmark"))
-            ('raise
-             (tab-bar-close-tab)
-             (bufferlo--bookmark-raise abm)
-             (throw :abort t)))
-          (setf (alist-get 'bufferlo-bookmark-tab-name (cdr current-tab)) 
bookmark-name))
-        (when msg
-          (message "Undo close tab bufferlo bookmark%s%s"
-                   (if bookmark-name (format ": %s" bookmark-name) "")
-                   (or msg "")))))))
+    (let* ((msg nil)
+           (msg-append (lambda (s) (setq msg (concat msg "; " s)))))
+      (catch :raise
+        (when
+            (catch :abort
+              (let ((duplicate-policy (bufferlo--bookmark-get-duplicate-policy
+                                       bookmark-name "tab" 
bufferlo-bookmark-tab-duplicate-policy 'undelete)))
+                (pcase duplicate-policy
+                  ('allow)
+                  ('clear
+                   (setq bookmark-name nil))
+                  ('clear-warn
+                   (setq bookmark-name nil)
+                   (funcall msg-append "cleared tab bookmark"))
+                  ('raise
+                   (tab-bar-close-tab)
+                   (bufferlo--bookmark-raise abm)
+                   (throw :raise t)))
+                (setf (alist-get 'bufferlo-bookmark-tab-name (cdr 
current-tab)) bookmark-name))
+              (when msg
+                (message "Undo close tab bufferlo bookmark%s%s"
+                         (if bookmark-name (format ": %s" bookmark-name) "")
+                         (or msg ""))))
+          (tab-bar-close-tab))))))
 
 (defsubst bufferlo--warn ()
   "Warn if `bufferlo-mode' is not enabled."

Reply via email to