From 61e039b91345d1cf60ebe3710d8ebaebb6d0d567 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Thu, 20 Jun 2024 18:42:18 +0200 Subject: [PATCH] Fix 'bookmark-bmenu-rename' --- lisp/bookmark.el | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index ccf4d247287..4b060e02b18 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -997,15 +997,17 @@ still there, in order, if the topmost one is ever deleted." (error "Unrecognized value for `overwrite-or-push': %S" overwrite-or-push)))))) -(defun bookmark-read-bookmark-name (prompt) - (let* ((buffer (current-buffer)) - (record (bookmark-make-record)) - (defaults (or (bookmark-prop-get record 'defaults) - (car record)))) +(defun bookmark-default-name () + (let ((record (bookmark-make-record))) + (or (bookmark-prop-get record 'defaults) + (car record)))) + +(defun bookmark-read-bookmark-name (prompt &optional default) + (let ((buffer (or bookmark-current-buffer (current-buffer)))) (minibuffer-with-setup-hook (lambda () (setq-local bookmark-current-buffer buffer)) - (read-string (format-prompt prompt defaults) nil nil defaults)))) + (read-string (format-prompt prompt default) nil nil default)))) ;;;###autoload (defun bookmark-set (name &optional no-overwrite) @@ -1022,7 +1024,8 @@ Use \\[bookmark-delete] to remove bookmarks (you give it a name and it removes only the first instance of a bookmark with that name from the list of bookmarks.)" (interactive (list (bookmark-read-bookmark-name - (if current-prefix-arg "Add bookmark named" "Set bookmark named")) + (if current-prefix-arg "Add bookmark named" "Set bookmark named") + (bookmark-default-name)) current-prefix-arg)) (bookmark-set-internal name (if no-overwrite 'push 'overwrite))) @@ -1045,7 +1048,9 @@ is nil, raise an error. Use \\[bookmark-delete] to remove bookmarks (you give it a name and it removes only the first instance of a bookmark with that name from the list of bookmarks.)" - (interactive (list (bookmark-read-bookmark-name "Set bookmark") current-prefix-arg)) + (interactive (list (bookmark-read-bookmark-name "Set bookmark" + (bookmark-default-name)) + current-prefix-arg)) (bookmark-set-internal name (if push-bookmark 'push nil))) (put 'bookmark-set-no-overwrite 'minibuffer-action 'bookmark-set) @@ -1482,7 +1487,8 @@ Optional second argument is obsolete and ignored." If called from keyboard, prompt for OLD-NAME and NEW-NAME. If called from menubar, select OLD-NAME from a menu and prompt for NEW-NAME." (interactive (let ((old (bookmark-completing-read "Old bookmark name"))) - (list old (bookmark-read-bookmark-name (format "Rename \"%s\" to" old))))) + (list old (bookmark-read-bookmark-name (format "Rename \"%s\" to" old) + (bookmark-default-name))))) (bookmark-maybe-load-default-file) (bookmark-set-name old-name new-name) @@ -2423,10 +2429,15 @@ confirmation first." (defun bookmark-bmenu-rename () "Rename bookmark on current line. Prompts for a new name." (interactive nil bookmark-bmenu-mode) - (let ((bmrk (bookmark-bmenu-bookmark)) - (thispoint (point))) - ;; FIXME: Second arg of `bookmark-rename'. - (bookmark-rename bmrk) + (let* ((old (bookmark-bmenu-bookmark)) + (new (bookmark-read-bookmark-name + (format "Rename \"%s\" to" old) + (or (save-current-buffer + (bookmark-handle-bookmark old) + (bookmark-default-name)) + old))) + (thispoint (point))) + (bookmark-rename old new) (goto-char thispoint))) -- 2.39.2