]> code.delx.au - gnu-emacs/blobdiff - lisp/bookmark.el
(facemenu-complete-face-list): Doc fix.
[gnu-emacs] / lisp / bookmark.el
index 119d3a7ee36137d6095488084c2d65d95f0a7496..4340048e7b6226c26c8fe4fc164a8ff086b66717 100644 (file)
@@ -1,6 +1,6 @@
 ;;; bookmark.el --- set bookmarks, maybe annotate them, jump to them later.
 
-;; Copyright (C) 1993, 1994, 1995 Free Software Foundation
+;; Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation
 
 ;; Author: Karl Fogel <kfogel@red-bean.com>
 ;; Maintainer: Karl Fogel <kfogel@red-bean.com>
@@ -82,7 +82,7 @@
 
 (require 'pp)
 
-(defconst bookmark-version "2.6.20"
+(defconst bookmark-version "2.6.4"
   "Version number of bookmark.el.  This is not related to the version
 of Emacs bookmark comes with; it is used solely by bookmark's
 maintainers to avoid version confusion.")
@@ -450,7 +450,11 @@ That is, all information but the name."
     (if cell
         (setcdr cell node)
       (nconc (bookmark-get-bookmark-record bookmark)
-             (list (cons 'info-node node))))))
+             (list (cons 'info-node node)))))
+
+  (message "%S" (assq 'info-node (bookmark-get-bookmark-record bookmark)))
+  (sit-for 4)
+  )
   
 
 (defvar bookmark-history nil
@@ -490,11 +494,13 @@ menus, so `completing-read' never gets a chance to set `bookmark-history'."
       (setq bookmark-history (cons (, string) bookmark-history)))))
 
 
-(defun bookmark-make (name &optional annotation overwrite)
+(defun bookmark-make (name &optional annotation overwrite info-node)
   "Make a bookmark named NAME.
 Optional second arg ANNOTATION gives it an annotation.
 Optional third arg OVERWRITE means replace any existing bookmarks with
-this name."
+this name.
+Optional fourth arg INFO-NODE means this bookmark is at info node
+INFO-NODE, so record this fact in the bookmark's entry."
   (bookmark-maybe-load-default-file)
   (let ((stripped-name (copy-sequence name)))
     (or bookmark-xemacsp
@@ -505,7 +511,7 @@ this name."
         ;; already existing bookmark under that name and
         ;; no prefix arg means just overwrite old bookmark
         (setcdr (bookmark-get-bookmark stripped-name)
-                (list (bookmark-make-cell annotation)))
+                (list (bookmark-make-cell annotation info-node)))
       
       ;; otherwise just cons it onto the front (either the bookmark
       ;; doesn't exist already, or there is no prefix arg.  In either
@@ -514,7 +520,7 @@ this name."
       (setq bookmark-alist
             (cons
              (list stripped-name 
-                   (bookmark-make-cell annotation))
+                   (bookmark-make-cell annotation info-node))
              bookmark-alist)))
     
     ;; Added by db
@@ -525,25 +531,38 @@ this name."
         (bookmark-save))))
 
 
-(defun bookmark-make-cell (annotation)
+(defun bookmark-make-cell (annotation &optional info-node)
   "Return the record part of a new bookmark, given ANNOTATION.
 Must be at the correct position in the buffer in which the bookmark is
-being set.  This will change soon."
-  (` ((filename . (, (bookmark-buffer-file-name)))
-      (front-context-string
-       . (, (if (>= (- (point-max) (point)) bookmark-search-size)
-                (buffer-substring-no-properties
-                 (point)
-                 (+ (point) bookmark-search-size))
-              nil)))
-      (rear-context-string
-       . (, (if (>= (- (point) (point-min)) bookmark-search-size)
-                (buffer-substring-no-properties
-                 (point)
-                 (- (point) bookmark-search-size))
-              nil)))
-      (position . (, (point)))
-      (annotation . (, annotation)))))
+being set.  This might change someday.
+Optional second arg INFO-NODE means this bookmark is at info node
+INFO-NODE, so record this fact in the bookmark's entry."
+  (let ((the-record
+         (` ((filename . (, (bookmark-buffer-file-name)))
+             (front-context-string
+              . (, (if (>= (- (point-max) (point)) bookmark-search-size)
+                       (buffer-substring-no-properties
+                        (point)
+                        (+ (point) bookmark-search-size))
+                     nil)))
+             (rear-context-string
+              . (, (if (>= (- (point) (point-min)) bookmark-search-size)
+                       (buffer-substring-no-properties
+                        (point)
+                        (- (point) bookmark-search-size))
+                     nil)))
+             (position . (, (point)))
+             ))))
+
+    ;; Now fill in the optional parts:
+    (if annotation
+        (nconc the-record (list (cons 'annotation annotation))))
+    (if info-node
+        (nconc the-record (list (cons 'info-node info-node))))
+
+    ;; Finally, return the completed record.
+    the-record))
+    
   
 \f
 ;;; File format stuff
@@ -590,11 +609,9 @@ being set.  This will change soon."
 ;; bookmark-jump will search for STRING-BEHIND and STRING-IN-FRONT in
 ;; case the file has changed since the bookmark was set.  It will
 ;; attempt to place the user before the changes, if there were any.
-;; annotation is the annotation for the bookmark; it may not exist
+;; ANNOTATION is the annotation for the bookmark; it may not exist
 ;; (for backward compatibility), be nil (no annotation), or be a
 ;; string.
-;;
-;; ANNOTATION is an annotation for the bookmark.
 
 
 (defconst bookmark-file-format-version 1
@@ -622,7 +639,7 @@ affect point."
             (forward-char -1)
             (read (current-buffer)))
         ;; Else no hope of getting information here.
-        (error "Not bookmark format.")))))
+        (error "Not bookmark format")))))
 
 
 (defun bookmark-upgrade-version-0-alist (old-list)
@@ -688,11 +705,11 @@ This expects to be called from point-min in a bookmark file."
      ((= version 0)
       (bookmark-upgrade-file-format-from-0))
      (t
-      (error "Bookmark file format version strangeness.")))))
+      (error "Bookmark file format version strangeness")))))
 
 
 (defun bookmark-insert-file-format-version-stamp ()
-  "Insert text indicating current version of bookmark file-format."
+  "Insert text indicating current version of bookmark file format."
   (insert
    (format ";;;; Emacs Bookmark Format Version %d ;;;;\n"
            bookmark-file-format-version))
@@ -733,7 +750,7 @@ the list of bookmarks.\)"
   (interactive (list nil current-prefix-arg))
   (or
    (bookmark-buffer-file-name)
-   (error "Buffer not visiting a file or directory."))
+   (error "Buffer not visiting a file or directory"))
 
   (bookmark-maybe-load-default-file)
 
