diff options
| author | Karl Fogel | 2009-10-05 01:35:34 +0000 |
|---|---|---|
| committer | Karl Fogel | 2009-10-05 01:35:34 +0000 |
| commit | 13901bcbc4926630bdb2127301af0cdf7bcc50f7 (patch) | |
| tree | f32b4a072307dc9f59ec5da0785b854cb3be50dc | |
| parent | 5c1b3e94ad244e8aa79314907b47fae25844cc3e (diff) | |
| download | emacs-13901bcbc4926630bdb2127301af0cdf7bcc50f7.tar.gz emacs-13901bcbc4926630bdb2127301af0cdf7bcc50f7.zip | |
* bookmark.el
(bookmark-get-bookmark, bookmark-get-bookmark-record,
bookmark-set-name, 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-location, bookmark-jump, bookmark-jump-other-window,
bookmark-handle-bookmark, bookmark-relocate, bookmark-insert-location,
bookmark-rename, bookmark-insert, bookmark-delete, bookmark-time-to-save-p,
bookmark-edit-annotation-mode, bookmark-edit-annotation): Improve doc
strings to say whether bookmark can be a string or a record or both,
and make other consistency and clarity fixes.
(bookmark-get-handler, bookmark--jump-via, bookmark-write-file,
bookmark-default-annotation-text, bookmark-yank-word,
bookmark-maybe-load-default-file, bookmark-maybe-sort-alist,
bookmark-import-new-list, bookmark-maybe-rename,
bookmark-bmenu-show-filenames, bookmark-bmenu-hide-filenames,
bookmark-bmenu-bookmark): Give these doc strings.
(bookmark-bmenu-check-position): Give this a doc string, but also
add a FIXME comment about how the function may be pointless.
(bookmark-default-handler): Rework doc string and change a parameter
name, to clarify that this takes a bookmark record not a bookmark name.
(bookmark-set): Change a parameter name to indicate its meaning,
and improve the doc string a bit.
(Bug#4188)
| -rw-r--r-- | lisp/ChangeLog | 30 | ||||
| -rw-r--r-- | lisp/bookmark.el | 193 |
2 files changed, 153 insertions, 70 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cf070abcce5..68f827b215a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,35 @@ | |||
| 1 | 2009-10-04 Karl Fogel <kfogel@red-bean.com> | 1 | 2009-10-04 Karl Fogel <kfogel@red-bean.com> |
| 2 | 2 | ||
| 3 | * bookmark.el (bookmark-get-bookmark, bookmark-get-bookmark-record, | ||
| 4 | bookmark-set-name, bookmark-prop-get, bookmark-prop-set, | ||
| 5 | bookmark-get-annotation, bookmark-set-annotation, | ||
| 6 | bookmark-get-filename, bookmark-set-filename, bookmark-get-position, | ||
| 7 | bookmark-set-position, bookmark-get-front-context-string, | ||
| 8 | bookmark-set-front-context-string, bookmark-get-rear-context-string, | ||
| 9 | bookmark-set-rear-context-string, bookmark-location, bookmark-jump, | ||
| 10 | bookmark-jump-other-window, bookmark-handle-bookmark, | ||
| 11 | bookmark-relocate, bookmark-insert-location, bookmark-rename, | ||
| 12 | bookmark-insert, bookmark-delete, bookmark-time-to-save-p, | ||
| 13 | bookmark-edit-annotation-mode, bookmark-edit-annotation): Improve | ||
| 14 | doc strings to say whether bookmark can be a string or a record | ||
| 15 | or both, and make other consistency and clarity fixes. | ||
| 16 | (bookmark-get-handler, bookmark--jump-via, bookmark-write-file | ||
| 17 | bookmark-default-annotation-text, bookmark-yank-word, | ||
| 18 | bookmark-maybe-load-default-file, bookmark-maybe-sort-alist, | ||
| 19 | bookmark-import-new-list, bookmark-maybe-rename, | ||
| 20 | bookmark-bmenu-show-filenames, bookmark-bmenu-hide-filenames, | ||
| 21 | bookmark-bmenu-bookmark): Give these doc strings. | ||
| 22 | (bookmark-bmenu-check-position): Give this a doc string, but also | ||
| 23 | add a FIXME comment about how the function may be pointless. | ||
| 24 | (bookmark-default-handler): Rework doc string and change a | ||
| 25 | parameter name, to clarify that this takes a bookmark record | ||
| 26 | not a bookmark name. | ||
| 27 | (bookmark-set): Change a parameter name to indicate its meaning, | ||
| 28 | and improve the doc string a bit. | ||
| 29 | (Bug#4188) | ||
| 30 | |||
| 31 | 2009-10-04 Karl Fogel <kfogel@red-bean.com> | ||
| 32 | |||
| 3 | * bookmark.el (bookmark-alist): Document the new `handler' element | 33 | * bookmark.el (bookmark-alist): Document the new `handler' element |
| 4 | in the param alist. | 34 | in the param alist. |
| 5 | (bookmark-make-record-function): Adjust documentation for above. | 35 | (bookmark-make-record-function): Adjust documentation for above. |
diff --git a/lisp/bookmark.el b/lisp/bookmark.el index c072b568a82..b2da75c8b1d 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el | |||
| @@ -325,8 +325,9 @@ through a file easier.") | |||
| 325 | 325 | ||
| 326 | (defun bookmark-get-bookmark (bookmark &optional noerror) | 326 | (defun bookmark-get-bookmark (bookmark &optional noerror) |
| 327 | "Return the bookmark record corresponding to BOOKMARK. | 327 | "Return the bookmark record corresponding to BOOKMARK. |
| 328 | If BOOKMARK is already a bookmark record, just return it, | 328 | If BOOKMARK is a string, look for the corresponding bookmark record in |
| 329 | Otherwise look for the corresponding bookmark in `bookmark-alist'." | 329 | `bookmark-alist'; return it if found, otherwise error. Else if |
| 330 | BOOKMARK is already a bookmark record, just return it." | ||
| 330 | (cond | 331 | (cond |
| 331 | ((consp bookmark) bookmark) | 332 | ((consp bookmark) bookmark) |
| 332 | ((stringp bookmark) | 333 | ((stringp bookmark) |
| @@ -335,8 +336,9 @@ Otherwise look for the corresponding bookmark in `bookmark-alist'." | |||
| 335 | 336 | ||
| 336 | 337 | ||
| 337 | (defun bookmark-get-bookmark-record (bookmark) | 338 | (defun bookmark-get-bookmark-record (bookmark) |
| 338 | "Return the guts of the entry for BOOKMARK in `bookmark-alist'. | 339 | "Return the record portion of the entry for BOOKMARK in |
| 339 | That is, all information but the name." | 340 | `bookmark-alist' (that is, all information but the name). |
| 341 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 340 | (let ((alist (cdr (bookmark-get-bookmark bookmark)))) | 342 | (let ((alist (cdr (bookmark-get-bookmark bookmark)))) |
| 341 | ;; The bookmark objects can either look like (NAME ALIST) or | 343 | ;; The bookmark objects can either look like (NAME ALIST) or |
| 342 | ;; (NAME . ALIST), so we have to distinguish the two here. | 344 | ;; (NAME . ALIST), so we have to distinguish the two here. |
| @@ -345,17 +347,20 @@ That is, all information but the name." | |||
| 345 | 347 | ||
| 346 | 348 | ||
| 347 | (defun bookmark-set-name (bookmark newname) | 349 | (defun bookmark-set-name (bookmark newname) |
| 348 | "Set BOOKMARK's name to NEWNAME." | 350 | "Set BOOKMARK's name to NEWNAME. |
| 351 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 349 | (setcar | 352 | (setcar |
| 350 | (if (stringp bookmark) (bookmark-get-bookmark bookmark) bookmark) | 353 | (if (stringp bookmark) (bookmark-get-bookmark bookmark) bookmark) |
| 351 | newname)) | 354 | newname)) |
| 352 | 355 | ||
| 353 | (defun bookmark-prop-get (bookmark prop) | 356 | (defun bookmark-prop-get (bookmark prop) |
| 354 | "Return the property PROP of BOOKMARK, or nil if none." | 357 | "Return the property PROP of BOOKMARK, or nil if none. |
| 358 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 355 | (cdr (assq prop (bookmark-get-bookmark-record bookmark)))) | 359 | (cdr (assq prop (bookmark-get-bookmark-record bookmark)))) |
| 356 | 360 | ||
| 357 | (defun bookmark-prop-set (bookmark prop val) | 361 | (defun bookmark-prop-set (bookmark prop val) |
| 358 | "Set the property PROP of BOOKMARK to VAL." | 362 | "Set the property PROP of BOOKMARK to VAL. |
| 363 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 359 | (let ((cell (assq prop (bookmark-get-bookmark-record bookmark)))) | 364 | (let ((cell (assq prop (bookmark-get-bookmark-record bookmark)))) |
| 360 | (if cell | 365 | (if cell |
| 361 | (setcdr cell val) | 366 | (setcdr cell val) |
| @@ -363,55 +368,67 @@ That is, all information but the name." | |||
| 363 | (list (cons prop val)))))) | 368 | (list (cons prop val)))))) |
| 364 | 369 | ||
| 365 | (defun bookmark-get-annotation (bookmark) | 370 | (defun bookmark-get-annotation (bookmark) |
| 366 | "Return the annotation of BOOKMARK, or nil if none." | 371 | "Return the annotation of BOOKMARK, or nil if none. |
| 372 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 367 | (bookmark-prop-get bookmark 'annotation)) | 373 | (bookmark-prop-get bookmark 'annotation)) |
| 368 | 374 | ||
| 369 | (defun bookmark-set-annotation (bookmark ann) | 375 | (defun bookmark-set-annotation (bookmark ann) |
| 370 | "Set the annotation of BOOKMARK to ANN." | 376 | "Set the annotation of BOOKMARK to ANN. |
| 377 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 371 | (bookmark-prop-set bookmark 'annotation ann)) | 378 | (bookmark-prop-set bookmark 'annotation ann)) |
| 372 | 379 | ||
| 373 | 380 | ||
| 374 | (defun bookmark-get-filename (bookmark) | 381 | (defun bookmark-get-filename (bookmark) |
| 375 | "Return the full filename of BOOKMARK." | 382 | "Return the full filename of BOOKMARK, or nil if none. |
| 383 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 376 | (bookmark-prop-get bookmark 'filename)) | 384 | (bookmark-prop-get bookmark 'filename)) |
| 377 | 385 | ||
| 378 | 386 | ||
| 379 | (defun bookmark-set-filename (bookmark filename) | 387 | (defun bookmark-set-filename (bookmark filename) |
| 380 | "Set the full filename of BOOKMARK to FILENAME." | 388 | "Set the full filename of BOOKMARK to FILENAME. |
| 389 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 381 | (bookmark-prop-set bookmark 'filename filename)) | 390 | (bookmark-prop-set bookmark 'filename filename)) |
| 382 | 391 | ||
| 383 | 392 | ||
| 384 | (defun bookmark-get-position (bookmark) | 393 | (defun bookmark-get-position (bookmark) |
| 385 | "Return the position \(i.e.: point\) of BOOKMARK." | 394 | "Return the position \(i.e.: point\) of BOOKMARK, or nil if none. |
| 395 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 386 | (bookmark-prop-get bookmark 'position)) | 396 | (bookmark-prop-get bookmark 'position)) |
| 387 | 397 | ||
| 388 | 398 | ||
| 389 | (defun bookmark-set-position (bookmark position) | 399 | (defun bookmark-set-position (bookmark position) |
| 390 | "Set the position \(i.e.: point\) of BOOKMARK to POSITION." | 400 | "Set the position \(i.e.: point\) of BOOKMARK to POSITION. |
| 401 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 391 | (bookmark-prop-set bookmark 'position position)) | 402 | (bookmark-prop-set bookmark 'position position)) |
| 392 | 403 | ||
| 393 | 404 | ||
| 394 | (defun bookmark-get-front-context-string (bookmark) | 405 | (defun bookmark-get-front-context-string (bookmark) |
| 395 | "Return the front-context-string of BOOKMARK." | 406 | "Return the front-context-string of BOOKMARK, or nil if none. |
| 407 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 396 | (bookmark-prop-get bookmark 'front-context-string)) | 408 | (bookmark-prop-get bookmark 'front-context-string)) |
| 397 | 409 | ||
| 398 | 410 | ||
| 399 | (defun bookmark-set-front-context-string (bookmark string) | 411 | (defun bookmark-set-front-context-string (bookmark string) |
| 400 | "Set the front-context-string of BOOKMARK to STRING." | 412 | "Set the front-context-string of BOOKMARK to STRING. |
| 413 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 401 | (bookmark-prop-set bookmark 'front-context-string string)) | 414 | (bookmark-prop-set bookmark 'front-context-string string)) |
| 402 | 415 | ||
| 403 | 416 | ||
| 404 | (defun bookmark-get-rear-context-string (bookmark) | 417 | (defun bookmark-get-rear-context-string (bookmark) |
| 405 | "Return the rear-context-string of BOOKMARK." | 418 | "Return the rear-context-string of BOOKMARK, or nil if none. |
| 419 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 406 | (bookmark-prop-get bookmark 'rear-context-string)) | 420 | (bookmark-prop-get bookmark 'rear-context-string)) |
| 407 | 421 | ||
| 408 | 422 | ||
| 409 | (defun bookmark-set-rear-context-string (bookmark string) | 423 | (defun bookmark-set-rear-context-string (bookmark string) |
| 410 | "Set the rear-context-string of BOOKMARK to STRING." | 424 | "Set the rear-context-string of BOOKMARK to STRING. |
| 425 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 411 | (bookmark-prop-set bookmark 'rear-context-string string)) | 426 | (bookmark-prop-set bookmark 'rear-context-string string)) |
| 412 | 427 | ||
| 413 | 428 | ||
| 414 | (defun bookmark-get-handler (bookmark) | 429 | (defun bookmark-get-handler (bookmark) |
| 430 | "Return the handler function for BOOKMARK, or nil if none. | ||
| 431 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 415 | (bookmark-prop-get bookmark 'handler)) | 432 | (bookmark-prop-get bookmark 'handler)) |
| 416 | 433 | ||
| 417 | (defvar bookmark-history nil | 434 | (defvar bookmark-history nil |
| @@ -715,27 +732,28 @@ This expects to be called from `point-min' in a bookmark file." | |||
| 715 | map)) | 732 | map)) |
| 716 | 733 | ||
| 717 | ;;;###autoload | 734 | ;;;###autoload |
| 718 | (defun bookmark-set (&optional name parg) | 735 | (defun bookmark-set (&optional name no-overwrite) |
| 719 | "Set a bookmark named NAME inside a file. | 736 | "Set a bookmark named NAME inside a file. |
| 720 | If name is nil, then the user will be prompted. | 737 | If name is nil, then prompt the user. |
| 721 | With prefix arg, will not overwrite a bookmark that has the same name | 738 | |
| 722 | as NAME if such a bookmark already exists, but instead will \"push\" | 739 | With prefix arg (NO-OVERWRITE), do not overwrite a bookmark that |
| 723 | the new bookmark onto the bookmark alist. Thus the most recently set | 740 | has the same name as NAME if such a bookmark already exists, but |
| 724 | bookmark with name NAME would be the one in effect at any given time, | 741 | instead \"push\" the new bookmark onto the bookmark alist. Thus |
| 725 | but the others are still there, should you decide to delete the most | 742 | the most recently set bookmark with name NAME would be the one in |
| 726 | recent one. | 743 | effect at any given time, but the others are still there, should |
| 744 | the user decide to delete the most recent one. | ||
| 727 | 745 | ||
| 728 | To yank words from the text of the buffer and use them as part of the | 746 | To yank words from the text of the buffer and use them as part of the |
| 729 | bookmark name, type C-w while setting a bookmark. Successive C-w's | 747 | bookmark name, type C-w while setting a bookmark. Successive C-w's |
| 730 | yank successive words. | 748 | yank successive words. |
| 731 | 749 | ||
| 732 | Typing C-u inserts the name of the last bookmark used in the buffer | 750 | Typing C-u inserts the name of the last bookmark used in the buffer |
| 733 | \(as an aid in using a single bookmark name to track your progress | 751 | \(as an aid in using a single bookmark name to track progress through |
| 734 | through a large file\). If no bookmark was used, then C-u inserts the | 752 | a large file\). If no bookmark was used, then C-u inserts the name of |
| 735 | name of the file being visited. | 753 | the file being visited. |
| 736 | 754 | ||
| 737 | Use \\[bookmark-delete] to remove bookmarks \(you give it a name, | 755 | Use \\[bookmark-delete] to remove bookmarks \(give it a name and it |
| 738 | and it removes only the first instance of a bookmark with that name from | 756 | removes only the first instance of a bookmark with that name from |
| 739 | the list of bookmarks.\)" | 757 | the list of bookmarks.\)" |
| 740 | (interactive (list nil current-prefix-arg)) | 758 | (interactive (list nil current-prefix-arg)) |
| 741 | (let* ((record (bookmark-make-record)) | 759 | (let* ((record (bookmark-make-record)) |
| @@ -755,7 +773,7 @@ the list of bookmarks.\)" | |||
| 755 | bookmark-minibuffer-read-name-map | 773 | bookmark-minibuffer-read-name-map |
| 756 | nil nil default)))) | 774 | nil nil default)))) |
| 757 | (and (string-equal str "") (setq str default)) | 775 | (and (string-equal str "") (setq str default)) |
| 758 | (bookmark-store str (cdr record) parg) | 776 | (bookmark-store str (cdr record) no-overwrite) |
| 759 | 777 | ||
| 760 | ;; Ask for an annotation buffer for this bookmark | 778 | ;; Ask for an annotation buffer for this bookmark |
| 761 | (if bookmark-use-annotations | 779 | (if bookmark-use-annotations |
| @@ -780,6 +798,9 @@ whose annotation is being edited.") | |||
| 780 | 798 | ||
| 781 | 799 | ||
| 782 | (defun bookmark-default-annotation-text (bookmark) | 800 | (defun bookmark-default-annotation-text (bookmark) |
| 801 | "Return default annotation text for BOOKMARK (a string, not a record). | ||
| 802 | The default annotation text is simply some text explaining how to use | ||
| 803 | annotations." | ||
| 783 | (concat "# Type the annotation for bookmark '" bookmark "' here.\n" | 804 | (concat "# Type the annotation for bookmark '" bookmark "' here.\n" |
| 784 | "# All lines which start with a '#' will be deleted.\n" | 805 | "# All lines which start with a '#' will be deleted.\n" |
| 785 | "# Type C-c C-c when done.\n#\n" | 806 | "# Type C-c C-c when done.\n#\n" |
| @@ -806,6 +827,8 @@ It takes one argument, the name of the bookmark, as a string.") | |||
| 806 | "Mode for editing the annotation of bookmark BOOKMARK. | 827 | "Mode for editing the annotation of bookmark BOOKMARK. |
| 807 | When you have finished composing, type \\[bookmark-send-annotation]. | 828 | When you have finished composing, type \\[bookmark-send-annotation]. |
| 808 | 829 | ||
| 830 | BOOKMARK is a bookmark name (a string) or a bookmark record. | ||
| 831 | |||
| 809 | \\{bookmark-edit-annotation-mode-map}" | 832 | \\{bookmark-edit-annotation-mode-map}" |
| 810 | (interactive) | 833 | (interactive) |
| 811 | (kill-all-local-variables) | 834 | (kill-all-local-variables) |
| @@ -842,7 +865,8 @@ Lines beginning with `#' are ignored." | |||
| 842 | 865 | ||
| 843 | 866 | ||
| 844 | (defun bookmark-edit-annotation (bookmark) | 867 | (defun bookmark-edit-annotation (bookmark) |
| 845 | "Pop up a buffer for editing bookmark BOOKMARK's annotation." | 868 | "Pop up a buffer for editing bookmark BOOKMARK's annotation. |
| 869 | BOOKMARK is a bookmark name (a string) or a bookmark record." | ||
| 846 | (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*")) | 870 | (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*")) |
| 847 | (bookmark-edit-annotation-mode bookmark)) | 871 | (bookmark-edit-annotation-mode bookmark)) |
| 848 | 872 | ||
| @@ -880,9 +904,9 @@ Default to file name if it's nil." | |||
| 880 | 904 | ||
| 881 | 905 | ||
| 882 | (defun bookmark-yank-word () | 906 | (defun bookmark-yank-word () |
| 907 | "Get the next word from the buffer and append it to the name of the | ||
| 908 | bookmark currently being set, advancing point by one word." | ||
| 883 | (interactive) | 909 | (interactive) |
| 884 | ;; get the next word from the buffer and append it to the name of | ||
| 885 | ;; the bookmark currently being set. | ||
| 886 | (let ((string (with-current-buffer bookmark-current-buffer | 910 | (let ((string (with-current-buffer bookmark-current-buffer |
| 887 | (goto-char bookmark-yank-point) | 911 | (goto-char bookmark-yank-point) |
| 888 | (buffer-substring-no-properties | 912 | (buffer-substring-no-properties |
| @@ -908,6 +932,7 @@ Default to file name if it's nil." | |||
| 908 | 932 | ||
| 909 | 933 | ||
| 910 | (defun bookmark-maybe-load-default-file () | 934 | (defun bookmark-maybe-load-default-file () |
| 935 | "If bookmarks have not been loaded from the default place, load them." | ||
| 911 | (and (not bookmarks-already-loaded) | 936 | (and (not bookmarks-already-loaded) |
| 912 | (null bookmark-alist) | 937 | (null bookmark-alist) |
| 913 | (prog2 | 938 | (prog2 |
| @@ -927,8 +952,8 @@ Default to file name if it's nil." | |||
| 927 | 952 | ||
| 928 | 953 | ||
| 929 | (defun bookmark-maybe-sort-alist () | 954 | (defun bookmark-maybe-sort-alist () |
| 930 | ;;Return the bookmark-alist for display. If the bookmark-sort-flag | 955 | "Return `bookmark-alist' for display. |
| 931 | ;;is non-nil, then return a sorted copy of the alist. | 956 | If `bookmark-sort-flag' is non-nil, then return a sorted copy of the alist." |
| 932 | (if bookmark-sort-flag | 957 | (if bookmark-sort-flag |
| 933 | (sort (copy-alist bookmark-alist) | 958 | (sort (copy-alist bookmark-alist) |
| 934 | (function | 959 | (function |
| @@ -941,6 +966,12 @@ Default to file name if it's nil." | |||
| 941 | Useful for example to unhide text in `outline-mode'.") | 966 | Useful for example to unhide text in `outline-mode'.") |
| 942 | 967 | ||
| 943 | (defun bookmark--jump-via (bookmark display-function) | 968 | (defun bookmark--jump-via (bookmark display-function) |
| 969 | "Handle BOOKMARK, then call DISPLAY-FUNCTION with current buffer as argument. | ||
| 970 | Bookmark may be a bookmark name (a string) or a bookmark record. | ||
| 971 | |||
| 972 | After calling DISPLAY-FUNCTION, set window point to the point specified | ||
| 973 | by BOOKMARK, if necessary, run `bookmark-after-jump-hook', and then show | ||
| 974 | any annotations for this bookmark." | ||
| 944 | (bookmark-handle-bookmark bookmark) | 975 | (bookmark-handle-bookmark bookmark) |
| 945 | (save-current-buffer | 976 | (save-current-buffer |
| 946 | (funcall display-function (current-buffer))) | 977 | (funcall display-function (current-buffer))) |
| @@ -966,7 +997,10 @@ this. | |||
| 966 | If the file pointed to by BOOKMARK no longer exists, you will be asked | 997 | If the file pointed to by BOOKMARK no longer exists, you will be asked |
| 967 | if you wish to give the bookmark a new location, and `bookmark-jump' | 998 | if you wish to give the bookmark a new location, and `bookmark-jump' |
| 968 | will then jump to the new location, as well as recording it in place | 999 | will then jump to the new location, as well as recording it in place |
| 969 | of the old one in the permanent bookmark record." | 1000 | of the old one in the permanent bookmark record. |
| 1001 | |||
| 1002 | BOOKMARK may be a bookmark name (a string) or a bookmark record, but | ||
| 1003 | the latter is usually only used by programmatic callers." | ||
| 970 | (interactive | 1004 | (interactive |
| 971 | (list (bookmark-completing-read "Jump to bookmark" | 1005 | (list (bookmark-completing-read "Jump to bookmark" |
| 972 | bookmark-current-bookmark))) | 1006 | bookmark-current-bookmark))) |
| @@ -978,8 +1012,7 @@ of the old one in the permanent bookmark record." | |||
| 978 | 1012 | ||
| 979 | ;;;###autoload | 1013 | ;;;###autoload |
| 980 | (defun bookmark-jump-other-window (bookmark) | 1014 | (defun bookmark-jump-other-window (bookmark) |
| 981 | "Jump to BOOKMARK (a point in some file) in another window. | 1015 | "Jump to BOOKMARK in another window. See `bookmark-jump' for more." |
| 982 | See `bookmark-jump'." | ||
| 983 | (interactive | 1016 | (interactive |
| 984 | (let ((bkm (bookmark-completing-read "Jump to bookmark (in another window)" | 1017 | (let ((bkm (bookmark-completing-read "Jump to bookmark (in another window)" |
| 985 | bookmark-current-bookmark))) | 1018 | bookmark-current-bookmark))) |
| @@ -1014,6 +1047,8 @@ be retrieved from a VC backend, else return nil." | |||
| 1014 | "Return the location pointed to by the bookmark BOOKMARK. | 1047 | "Return the location pointed to by the bookmark BOOKMARK. |
| 1015 | The return value has the form (BUFFER . POINT). | 1048 | The return value has the form (BUFFER . POINT). |
| 1016 | 1049 | ||
| 1050 | BOOKMARK may be a bookmark name (a string) or a bookmark record. | ||
| 1051 | |||
| 1017 | Note: this function is deprecated and is present for Emacs 22 | 1052 | Note: this function is deprecated and is present for Emacs 22 |
| 1018 | compatibility only." | 1053 | compatibility only." |
| 1019 | (save-excursion | 1054 | (save-excursion |
| @@ -1025,8 +1060,8 @@ compatibility only." | |||
| 1025 | (defun bookmark-handle-bookmark (bookmark) | 1060 | (defun bookmark-handle-bookmark (bookmark) |
| 1026 | "Call BOOKMARK's handler or `bookmark-default-handler' if it has none. | 1061 | "Call BOOKMARK's handler or `bookmark-default-handler' if it has none. |
| 1027 | Changes current buffer and point and returns nil, or signals a `file-error'. | 1062 | Changes current buffer and point and returns nil, or signals a `file-error'. |
| 1028 | BOOKMARK can be a bookmark record used internally by some other | 1063 | |
| 1029 | elisp package, or the name of a bookmark to be found in `bookmark-alist'." | 1064 | BOOKMARK may be a bookmark name (a string) or a bookmark record." |
| 1030 | (condition-case err | 1065 | (condition-case err |
| 1031 | (funcall (or (bookmark-get-handler bookmark) | 1066 | (funcall (or (bookmark-get-handler bookmark) |
| 1032 | 'bookmark-default-handler) | 1067 | 'bookmark-default-handler) |
| @@ -1060,15 +1095,15 @@ elisp package, or the name of a bookmark to be found in `bookmark-alist'." | |||
| 1060 | (setq bookmark-current-bookmark bookmark)) | 1095 | (setq bookmark-current-bookmark bookmark)) |
| 1061 | nil) | 1096 | nil) |
| 1062 | 1097 | ||
| 1063 | (defun bookmark-default-handler (bmk) | 1098 | (defun bookmark-default-handler (bmk-record) |
| 1064 | "Default handler to jump to a particular bookmark location. | 1099 | "Default handler to jump to a particular bookmark location. |
| 1065 | BMK is a bookmark record. | 1100 | BMK-RECORD is a bookmark record, not a bookmark name (i.e., not a string). |
| 1066 | Changes current buffer and point and returns nil, or signals a `file-error'." | 1101 | Changes current buffer and point and returns nil, or signals a `file-error'." |
| 1067 | (let* ((file (bookmark-get-filename bmk)) | 1102 | (let* ((file (bookmark-get-filename bmk-record)) |
| 1068 | (buf (bookmark-prop-get bmk 'buffer)) | 1103 | (buf (bookmark-prop-get bmk-record 'buffer)) |
| 1069 | (forward-str (bookmark-get-front-context-string bmk)) | 1104 | (forward-str (bookmark-get-front-context-string bmk-record)) |
| 1070 | (behind-str (bookmark-get-rear-context-string bmk)) | 1105 | (behind-str (bookmark-get-rear-context-string bmk-record)) |
| 1071 | (place (bookmark-get-position bmk))) | 1106 | (place (bookmark-get-position bmk-record))) |
| 1072 | ;; FIXME: bookmark-file-or-variation-thereof was needed for Info files, | 1107 | ;; FIXME: bookmark-file-or-variation-thereof was needed for Info files, |
| 1073 | ;; but now that Info bookmarks are handled elsewhere it seems that we | 1108 | ;; but now that Info bookmarks are handled elsewhere it seems that we |
| 1074 | ;; should be able to get rid of it. --Stef | 1109 | ;; should be able to get rid of it. --Stef |
| @@ -1076,7 +1111,7 @@ Changes current buffer and point and returns nil, or signals a `file-error'." | |||
| 1076 | (setq file (bookmark-file-or-variation-thereof file)))) | 1111 | (setq file (bookmark-file-or-variation-thereof file)))) |
| 1077 | (signal 'file-error | 1112 | (signal 'file-error |
| 1078 | `("Jumping to bookmark" "No such file or directory" | 1113 | `("Jumping to bookmark" "No such file or directory" |
| 1079 | (bookmark-get-filename bmk))) | 1114 | (bookmark-get-filename bmk-record))) |
| 1080 | (set-buffer (or buf (find-file-noselect file))) | 1115 | (set-buffer (or buf (find-file-noselect file))) |
| 1081 | (if place (goto-char place)) | 1116 | (if place (goto-char place)) |
| 1082 | 1117 | ||
| @@ -1096,6 +1131,8 @@ Changes current buffer and point and returns nil, or signals a `file-error'." | |||
| 1096 | ;;;###autoload | 1131 | ;;;###autoload |
| 1097 | (defun bookmark-relocate (bookmark) | 1132 | (defun bookmark-relocate (bookmark) |
| 1098 | "Relocate BOOKMARK to another file (reading file name with minibuffer). | 1133 | "Relocate BOOKMARK to another file (reading file name with minibuffer). |
| 1134 | BOOKMARK is a bookmark name (a string), not a bookmark record. | ||
| 1135 | |||
| 1099 | This makes an already existing bookmark point to that file, instead of | 1136 | This makes an already existing bookmark point to that file, instead of |
| 1100 | the one it used to point at. Useful when a file has been renamed | 1137 | the one it used to point at. Useful when a file has been renamed |
| 1101 | after a bookmark was set in it." | 1138 | after a bookmark was set in it." |
| @@ -1118,6 +1155,8 @@ after a bookmark was set in it." | |||
| 1118 | ;;;###autoload | 1155 | ;;;###autoload |
| 1119 | (defun bookmark-insert-location (bookmark &optional no-history) | 1156 | (defun bookmark-insert-location (bookmark &optional no-history) |
| 1120 | "Insert the name of the file associated with BOOKMARK. | 1157 | "Insert the name of the file associated with BOOKMARK. |
| 1158 | BOOKMARK is a bookmark name (a string), not a bookmark record. | ||
| 1159 | |||
| 1121 | Optional second arg NO-HISTORY means don't record this in the | 1160 | Optional second arg NO-HISTORY means don't record this in the |
| 1122 | minibuffer history list `bookmark-history'." | 1161 | minibuffer history list `bookmark-history'." |
| 1123 | (interactive (list (bookmark-completing-read "Insert bookmark location"))) | 1162 | (interactive (list (bookmark-completing-read "Insert bookmark location"))) |
| @@ -1139,7 +1178,8 @@ minibuffer history list `bookmark-history'." | |||
| 1139 | (defalias 'bookmark-locate 'bookmark-insert-location) | 1178 | (defalias 'bookmark-locate 'bookmark-insert-location) |
| 1140 | 1179 | ||
| 1141 | (defun bookmark-location (bookmark) | 1180 | (defun bookmark-location (bookmark) |
| 1142 | "Return the name of the file associated with BOOKMARK." | 1181 | "Return the name of the file associated with BOOKMARK. |
| 1182 | BOOKMARK may be a bookmark name (a string) or a bookmark record." | ||
| 1143 | (bookmark-maybe-load-default-file) | 1183 | (bookmark-maybe-load-default-file) |
| 1144 | (bookmark-get-filename bookmark)) | 1184 | (bookmark-get-filename bookmark)) |
| 1145 | 1185 | ||
| @@ -1150,6 +1190,8 @@ minibuffer history list `bookmark-history'." | |||
| 1150 | If called from keyboard, prompt for OLD and NEW. If called from | 1190 | If called from keyboard, prompt for OLD and NEW. If called from |
| 1151 | menubar, select OLD from a menu and prompt for NEW. | 1191 | menubar, select OLD from a menu and prompt for NEW. |
| 1152 | 1192 | ||
| 1193 | Both OLD and NEW are bookmark names (strings), never bookmark records. | ||
| 1194 | |||
| 1153 | If called from Lisp, prompt for NEW if only OLD was passed as an | 1195 | If called from Lisp, prompt for NEW if only OLD was passed as an |
| 1154 | argument. If called with two strings, then no prompting is done. You | 1196 | argument. If called with two strings, then no prompting is done. You |
| 1155 | must pass at least OLD when calling from Lisp. | 1197 | must pass at least OLD when calling from Lisp. |
| @@ -1186,6 +1228,8 @@ name." | |||
| 1186 | ;;;###autoload | 1228 | ;;;###autoload |
| 1187 | (defun bookmark-insert (bookmark) | 1229 | (defun bookmark-insert (bookmark) |
| 1188 | "Insert the text of the file pointed to by bookmark BOOKMARK. | 1230 | "Insert the text of the file pointed to by bookmark BOOKMARK. |
| 1231 | BOOKMARK is a bookmark name (a string), not a bookmark record. | ||
| 1232 | |||
| 1189 | You may have a problem using this function if the value of variable | 1233 | You may have a problem using this function if the value of variable |
| 1190 | `bookmark-alist' is nil. If that happens, you need to load in some | 1234 | `bookmark-alist' is nil. If that happens, you need to load in some |
| 1191 | bookmarks. See help on function `bookmark-load' for more about | 1235 | bookmarks. See help on function `bookmark-load' for more about |
| @@ -1206,6 +1250,8 @@ this." | |||
| 1206 | ;;;###autoload | 1250 | ;;;###autoload |
| 1207 | (defun bookmark-delete (bookmark &optional batch) | 1251 | (defun bookmark-delete (bookmark &optional batch) |
| 1208 | "Delete BOOKMARK from the bookmark list. | 1252 | "Delete BOOKMARK from the bookmark list. |
| 1253 | BOOKMARK is a bookmark name (a string), not a bookmark record. | ||
| 1254 | |||
| 1209 | Removes only the first instance of a bookmark with that name. If | 1255 | Removes only the first instance of a bookmark with that name. If |
| 1210 | there are one or more other bookmarks with the same name, they will | 1256 | there are one or more other bookmarks with the same name, they will |
| 1211 | not be deleted. Defaults to the \"current\" bookmark \(that is, the | 1257 | not be deleted. Defaults to the \"current\" bookmark \(that is, the |
| @@ -1233,14 +1279,13 @@ probably because we were called from there." | |||
| 1233 | (bookmark-save)))) | 1279 | (bookmark-save)))) |
| 1234 | 1280 | ||
| 1235 | 1281 | ||
| 1236 | (defun bookmark-time-to-save-p (&optional last-time) | 1282 | (defun bookmark-time-to-save-p (&optional final-time) |
| 1237 | ;; By Gregory M. Saunders <saunders@cis.ohio-state.edu> | 1283 | "Return t if it is time to save bookmarks to disk, nil otherwise. |
| 1238 | ;; finds out whether it's time to save bookmarks to a file, by | 1284 | Optional argument FINAL-TIME means this is being called when Emacs |
| 1239 | ;; examining the value of variable bookmark-save-flag, and maybe | 1285 | is being killed, so save even if `bookmark-save-flag' is a number and |
| 1240 | ;; bookmark-alist-modification-count. Returns t if they should be | 1286 | is greater than `bookmark-alist-modification-count'." |
| 1241 | ;; saved, nil otherwise. if last-time is non-nil, then this is | 1287 | ;; By Gregory M. Saunders <saunders{_AT_}cis.ohio-state.edu> |
| 1242 | ;; being called when emacs is killed. | 1288 | (cond (final-time |
| 1243 | (cond (last-time | ||
| 1244 | (and (> bookmark-alist-modification-count 0) | 1289 | (and (> bookmark-alist-modification-count 0) |
| 1245 | bookmark-save-flag)) | 1290 | bookmark-save-flag)) |
| 1246 | ((numberp bookmark-save-flag) | 1291 | ((numberp bookmark-save-flag) |
| @@ -1298,6 +1343,7 @@ for a file, defaulting to the file defined by variable | |||
| 1298 | 1343 | ||
| 1299 | 1344 | ||
| 1300 | (defun bookmark-write-file (file) | 1345 | (defun bookmark-write-file (file) |
| 1346 | "Write `bookmark-alist' to FILE." | ||
| 1301 | (bookmark-maybe-message "Saving bookmarks to file %s..." file) | 1347 | (bookmark-maybe-message "Saving bookmarks to file %s..." file) |
| 1302 | (with-current-buffer (get-buffer-create " *Bookmarks*") | 1348 | (with-current-buffer (get-buffer-create " *Bookmarks*") |
| 1303 | (goto-char (point-min)) | 1349 | (goto-char (point-min)) |
| @@ -1326,10 +1372,8 @@ for a file, defaulting to the file defined by variable | |||
| 1326 | 1372 | ||
| 1327 | 1373 | ||
| 1328 | (defun bookmark-import-new-list (new-list) | 1374 | (defun bookmark-import-new-list (new-list) |
| 1329 | ;; Walk over the new list, adding each individual bookmark | 1375 | "Add NEW-LIST of bookmarks to `bookmark-alist', rename new bookmarks |
| 1330 | ;; carefully. "Carefully" means checking against the existing | 1376 | with \"<N>\" extensions where they collide with existing bookmark names." |
| 1331 | ;; bookmark-alist and renaming the new bookmarks with <N> extensions | ||
| 1332 | ;; as necessary. | ||
| 1333 | (let ((lst new-list) | 1377 | (let ((lst new-list) |
| 1334 | (names (bookmark-all-names))) | 1378 | (names (bookmark-all-names))) |
| 1335 | (while lst | 1379 | (while lst |
| @@ -1341,11 +1385,8 @@ for a file, defaulting to the file defined by variable | |||
| 1341 | 1385 | ||
| 1342 | 1386 | ||
| 1343 | (defun bookmark-maybe-rename (full-record names) | 1387 | (defun bookmark-maybe-rename (full-record names) |
| 1344 | ;; just a helper for bookmark-import-new-list; it is only for | 1388 | "If bookmark record FULL-RECORD collides with anything in NAMES, give |
| 1345 | ;; readability that this is not inlined. | 1389 | FULL-RECORD a new name. This is a helper for `bookmark-import-new-list'." |
| 1346 | ;; | ||
| 1347 | ;; Once this has found a free name, it sets full-record to that | ||
| 1348 | ;; name. | ||
| 1349 | (let ((found-name (bookmark-name-from-full-record full-record))) | 1390 | (let ((found-name (bookmark-name-from-full-record full-record))) |
| 1350 | (if (member found-name names) | 1391 | (if (member found-name names) |
| 1351 | ;; We've got a conflict, so generate a new name | 1392 | ;; We've got a conflict, so generate a new name |
| @@ -1602,6 +1643,10 @@ Optional argument SHOW means show them unconditionally." | |||
| 1602 | 1643 | ||
| 1603 | 1644 | ||
| 1604 | (defun bookmark-bmenu-show-filenames (&optional force) | 1645 | (defun bookmark-bmenu-show-filenames (&optional force) |
| 1646 | "In an interactive bookmark list, show filenames along with bookmarks. | ||
| 1647 | |||
| 1648 | If FORCE is non-nil, force a redisplay showing the filenames; this is | ||
| 1649 | used mainly for debugging, and should not be necessary in normal usage." | ||
| 1605 | (if (and (not force) bookmark-bmenu-toggle-filenames) | 1650 | (if (and (not force) bookmark-bmenu-toggle-filenames) |
| 1606 | nil ;already shown, so do nothing | 1651 | nil ;already shown, so do nothing |
| 1607 | (save-excursion | 1652 | (save-excursion |
| @@ -1628,6 +1673,10 @@ Optional argument SHOW means show them unconditionally." | |||
| 1628 | 1673 | ||
| 1629 | 1674 | ||
| 1630 | (defun bookmark-bmenu-hide-filenames (&optional force) | 1675 | (defun bookmark-bmenu-hide-filenames (&optional force) |
| 1676 | "In an interactive bookmark list, hide the filenames of the bookmarks. | ||
| 1677 | |||
| 1678 | If FORCE is non-nil, force a redisplay hiding the filenames; this is | ||
| 1679 | used mainly for debugging, and should not be necessary in normal usage." | ||
| 1631 | (if (and (not force) bookmark-bmenu-toggle-filenames) | 1680 | (if (and (not force) bookmark-bmenu-toggle-filenames) |
| 1632 | ;; nothing to hide if above is nil | 1681 | ;; nothing to hide if above is nil |
| 1633 | (save-excursion | 1682 | (save-excursion |
| @@ -1664,9 +1713,12 @@ Optional argument SHOW means show them unconditionally." | |||
| 1664 | 1713 | ||
| 1665 | 1714 | ||
| 1666 | (defun bookmark-bmenu-check-position () | 1715 | (defun bookmark-bmenu-check-position () |
| 1667 | ;; Returns non-nil if on a line with a bookmark. | 1716 | "Return non-nil if on a line with a bookmark (the actual value |
| 1668 | ;; (The actual value returned is bookmark-alist). | 1717 | returned is `bookmark-alist'). Else reposition and try again; else if |
| 1669 | ;; Else reposition and try again, else return nil. | 1718 | still no bookmark, return nil." |
| 1719 | ;; FIXME: I don't believe this doc string. As far as I can tell, | ||
| 1720 | ;; this function always just returns bookmark-alist. So what is | ||
| 1721 | ;; it for, really? -kfogel, 2009-10-04 | ||
| 1670 | (cond ((< (count-lines (point-min) (point)) 2) | 1722 | (cond ((< (count-lines (point-min) (point)) 2) |
| 1671 | (goto-char (point-min)) | 1723 | (goto-char (point-min)) |
| 1672 | (forward-line 2) | 1724 | (forward-line 2) |
| @@ -1679,6 +1731,7 @@ Optional argument SHOW means show them unconditionally." | |||
| 1679 | 1731 | ||
| 1680 | 1732 | ||
| 1681 | (defun bookmark-bmenu-bookmark () | 1733 | (defun bookmark-bmenu-bookmark () |
| 1734 | "Return the bookmark for this line in an interactive bookmark list buffer." | ||
| 1682 | ;; return a string which is bookmark of this line. | 1735 | ;; return a string which is bookmark of this line. |
| 1683 | (if (bookmark-bmenu-check-position) | 1736 | (if (bookmark-bmenu-check-position) |
| 1684 | (save-excursion | 1737 | (save-excursion |