aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Fogel2010-12-08 03:09:27 -0500
committerKarl Fogel2010-12-08 03:09:27 -0500
commiteff37c5e4460e708dfa172d9d9c5b068a62407db (patch)
tree4bc951f60b84cacd56e466f7e656b49db739df9a
parentac8331a7bfdaeb3e96d9e79ff78e0ae823192c19 (diff)
downloademacs-eff37c5e4460e708dfa172d9d9c5b068a62407db.tar.gz
emacs-eff37c5e4460e708dfa172d9d9c5b068a62407db.zip
Adjust parameter names and doc strings to resolve confusion over
whether "bookmark" meant a bookmark name or a bookmark record. Along the way, shorten one function's name for similar reasons. (Issue #7548) * lisp/bookmark.el (bookmark-name-from-record): New name for `bookmark-name-from-full-record'. All callers changed. (bookmark-get-bookmark, bookmark-get-bookmark-record, bookmark-default-annotation-text, bookmark-prop-get, bookmark-prop-set, bookmark-get-annotation, bookmark-set-annotation, bookmark-get-filename, bookmark-set-filename, bookmark-get-position, bookmark-set-position, bookmark-get-front-context-string, bookmark-set-front-context-string, bookmark-get-rear-context-string, bookmark-set-rear-context-string, bookmark-get-handler, bookmark-edit-annotation, bookmark--jump-via, bookmark-handle-bookmark, bookmark-location, bookmark-show-annotation): Rename `bookmark' parameter to `bookmark-name-or-record', to clearly show its role, and shorten or adjust doc strings accordingly. (bookmark-set-name): Same, and pass the parameter directly to `bookmark-get-bookmark' instead of redundantly doing the callee's work. (bookmark-default-annotation-text, bookmark-send-edited-annotation, bookmark-relocate, bookmark-insert-location, bookmark-insert, bookmark-delete): Rename `bookmark' parameter to `bookmark-name', and in some cases shorten doc string accordingly. (bookmark-rename): Change `old' and `new' parameters to `old-name' and `new-name', and adjust an internal variable to avoid confusion. (bookmark-jump, bookmark-jump-noselect): Clarify `bookmark' parameter in doc string.
-rw-r--r--lisp/ChangeLog30
-rw-r--r--lisp/bookmark.el331
2 files changed, 184 insertions, 177 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a098dae546f..cb797763cbd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,33 @@
12010-12-08 Karl Fogel <kfogel@red-bean.com>
2
3 * bookmark.el: Adjust parameter names and doc strings to resolve
4 confusion over whether "bookmark" meant a bookmark name or a
5 bookmark record. Along the way, shorten one function's name for
6 similar reasons. (Issue #7548)
7 (bookmark-name-from-record): New name for
8 `bookmark-name-from-full-record'. All callers changed.
9 (bookmark-get-bookmark, bookmark-get-bookmark-record)
10 (bookmark-default-annotation-text, bookmark-prop-get, bookmark-prop-set)
11 (bookmark-get-annotation, bookmark-set-annotation)
12 (bookmark-get-filename, bookmark-set-filename)
13 (bookmark-get-position, bookmark-set-position)
14 (bookmark-get-front-context-string, bookmark-set-front-context-string)
15 (bookmark-get-rear-context-string, bookmark-set-rear-context-string)
16 (bookmark-get-handler, bookmark-edit-annotation, bookmark--jump-via)
17 (bookmark-handle-bookmark, bookmark-location, bookmark-show-annotation):
18 Rename `bookmark' parameter to `bookmark-name-or-record', to
19 clearly show its role, and shorten or adjust doc strings accordingly.
20 (bookmark-set-name): Same, and pass the parameter directly to
21 `bookmark-get-bookmark' instead of redundantly doing the callee's work.
22 (bookmark-default-annotation-text, bookmark-send-edited-annotation)
23 (bookmark-relocate, bookmark-insert-location, bookmark-insert)
24 (bookmark-delete): Rename `bookmark' parameter to `bookmark-name',
25 and in some cases shorten doc string accordingly.
26 (bookmark-rename): Change `old' and `new' parameters to `old-name'
27 and `new-name', and adjust an internal variable to avoid confusion.
28 (bookmark-jump, bookmark-jump-noselect): Clarify `bookmark'
29 parameter in doc string.
30
12010-12-08 Glenn Morris <rgm@gnu.org> 312010-12-08 Glenn Morris <rgm@gnu.org>
2 32
3 * progmodes/gdb-mi.el (gdb): Try to initialize comint input history 33 * progmodes/gdb-mi.el (gdb): Try to initialize comint input history
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 11883febb07..268a370cdb6 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -305,124 +305,112 @@ This point is in `bookmark-current-buffer'.")
305;; need to know anything about the format of bookmark-alist entries. 305;; need to know anything about the format of bookmark-alist entries.
306;; Everyone else should go through them. 306;; Everyone else should go through them.
307 307
308(defun bookmark-name-from-full-record (full-record) 308(defun bookmark-name-from-record (bookmark-record)
309 "Return name of FULL-RECORD (an alist element instead of a string)." 309 "Return the name of BOOKMARK-RECORD. BOOKMARK-RECORD is, e.g.,
310 (car full-record)) 310one element from `bookmark-alist'."
311 (car bookmark-record))
311 312
312 313
313(defun bookmark-all-names () 314(defun bookmark-all-names ()
314 "Return a list of all current bookmark names." 315 "Return a list of all current bookmark names."
315 (bookmark-maybe-load-default-file) 316 (bookmark-maybe-load-default-file)
316 (mapcar 'bookmark-name-from-full-record bookmark-alist)) 317 (mapcar 'bookmark-name-from-record bookmark-alist))
317 318
318 319
319(defun bookmark-get-bookmark (bookmark &optional noerror) 320(defun bookmark-get-bookmark (bookmark-name-or-record &optional noerror)
320 "Return the bookmark record corresponding to BOOKMARK. 321 "Return the bookmark record corresponding to BOOKMARK-NAME-OR-RECORD.
321If BOOKMARK is a string, look for the corresponding bookmark record in 322If BOOKMARK-NAME-OR-RECORD is a string, look for the corresponding
322`bookmark-alist'; return it if found, otherwise error. Else if 323bookmark record in `bookmark-alist'; return it if found, otherwise
323BOOKMARK is already a bookmark record, just return it." 324error. Else if BOOKMARK-NAME-OR-RECORD is already a bookmark record,
325just return it."
324 (cond 326 (cond
325 ((consp bookmark) bookmark) 327 ((consp bookmark-name-or-record) bookmark-name-or-record)
326 ((stringp bookmark) 328 ((stringp bookmark-name-or-record)
327 (or (assoc-string bookmark bookmark-alist bookmark-completion-ignore-case) 329 (or (assoc-string bookmark-name-or-record bookmark-alist
328 (unless noerror (error "Invalid bookmark %s" bookmark)))))) 330 bookmark-completion-ignore-case)
329 331 (unless noerror (error "Invalid bookmark %s"
330 332 bookmark-name-or-record))))))
331(defun bookmark-get-bookmark-record (bookmark) 333
332 "Return the record portion of the entry for BOOKMARK in 334
333`bookmark-alist' (that is, all information but the name). 335(defun bookmark-get-bookmark-record (bookmark-name-or-record)
334BOOKMARK may be a bookmark name (a string) or a bookmark record." 336 "Return the record portion of the entry for BOOKMARK-NAME-OR-RECORD in
335 (let ((alist (cdr (bookmark-get-bookmark bookmark)))) 337`bookmark-alist' (that is, all information but the name)."
338 (let ((alist (cdr (bookmark-get-bookmark bookmark-name-or-record))))
336 ;; The bookmark objects can either look like (NAME ALIST) or 339 ;; The bookmark objects can either look like (NAME ALIST) or
337 ;; (NAME . ALIST), so we have to distinguish the two here. 340 ;; (NAME . ALIST), so we have to distinguish the two here.
338 (if (and (null (cdr alist)) (consp (caar alist))) 341 (if (and (null (cdr alist)) (consp (caar alist)))
339 (car alist) alist))) 342 (car alist) alist)))
340 343
341 344
342(defun bookmark-set-name (bookmark newname) 345(defun bookmark-set-name (bookmark-name-or-record newname)
343 "Set BOOKMARK's name to NEWNAME. 346 "Set BOOKMARK-NAME-OR-RECORD's name to NEWNAME."
344BOOKMARK may be a bookmark name (a string) or a bookmark record." 347 (setcar (bookmark-get-bookmark bookmark-name-or-record) newname))
345 (setcar
346 (if (stringp bookmark) (bookmark-get-bookmark bookmark) bookmark)
347 newname))
348 348
349(defun bookmark-prop-get (bookmark prop) 349(defun bookmark-prop-get (bookmark-name-or-record prop)
350 "Return the property PROP of BOOKMARK, or nil if none. 350 "Return the property PROP of BOOKMARK-NAME-OR-RECORD, or nil if none."
351BOOKMARK may be a bookmark name (a string) or a bookmark record." 351 (cdr (assq prop (bookmark-get-bookmark-record bookmark-name-or-record))))
352 (cdr (assq prop (bookmark-get-bookmark-record bookmark))))
353 352
354(defun bookmark-prop-set (bookmark prop val) 353(defun bookmark-prop-set (bookmark-name-or-record prop val)
355 "Set the property PROP of BOOKMARK to VAL. 354 "Set the property PROP of BOOKMARK-NAME-OR-RECORD to VAL."
356BOOKMARK may be a bookmark name (a string) or a bookmark record." 355 (let ((cell (assq
357 (let ((cell (assq prop (bookmark-get-bookmark-record bookmark)))) 356 prop (bookmark-get-bookmark-record bookmark-name-or-record))))
358 (if cell 357 (if cell
359 (setcdr cell val) 358 (setcdr cell val)
360 (nconc (bookmark-get-bookmark-record bookmark) 359 (nconc (bookmark-get-bookmark-record bookmark-name-or-record)
361 (list (cons prop val)))))) 360 (list (cons prop val))))))
362 361
363(defun bookmark-get-annotation (bookmark) 362(defun bookmark-get-annotation (bookmark-name-or-record)
364 "Return the annotation of BOOKMARK, or nil if none. 363 "Return the annotation of BOOKMARK-NAME-OR-RECORD, or nil if none."
365BOOKMARK may be a bookmark name (a string) or a bookmark record." 364 (bookmark-prop-get bookmark-name-or-record 'annotation))
366 (bookmark-prop-get bookmark 'annotation))
367 365
368(defun bookmark-set-annotation (bookmark ann) 366(defun bookmark-set-annotation (bookmark-name-or-record ann)
369 "Set the annotation of BOOKMARK to ANN. 367 "Set the annotation of BOOKMARK-NAME-OR-RECORD to ANN."
370BOOKMARK may be a bookmark name (a string) or a bookmark record." 368 (bookmark-prop-set bookmark-name-or-record 'annotation ann))
371 (bookmark-prop-set bookmark 'annotation ann))
372 369
373 370
374(defun bookmark-get-filename (bookmark) 371(defun bookmark-get-filename (bookmark-name-or-record)
375 "Return the full filename of BOOKMARK, or nil if none. 372 "Return the full filename of BOOKMARK-NAME-OR-RECORD, or nil if none."
376BOOKMARK may be a bookmark name (a string) or a bookmark record." 373 (bookmark-prop-get bookmark-name-or-record 'filename))
377 (bookmark-prop-get bookmark 'filename))
378 374
379 375
380(defun bookmark-set-filename (bookmark filename) 376(defun bookmark-set-filename (bookmark-name-or-record filename)
381 "Set the full filename of BOOKMARK to FILENAME. 377 "Set the full filename of BOOKMARK-NAME-OR-RECORD to FILENAME."
382BOOKMARK may be a bookmark name (a string) or a bookmark record." 378 (bookmark-prop-set bookmark-name-or-record 'filename filename))
383 (bookmark-prop-set bookmark 'filename filename))
384 379
385 380
386(defun bookmark-get-position (bookmark) 381(defun bookmark-get-position (bookmark-name-or-record)
387 "Return the position (i.e.: point) of BOOKMARK, or nil if none. 382 "Return the position (i.e.: point) of BOOKMARK-NAME-OR-RECORD, or nil if none."
388BOOKMARK may be a bookmark name (a string) or a bookmark record." 383 (bookmark-prop-get bookmark-name-or-record 'position))
389 (bookmark-prop-get bookmark 'position))
390 384
391 385
392(defun bookmark-set-position (bookmark position) 386(defun bookmark-set-position (bookmark-name-or-record position)
393 "Set the position (i.e.: point) of BOOKMARK to POSITION. 387 "Set the position (i.e.: point) of BOOKMARK-NAME-OR-RECORD to POSITION."
394BOOKMARK may be a bookmark name (a string) or a bookmark record." 388 (bookmark-prop-set bookmark-name-or-record 'position position))
395 (bookmark-prop-set bookmark 'position position))
396 389
397 390
398(defun bookmark-get-front-context-string (bookmark) 391(defun bookmark-get-front-context-string (bookmark-name-or-record)
399 "Return the front-context-string of BOOKMARK, or nil if none. 392 "Return the front-context-string of BOOKMARK-NAME-OR-RECORD, or nil if none."
400BOOKMARK may be a bookmark name (a string) or a bookmark record." 393 (bookmark-prop-get bookmark-name-or-record 'front-context-string))
401 (bookmark-prop-get bookmark 'front-context-string))
402 394
403 395
404(defun bookmark-set-front-context-string (bookmark string) 396(defun bookmark-set-front-context-string (bookmark-name-or-record string)
405 "Set the front-context-string of BOOKMARK to STRING. 397 "Set the front-context-string of BOOKMARK-NAME-OR-RECORD to STRING."
406BOOKMARK may be a bookmark name (a string) or a bookmark record." 398 (bookmark-prop-set bookmark-name-or-record 'front-context-string string))
407 (bookmark-prop-set bookmark 'front-context-string string))
408 399
409 400
410(defun bookmark-get-rear-context-string (bookmark) 401(defun bookmark-get-rear-context-string (bookmark-name-or-record)
411 "Return the rear-context-string of BOOKMARK, or nil if none. 402 "Return the rear-context-string of BOOKMARK-NAME-OR-RECORD, or nil if none."
412BOOKMARK may be a bookmark name (a string) or a bookmark record." 403 (bookmark-prop-get bookmark-name-or-record 'rear-context-string))
413 (bookmark-prop-get bookmark 'rear-context-string))
414 404
415 405
416(defun bookmark-set-rear-context-string (bookmark string) 406(defun bookmark-set-rear-context-string (bookmark-name-or-record string)
417 "Set the rear-context-string of BOOKMARK to STRING. 407 "Set the rear-context-string of BOOKMARK-NAME-OR-RECORD to STRING."
418BOOKMARK may be a bookmark name (a string) or a bookmark record." 408 (bookmark-prop-set bookmark-name-or-record 'rear-context-string string))
419 (bookmark-prop-set bookmark 'rear-context-string string))
420 409
421 410
422(defun bookmark-get-handler (bookmark) 411(defun bookmark-get-handler (bookmark-name-or-record)
423 "Return the handler function for BOOKMARK, or nil if none. 412 "Return the handler function for BOOKMARK-NAME-OR-RECORD, or nil if none."
424BOOKMARK may be a bookmark name (a string) or a bookmark record." 413 (bookmark-prop-get bookmark-name-or-record 'handler))
425 (bookmark-prop-get bookmark 'handler))
426 414
427(defvar bookmark-history nil 415(defvar bookmark-history nil
428 "The history list for bookmark functions.") 416 "The history list for bookmark functions.")
@@ -830,11 +818,11 @@ This is used in `bookmark-edit-annotation' to record the bookmark
830whose annotation is being edited.") 818whose annotation is being edited.")
831 819
832 820
833(defun bookmark-default-annotation-text (bookmark) 821(defun bookmark-default-annotation-text (bookmark-name)
834 "Return default annotation text for BOOKMARK (a string, not a record). 822 "Return default annotation text for BOOKMARK-NAME.
835The default annotation text is simply some text explaining how to use 823The default annotation text is simply some text explaining how to use
836annotations." 824annotations."
837 (concat "# Type the annotation for bookmark '" bookmark "' here.\n" 825 (concat "# Type the annotation for bookmark '" bookmark-name "' here.\n"
838 "# All lines which start with a '#' will be deleted.\n" 826 "# All lines which start with a '#' will be deleted.\n"
839 "# Type C-c C-c when done.\n#\n" 827 "# Type C-c C-c when done.\n#\n"
840 "# Author: " (user-full-name) " <" (user-login-name) "@" 828 "# Author: " (user-full-name) " <" (user-login-name) "@"
@@ -856,22 +844,20 @@ It takes one argument, the name of the bookmark, as a string.")
856 "Keymap for editing an annotation of a bookmark.") 844 "Keymap for editing an annotation of a bookmark.")
857 845
858 846
859(defun bookmark-edit-annotation-mode (bookmark) 847(defun bookmark-edit-annotation-mode (bookmark-name-or-record)
860 "Mode for editing the annotation of bookmark BOOKMARK. 848 "Mode for editing the annotation of bookmark BOOKMARK-NAME-OR-RECORD.
861When you have finished composing, type \\[bookmark-send-annotation]. 849When you have finished composing, type \\[bookmark-send-annotation].
862 850
863BOOKMARK is a bookmark name (a string) or a bookmark record.
864
865\\{bookmark-edit-annotation-mode-map}" 851\\{bookmark-edit-annotation-mode-map}"
866 (interactive) 852 (interactive)
867 (kill-all-local-variables) 853 (kill-all-local-variables)
868 (make-local-variable 'bookmark-annotation-name) 854 (make-local-variable 'bookmark-annotation-name)
869 (setq bookmark-annotation-name bookmark) 855 (setq bookmark-annotation-name bookmark-name-or-record)
870 (use-local-map bookmark-edit-annotation-mode-map) 856 (use-local-map bookmark-edit-annotation-mode-map)
871 (setq major-mode 'bookmark-edit-annotation-mode 857 (setq major-mode 'bookmark-edit-annotation-mode
872 mode-name "Edit Bookmark Annotation") 858 mode-name "Edit Bookmark Annotation")
873 (insert (funcall bookmark-edit-annotation-text-func bookmark)) 859 (insert (funcall bookmark-edit-annotation-text-func bookmark-name-or-record))
874 (let ((annotation (bookmark-get-annotation bookmark))) 860 (let ((annotation (bookmark-get-annotation bookmark-name-or-record)))
875 (if (and annotation (not (string-equal annotation ""))) 861 (if (and annotation (not (string-equal annotation "")))
876 (insert annotation))) 862 (insert annotation)))
877 (run-mode-hooks 'text-mode-hook)) 863 (run-mode-hooks 'text-mode-hook))
@@ -890,19 +876,18 @@ Lines beginning with `#' are ignored."
890 (forward-line 1))) 876 (forward-line 1)))
891 ;; Take no chances with text properties. 877 ;; Take no chances with text properties.
892 (let ((annotation (buffer-substring-no-properties (point-min) (point-max))) 878 (let ((annotation (buffer-substring-no-properties (point-min) (point-max)))
893 (bookmark bookmark-annotation-name)) 879 (bookmark-name bookmark-annotation-name))
894 (bookmark-set-annotation bookmark annotation) 880 (bookmark-set-annotation bookmark-name annotation)
895 (setq bookmark-alist-modification-count 881 (setq bookmark-alist-modification-count
896 (1+ bookmark-alist-modification-count)) 882 (1+ bookmark-alist-modification-count))
897 (bookmark-bmenu-surreptitiously-rebuild-list)) 883 (bookmark-bmenu-surreptitiously-rebuild-list))
898 (kill-buffer (current-buffer))) 884 (kill-buffer (current-buffer)))
899 885
900 886
901(defun bookmark-edit-annotation (bookmark) 887(defun bookmark-edit-annotation (bookmark-name-or-record)
902 "Pop up a buffer for editing bookmark BOOKMARK's annotation. 888 "Pop up a buffer for editing bookmark BOOKMARK-NAME-OR-RECORD's annotation."
903BOOKMARK is a bookmark name (a string) or a bookmark record."
904 (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*")) 889 (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*"))
905 (bookmark-edit-annotation-mode bookmark)) 890 (bookmark-edit-annotation-mode bookmark-name-or-record))
906 891
907 892
908(defun bookmark-insert-current-bookmark () 893(defun bookmark-insert-current-bookmark ()
@@ -1002,14 +987,14 @@ If `bookmark-sort-flag' is non-nil, then return a sorted copy of the alist."
1002 "Hook run after `bookmark-jump' jumps to a bookmark. 987 "Hook run after `bookmark-jump' jumps to a bookmark.
1003Useful for example to unhide text in `outline-mode'.") 988Useful for example to unhide text in `outline-mode'.")
1004 989
1005(defun bookmark--jump-via (bookmark display-function) 990(defun bookmark--jump-via (bookmark-name-or-record display-function)
1006 "Handle BOOKMARK, then call DISPLAY-FUNCTION with current buffer as argument. 991 "Handle BOOKMARK-NAME-OR-RECORD, then call DISPLAY-FUNCTION with
1007Bookmark may be a bookmark name (a string) or a bookmark record. 992current buffer as argument.
1008 993
1009After calling DISPLAY-FUNCTION, set window point to the point specified 994After calling DISPLAY-FUNCTION, set window point to the point specified
1010by BOOKMARK, if necessary, run `bookmark-after-jump-hook', and then show 995by BOOKMARK-NAME-OR-RECORD, if necessary, run `bookmark-after-jump-hook',
1011any annotations for this bookmark." 996and then show any annotations for this bookmark."
1012 (bookmark-handle-bookmark bookmark) 997 (bookmark-handle-bookmark bookmark-name-or-record)
1013 (save-current-buffer 998 (save-current-buffer
1014 (funcall display-function (current-buffer))) 999 (funcall display-function (current-buffer)))
1015 (let ((win (get-buffer-window (current-buffer) 0))) 1000 (let ((win (get-buffer-window (current-buffer) 0)))
@@ -1020,7 +1005,7 @@ any annotations for this bookmark."
1020 (if bookmark-automatically-show-annotations 1005 (if bookmark-automatically-show-annotations
1021 ;; if there is an annotation for this bookmark, 1006 ;; if there is an annotation for this bookmark,
1022 ;; show it in a buffer. 1007 ;; show it in a buffer.
1023 (bookmark-show-annotation bookmark))) 1008 (bookmark-show-annotation bookmark-name-or-record)))
1024 1009
1025 1010
1026;;;###autoload 1011;;;###autoload
@@ -1036,8 +1021,8 @@ if you wish to give the bookmark a new location, and `bookmark-jump'
1036will then jump to the new location, as well as recording it in place 1021will then jump to the new location, as well as recording it in place
1037of the old one in the permanent bookmark record. 1022of the old one in the permanent bookmark record.
1038 1023
1039BOOKMARK may be a bookmark name (a string) or a bookmark record, but 1024BOOKMARK is usually a bookmark name (a string). It can also be a
1040the latter is usually only used by programmatic callers. 1025bookmark record, but this is usually only done by programmatic callers.
1041 1026
1042If DISPLAY-FUNC is non-nil, it is a function to invoke to display the 1027If DISPLAY-FUNC is non-nil, it is a function to invoke to display the
1043bookmark. It defaults to `switch-to-buffer'. A typical value for 1028bookmark. It defaults to `switch-to-buffer'. A typical value for
@@ -1061,11 +1046,9 @@ DISPLAY-FUNC would be `switch-to-buffer-other-window'."
1061 1046
1062 1047
1063(defun bookmark-jump-noselect (bookmark) 1048(defun bookmark-jump-noselect (bookmark)
1064 "Return the location pointed to by the bookmark BOOKMARK. 1049 "Return the location pointed to by BOOKMARK (see `bookmark-jump').
1065The return value has the form (BUFFER . POINT). 1050The return value has the form (BUFFER . POINT).
1066 1051
1067BOOKMARK may be a bookmark name (a string) or a bookmark record.
1068
1069Note: this function is deprecated and is present for Emacs 22 1052Note: this function is deprecated and is present for Emacs 22
1070compatibility only." 1053compatibility only."
1071 (save-excursion 1054 (save-excursion
@@ -1074,26 +1057,27 @@ compatibility only."
1074 1057
1075(make-obsolete 'bookmark-jump-noselect 'bookmark-handle-bookmark "23.1") 1058(make-obsolete 'bookmark-jump-noselect 'bookmark-handle-bookmark "23.1")
1076 1059
1077(defun bookmark-handle-bookmark (bookmark) 1060(defun bookmark-handle-bookmark (bookmark-name-or-record)
1078 "Call BOOKMARK's handler or `bookmark-default-handler' if it has none. 1061 "Call BOOKMARK-NAME-OR-RECORD's handler or `bookmark-default-handler'
1079BOOKMARK may be a bookmark name (a string) or a bookmark record. 1062if it has none. This changes current buffer and point and returns nil,
1080 1063or signals a `file-error'.
1081Changes current buffer and point and returns nil, or signals a `file-error'.
1082 1064
1083If BOOKMARK has no file, this is a no-op. If BOOKMARK has a file, but 1065If BOOKMARK-NAME-OR-RECORD has no file, this is a no-op. If
1084that file no longer exists, then offer interactively to relocate BOOKMARK." 1066BOOKMARK-NAME-OR-RECORD has a file, but that file no longer exists,
1067then offer interactively to relocate BOOKMARK-NAME-OR-RECORD."
1085 (condition-case err 1068 (condition-case err
1086 (funcall (or (bookmark-get-handler bookmark) 1069 (funcall (or (bookmark-get-handler bookmark-name-or-record)
1087 'bookmark-default-handler) 1070 'bookmark-default-handler)
1088 (bookmark-get-bookmark bookmark)) 1071 (bookmark-get-bookmark bookmark-name-or-record))
1089 (bookmark-error-no-filename ;file-error 1072 (bookmark-error-no-filename ;file-error
1090 ;; We were unable to find the marked file, so ask if user wants to 1073 ;; We were unable to find the marked file, so ask if user wants to
1091 ;; relocate the bookmark, else remind them to consider deletion. 1074 ;; relocate the bookmark, else remind them to consider deletion.
1092 (when (stringp bookmark) 1075 (when (stringp bookmark-name-or-record)
1093 ;; `bookmark' can be either a bookmark name (from `bookmark-alist') 1076 ;; `bookmark-name-or-record' can be either a bookmark name
1094 ;; or a bookmark object. If it's an object, we assume it's a 1077 ;; (from `bookmark-alist') or a bookmark object. If it's an
1095 ;; bookmark used internally by some other package. 1078 ;; object, we assume it's a bookmark used internally by some
1096 (let ((file (bookmark-get-filename bookmark))) 1079 ;; other package.
1080 (let ((file (bookmark-get-filename bookmark-name-or-record)))
1097 (when file ;Don't know how to relocate if there's no `file'. 1081 (when file ;Don't know how to relocate if there's no `file'.
1098 ;; If file is not a dir, directory-file-name just returns file. 1082 ;; If file is not a dir, directory-file-name just returns file.
1099 (let ((display-name (directory-file-name file))) 1083 (let ((display-name (directory-file-name file)))
@@ -1106,20 +1090,20 @@ that file no longer exists, then offer interactively to relocate BOOKMARK."
1106 (let ((use-dialog-box nil) 1090 (let ((use-dialog-box nil)
1107 (use-file-dialog nil)) 1091 (use-file-dialog nil))
1108 (if (y-or-n-p (concat display-name " nonexistent. Relocate \"" 1092 (if (y-or-n-p (concat display-name " nonexistent. Relocate \""
1109 bookmark "\"? ")) 1093 bookmark-name-or-record "\"? "))
1110 (progn 1094 (progn
1111 (bookmark-relocate bookmark) 1095 (bookmark-relocate bookmark-name-or-record)
1112 ;; Try again. 1096 ;; Try again.
1113 (funcall (or (bookmark-get-handler bookmark) 1097 (funcall (or (bookmark-get-handler bookmark-name-or-record)
1114 'bookmark-default-handler) 1098 'bookmark-default-handler)
1115 (bookmark-get-bookmark bookmark))) 1099 (bookmark-get-bookmark bookmark-name-or-record)))
1116 (message 1100 (message
1117 "Bookmark not relocated; consider removing it (%s)." 1101 "Bookmark not relocated; consider removing it (%s)."
1118 bookmark) 1102 bookmark-name-or-record)
1119 (signal (car err) (cdr err)))))))))) 1103 (signal (car err) (cdr err))))))))))
1120 ;; Added by db. 1104 ;; Added by db.
1121 (when (stringp bookmark) 1105 (when (stringp bookmark-name-or-record)
1122 (setq bookmark-current-bookmark bookmark)) 1106 (setq bookmark-current-bookmark bookmark-name-or-record))
1123 nil) 1107 nil)
1124 1108
1125(put 'bookmark-error-no-filename 1109(put 'bookmark-error-no-filename
@@ -1159,23 +1143,22 @@ Changes current buffer and point and returns nil, or signals a `file-error'."
1159 nil)) 1143 nil))
1160 1144
1161;;;###autoload 1145;;;###autoload
1162(defun bookmark-relocate (bookmark) 1146(defun bookmark-relocate (bookmark-name)
1163 "Relocate BOOKMARK to another file (reading file name with minibuffer). 1147 "Relocate BOOKMARK-NAME to another file, reading file name with minibuffer.
1164BOOKMARK is a bookmark name (a string), not a bookmark record.
1165 1148
1166This makes an already existing bookmark point to that file, instead of 1149This makes an already existing bookmark point to that file, instead of
1167the one it used to point at. Useful when a file has been renamed 1150the one it used to point at. Useful when a file has been renamed
1168after a bookmark was set in it." 1151after a bookmark was set in it."
1169 (interactive (list (bookmark-completing-read "Bookmark to relocate"))) 1152 (interactive (list (bookmark-completing-read "Bookmark to relocate")))
1170 (bookmark-maybe-historicize-string bookmark) 1153 (bookmark-maybe-historicize-string bookmark-name)
1171 (bookmark-maybe-load-default-file) 1154 (bookmark-maybe-load-default-file)
1172 (let* ((bmrk-filename (bookmark-get-filename bookmark)) 1155 (let* ((bmrk-filename (bookmark-get-filename bookmark-name))
1173 (newloc (abbreviate-file-name 1156 (newloc (abbreviate-file-name
1174 (expand-file-name 1157 (expand-file-name
1175 (read-file-name 1158 (read-file-name
1176 (format "Relocate %s to: " bookmark) 1159 (format "Relocate %s to: " bookmark-name)
1177 (file-name-directory bmrk-filename)))))) 1160 (file-name-directory bmrk-filename))))))
1178 (bookmark-set-filename bookmark newloc) 1161 (bookmark-set-filename bookmark-name newloc)
1179 (setq bookmark-alist-modification-count 1162 (setq bookmark-alist-modification-count
1180 (1+ bookmark-alist-modification-count)) 1163 (1+ bookmark-alist-modification-count))
1181 (if (bookmark-time-to-save-p) 1164 (if (bookmark-time-to-save-p)
@@ -1184,17 +1167,16 @@ after a bookmark was set in it."
1184 1167
1185 1168
1186;;;###autoload 1169;;;###autoload
1187(defun bookmark-insert-location (bookmark &optional no-history) 1170(defun bookmark-insert-location (bookmark-name &optional no-history)
1188 "Insert the name of the file associated with BOOKMARK. 1171 "Insert the name of the file associated with BOOKMARK-NAME.
1189BOOKMARK is a bookmark name (a string), not a bookmark record.
1190 1172
1191Optional second arg NO-HISTORY means don't record this in the 1173Optional second arg NO-HISTORY means don't record this in the
1192minibuffer history list `bookmark-history'." 1174minibuffer history list `bookmark-history'."
1193 (interactive (list (bookmark-completing-read "Insert bookmark location"))) 1175 (interactive (list (bookmark-completing-read "Insert bookmark location")))
1194 (or no-history (bookmark-maybe-historicize-string bookmark)) 1176 (or no-history (bookmark-maybe-historicize-string bookmark-name))
1195 (let ((start (point))) 1177 (let ((start (point)))
1196 (prog1 1178 (prog1
1197 (insert (bookmark-location bookmark)) 1179 (insert (bookmark-location bookmark-name))
1198 (if (display-mouse-p) 1180 (if (display-mouse-p)
1199 (add-text-properties 1181 (add-text-properties
1200 start 1182 start
@@ -1208,42 +1190,39 @@ minibuffer history list `bookmark-history'."
1208;;;###autoload 1190;;;###autoload
1209(defalias 'bookmark-locate 'bookmark-insert-location) 1191(defalias 'bookmark-locate 'bookmark-insert-location)
1210 1192
1211(defun bookmark-location (bookmark) 1193(defun bookmark-location (bookmark-name-or-record)
1212 "Return a description of the location of BOOKMARK. 1194 "Return a description of the location of BOOKMARK-NAME-OR-RECORD."
1213BOOKMARK may be a bookmark name (a string) or a bookmark record."
1214 (bookmark-maybe-load-default-file) 1195 (bookmark-maybe-load-default-file)
1215 ;; We could call the `handler' and ask for it to construct a description 1196 ;; We could call the `handler' and ask for it to construct a description
1216 ;; dynamically: it would open up several new possibilities, but it 1197 ;; dynamically: it would open up several new possibilities, but it
1217 ;; would have the major disadvantage of forcing to load each and 1198 ;; would have the major disadvantage of forcing to load each and
1218 ;; every handler when the user calls bookmark-menu. 1199 ;; every handler when the user calls bookmark-menu.
1219 (or (bookmark-prop-get bookmark 'location) 1200 (or (bookmark-prop-get bookmark-name-or-record 'location)
1220 (bookmark-get-filename bookmark) 1201 (bookmark-get-filename bookmark-name-or-record)
1221 "-- Unknown location --")) 1202 "-- Unknown location --"))
1222 1203
1223 1204
1224;;;###autoload 1205;;;###autoload
1225(defun bookmark-rename (old &optional new) 1206(defun bookmark-rename (old-name &optional new-name)
1226 "Change the name of OLD bookmark to NEW name. 1207 "Change the name of OLD-NAME bookmark to NEW-NAME name.
1227If called from keyboard, prompt for OLD and NEW. If called from 1208If called from keyboard, prompt for OLD-NAME and NEW-NAME.
1228menubar, select OLD from a menu and prompt for NEW. 1209If called from menubar, select OLD-NAME from a menu and prompt for NEW-NAME.
1229
1230Both OLD and NEW are bookmark names (strings), never bookmark records.
1231 1210
1232If called from Lisp, prompt for NEW if only OLD was passed as an 1211If called from Lisp, prompt for NEW-NAME if only OLD-NAME was passed
1233argument. If called with two strings, then no prompting is done. You 1212as an argument. If called with two strings, then no prompting is done.
1234must pass at least OLD when calling from Lisp. 1213You must pass at least OLD-NAME when calling from Lisp.
1235 1214
1236While you are entering the new name, consecutive C-w's insert 1215While you are entering the new name, consecutive C-w's insert
1237consecutive words from the text of the buffer into the new bookmark 1216consecutive words from the text of the buffer into the new bookmark
1238name." 1217name."
1239 (interactive (list (bookmark-completing-read "Old bookmark name"))) 1218 (interactive (list (bookmark-completing-read "Old bookmark name")))
1240 (bookmark-maybe-historicize-string old) 1219 (bookmark-maybe-historicize-string old-name)
1241 (bookmark-maybe-load-default-file) 1220 (bookmark-maybe-load-default-file)
1242 1221
1243 (setq bookmark-yank-point (point)) 1222 (setq bookmark-yank-point (point))
1244 (setq bookmark-current-buffer (current-buffer)) 1223 (setq bookmark-current-buffer (current-buffer))
1245 (let ((newname 1224 (let ((final-new-name
1246 (or new ; use second arg, if non-nil 1225 (or new-name ; use second arg, if non-nil
1247 (read-from-minibuffer 1226 (read-from-minibuffer
1248 "New name: " 1227 "New name: "
1249 nil 1228 nil
@@ -1252,8 +1231,8 @@ name."
1252 now-map) 1231 now-map)
1253 nil 1232 nil
1254 'bookmark-history)))) 1233 'bookmark-history))))
1255 (bookmark-set-name old newname) 1234 (bookmark-set-name old-name final-new-name)
1256 (setq bookmark-current-bookmark newname) 1235 (setq bookmark-current-bookmark final-new-name)
1257 (bookmark-bmenu-surreptitiously-rebuild-list) 1236 (bookmark-bmenu-surreptitiously-rebuild-list)
1258 (setq bookmark-alist-modification-count 1237 (setq bookmark-alist-modification-count
1259 (1+ bookmark-alist-modification-count)) 1238 (1+ bookmark-alist-modification-count))
@@ -1262,21 +1241,21 @@ name."
1262 1241
1263 1242
1264;;;###autoload 1243;;;###autoload
1265(defun bookmark-insert (bookmark) 1244(defun bookmark-insert (bookmark-name)
1266 "Insert the text of the file pointed to by bookmark BOOKMARK. 1245 "Insert the text of the file pointed to by bookmark BOOKMARK-NAME.
1267BOOKMARK is a bookmark name (a string), not a bookmark record. 1246BOOKMARK-NAME is a bookmark name (a string), not a bookmark record.
1268 1247
1269You may have a problem using this function if the value of variable 1248You may have a problem using this function if the value of variable
1270`bookmark-alist' is nil. If that happens, you need to load in some 1249`bookmark-alist' is nil. If that happens, you need to load in some
1271bookmarks. See help on function `bookmark-load' for more about 1250bookmarks. See help on function `bookmark-load' for more about
1272this." 1251this."
1273 (interactive (list (bookmark-completing-read "Insert bookmark contents"))) 1252 (interactive (list (bookmark-completing-read "Insert bookmark contents")))
1274 (bookmark-maybe-historicize-string bookmark) 1253 (bookmark-maybe-historicize-string bookmark-name)
1275 (bookmark-maybe-load-default-file) 1254 (bookmark-maybe-load-default-file)
1276 (let ((orig-point (point)) 1255 (let ((orig-point (point))
1277 (str-to-insert 1256 (str-to-insert
1278 (save-current-buffer 1257 (save-current-buffer
1279 (bookmark-handle-bookmark bookmark) 1258 (bookmark-handle-bookmark bookmark-name)
1280 (buffer-string)))) 1259 (buffer-string))))
1281 (insert str-to-insert) 1260 (insert str-to-insert)
1282 (push-mark) 1261 (push-mark)
@@ -1284,9 +1263,8 @@ this."
1284 1263
1285 1264
1286;;;###autoload 1265;;;###autoload
1287(defun bookmark-delete (bookmark &optional batch) 1266(defun bookmark-delete (bookmark-name &optional batch)
1288 "Delete BOOKMARK from the bookmark list. 1267 "Delete BOOKMARK-NAME from the bookmark list.
1289BOOKMARK is a bookmark name (a string), not a bookmark record.
1290 1268
1291Removes only the first instance of a bookmark with that name. If 1269Removes only the first instance of a bookmark with that name. If
1292there are one or more other bookmarks with the same name, they will 1270there are one or more other bookmarks with the same name, they will
@@ -1297,9 +1275,9 @@ probably because we were called from there."
1297 (interactive 1275 (interactive
1298 (list (bookmark-completing-read "Delete bookmark" 1276 (list (bookmark-completing-read "Delete bookmark"
1299 bookmark-current-bookmark))) 1277 bookmark-current-bookmark)))
1300 (bookmark-maybe-historicize-string bookmark) 1278 (bookmark-maybe-historicize-string bookmark-name)
1301 (bookmark-maybe-load-default-file) 1279 (bookmark-maybe-load-default-file)
1302 (let ((will-go (bookmark-get-bookmark bookmark 'noerror))) 1280 (let ((will-go (bookmark-get-bookmark bookmark-name 'noerror)))
1303 (setq bookmark-alist (delq will-go bookmark-alist)) 1281 (setq bookmark-alist (delq will-go bookmark-alist))
1304 ;; Added by db, nil bookmark-current-bookmark if the last 1282 ;; Added by db, nil bookmark-current-bookmark if the last
1305 ;; occurrence has been deleted 1283 ;; occurrence has been deleted
@@ -1413,13 +1391,13 @@ they conflict with existing bookmark names."
1413 (dolist (full-record new-list) 1391 (dolist (full-record new-list)
1414 (bookmark-maybe-rename full-record names) 1392 (bookmark-maybe-rename full-record names)
1415 (setq bookmark-alist (nconc bookmark-alist (list full-record))) 1393 (setq bookmark-alist (nconc bookmark-alist (list full-record)))
1416 (push (bookmark-name-from-full-record full-record) names)))) 1394 (push (bookmark-name-from-record full-record) names))))
1417 1395
1418 1396
1419(defun bookmark-maybe-rename (full-record names) 1397(defun bookmark-maybe-rename (full-record names)
1420 "Rename bookmark FULL-RECORD if its current name is already used. 1398 "Rename bookmark FULL-RECORD if its current name is already used.
1421This is a helper for `bookmark-import-new-list'." 1399This is a helper for `bookmark-import-new-list'."
1422 (let ((found-name (bookmark-name-from-full-record full-record))) 1400 (let ((found-name (bookmark-name-from-record full-record)))
1423 (if (member found-name names) 1401 (if (member found-name names)
1424 ;; We've got a conflict, so generate a new name 1402 ;; We've got a conflict, so generate a new name
1425 (let ((count 2) 1403 (let ((count 2)
@@ -1577,7 +1555,7 @@ deletion, or > if it is flagged for displaying."
1577 (add-text-properties (point-min) (point) 1555 (add-text-properties (point-min) (point)
1578 '(font-lock-face bookmark-menu-heading)) 1556 '(font-lock-face bookmark-menu-heading))
1579 (dolist (full-record (bookmark-maybe-sort-alist)) 1557 (dolist (full-record (bookmark-maybe-sort-alist))
1580 (let ((name (bookmark-name-from-full-record full-record)) 1558 (let ((name (bookmark-name-from-record full-record))
1581 (annotation (bookmark-get-annotation full-record)) 1559 (annotation (bookmark-get-annotation full-record))
1582 (start (point)) 1560 (start (point))
1583 end) 1561 end)
@@ -1747,16 +1725,15 @@ last full line, move to the last full line. The return value is undefined."
1747 (get-text-property (point) 'bookmark-name-prop))) 1725 (get-text-property (point) 'bookmark-name-prop)))
1748 1726
1749 1727
1750(defun bookmark-show-annotation (bookmark) 1728(defun bookmark-show-annotation (bookmark-name-or-record)
1751 "Display the annotation for bookmark named BOOKMARK in a buffer, 1729 "Display the annotation for BOOKMARK-NAME-OR-RECORD in a buffer,
1752if an annotation exists." 1730if an annotation exists."
1753 (let ((annotation (bookmark-get-annotation bookmark))) 1731 (let ((annotation (bookmark-get-annotation bookmark-name-or-record)))
1754 (when (and annotation (not (string-equal annotation ""))) 1732 (when (and annotation (not (string-equal annotation "")))
1755 (save-excursion 1733 (save-excursion
1756 (let ((old-buf (current-buffer))) 1734 (let ((old-buf (current-buffer)))
1757 (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t) 1735 (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t)
1758 (delete-region (point-min) (point-max)) 1736 (delete-region (point-min) (point-max))
1759 ;; (insert (concat "Annotation for bookmark '" bookmark "':\n\n"))
1760 (insert annotation) 1737 (insert annotation)
1761 (goto-char (point-min)) 1738 (goto-char (point-min))
1762 (switch-to-buffer-other-window old-buf)))))) 1739 (switch-to-buffer-other-window old-buf))))))
@@ -1768,7 +1745,7 @@ if an annotation exists."
1768 (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t) 1745 (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t)
1769 (delete-region (point-min) (point-max)) 1746 (delete-region (point-min) (point-max))
1770 (dolist (full-record bookmark-alist) 1747 (dolist (full-record bookmark-alist)
1771 (let* ((name (bookmark-name-from-full-record full-record)) 1748 (let* ((name (bookmark-name-from-record full-record))
1772 (ann (bookmark-get-annotation full-record))) 1749 (ann (bookmark-get-annotation full-record)))
1773 (insert (concat name ":\n")) 1750 (insert (concat name ":\n"))
1774 (if (and ann (not (string-equal ann ""))) 1751 (if (and ann (not (string-equal ann "")))