Mercurial > emacs
changeset 92568:f91d9f543b0a
* bookmark.el (bookmark-set): Don't check for
`bookmark-make-name-function' since `bookmark-buffer-file-name'
already takes care of this.
(bookmark-buffer-name): Removed Info-mode specific code.
(bookmark-buffer-file-name): Removed Info-mode specific code.
* info.el (bookmark-get-info-node): Define this function in
info.el, not in bookmark.el.
(Info-mode): Set `bookmark-make-name-function' to
`Info-bookmark-make-name' locally.
(Info-bookmark-make-name): New function.
* bookmark.el (bookmark-make-name-function): New variable.
author | Bastien Guerry <bzg@altern.org> |
---|---|
date | Fri, 07 Mar 2008 19:31:59 +0000 |
parents | 059f423b02f8 |
children | 2700d0403f58 |
files | lisp/ChangeLog lisp/bookmark.el lisp/info.el |
diffstat | 3 files changed, 45 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Fri Mar 07 17:03:37 2008 +0000 +++ b/lisp/ChangeLog Fri Mar 07 19:31:59 2008 +0000 @@ -1,3 +1,19 @@ +2008-03-07 Bastien Guerry <bzg@altern.org> + + * bookmark.el (bookmark-set): Don't check for + `bookmark-make-name-function' since `bookmark-buffer-file-name' + already takes care of this. + (bookmark-buffer-name): Removed Info-mode specific code. + (bookmark-buffer-file-name): Removed Info-mode specific code. + + * info.el (bookmark-get-info-node): Define this function in + info.el, not in bookmark.el. + (Info-mode): Set `bookmark-make-name-function' to + `Info-bookmark-make-name' locally. + (Info-bookmark-make-name): New function. + + * bookmark.el (bookmark-make-name-function): New variable. + 2008-03-07 Karl Fogel <kfogel@red-bean.com> * bookmark.el (bookmark-set): Make `bookmark-make-record-function'
--- a/lisp/bookmark.el Fri Mar 07 17:03:37 2008 +0000 +++ b/lisp/bookmark.el Fri Mar 07 19:31:59 2008 +0000 @@ -314,6 +314,7 @@ ;; know anything about the format of bookmark-alist entries. ;; Everyone else should go through them. + (defun bookmark-name-from-full-record (full-record) "Return name of FULL-RECORD \(an alist element instead of a string\)." (car full-record)) @@ -463,6 +464,13 @@ (interactive-p) (setq bookmark-history (cons ,string bookmark-history)))) +(defvar bookmark-make-name-function nil + "A function that should be called to return the name of the bookmark. +When called with an argument, the function should return a file +name -- or whatever is required to jump to the location. Modes +may set this variable buffer-locally to enable a default name to +be proposed when calling `bookmark-set'.") + (defvar bookmark-make-record-function 'bookmark-make-record-for-text-file "A function that should be called to create a bookmark record. Modes may set this variable buffer-locally to enable bookmarking of @@ -738,7 +746,6 @@ the list of bookmarks.\)" (interactive (list nil current-prefix-arg)) (or - (local-variable-p 'bookmark-make-record-function) (bookmark-buffer-file-name) (error "Buffer not visiting a file or directory")) @@ -947,8 +954,9 @@ "Return the name of the current buffer's file, non-directory. In Info, return the current node." (cond - ;; Are we in Info? - ((derived-mode-p 'Info-mode) Info-current-node) + ;; Is the mode defining the bookmark buffer name? + (bookmark-make-name-function + (funcall bookmark-make-name-function)) ;; Or are we a file? (buffer-file-name (file-name-nondirectory buffer-file-name)) ;; Or are we a directory? @@ -988,8 +996,10 @@ "Return the current buffer's file in a way useful for bookmarks. For example, if this is a Info buffer, return the Info file's name." (cond - ((eq major-mode 'Info-mode) - Info-current-file) + ;; Return the location the handler should jump to + ;; E.g. the Info file name for the Info handler + (bookmark-make-name-function + (funcall bookmark-make-name-function t)) (buffer-file-name ;; Abbreviate the path, both so it's shorter and so it's more ;; portable. E.g., the user's home dir might be a different
--- a/lisp/info.el Fri Mar 07 17:03:37 2008 +0000 +++ b/lisp/info.el Fri Mar 07 19:31:59 2008 +0000 @@ -3489,6 +3489,8 @@ (Info-set-mode-line) (set (make-local-variable 'bookmark-make-record-function) 'Info-bookmark-make-record) + (set (make-local-variable 'bookmark-make-name-function) + 'Info-bookmark-make-name) (run-mode-hooks 'Info-mode-hook)) ;; When an Info buffer is killed, make sure the associated tags buffer @@ -4326,6 +4328,13 @@ ;; This is only called from bookmark.el. (declare-function bookmark-buffer-file-name "bookmark" ()) + +(defun Info-bookmark-make-name (&optional file) + "Return the default name for the bookmark. +When FILE is non-nil, return the Info file instead." + (if file Info-current-file Info-current-node)) + + (defun Info-bookmark-make-record (annotation) (let ((the-record `((filename . ,(bookmark-buffer-file-name)) @@ -4356,15 +4365,19 @@ ;; Finally, return the completed record. the-record)) + (defvar bookmark-current-bookmark) (declare-function bookmark-get-filename "bookmark" (bookmark)) (declare-function bookmark-get-front-context-string "bookmark" (bookmark)) (declare-function bookmark-get-rear-context-string "bookmark" (bookmark)) (declare-function bookmark-get-position "bookmark" (bookmark)) -(declare-function bookmark-get-info-node "bookmark" (bookmark)) (declare-function bookmark-file-or-variation-thereof "bookmark" (file)) (declare-function bookmark-jump-noselect "bookmark" (str)) +(defun bookmark-get-info-node (bookmark) + "Get the info node associated with BOOKMARK." + (cdr (assq 'info-node (bookmark-get-bookmark-record bookmark)))) + ;;;###autoload (defun Info-bookmark-jump (bmk) ;; This implements the `handler' function interface for record type returned