aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/bookmark.el16
2 files changed, 14 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 46716b2e4c1..2ac896efc8d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12008-11-21 Stefan Monnier <monnier@iro.umontreal.ca> 12008-11-21 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * bookmark.el (bookmark-get-bookmark): Add `noerror' arg.
4 Signal error for invalid bookmark.
5 (bookmark-get-bookmark-record): Undo last change.
6 (bookmark-store, bookmark-delete): Use new arg `noerror'.
7
3 * bookmark.el (bookmark-buffer-file-name): Also abbreviate dired-dir. 8 * bookmark.el (bookmark-buffer-file-name): Also abbreviate dired-dir.
4 Suggested by Toru TSUNEYOSHI. 9 Suggested by Toru TSUNEYOSHI.
5 10
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 1ae32d1fb0e..1dfb3feca44 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -79,6 +79,7 @@
79;;; Code: 79;;; Code:
80 80
81(require 'pp) 81(require 'pp)
82(eval-when-compile (require 'cl))
82 83
83;;; Misc comments: 84;;; Misc comments:
84;; 85;;
@@ -317,21 +318,21 @@ through a file easier.")
317 (mapcar 'bookmark-name-from-full-record bookmark-alist)) 318 (mapcar 'bookmark-name-from-full-record bookmark-alist))
318 319
319 320
320(defun bookmark-get-bookmark (bookmark) 321(defun bookmark-get-bookmark (bookmark &optional noerror)
321 "Return the bookmark record corresponding to BOOKMARK. 322 "Return the bookmark record corresponding to BOOKMARK.
322If BOOKMARK is already a bookmark record, just return it, 323If BOOKMARK is already a bookmark record, just return it,
323Otherwise look for the corresponding bookmark in `bookmark-alist'." 324Otherwise look for the corresponding bookmark in `bookmark-alist'."
324 (cond 325 (cond
325 ((consp bookmark) bookmark) 326 ((consp bookmark) bookmark)
326 ((stringp bookmark) 327 ((stringp bookmark)
327 (assoc-string bookmark bookmark-alist bookmark-completion-ignore-case)))) 328 (or (assoc-string bookmark bookmark-alist bookmark-completion-ignore-case)
329 (unless noerror (error "Invalid bookmark %s" bookmark))))))
328 330
329 331
330(defun bookmark-get-bookmark-record (bookmark) 332(defun bookmark-get-bookmark-record (bookmark)
331 "Return the guts of the entry for BOOKMARK in `bookmark-alist'. 333 "Return the guts of the entry for BOOKMARK in `bookmark-alist'.
332That is, all information but the name." 334That is, all information but the name."
333 (let ((alist (cdr (or (bookmark-get-bookmark bookmark) 335 (let ((alist (cdr (bookmark-get-bookmark bookmark))))
334 (error "Invalid bookmark %s" bookmark)))))
335 ;; The bookmark objects can either look like (NAME ALIST) or 336 ;; The bookmark objects can either look like (NAME ALIST) or
336 ;; (NAME . ALIST), so we have to distinguish the two here. 337 ;; (NAME . ALIST), so we have to distinguish the two here.
337 (if (and (null (cdr alist)) (consp (caar alist))) 338 (if (and (null (cdr alist)) (consp (caar alist)))
@@ -487,7 +488,8 @@ old one."
487 ;; XEmacs's `set-text-properties' doesn't work on 488 ;; XEmacs's `set-text-properties' doesn't work on
488 ;; free-standing strings, apparently. 489 ;; free-standing strings, apparently.
489 (set-text-properties 0 (length stripped-name) nil stripped-name)) 490 (set-text-properties 0 (length stripped-name) nil stripped-name))
490 (if (and (bookmark-get-bookmark stripped-name) (not no-overwrite)) 491 (if (and (not no-overwrite)
492 (bookmark-get-bookmark stripped-name 'noerror))
491 ;; already existing bookmark under that name and 493 ;; already existing bookmark under that name and
492 ;; no prefix arg means just overwrite old bookmark 494 ;; no prefix arg means just overwrite old bookmark
493 ;; Use the new (NAME . ALIST) format. 495 ;; Use the new (NAME . ALIST) format.
@@ -1211,11 +1213,11 @@ probably because we were called from there."
1211 bookmark-current-bookmark))) 1213 bookmark-current-bookmark)))
1212 (bookmark-maybe-historicize-string bookmark) 1214 (bookmark-maybe-historicize-string bookmark)
1213 (bookmark-maybe-load-default-file) 1215 (bookmark-maybe-load-default-file)
1214 (let ((will-go (bookmark-get-bookmark bookmark))) 1216 (let ((will-go (bookmark-get-bookmark bookmark 'noerror)))
1215 (setq bookmark-alist (delq will-go bookmark-alist)) 1217 (setq bookmark-alist (delq will-go bookmark-alist))
1216 ;; Added by db, nil bookmark-current-bookmark if the last 1218 ;; Added by db, nil bookmark-current-bookmark if the last
1217 ;; occurrence has been deleted 1219 ;; occurrence has been deleted
1218 (or (bookmark-get-bookmark bookmark-current-bookmark) 1220 (or (bookmark-get-bookmark bookmark-current-bookmark 'noerror)
1219 (setq bookmark-current-bookmark nil))) 1221 (setq bookmark-current-bookmark nil)))
1220 ;; Don't rebuild the list 1222 ;; Don't rebuild the list
1221 (if batch 1223 (if batch