aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorBastien Guerry2008-03-07 19:31:59 +0000
committerBastien Guerry2008-03-07 19:31:59 +0000
commitf9bf695080bde66ba8d6180a23bfa8c0408dfb72 (patch)
treed1700f1b2523e22a42e855c78db4977c7f4db2e5 /lisp
parent9dfcb52e0be6b6bb8b7a3b9cd3f827ceb2d087f6 (diff)
downloademacs-f9bf695080bde66ba8d6180a23bfa8c0408dfb72.tar.gz
emacs-f9bf695080bde66ba8d6180a23bfa8c0408dfb72.zip
* 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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog16
-rw-r--r--lisp/bookmark.el20
-rw-r--r--lisp/info.el15
3 files changed, 45 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d6d0a08451b..d162ea33fb1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,19 @@
12008-03-07 Bastien Guerry <bzg@altern.org>
2
3 * bookmark.el (bookmark-set): Don't check for
4 `bookmark-make-name-function' since `bookmark-buffer-file-name'
5 already takes care of this.
6 (bookmark-buffer-name): Removed Info-mode specific code.
7 (bookmark-buffer-file-name): Removed Info-mode specific code.
8
9 * info.el (bookmark-get-info-node): Define this function in
10 info.el, not in bookmark.el.
11 (Info-mode): Set `bookmark-make-name-function' to
12 `Info-bookmark-make-name' locally.
13 (Info-bookmark-make-name): New function.
14
15 * bookmark.el (bookmark-make-name-function): New variable.
16
12008-03-07 Karl Fogel <kfogel@red-bean.com> 172008-03-07 Karl Fogel <kfogel@red-bean.com>
2 18
3 * bookmark.el (bookmark-set): Make `bookmark-make-record-function' 19 * bookmark.el (bookmark-set): Make `bookmark-make-record-function'
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 3d5db0de53c..46e3841f337 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -314,6 +314,7 @@ through a file easier.")
314;; know anything about the format of bookmark-alist entries. 314;; know anything about the format of bookmark-alist entries.
315;; Everyone else should go through them. 315;; Everyone else should go through them.
316 316
317
317(defun bookmark-name-from-full-record (full-record) 318(defun bookmark-name-from-full-record (full-record)
318 "Return name of FULL-RECORD \(an alist element instead of a string\)." 319 "Return name of FULL-RECORD \(an alist element instead of a string\)."
319 (car full-record)) 320 (car full-record))
@@ -463,6 +464,13 @@ menus, so `completing-read' never gets a chance to set `bookmark-history'."
463 (interactive-p) 464 (interactive-p)
464 (setq bookmark-history (cons ,string bookmark-history)))) 465 (setq bookmark-history (cons ,string bookmark-history))))
465 466
467(defvar bookmark-make-name-function nil
468 "A function that should be called to return the name of the bookmark.
469When called with an argument, the function should return a file
470name -- or whatever is required to jump to the location. Modes
471may set this variable buffer-locally to enable a default name to
472be proposed when calling `bookmark-set'.")
473
466(defvar bookmark-make-record-function 'bookmark-make-record-for-text-file 474(defvar bookmark-make-record-function 'bookmark-make-record-for-text-file
467 "A function that should be called to create a bookmark record. 475 "A function that should be called to create a bookmark record.
468Modes may set this variable buffer-locally to enable bookmarking of 476Modes may set this variable buffer-locally to enable bookmarking of
@@ -738,7 +746,6 @@ and it removes only the first instance of a bookmark with that name from
738the list of bookmarks.\)" 746the list of bookmarks.\)"
739 (interactive (list nil current-prefix-arg)) 747 (interactive (list nil current-prefix-arg))
740 (or 748 (or
741 (local-variable-p 'bookmark-make-record-function)
742 (bookmark-buffer-file-name) 749 (bookmark-buffer-file-name)
743 (error "Buffer not visiting a file or directory")) 750 (error "Buffer not visiting a file or directory"))
744 751
@@ -947,8 +954,9 @@ The directory part of the file name is not used."
947 "Return the name of the current buffer's file, non-directory. 954 "Return the name of the current buffer's file, non-directory.
948In Info, return the current node." 955In Info, return the current node."
949 (cond 956 (cond
950 ;; Are we in Info? 957 ;; Is the mode defining the bookmark buffer name?
951 ((derived-mode-p 'Info-mode) Info-current-node) 958 (bookmark-make-name-function
959 (funcall bookmark-make-name-function))
952 ;; Or are we a file? 960 ;; Or are we a file?
953 (buffer-file-name (file-name-nondirectory buffer-file-name)) 961 (buffer-file-name (file-name-nondirectory buffer-file-name))
954 ;; Or are we a directory? 962 ;; Or are we a directory?
@@ -988,8 +996,10 @@ In Info, return the current node."
988 "Return the current buffer's file in a way useful for bookmarks. 996 "Return the current buffer's file in a way useful for bookmarks.
989For example, if this is a Info buffer, return the Info file's name." 997For example, if this is a Info buffer, return the Info file's name."
990 (cond 998 (cond
991 ((eq major-mode 'Info-mode) 999 ;; Return the location the handler should jump to
992 Info-current-file) 1000 ;; E.g. the Info file name for the Info handler
1001 (bookmark-make-name-function
1002 (funcall bookmark-make-name-function t))
993 (buffer-file-name 1003 (buffer-file-name
994 ;; Abbreviate the path, both so it's shorter and so it's more 1004 ;; Abbreviate the path, both so it's shorter and so it's more
995 ;; portable. E.g., the user's home dir might be a different 1005 ;; portable. E.g., the user's home dir might be a different
diff --git a/lisp/info.el b/lisp/info.el
index ae295cc06ef..5f074b686d6 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -3489,6 +3489,8 @@ Advanced commands:
3489 (Info-set-mode-line) 3489 (Info-set-mode-line)
3490 (set (make-local-variable 'bookmark-make-record-function) 3490 (set (make-local-variable 'bookmark-make-record-function)
3491 'Info-bookmark-make-record) 3491 'Info-bookmark-make-record)
3492 (set (make-local-variable 'bookmark-make-name-function)
3493 'Info-bookmark-make-name)
3492 (run-mode-hooks 'Info-mode-hook)) 3494 (run-mode-hooks 'Info-mode-hook))
3493 3495
3494;; When an Info buffer is killed, make sure the associated tags buffer 3496;; When an Info buffer is killed, make sure the associated tags buffer
@@ -4326,6 +4328,13 @@ BUFFER is the buffer speedbar is requesting buttons for."
4326;; This is only called from bookmark.el. 4328;; This is only called from bookmark.el.
4327(declare-function bookmark-buffer-file-name "bookmark" ()) 4329(declare-function bookmark-buffer-file-name "bookmark" ())
4328 4330
4331
4332(defun Info-bookmark-make-name (&optional file)
4333 "Return the default name for the bookmark.
4334When FILE is non-nil, return the Info file instead."
4335 (if file Info-current-file Info-current-node))
4336
4337
4329(defun Info-bookmark-make-record (annotation) 4338(defun Info-bookmark-make-record (annotation)
4330 (let ((the-record 4339 (let ((the-record
4331 `((filename . ,(bookmark-buffer-file-name)) 4340 `((filename . ,(bookmark-buffer-file-name))
@@ -4356,15 +4365,19 @@ BUFFER is the buffer speedbar is requesting buttons for."
4356 ;; Finally, return the completed record. 4365 ;; Finally, return the completed record.
4357 the-record)) 4366 the-record))
4358 4367
4368
4359(defvar bookmark-current-bookmark) 4369(defvar bookmark-current-bookmark)
4360(declare-function bookmark-get-filename "bookmark" (bookmark)) 4370(declare-function bookmark-get-filename "bookmark" (bookmark))
4361(declare-function bookmark-get-front-context-string "bookmark" (bookmark)) 4371(declare-function bookmark-get-front-context-string "bookmark" (bookmark))
4362(declare-function bookmark-get-rear-context-string "bookmark" (bookmark)) 4372(declare-function bookmark-get-rear-context-string "bookmark" (bookmark))
4363(declare-function bookmark-get-position "bookmark" (bookmark)) 4373(declare-function bookmark-get-position "bookmark" (bookmark))
4364(declare-function bookmark-get-info-node "bookmark" (bookmark))
4365(declare-function bookmark-file-or-variation-thereof "bookmark" (file)) 4374(declare-function bookmark-file-or-variation-thereof "bookmark" (file))
4366(declare-function bookmark-jump-noselect "bookmark" (str)) 4375(declare-function bookmark-jump-noselect "bookmark" (str))
4367 4376
4377(defun bookmark-get-info-node (bookmark)
4378 "Get the info node associated with BOOKMARK."
4379 (cdr (assq 'info-node (bookmark-get-bookmark-record bookmark))))
4380
4368;;;###autoload 4381;;;###autoload
4369(defun Info-bookmark-jump (bmk) 4382(defun Info-bookmark-jump (bmk)
4370 ;; This implements the `handler' function interface for record type returned 4383 ;; This implements the `handler' function interface for record type returned