branch: externals/bufferlo
commit 4c6e28b188f99abe4ad358f7baf19b0b05772d52
Author: shipmints <[email protected]>
Commit: shipmints <[email protected]>
Change idle timer to regular timer (BREAKING CHANGE)
Rename 'bufferlo-bookmarks-auto-save-idle-interval' to
'bufferlo-bookmarks-auto-save-interval'.
Update docs.
Allow bufferlo-bookmarks-auto-save-interval to be nil.
The idle vs. regular timer choice is based on lengthy discussions with
a key Emacs maintainer. Bufferlo will be in harmony with savehist,
save-place, etc. Emacs core save timers.
---
README.org | 8 ++++----
bufferlo.el | 49 ++++++++++++++++++++++++-------------------------
2 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/README.org b/README.org
index e264b83820..7a479bfbf8 100644
--- a/README.org
+++ b/README.org
@@ -56,7 +56,7 @@ Note: Code examples use ~setq~ to customize options. You may
also use
~M-x customize-group bufferlo~. Emacs 29 introduced ~setopt~ which
works correctly in the presence of ~defcustom~ setters. Currently the
only bufferlo option with such a setter is
-~bufferlo-bookmarks-auto-save-idle-interval~ so be sure to set that
+~bufferlo-bookmarks-auto-save-interval~ so be sure to set that
interval timer in advance of enabling ~bufferlo-mode~.
Note: Many bufferlo commands have short-hand aliases to accommodate
@@ -407,8 +407,8 @@ To set the automatic save timer, set the number of whole
integer
seconds between saves that you prefer, or 0, the default, to disable
the timer:
#+begin_src emacs-lisp
- (setq bufferlo-bookmarks-auto-save-idle-interval 120) ; do this in advance
of enabling `bufferlo-mode'
- (setopt bufferlo-bookmarks-auto-save-idle-interval 120) ; or use setopt, to
invoke the custom setter
+ (setq bufferlo-bookmarks-auto-save-interval 120) ; do this in advance of
enabling `bufferlo-mode'
+ (setopt bufferlo-bookmarks-auto-save-interval 120) ; or use setopt, to
invoke the custom setter
#+end_src
By default, bufferlo will save all active bookmarks. To select the
@@ -1106,7 +1106,7 @@ remain in force until they are saved if this policy is
set to t.
(setq bufferlo-bookmarks-save-at-emacs-exit-policy 'all)
(setq bufferlo-bookmarks-load-at-emacs-startup 'pred)
(setq bufferlo-bookmarks-load-at-emacs-startup-tabs-make-frame nil)
- (setopt bufferlo-bookmarks-auto-save-idle-interval (* 60 5)) ; 5 minutes
+ (setopt bufferlo-bookmarks-auto-save-interval (* 60 5)) ; 5 minutes
(setq bufferlo-bookmarks-auto-save-messages 'saved)
(setq bufferlo-set-restore-geometry-policy 'all)
(setq bufferlo-set-restore-tabs-reuse-init-frame 'reuse) ; nil 'reuse
'reuse-reset-geometry
diff --git a/bufferlo.el b/bufferlo.el
index 9b8c64e7eb..c7539c1707 100644
--- a/bufferlo.el
+++ b/bufferlo.el
@@ -393,12 +393,11 @@ advance that prevent duplicate frame and tab bookmarks."
(defcustom bufferlo-bookmarks-save-predicate-functions
(list #'bufferlo-bookmarks-save-all-p)
"Functions to filter active bufferlo bookmarks to save.
-These are applied when
-`bufferlo-bookmarks-auto-save-idle-interval' is > 0, or manually
-via `bufferlo-bookmarks-save'. Functions are passed the bufferlo
-bookmark name and invoked until the first positive result. Set to
-`#'bufferlo-bookmarks-save-all-p' to save all bookmarks or
-provide your own predicates (note: be sure to remove
+These are applied when `bufferlo-bookmarks-auto-save-interval' is > 0,
+or manually via `bufferlo-bookmarks-save'. Functions are passed the
+bufferlo bookmark name and invoked until the first positive result. Set
+to `#'bufferlo-bookmarks-save-all-p' to save all bookmarks or provide
+your own predicates (note: be sure to remove
`#'bufferlo-bookmarks-save-all-p' from the list)."
:type 'hook)
@@ -523,7 +522,7 @@ frame bookmark is a collection of tab bookmarks."
(defvar bufferlo--bookmarks-auto-save-timer nil
"Timer to save bufferlo bookmarks.
-This is controlled by `bufferlo-bookmarks-auto-save-idle-interval'.")
+This is controlled by `bufferlo-bookmarks-auto-save-interval'.")
(defun bufferlo--bookmarks-auto-save-timer-maybe-cancel ()
"Cancel and clear the bufferlo bookmark auto-save timer, if set."
@@ -531,19 +530,20 @@ This is controlled by
`bufferlo-bookmarks-auto-save-idle-interval'.")
(cancel-timer bufferlo--bookmarks-auto-save-timer))
(setq bufferlo--bookmarks-auto-save-timer nil))
-(defvar bufferlo-bookmarks-auto-save-idle-interval) ; byte compiler
+(defvar bufferlo-bookmarks-auto-save-interval) ; byte compiler
(defun bufferlo--bookmarks-auto-save-timer-maybe-start ()
"Start the bufferlo auto-save bookmarks timer, if needed."
(bufferlo--bookmarks-auto-save-timer-maybe-cancel)
- (when (> bufferlo-bookmarks-auto-save-idle-interval 0)
+ (when (and (integerp bufferlo-bookmarks-auto-save-interval)
+ (> bufferlo-bookmarks-auto-save-interval 0))
(setq bufferlo--bookmarks-auto-save-timer
- (run-with-idle-timer
- bufferlo-bookmarks-auto-save-idle-interval
- bufferlo-bookmarks-auto-save-idle-interval
+ (run-with-timer
+ bufferlo-bookmarks-auto-save-interval
+ bufferlo-bookmarks-auto-save-interval
#'bufferlo-bookmarks-save))))
-(defcustom bufferlo-bookmarks-auto-save-idle-interval 0
- "Save bufferlo bookmarks when Emacs has been idle this many seconds.
+(defcustom bufferlo-bookmarks-auto-save-interval 0
+ "Save bufferlo bookmarks every interval of this many seconds.
Set to 0 to disable the timer. Units are whole integer seconds."
:type 'natnum
:set (lambda (sym val)
@@ -3422,23 +3422,22 @@ Specify NO-MESSAGE to inhibit the bookmark save status
message."
(defun bufferlo-bookmarks-save (&optional all)
"Save active bufferlo bookmarks.
-This is invoked via an optional idle timer which runs according
-to `bufferlo-bookmarks-auto-save-idle-interval', or and is
-optionally invoked at Emacs exit.
+This is invoked via an optional timer which runs according to
+`bufferlo-bookmarks-auto-save-interval', or and is optionally invoked at
+Emacs exit.
-You may invoke this manually at any time to save active
-bookmarks; however, doing so does not reset the save interval
-timer.
+You may invoke this manually at any time to save active bookmarks;
+however, doing so does not reset the save interval timer.
Each bookmark is filtered according to
`bufferlo-bookmarks-save-predicate-functions'.
-Specify ALL to ignore the predicates and save every active
-bufferlo bookmark or use a prefix argument across ALL frames,
-overriding `bufferlo-bookmarks-save-frame-policy'.
+Specify ALL to ignore the predicates and save every active bufferlo
+bookmark or use a prefix argument across ALL frames, overriding
+`bufferlo-bookmarks-save-frame-policy'.
-Note: if there are duplicate active bufferlo bookmarks, the last
-one to be saved will take precedence.
+Note: If there are duplicate active bufferlo bookmarks, the last one to
+be saved will take precedence.
Duplicate bookmarks are handled according to
`bufferlo-bookmarks-save-duplicates-policy'."