[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/bufferlo 82d79b1786 170/192: Fix buffer renaming during
From: |
ELPA Syncer |
Subject: |
[elpa] externals/bufferlo 82d79b1786 170/192: Fix buffer renaming during restoration |
Date: |
Sat, 19 Apr 2025 15:58:20 -0400 (EDT) |
branch: externals/bufferlo
commit 82d79b17862f09453b7d7e68b7985b39a4df560b
Author: Florian Rommel <mail@florommel.de>
Commit: Florian Rommel <mail@florommel.de>
Fix buffer renaming during restoration
Co-authored-by: shipmints <shipmints@gmail.com>
---
bufferlo.el | 40 ++++++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/bufferlo.el b/bufferlo.el
index a6fdcf7e14..ea44a0df37 100644
--- a/bufferlo.el
+++ b/bufferlo.el
@@ -2185,14 +2185,26 @@ FRAME specifies the frame; the default value of nil
selects the current frame."
(defun bufferlo--ws-replace-buffer-names (ws replace-alist)
"Replace buffer names according to REPLACE-ALIST in the window state WS."
- (dolist (el ws)
- (when-let* ((type (and (listp el) (car el))))
- (cond ((memq type '(vc hc))
- (bufferlo--ws-replace-buffer-names (cdr el) replace-alist))
- ((eq type 'leaf)
- (let ((bc (assq 'buffer (cdr el))))
- (when-let* ((replace (assoc (cadr bc) replace-alist)))
- (setf (cadr bc) (cdr replace)))))))))
+ (mapc (lambda (el)
+ (when (memq (car el) '(leaf vc hc))
+ (bufferlo--ws-replace-buffer-names el replace-alist)))
+ (if (consp (car ws))
+ (list (cdr ws))
+ (cdr ws)))
+ ;; Replace name in the buffer field
+ (when-let* ((buffer-loc (assq 'buffer ws))
+ (buffer (cadr buffer-loc))
+ (replace (assoc buffer replace-alist)))
+ (setf (cadr buffer-loc) (cdr replace)))
+ ;; Replace names in the prev-buffers list
+ (when-let* ((prev-buffers-loc (assq 'prev-buffers ws))
+ (prev-buffers (cdr prev-buffers-loc)))
+ (setf (cdr prev-buffers-loc)
+ (mapcar (lambda (be)
+ (if-let ((replace (assoc (car be) replace-alist)))
+ (cons (cdr replace) (cdr be))
+ be))
+ prev-buffers))))
(defvar bufferlo--bookmark-set-loading nil
"Let bind to t when a bookmark set is being loaded.
@@ -2386,17 +2398,25 @@ this bookmark is embedded in a frame bookmark."
(message "Bufferlo bookmark: Could not restore %s
(error %s)"
orig-name err)))
(unless (eq (current-buffer) dummy)
- (unless (string-equal orig-name (buffer-name))
- (cons orig-name (buffer-name)))))))
+ ;; Return a list of (cons <string> <buffer>).
+ ;; The buffer may be renamed later (by uniquify).
+ ;; Using the buffer name directly would not
+ ;; account for this!
+ (cons orig-name (current-buffer))))))
(renamed (mapcar restore (alist-get 'buffer-bookmarks bookmark)))
(replace-renamed (lambda (b)
(if-let* ((replace
(assoc b renamed)))
(cdr replace) b)))
(bl (mapcar replace-renamed (alist-get 'buffer-list bookmark)))
+ ;; Some of the bl items may already be buffers after renaming.
+ ;; Others are still buffer names (strings). These items had no
+ ;; bookmark associated with them.
(bl (seq-filter #'get-buffer bl))
(bl (mapcar #'get-buffer bl)))
(kill-buffer dummy)
+ ;; Note that we replace buffer names with buffers in ws.
+ ;; `window-state-put' accepts this.
(bufferlo--ws-replace-buffer-names ws renamed)
(window-state-put ws (frame-root-window) 'safe)
(set-frame-parameter nil 'buffer-list bl)
- [elpa] externals/bufferlo 4e8ff83370 109/192: Remove vestigial message in set handler, (continued)
- [elpa] externals/bufferlo 4e8ff83370 109/192: Remove vestigial message in set handler, ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo e6e9b3a030 114/192: Change default value for bufferlo-kill-modified-buffers-policy, ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo dcb2643afc 117/192: Rename bufferlo-bookmark-{save, load, close}-curr, ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo f2e3d2d2a0 122/192: Clarify docstrings saying if rather than when, ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo 3b8a134f10 131/192: Support define-ibuffer-op opstring prompt functions, ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo 43aecf49d5 132/192: Support inhibiting bookmark-insert, ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo 73c3d1df91 139/192: Improve 'bufferlo-mode-line' and mode on/off behavior, ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo f897ace31c 140/192: Mention bookmark list type column width, and shell-mode bookmarks, ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo 6254d49b67 151/192: Usability improvements to bufferlo-set-list-interactive, ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo 8228953344 157/192: Ignore tab-bar--tab advice on Emacs 31, ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo 82d79b1786 170/192: Fix buffer renaming during restoration,
ELPA Syncer <=
- [elpa] externals/bufferlo cb215f5e98 179/192: Add bufferlo-bookmark-tab-failed-buffer-policy, ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo 362de728ab 003/192: WIP., ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo c13fc1094e 022/192: bufferlo-prefer-local-buffers 'tabs sets switch-to-prev-buffer-skip., ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo b626c89127 017/192: Rely only on tab numbers or names, not references to ephemeral tab objects. Cures a couple of issues with saving/closing., ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo 5177279f4e 013/192: Eliminated null-error. Better delete-frame. Added bufferlo-bookmarks-close-interactive., ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo a5ed640ba3 018/192: Add additional author and maintainer to help Flo support the expanded code base., ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo 70ceb0491f 029/192: Add convenience aliases to shorten which-key key bindings help text., ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo ca71c5f2e2 027/192: Ach, changed the file name to harmonize with the command-line argument., ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo b56ca70306 026/192: Add user-emacs-dir/bufferlo-no-load file to inhibit bufferlo bookmark loading., ELPA Syncer, 2025/04/19
- [elpa] externals/bufferlo 369d48eb5a 032/192: bufferlo-kill-buffers-prompt for bufferlo-kill-buffers bufferlo-kill-orphan-buffers, ELPA Syncer, 2025/04/19