branch: externals/bufferlo
commit d4145231c824352bb68648c4e90c1f44e6774fca
Author: Stéphane Marks <[email protected]>
Commit: Flo Rommel <[email protected]>
Refine bookmark-buffer-locals and bookmark-text-scale-mode-amount
---
README.org | 15 ++++++++++-----
bufferlo.el | 35 +++++++++++++++++++++++++++++++++--
2 files changed, 43 insertions(+), 7 deletions(-)
diff --git a/README.org b/README.org
index 29bd6ce211..d4c9cf9bb9 100644
--- a/README.org
+++ b/README.org
@@ -707,15 +707,17 @@ prefer
[[https://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variable
take care to store buffer local variables that you consider safe to restore,
see
[[https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Local-Variables.html#index-safe_002dlocal_002dvariable_002dp][risky-local-variable-p]]).
+Note: These need to be bound before ~bufferlo-mode~ is enabled.
+
#+begin_src emacs-lisp
;; To persist text-scale-mode-amount
- (add-hook 'bufferlo-bookmark-map-functions
#'bufferlo-bookmark-map-function-text-scale-mode-amount)
- (add-hook 'bufferlo-bookmark-buffer-handler-functions
#'bufferlo-bookmark-buffer-handler-text-scale-mode-amount)
+ (setq bufferlo-bookmark-text-scale-mode-amount t)
+#+end_src
+#+begin_src emacs-lisp
;; To persist buffer-local variables
- (setq bufferlo-bookmark-buffer-locals '(my:special-local-1
my:special-local-2))
- (add-hook 'bufferlo-bookmark-map-functions
#'bufferlo-bookmark-map-function-buffer-locals)
- (add-hook 'bufferlo-bookmark-buffer-handler-functions
#'bufferlo-bookmark-buffer-handler-buffer-locals)
+ (setq bufferlo-bookmark-buffer-locals t)
+ (setq bufferlo-bookmark-buffer-local-variables '(my:special-local-1
my:special-local-2))
#+end_src
*** Frame geometry options
@@ -1163,6 +1165,8 @@ remain in force until they are saved if this policy is
set to t.
(setq bufferlo-prefer-local-buffers 'tabs)
(setq bufferlo-ibuffer-bind-local-buffer-filter t)
(setq bufferlo-ibuffer-bind-keys t)
+ (setq bufferlo-bookmark-buffer-locals t)
+ (setq bufferlo-bookmark-text-scale-mode-amount t)
:config
(setq bufferlo-mode-line-prefix "🐃") ; "🐮"
(setq bufferlo-mode-line-set-active-prefix "Ⓢ")
@@ -1203,6 +1207,7 @@ remain in force until they are saved if this policy is
set to t.
(setq bufferlo-bookmark-frame-save-on-delete 'when-bookmarked)
(setq bufferlo-bookmark-tab-save-on-close 'when-bookmarked)
(setq bufferlo-close-tab-kill-buffers-prompt t)
+ (setq bufferlo-bookmark-buffer-local-variables '(tab-width))
(setq bufferlo-bookmark-frame-load-make-frame 'restore-geometry)
(setq bufferlo-bookmark-frame-load-policy 'prompt)
(setq bufferlo-bookmark-frame-duplicate-policy 'prompt)
diff --git a/bufferlo.el b/bufferlo.el
index 9c1c59c581..85820066a2 100644
--- a/bufferlo.el
+++ b/bufferlo.el
@@ -192,7 +192,7 @@ This overrides buffers excluded by
`bufferlo-bookmark-buffers-exclude-filters'."
:package-version '(bufferlo . "1.1")
:type '(repeat regexp))
-(defcustom bufferlo-bookmark-buffer-locals '()
+(defcustom bufferlo-bookmark-buffer-local-variables '()
"List of buffer-local variables to store/restore in/from buffer bookmarks.
This is a list of symbols; e.g., \\='(my:special-local my:special-local-2).
@@ -212,6 +212,16 @@ Local Variables'."
:package-version '(bufferlo . "1.3")
:type '(repeat symbol))
+(defcustom bufferlo-bookmark-buffer-locals t
+ "If non-nil, enable bookmark buffer-local variable persistence."
+ :package-version '(bufferlo . "1.3")
+ :type 'boolean)
+
+(defcustom bufferlo-bookmark-text-scale-mode-amount t
+ "If non-nil, enable bookmark `text-scale-mode-amount` persistence."
+ :package-version '(bufferlo . "1.3")
+ :type 'boolean)
+
(defcustom bufferlo-bookmark-frame-load-make-frame nil
"Frame bookmark loading frame and geometry policy.
If nil, reuse the existing frame.
@@ -1202,6 +1212,14 @@ Otherwise it is a list of conditions for which to
prompt."
;; bookmark hook and advice
(add-hook 'bookmark-after-load-file-hook
#'bufferlo--bookmark-after-load-file-hook)
+ ;; bufferlo-bookmark-buffer-locals
+ (when bufferlo-bookmark-buffer-locals
+ (add-hook 'bufferlo-bookmark-map-functions
#'bufferlo-bookmark-map-function-buffer-locals)
+ (add-hook 'bufferlo-bookmark-buffer-handler-functions
#'bufferlo-bookmark-buffer-handler-buffer-locals))
+ (when bufferlo-bookmark-text-scale-mode-amount
+ (add-hook 'bufferlo-bookmark-map-functions
#'bufferlo-bookmark-map-function-text-scale-mode-amount)
+ (add-hook 'bufferlo-bookmark-buffer-handler-functions
#'bufferlo-bookmark-buffer-handler-text-scale-mode-amount))
+ ;; bookmark commands advice
(advice-add #'bookmark--jump-via :around
#'bufferlo--bookmark--jump-via-advice)
(advice-add #'bookmark-rename :around
#'bufferlo--bookmark-rename-advice)
(advice-add #'bookmark-delete :around
#'bufferlo--bookmark-delete-advice)
@@ -1255,6 +1273,19 @@ Otherwise it is a list of conditions for which to
prompt."
;; bookmark hook and advice
(remove-hook 'bookmark-after-load-file-hook
#'bufferlo--bookmark-after-load-file-hook)
+ ;; bufferlo-bookmark-buffer-locals
+ (progn
+ (remove-hook 'bufferlo-bookmark-map-functions
+ #'bufferlo-bookmark-map-function-buffer-locals)
+ (remove-hook 'bufferlo-bookmark-buffer-handler-functions
+ #'bufferlo-bookmark-buffer-handler-buffer-locals))
+ ;; bufferlo-bookmark-text-scale-mode-amount
+ (progn
+ (remove-hook 'bufferlo-bookmark-map-functions
+ #'bufferlo-bookmark-map-function-text-scale-mode-amount)
+ (remove-hook 'bufferlo-bookmark-buffer-handler-functions
+ #'bufferlo-bookmark-buffer-handler-text-scale-mode-amount))
+ ;; bookmark commands advice
(advice-remove #'bookmark--jump-via #'bufferlo--bookmark--jump-via-advice)
(advice-remove #'bookmark-rename #'bufferlo--bookmark-rename-advice)
(advice-remove #'bookmark-delete #'bufferlo--bookmark-delete-advice)
@@ -2551,7 +2582,7 @@ to restore, which see `risky-local-variable-p`."
(mapcar (lambda (sym)
(when (local-variable-p sym)
(cons sym (symbol-value sym))))
- bufferlo-bookmark-buffer-locals))))
+ bufferlo-bookmark-buffer-local-variables))))
(bookmark-prop-set bookmark-record
'bufferlo-buffer-locals
buffer-locals))