Mercurial > emacs
comparison lisp/bookmark.el @ 92556:5944be8c8211
Change a return type, for greater extensibility. See
http://lists.gnu.org/archive/html/emacs-devel/2007-12/msg01077.html
and its thread for discussion leading to this change.
* emacs-cvs/lisp/bookmark.el:
(bookmark-jump-noselect): Return an alist instead of a dotted pair.
(bookmark-jump, bookmark-jump-other-window, bookmark-insert)
(bookmark-bmenu-2-window, bookmark-bmenu-other-window)
(bookmark-bmenu-switch-other-window): Adjust accordingly.
(bookmark-make-cell-function): Adjust documentation accordingly.
* emacs-cvs/lisp/image-mode.el
(image-bookmark-jump): Adjust return type accordingly; document.
* emacs-cvs/lisp/doc-view.el
(doc-view-bookmark-jump): Adjust return type accordingly; document.
author | Karl Fogel <kfogel@red-bean.com> |
---|---|
date | Fri, 07 Mar 2008 05:44:37 +0000 |
parents | 4170d4a36502 |
children | 059f423b02f8 |
comparison
equal
deleted
inserted
replaced
92555:d238ebc2c1e0 | 92556:5944be8c8211 |
---|---|
461 menus, so `completing-read' never gets a chance to set `bookmark-history'." | 461 menus, so `completing-read' never gets a chance to set `bookmark-history'." |
462 `(or | 462 `(or |
463 (interactive-p) | 463 (interactive-p) |
464 (setq bookmark-history (cons ,string bookmark-history)))) | 464 (setq bookmark-history (cons ,string bookmark-history)))) |
465 | 465 |
466 (defvar bookmark-make-cell-function 'bookmark-make-cell-for-text-file | 466 (defvar bookmark-make-record-function 'bookmark-make-record-for-text-file |
467 "A function that should be called to create the bookmark | 467 "A function that should be called to create a bookmark record. |
468 record. Modes may set this variable buffer-locally to enable | 468 Modes may set this variable buffer-locally to enable bookmarking of |
469 bookmarking of non-text files like images or pdf documents. | 469 locations that should be treated specially, such as Info nodes, |
470 news posts, images, pdf documents, etc. | |
470 | 471 |
471 The function will be called with one argument: ANNOTATION. | 472 The function will be called with one argument: ANNOTATION. |
472 See `bookmark-make-cell-for-text-file' for a description. | 473 See `bookmark-make-record-for-text-file' for a description. |
473 | 474 |
474 The returned record may contain a special cons (handler . SOME-FUNCTION) | 475 The returned record may contain a special cons (handler . SOME-FUNCTION) |
475 which sets the handler function that should be used to open this | 476 which sets the handler function that should be used to open this |
476 bookmark instead of `bookmark-default-handler'. The handler should | 477 bookmark instead of `bookmark-default-handler'. The handler should |
477 return an alist like the one that function returns, and (of course) | 478 return an alist like the one that function returns, and (of course) |
490 (set-text-properties 0 (length stripped-name) nil stripped-name)) | 491 (set-text-properties 0 (length stripped-name) nil stripped-name)) |
491 (if (and (bookmark-get-bookmark stripped-name) (not overwrite)) | 492 (if (and (bookmark-get-bookmark stripped-name) (not overwrite)) |
492 ;; already existing bookmark under that name and | 493 ;; already existing bookmark under that name and |
493 ;; no prefix arg means just overwrite old bookmark | 494 ;; no prefix arg means just overwrite old bookmark |
494 (setcdr (bookmark-get-bookmark stripped-name) | 495 (setcdr (bookmark-get-bookmark stripped-name) |
495 (list (funcall bookmark-make-cell-function annotation))) | 496 (list (funcall bookmark-make-record-function annotation))) |
496 | 497 |
497 ;; otherwise just cons it onto the front (either the bookmark | 498 ;; otherwise just cons it onto the front (either the bookmark |
498 ;; doesn't exist already, or there is no prefix arg. In either | 499 ;; doesn't exist already, or there is no prefix arg. In either |
499 ;; case, we want the new bookmark consed onto the alist...) | 500 ;; case, we want the new bookmark consed onto the alist...) |
500 | 501 |
501 (setq bookmark-alist | 502 (setq bookmark-alist |
502 (cons | 503 (cons |
503 (list stripped-name | 504 (list stripped-name |
504 (funcall bookmark-make-cell-function annotation)) | 505 (funcall bookmark-make-record-function annotation)) |
505 bookmark-alist))) | 506 bookmark-alist))) |
506 | 507 |
507 ;; Added by db | 508 ;; Added by db |
508 (setq bookmark-current-bookmark stripped-name) | 509 (setq bookmark-current-bookmark stripped-name) |
509 (setq bookmark-alist-modification-count | 510 (setq bookmark-alist-modification-count |
510 (1+ bookmark-alist-modification-count)) | 511 (1+ bookmark-alist-modification-count)) |
511 (if (bookmark-time-to-save-p) | 512 (if (bookmark-time-to-save-p) |
512 (bookmark-save)))) | 513 (bookmark-save)))) |
513 | 514 |
514 | 515 |
515 (defun bookmark-make-cell-for-text-file (annotation) | 516 (defun bookmark-make-record-for-text-file (annotation) |
516 "Return the record part of a new bookmark, given ANNOTATION. | 517 "Return the record part of a new bookmark, given ANNOTATION. |
517 Must be at the correct position in the buffer in which the bookmark is | 518 Must be at the correct position in the buffer in which the bookmark is |
518 being set. This might change someday. | 519 being set (this might change someday)." |
519 Optional second arg INFO-NODE means this bookmark is at info node | |
520 INFO-NODE, so record this fact in the bookmark's entry." | |
521 (let ((the-record | 520 (let ((the-record |
522 `((filename . ,(bookmark-buffer-file-name)) | 521 `((filename . ,(bookmark-buffer-file-name)) |
523 (front-context-string | 522 (front-context-string |
524 . ,(if (>= (- (point-max) (point)) bookmark-search-size) | 523 . ,(if (>= (- (point-max) (point)) bookmark-search-size) |
525 (buffer-substring-no-properties | 524 (buffer-substring-no-properties |
805 (let ((annotation (buffer-string)) | 804 (let ((annotation (buffer-string)) |
806 (parg bookmark-annotation-paragraph) | 805 (parg bookmark-annotation-paragraph) |
807 (bookmark bookmark-annotation-name) | 806 (bookmark bookmark-annotation-name) |
808 (pt bookmark-annotation-point) | 807 (pt bookmark-annotation-point) |
809 (buf bookmark-annotation-buffer)) | 808 (buf bookmark-annotation-buffer)) |
810 ;; for bookmark-make-cell to work, we need to be | 809 ;; for bookmark-make-record-function to work, we need to be |
811 ;; in the relevant buffer, at the relevant point. | 810 ;; in the relevant buffer, at the relevant point. |
812 ;; Actually, bookmark-make-cell should probably be re-written, | 811 ;; Actually, the bookmark-make-record-function spec should |
813 ;; to avoid this need. Should I handle the error if a buffer is | 812 ;; probably be changed to avoid this need. Should I handle the |
814 ;; killed between "C-x r m" and a "C-c C-c" in the annotation buffer? | 813 ;; error if a buffer is killed between "C-x r m" and a "C-c C-c" |
814 ;; in the annotation buffer? | |
815 (save-excursion | 815 (save-excursion |
816 (pop-to-buffer buf) | 816 (pop-to-buffer buf) |
817 (goto-char pt) | 817 (goto-char pt) |
818 (bookmark-make bookmark annotation parg) | 818 (bookmark-make bookmark annotation parg) |
819 (setq bookmark-current-bookmark bookmark)) | 819 (setq bookmark-current-bookmark bookmark)) |