@@ -760,15 +777,18 @@ the list of bookmarks.\)"
     (if bookmark-use-annotations
        (bookmark-read-annotation parg str)
       (progn
-       (bookmark-make str annotation parg)
-        ;; In Info, there's a little more information to record:
-        (if (eq major-mode 'Info-mode)
-            (bookmark-set-info-node str Info-current-node))
+       (bookmark-make str annotation parg (bookmark-info-current-node))
        (setq bookmark-current-bookmark str)
        (bookmark-bmenu-surreptitiously-rebuild-list)
        (goto-char bookmark-current-point)))))
 
 
+(defun bookmark-info-current-node ()
+  "If in Info-mode, return current node name (a string), else nil."
+  (if (eq major-mode 'Info-mode)
+      Info-current-node))
+
+
 (defun bookmark-kill-line (&optional newline-too)
   "Kill from point to end of line.
 If optional arg NEWLINE-TOO is non-nil, delete the newline too.
@@ -788,12 +808,13 @@ Does not affect the kill-ring."
 
 
 (defun bookmark-send-annotation ()
-  "After remove lines beginning with '#', use the contents of this buffer
-as the annotation for a bookmark, and store it in the bookmark list with
+  "Use buffer contents as the annotation for a bookmark.
+Exclude lines that begin with `#'.
+Store the annotation text in the bookmark list with
 the bookmark (and file, and point) specified in buffer local variables."
   (interactive)
   (if (not (eq major-mode 'bookmark-read-annotation-mode))
-      (error "Not in bookmark-read-annotation-mode."))
+      (error "Not in bookmark-read-annotation-mode"))
   (goto-char (point-min))
   (while (< (point) (point-max))
     (if (looking-at "^#")
@@ -812,7 +833,7 @@ the bookmark (and file, and point) specified in buffer local variables."
     (save-excursion 
       (pop-to-buffer buf)
       (goto-char pt)
-      (bookmark-make bookmark annotation parg)
+      (bookmark-make bookmark annotation parg (bookmark-info-current-node))
       (setq bookmark-current-bookmark bookmark))
     (bookmark-bmenu-surreptitiously-rebuild-list)
     (goto-char bookmark-current-point))
@@ -829,10 +850,8 @@ the bookmark (and file, and point) specified in buffer local variables."
 
 
 (defvar bookmark-read-annotation-text-func 'bookmark-default-annotation-text
-  "A variable containing a function which returns the text to insert
-into an annotation composition buffer.  It takes the name of the bookmark,
-as a string, as an arg.")
-
+  "Function to return default text to use for a bookmark annotation.
+It takes the name of the bookmark, as a string, as an arg.")
 
 (defun bookmark-read-annotation-mode (buf point parg bookmark)
   "Mode for composing annotations for a bookmark.
@@ -861,8 +880,8 @@ the annotation.
 
 
 (defun bookmark-read-annotation (parg bookmark)
-  "Pop up a buffer for entering a bookmark annotation.  Text surrounding
-the bookmark is PARG; the bookmark name is BOOKMARK."
+  "Pop up a buffer for entering a bookmark annotation.
+Text surrounding the bookmark is PARG; the bookmark name is BOOKMARK."
   (let ((buf (current-buffer))
        (point (point)))
     (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*"))
@@ -898,11 +917,10 @@ When you have finished composing, type \\[bookmark-send-annotation].
 
 
 (defun bookmark-send-edited-annotation ()
-  "After remove lines beginning with '#', use the contents of this buffer
-as the new annotation for a bookmark."
+  "Use buffer contents (minus beginning with `#' as annotation for a bookmark."
   (interactive)
   (if (not (eq major-mode 'bookmark-edit-annotation-mode))
-      (error "Not in bookmark-edit-annotation-mode."))
+      (error "Not in bookmark-edit-annotation-mode"))
   (goto-char (point-min))
   (while (< (point) (point-max))
     (if (looking-at "^#")
@@ -925,8 +943,8 @@ as the new annotation for a bookmark."
 
 
 (defun bookmark-insert-current-bookmark ()
-  "Insert this buffer's value of bookmark-current-bookmark, default
-to file name if it's nil."
+  "Insert this buffer's value of bookmark-current-bookmark.
+Default to file name if it's nil."
   (interactive)
   (let ((str
         (save-excursion
@@ -936,8 +954,8 @@ to file name if it's nil."
 
 
 (defun bookmark-insert-buffer-name ()
-  "Insert the name (sans path) of the current file into the bookmark
-name that is being set."
+  "Insert the current file name into the bookmark name being set.
+The directory part of the file name is not used."
   (interactive)
   (let ((str
          (save-excursion
@@ -1001,7 +1019,6 @@ For example, if this is a Info buffer, return the Info file's name."
 (defun bookmark-maybe-load-default-file ()
   (and (not bookmarks-already-loaded)
        (null bookmark-alist)
-
        (prog2
            (and
             ;; Possibly the old bookmark file, "~/.emacs-bkmrks", needs
@@ -1123,10 +1140,10 @@ of the old one in the permanent bookmark record."
 
 ;;;###autoload
 (defun bookmark-relocate (bookmark)
-  "Relocate BOOKMARK -- prompts for a filename, and makes an already
-existing bookmark point to that file, instead of the one it used to
-point at.  Useful when a file has been renamed after a bookmark was
-set in it."
+  "Relocate BOOKMARK to another file (reading file name with minibuffer).
+This makes an already existing bookmark point to that file, instead of
+the one it used to point at.  Useful when a file has been renamed
+after a bookmark was set in it."
   (interactive (bookmark-completing-read "Bookmark to relocate"))
   (bookmark-maybe-historicize-string bookmark)
   (bookmark-maybe-load-default-file)
@@ -1147,6 +1164,8 @@ minibuffer history list `bookmark-history'."
   (or no-history (bookmark-maybe-historicize-string bookmark))
   (insert (bookmark-location bookmark)))
 
+;;;###autoload
+(defalias 'bookmark-locate 'bookmark-insert-location)
 
 (defun bookmark-location (bookmark)
   "Return the name of the file associated with BOOKMARK."
@@ -1156,11 +1175,11 @@ minibuffer history list `bookmark-history'."
 
 ;;;###autoload
 (defun bookmark-rename (old &optional new)
-  "Change the name of OLD bookmark to NEW name.  If called from
-keyboard, prompts for OLD and NEW.  If called from menubar, OLD is
-selected from a menu, and prompts for NEW.
+  "Change the name of OLD bookmark to NEW name.
+If called from keyboard, prompt for OLD and NEW.  If called from
+menubar, select OLD from a menu and prompt for NEW.
 
-If called from Lisp, prompts for NEW if only OLD was passed as an
+If called from Lisp, prompt for NEW if only OLD was passed as an
 argument.  If called with two strings, then no prompting is done.  You
 must pass at least OLD when calling from Lisp.
 
@@ -1261,9 +1280,8 @@ probably because we were called from there."
 
 ;;;###autoload
 (defun bookmark-write ()
-  "Write bookmarks to a file \(for which the user will be prompted
-interactively\).  Don't use this in Lisp programs; use bookmark-save
-instead."
+  "Write bookmarks to a file (reading the file name with the minibuffer).
+Don't use this in Lisp programs; use `bookmark-save' instead."
   (interactive)
   (bookmark-maybe-load-default-file)
   (bookmark-save t))
@@ -1312,7 +1330,7 @@ for a file, defaulting to the file defined by variable
   (save-excursion
     (save-window-excursion
       (if (>= baud-rate 9600)
-          (message (format "Saving bookmarks to file %s..." file)))
+          (message "Saving bookmarks to file %s..." file))
       (set-buffer (let ((enable-local-variables nil))
                     (find-file-noselect file)))
       (goto-char (point-min))
@@ -1329,7 +1347,7 @@ for a file, defaulting to the file defined by variable
         (write-file file)
         (kill-buffer (current-buffer))
         (if (>= baud-rate 9600)
-            (message (format "Saving bookmarks to file %s...done" file)))
+            (message "Saving bookmarks to file %s...done" file))
         ))))
 
 
@@ -1360,7 +1378,7 @@ explicitly."
       (save-excursion
         (save-window-excursion
           (if (and (null no-msg) (>= baud-rate 9600))
-              (message (format "Loading bookmarks from %s..." file)))
+              (message "Loading bookmarks from %s..." file))
           (set-buffer (let ((enable-local-variables nil))
                         (find-file-noselect file)))
           (goto-char (point-min))
@@ -1375,11 +1393,11 @@ explicitly."
                   (setq bookmark-alist
                         (append blist (if (not revert) bookmark-alist)))
                   (bookmark-bmenu-surreptitiously-rebuild-list)) 
-              (error (format "Invalid bookmark list in %s." file))))
+              (error "Invalid bookmark list in %s" file)))
           (kill-buffer (current-buffer)))
        (if (and (null no-msg) (>= baud-rate 9600))
-            (message (format "Loading bookmarks from %s...done" file))))
-    (error (format "Cannot read bookmark file %s." file))))
+            (message "Loading bookmarks from %s...done" file)))
+    (error "Cannot read bookmark file %s" file)))
 
 
 \f
@@ -1406,9 +1424,11 @@ explicitly."
   (define-key bookmark-bmenu-mode-map "2" 'bookmark-bmenu-2-window)
   (define-key bookmark-bmenu-mode-map "1" 'bookmark-bmenu-1-window)
   (define-key bookmark-bmenu-mode-map "j" 'bookmark-bmenu-this-window)
+  (define-key bookmark-bmenu-mode-map "\C-c\C-c" 'bookmark-bmenu-this-window)
   (define-key bookmark-bmenu-mode-map "f" 'bookmark-bmenu-this-window)
   (define-key bookmark-bmenu-mode-map "o" 'bookmark-bmenu-other-window)
-  (define-key bookmark-bmenu-mode-map "\C-o" 'bookmark-bmenu-switch-other-window)
+  (define-key bookmark-bmenu-mode-map "\C-o"
+    'bookmark-bmenu-switch-other-window)
   (define-key bookmark-bmenu-mode-map "s" 'bookmark-bmenu-save)
   (define-key bookmark-bmenu-mode-map "k" 'bookmark-bmenu-delete)
   (define-key bookmark-bmenu-mode-map "\C-d" 'bookmark-bmenu-delete-backwards)
@@ -1681,7 +1701,7 @@ if an annotation exists."
 
 
 (defun bookmark-bmenu-mark ()
-  "Mark bookmark on this line to be displayed by \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-select] command."
+  "Mark bookmark on this line to be displayed by \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-select]."
   (interactive)
   (beginning-of-line)
   (if (bookmark-bmenu-check-position)
@@ -1866,7 +1886,8 @@ Optional BACKUP means move up."
 
 
 (defun bookmark-bmenu-delete ()
-  "Mark bookmark on this line to be deleted by \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions] command."
+  "Mark bookmark on this line to be deleted.
+To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions]."
   (interactive)
   (beginning-of-line)
   (if (bookmark-bmenu-check-position)
@@ -1877,8 +1898,8 @@ Optional BACKUP means move up."
 
 
 (defun bookmark-bmenu-delete-backwards ()
-  "Mark bookmark on this line to be deleted by \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions] command
-and then move up one line"
+  "Mark bookmark on this line to be deleted, then move up one line.
+To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions]."
   (interactive)
   (bookmark-bmenu-delete)
   (forward-line -2)
@@ -2126,9 +2147,7 @@ corresponding bookmark function from Lisp \(the one without the
 ;; We MUST autoload EACH form used to set up this variable's value, so
 ;; that the whole job is done in loaddefs.el.
 
-;; FSF Emacs menubar stuff
-;; The odd conditional structure is due to the limitations of autoload
-;; cookies.
+;; Emacs menubar stuff.
 
 ;;;###autoload
 (defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions"))