(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)
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)))
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)
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)
(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)))