summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel do Nascimento Ribeiro <gabriel376@hotmail.com>2022-11-16 21:59:17 -0300
committerEli Zaretskii <eliz@gnu.org>2022-11-20 12:14:51 +0200
commitfbad9c05ea1066c0ae48d40eca782bd406e4c42d (patch)
tree3ea80a40629e426af6f87a5a7ee7c6a8ef526330
parentd46d67bef14cd0b9acb4f6a542e720ac34a0f51d (diff)
downloademacs-fbad9c05ea1066c0ae48d40eca782bd406e4c42d.tar.gz
Handle error in bookmark-relocate when filename is nil
* lisp/bookmark.el (bookmark-relocate): Handle error when filename is nil. (Bug#59326)
-rw-r--r--lisp/bookmark.el31
1 files changed, 18 insertions, 13 deletions
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 15e7273f917..7f3a264f53d 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1396,20 +1396,25 @@ after a bookmark was set in it."
(interactive (list (bookmark-completing-read "Bookmark to relocate")))
(bookmark-maybe-historicize-string bookmark-name)
(bookmark-maybe-load-default-file)
- (let* ((bmrk-filename (bookmark-get-filename bookmark-name))
- (newloc (abbreviate-file-name
- (expand-file-name
- (read-file-name
- (format "Relocate %s to: " bookmark-name)
- (file-name-directory bmrk-filename))))))
- (bookmark-set-filename bookmark-name newloc)
- (bookmark-update-last-modified bookmark-name)
- (setq bookmark-alist-modification-count
- (1+ bookmark-alist-modification-count))
- (if (bookmark-time-to-save-p)
+ (let ((bmrk-filename (bookmark-get-filename bookmark-name)))
+ ;; FIXME: Make `bookmark-relocate' support bookmark Types
+ ;; besides files and directories.
+ (unless bmrk-filename
+ (user-error "Cannot relocate bookmark of type \"%s\""
+ (bookmark-type-from-full-record
+ (bookmark-get-bookmark bookmark-name))))
+ (let ((newloc (abbreviate-file-name
+ (expand-file-name
+ (read-file-name
+ (format "Relocate %s to: " bookmark-name)
+ (file-name-directory bmrk-filename))))))
+ (bookmark-set-filename bookmark-name newloc)
+ (bookmark-update-last-modified bookmark-name)
+ (setq bookmark-alist-modification-count
+ (1+ bookmark-alist-modification-count))
+ (when (bookmark-time-to-save-p)
(bookmark-save))
- (bookmark-bmenu-surreptitiously-rebuild-list)))
-
+ (bookmark-bmenu-surreptitiously-rebuild-list))))
;;;###autoload
(defun bookmark-insert-location (bookmark-name &optional no-history)