diff lisp/packages/bookmark.el @ 153:25f70ba0133c r20-3b3

Import from CVS: tag r20-3b3
author cvs
date Mon, 13 Aug 2007 09:38:25 +0200
parents cca96a509cfe
children 28f395d8dc7a
line wrap: on
line diff
--- a/lisp/packages/bookmark.el	Mon Aug 13 09:37:21 2007 +0200
+++ b/lisp/packages/bookmark.el	Mon Aug 13 09:38:25 2007 +0200
@@ -1,20 +1,13 @@
 ;;; 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@cyclic.com>
-;; Maintainer: Karl Fogel <kfogel@cyclic.com>
+;; Author: Karl Fogel <kfogel@red-bean.com>
+;; Maintainer: Karl Fogel <kfogel@red-bean.com>
 ;; Created: July, 1993
-;; Author's Update Number: 2.6.14-x
+;; Author's Update Number: see variable `bookmark-version'.
 ;; Keywords: bookmarks, placeholders, annotations
 
-;;; Summary:
-;; This package is for setting "bookmarks" in files.  A bookmark
-;; associates a string with a location in a certain file.  Thus, you
-;; can navigate your way to that location by providing the string.
-;; See the "User Variables" section for customizations.
-
-;;; Copyright info:
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
@@ -28,11 +21,16 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 19.30.
-;;; We appear to have a more recent version than FSF?
+;;; Commentary:
+
+;; This package is for setting "bookmarks" in files.  A bookmark
+;; associates a string with a location in a certain file.  Thus, you
+;; can navigate your way to that location by providing the string.
+;; See the "User Variables" section for customizations.
 
 ;; Thanks to David Bremner <bremner@cs.sfu.ca> for thinking of and
 ;; then implementing the bookmark-current-bookmark idea.  He even
@@ -50,7 +48,7 @@
 ;; bookmark-bmenu-check-position, and some of the Lucid compatibility
 ;; stuff).
 
-;; Kudos (whatever they are) go to Jim Blandy <jimb@cyclic.com>
+;; Kudos (whatever they are) go to Jim Blandy <jimb@red-bean.com>
 ;; for his eminently sensible suggestion to separate bookmark-jump
 ;; into bookmark-jump and bookmark-jump-noselect, which made many
 ;; other things cleaner as well.
@@ -79,12 +77,15 @@
 ;; FAVORITE CHINESE RESTAURANT: 
 ;; Boy, that's a tough one.  Probably Hong Min, or maybe Emperor's
 ;; Choice (both in Chicago's Chinatown).  Well, both.  How about you?
+
+;;;; Code:
 
-
 (require 'pp)
 
-
-;;;; Code:
+(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.")
 
 ;;; Misc comments:
 ;;
@@ -98,24 +99,17 @@
 
 ;;; User Variables
 
-(defgroup bookmark nil
-  "Setting, annotation and jumping to bookmarks"
-  :group 'matching)
+(defvar bookmark-use-annotations nil
+  "*If non-nil, saving a bookmark will query for an annotation in a
+buffer.")
 
 
-(defcustom bookmark-use-annotations nil
-  "*If non-nil, saving a bookmark will query for an annotation in a
-buffer."
-  :type 'boolean
-  :group 'bookmark)
-
-
-(defcustom bookmark-save-flag t
+(defvar bookmark-save-flag t
   "*Controls when Emacs saves bookmarks to a file.
 --> Nil means never save bookmarks, except when `bookmark-save' is
     explicitly called \(\\[bookmark-save]\).
 --> t means save bookmarks when Emacs is killed.
---> Otherise, it should be a number that is the frequency with which
+--> Otherwise, it should be a number that is the frequency with which
     the bookmark list is saved \(i.e.: the number of times which
     Emacs' bookmark list may be modified before it is automatically
     saved.\).  If it is a number, Emacs will also automatically save
@@ -126,9 +120,7 @@
 behavior.\)
 
 To specify the file in which to save them, modify the variable
-bookmark-default-file, which is `~/.emacs.bmk' by default."
-  :type '(choice (const nil) (const t) integer)
-  :group 'bookmark)
+bookmark-default-file, which is `~/.emacs.bmk' by default.")
 
 
 (defconst bookmark-old-default-file "~/.emacs-bkmrks"
@@ -139,76 +131,58 @@
 (defvar bookmark-file nil
   "Old name for `bookmark-default-file'.")
 
-(defcustom bookmark-default-file
-  (if (and (boundp 'bookmark-file) bookmark-file)
+(defvar bookmark-default-file
+  (if bookmark-file
       ;; In case user set `bookmark-file' in her .emacs:
       bookmark-file
-    (if (eq system-type 'ms-dos)
-        "~/emacs.bmk" ; Cannot have initial dot [Yuck!]
-      "~/.emacs.bmk"))
-  "*File in which to save bookmarks by default."
-  :type 'file
-  :group 'bookmark)
+    (convert-standard-filename "~/.emacs.bmk"))
+  "*File in which to save bookmarks by default.")
 
 
-(defcustom bookmark-version-control 'nospecial
+(defvar bookmark-version-control 'nospecial
   "*Whether or not to make numbered backups of the bookmark file.
 It can have four values: t, nil, `never', and `nospecial'.
 The first three have the same meaning that they do for the
 variable `version-control', and the final value `nospecial' means just
-use the value of `version-control'."
-  :type '(choice (const t) (const nil) (const never) (const nospecial))
-  :group 'bookmark)
+use the value of `version-control'.")
 
 
-(defcustom bookmark-completion-ignore-case t
-  "*Non-nil means bookmark functions ignore case in completion."
-  :type 'boolean
-  :group 'bookmark)
+(defvar bookmark-completion-ignore-case t
+  "*Non-nil means bookmark functions ignore case in completion.")
 
 
-(defcustom bookmark-sort-flag t
+(defvar bookmark-sort-flag t
   "*Non-nil means that bookmarks will be displayed sorted by bookmark
 name.  Otherwise they will be displayed in LIFO order (that is, most
-recently set ones come first, oldest ones come last)."
-  :type 'boolean
-  :group 'bookmark)
+recently set ones come first, oldest ones come last).")
+
+
+(defvar bookmark-automatically-show-annotations t
+  "*Nil means don't show annotations when jumping to a bookmark.")
 
 
-(defcustom bookmark-automatically-show-annotations t
-  "*Nil means don't show annotations when jumping to a bookmark."
-  :type 'boolean
-  :group 'bookmark)
+(defvar bookmark-bmenu-file-column 30
+  "*Column at which to display filenames in a buffer listing bookmarks.
+You can toggle whether files are shown with \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-toggle-filenames].")
 
 
-(defcustom bookmark-bmenu-file-column 30
-  "*Column at which to display filenames in a buffer listing bookmarks.
-You can toggle whether files are shown with \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-toggle-filenames]."
-  :type 'integer
-  :group 'bookmark)
-
-
-(defcustom bookmark-bmenu-toggle-filenames t
+(defvar bookmark-bmenu-toggle-filenames t
   "*Non-nil means show filenames when listing bookmarks.
 This may result in truncated bookmark names.  To disable this, put the
 following in your .emacs:
 
-\(setq bookmark-bmenu-toggle-filenames nil\)"
-  :type 'boolean
-  :group 'bookmark)
+\(setq bookmark-bmenu-toggle-filenames nil\)")
 
 
-(defcustom bookmark-menu-length 70
-  "*Maximum length of a bookmark name displayed on a popup menu."
-  :type 'integer
-  :group 'boolean)
+(defvar bookmark-menu-length 70
+  "*Maximum length of a bookmark name displayed on a popup menu.")
 
 
 ;;; No user-serviceable parts beyond this point.
 
 ;; Is it XEmacs?
 (defconst bookmark-xemacsp
-  (string-match "\\(Lucid\\|XEmacs\\)" emacs-version))
+  (string-match "\\(Lucid\\|Xemacs\\)" emacs-version))
 
 
 ;; Added  for lucid emacs  compatibility, db
@@ -217,6 +191,18 @@
 ;; suggested for lucid compatibility by david hughes:
 (or (fboundp 'frame-height)  (defalias 'frame-height 'screen-height))
 
+;; This variable is probably obsolete now...
+(or (boundp 'baud-rate)
+    ;; some random value higher than 9600    
+    (setq baud-rate 19200))
+
+;; XEmacs apparently call this `buffer-substring-without-properties',
+;; sigh.
+(or (fboundp 'buffer-substring-no-properties)
+    (if (fboundp 'buffer-substring-without-properties)
+        (fset 'buffer-substring-no-properties
+              'buffer-substring-without-properties)
+      (fset 'buffer-substring-no-properties 'buffer-substring)))
 
 
 ;;; Keymap stuff:
@@ -310,7 +296,7 @@
 
 ;; just add the hook to make sure that people don't lose bookmarks
 ;; when they kill Emacs, unless they don't want to save them.
-;;;Don't ###autoload this, there's no need. -jwz
+;;;###autoload
 (add-hook 'kill-emacs-hook
           (function
            (lambda () (and (featurep 'bookmark)
@@ -462,7 +448,11 @@
     (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
@@ -502,19 +492,24 @@
       (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)))
-    (set-text-properties 0 (length stripped-name) nil stripped-name)
+    (or bookmark-xemacsp
+        ;; XEmacs's `set-text-properties' doesn't work on
+        ;; free-standing strings, apparently.
+        (set-text-properties 0 (length stripped-name) nil stripped-name))
     (if (and (bookmark-get-bookmark stripped-name) (not overwrite))
-        ;; already existing boookmark under that name and
+        ;; 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
@@ -523,7 +518,7 @@
       (setq bookmark-alist
             (cons
              (list stripped-name 
-                   (bookmark-make-cell annotation))
+                   (bookmark-make-cell annotation info-node))
              bookmark-alist)))
     
     ;; Added by db
@@ -534,25 +529,38 @@
         (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))
+    
   
 
 ;;; File format stuff
@@ -599,11 +607,9 @@
 ;; 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
@@ -631,7 +637,7 @@
             (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)
@@ -667,7 +673,7 @@
     (pp new-list (current-buffer))
     (save-buffer))
   (goto-char (point-min))
-  (message "Upgrading bookmark format from 0 to %d... done."
+  (message "Upgrading bookmark format from 0 to %d...done"
            bookmark-file-format-version)
   )
 
@@ -697,11 +703,11 @@
      ((= 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))
@@ -742,7 +748,7 @@
   (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)
 
@@ -769,15 +775,18 @@
     (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.
@@ -797,12 +806,13 @@
 
 
 (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 "^#")
@@ -821,7 +831,7 @@
     (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))
@@ -838,10 +848,8 @@
 
 
 (defvar bookmark-read-annotation-text-func 'bookmark-default-annotation-text
-  "A variable containing a function which returns the text to insert
-into an annotation compisition 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.
@@ -870,8 +878,8 @@
 
 
 (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*"))
@@ -907,11 +915,10 @@
 
 
 (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 "^#")
@@ -934,8 +941,8 @@
 
 
 (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
@@ -945,8 +952,8 @@
 
 
 (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
@@ -1010,7 +1017,6 @@
 (defun bookmark-maybe-load-default-file ()
   (and (not bookmarks-already-loaded)
        (null bookmark-alist)
-
        (prog2
            (and
             ;; Possibly the old bookmark file, "~/.emacs-bkmrks", needs
@@ -1108,10 +1114,10 @@
           ;; rather than after and remain perhaps unaware of the changes.
           (if forward-str
               (if (search-forward forward-str (point-max) t)
-                  (backward-char (length forward-str))))
+                  (goto-char (match-beginning 0))))
           (if behind-str
               (if (search-backward behind-str (point-min) t)
-                  (forward-char (length behind-str))))
+                  (goto-char (match-end 0))))
           ;; added by db
           (setq bookmark-current-bookmark str)
           (cons (current-buffer) (point)))
@@ -1132,10 +1138,10 @@
 
 ;;;###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)
@@ -1154,8 +1160,18 @@
 minibuffer history list `bookmark-history'."
   (interactive (bookmark-completing-read "Insert bookmark location"))
   (or no-history (bookmark-maybe-historicize-string bookmark))
-  (insert (bookmark-location bookmark)))
+  (let ((start (point)))
+    (prog1
+	(insert (bookmark-location bookmark)) ; *Return this line*
+      (if window-system
+	  (put-text-property start 
+			     (save-excursion (re-search-backward
+					      "[^ \t]")
+					     (1+ (point)))
+			     'mouse-face 'highlight)))))
 
+;;;###autoload
+(defalias 'bookmark-locate 'bookmark-insert-location)
 
 (defun bookmark-location (bookmark)
   "Return the name of the file associated with BOOKMARK."
@@ -1165,11 +1181,11 @@
 
 ;;;###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.
 
@@ -1270,9 +1286,8 @@
 
 ;;;###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))
@@ -1320,7 +1335,7 @@
 (defun bookmark-write-file (file)
   (save-excursion
     (save-window-excursion
-      (if (>= (device-baud-rate) 9600)
+      (if (>= baud-rate 9600)
           (message "Saving bookmarks to file %s..." file))
       (set-buffer (let ((enable-local-variables nil))
                     (find-file-noselect file)))
@@ -1337,8 +1352,8 @@
                t))))
         (write-file file)
         (kill-buffer (current-buffer))
-        (if (>= (device-baud-rate) 9600)
-            (message "Saving bookmarks to file %s... done." file))
+        (if (>= baud-rate 9600)
+            (message "Saving bookmarks to file %s...done" file))
         ))))
 
 
@@ -1368,7 +1383,7 @@
   (if (file-readable-p file)
       (save-excursion
         (save-window-excursion
-          (if (and (null no-msg) (>= (device-baud-rate) 9600))
+          (if (and (null no-msg) (>= baud-rate 9600))
               (message "Loading bookmarks from %s..." file))
           (set-buffer (let ((enable-local-variables nil))
                         (find-file-noselect file)))
@@ -1384,11 +1399,11 @@
                   (setq bookmark-alist
                         (append blist (if (not revert) bookmark-alist)))
                   (bookmark-bmenu-surreptitiously-rebuild-list)) 
-              (error "Invalid bookmark list in %s." file)))
+              (error "Invalid bookmark list in %s" file)))
           (kill-buffer (current-buffer)))
-	(if (and (null no-msg) (>= (device-baud-rate) 9600))
-            (message "Loading bookmarks from %s... done" file)))
-    (error "Cannot read bookmark file %s." file)))
+	(if (and (null no-msg) (>= baud-rate 9600))
+            (message "Loading bookmarks from %s...done" file)))
+    (error "Cannot read bookmark file %s" file)))
 
 
 
@@ -1415,14 +1430,15 @@
   (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)
   (define-key bookmark-bmenu-mode-map "x" 'bookmark-bmenu-execute-deletions)
-  (define-key bookmark-bmenu-mode-map "\C-k" 'bookmark-bmenu-delete)
   (define-key bookmark-bmenu-mode-map "d" 'bookmark-bmenu-delete)
   (define-key bookmark-bmenu-mode-map " " 'next-line)
   (define-key bookmark-bmenu-mode-map "n" 'next-line)
@@ -1436,7 +1452,9 @@
   (define-key bookmark-bmenu-mode-map "t" 'bookmark-bmenu-toggle-filenames)
   (define-key bookmark-bmenu-mode-map "a" 'bookmark-bmenu-show-annotation)
   (define-key bookmark-bmenu-mode-map "A" 'bookmark-bmenu-show-all-annotations)
-  (define-key bookmark-bmenu-mode-map "e" 'bookmark-bmenu-edit-annotation))
+  (define-key bookmark-bmenu-mode-map "e" 'bookmark-bmenu-edit-annotation)
+  (define-key bookmark-bmenu-mode-map [mouse-2]
+    'bookmark-bmenu-other-window-with-mouse))
 
   
 
@@ -1479,7 +1497,7 @@
     (bookmark-maybe-sort-alist)
     (mapcar
      (lambda (full-record)
-       ;; if a bookmark has an annotation, precede it with a "*"
+       ;; if a bookmark has an annotation, prepend a "*"
        ;; in the list of bookmarks.
        (let ((annotation (bookmark-get-annotation
                           (bookmark-name-from-full-record full-record))))
@@ -1487,7 +1505,16 @@
                   (not (string-equal annotation "")))
              (insert " *")
            (insert "  "))
-         (insert (concat (bookmark-name-from-full-record full-record) "\n"))))
+	 (let ((start (point)))
+	   (insert (bookmark-name-from-full-record full-record))
+	   (if window-system
+	       (put-text-property start 
+				  (save-excursion (re-search-backward
+						   "[^ \t]")
+						  (1+ (point)))
+				  'mouse-face 'highlight))
+	   (insert "\n")
+	   )))
      bookmark-alist))
   (goto-char (point-min))
   (forward-line 2)
@@ -1523,7 +1550,7 @@
 \\[bookmark-bmenu-rename] -- rename this bookmark \(prompts for new name\).   
 \\[bookmark-bmenu-delete] -- mark this bookmark to be deleted, and move down.
 \\[bookmark-bmenu-delete-backwards] -- mark this bookmark to be deleted, and move up. 
-\\[bookmark-bmenu-execute-deletions] -- delete marked bookmarks.
+\\[bookmark-bmenu-execute-deletions] -- delete bookmarks marked with `\\[bookmark-bmenu-delete]'.
 \\[bookmark-bmenu-save] -- save the current bookmark list in the default file.
   With a prefix arg, prompts for a file to save in.
 \\[bookmark-bmenu-load] -- load in a file of bookmarks (prompts for file.)
@@ -1573,8 +1600,13 @@
             (let ((bmrk (bookmark-bmenu-bookmark)))
               (setq bookmark-bmenu-hidden-bookmarks
                     (cons bmrk bookmark-bmenu-hidden-bookmarks))
-              (move-to-column bookmark-bmenu-file-column t)
-              (delete-region (point) (progn (end-of-line) (point)))
+	      (let ((start (save-excursion (end-of-line) (point))))
+		(move-to-column bookmark-bmenu-file-column t)
+		;; Strip off `mouse-face' from the white spaces region.
+		(if window-system
+		    (remove-text-properties start (point)
+					    '(mouse-face))))
+	      (delete-region (point) (progn (end-of-line) (point)))
               (insert "  ")
               ;; Pass the NO-HISTORY arg:
               (bookmark-insert-location bmrk t)
@@ -1600,7 +1632,14 @@
               (while bookmark-bmenu-hidden-bookmarks
                 (move-to-column bookmark-bmenu-bookmark-column t)
                 (bookmark-kill-line)
-                (insert (car bookmark-bmenu-hidden-bookmarks))
+		(let ((start (point)))
+		  (insert (car bookmark-bmenu-hidden-bookmarks))
+		  (if window-system
+		      (put-text-property start 
+					 (save-excursion (re-search-backward
+							  "[^ \t]")
+							 (1+ (point)))
+					 'mouse-face 'highlight)))
                 (setq bookmark-bmenu-hidden-bookmarks
                       (cdr bookmark-bmenu-hidden-bookmarks))
                 (forward-line 1))))))))
@@ -1640,7 +1679,7 @@
       (beginning-of-line)
       (forward-char bookmark-bmenu-bookmark-column)
       (prog1
-          (buffer-substring (point)
+          (buffer-substring-no-properties (point) 
                             (progn 
                               (end-of-line)
                               (point)))
@@ -1691,7 +1730,7 @@
 
 
 (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)
@@ -1818,6 +1857,19 @@
             (set-buffer o-buffer))
 	  (bookmark-show-annotation bookmark)))))
 
+(defun bookmark-bmenu-other-window-with-mouse (event)
+  "Select bookmark at the mouse pointer in other window, leaving bookmark menu visible."
+  (interactive "e")
+  (save-excursion
+    (set-buffer (if (fboundp 'event-buffer) ; XEmacs
+		    (event-buffer event)
+		  (window-buffer (posn-window (event-end event)))))
+    (save-excursion
+      (goto-char (if (fboundp 'event-closest-point)
+		     (event-closest-point event)
+		   (posn-point (event-end event))))
+      (bookmark-bmenu-other-window))))
+
 
 (defun bookmark-bmenu-show-annotation ()
   "Show the annotation for the current bookmark in another window."
@@ -1876,7 +1928,8 @@
 
 
 (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)
@@ -1887,8 +1940,8 @@
 
 
 (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)
@@ -1899,6 +1952,7 @@
 (defun bookmark-bmenu-execute-deletions ()
   "Delete bookmarks marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands."
   (interactive)
+  (message "Deleting bookmarks...")
   (let ((hide-em bookmark-bmenu-toggle-filenames)
         (o-point  (point))
         (o-str    (save-excursion
@@ -1930,7 +1984,9 @@
     (setq bookmark-alist-modification-count
           (1+ bookmark-alist-modification-count))
     (if (bookmark-time-to-save-p)
-        (bookmark-save))))
+        (bookmark-save))
+    (message "Deleting bookmarks...done")
+    ))
 
 
 (defun bookmark-bmenu-rename ()
@@ -2026,7 +2082,19 @@
 in the menu.
 The number of panes depends on the number of entries."
   (interactive "e")
-  (x-popup-menu event (bookmark-menu-build-paned-menu name entries)))
+  (cond ((fboundp 'x-popup-menu) ; Emacs
+	 (x-popup-menu event (bookmark-menu-build-paned-menu name entries)))
+	(t ; XEmacs
+	 (get-popup-menu-response
+	  (cons title
+		(mapcar
+		 (function
+		  (lambda (x)
+		    (if (stringp x)
+			(vector x nil nil) 
+		      (vector (car x) (list (car x)) t))))
+		 (bookmark-menu-build-paned-menu name entries)))))))
+
 
 
 (defun bookmark-menu-popup-paned-bookmark-menu (event name)
@@ -2039,12 +2107,9 @@
 (defun bookmark-popup-menu-and-apply-function (func-sym menu-label event)
   ;; help function for making menus that need to apply a bookmark
   ;; function to a string.
-  (if bookmark-xemacsp
-      (popup-menu (bookmark-build-xemacs-menu
- 		   menu-label (bookmark-all-names) func-sym))
-    (let* ((choice (bookmark-menu-popup-paned-bookmark-menu
- 		    event menu-label)))
-      (if choice (apply func-sym (list choice))))))
+  (let* ((choice (bookmark-menu-popup-paned-bookmark-menu
+                  event menu-label)))
+    (if choice (apply func-sym (list choice)))))
 
 
 ;;;###autoload
@@ -2136,66 +2201,60 @@
 ;; We MUST autoload EACH form used to set up this variable's value, so
 ;; that the whole job is done in loaddefs.el.
 
-;; a pox on autoloading this form.  It's too big. --ben
-;(if (string-match "\\(Lucid\\|XEmacs\\)" emacs-version)
-;    (progn
-;      (defvar bookmark-xemacs-menu
-;	'("Bookmarks"
-;	  ["Jump to bookmark"  	      bookmark-menu-jump t]
-;	  ["Set bookmark"  	      bookmark-set t]
-;	  "---"
-;	  ["Insert contents"  	      bookmark-menu-insert t]
-;	  ["Insert location"  	      bookmark-menu-locate t]
-;	  "---"
-;	  ["Rename bookmark"  	      bookmark-menu-rename t]
-;	  ["Delete bookmark"  	      bookmark-menu-delete t]
-;	  ["Edit Bookmark List"       bookmark-bmenu-list t]
-;	  "---"
-;	  ["Save bookmarks"           bookmark-save t]
-;	  ["Save bookmarks as..."     bookmark-write t]
-;	  ["Load a bookmark file"     bookmark-load t]))
-;      ;; Display a solid horizontal line 
-;      ;;(add-menu-button '("File") ["---" nil nil] "Insert File...")
-;      ;;(add-submenu '("File") bookmark-xemacs-menu "Insert File...")
-;      (add-hook 'before-init-hook
-;		(lambda ()
-;		  (if (featurep 'menubar)
-;		      (add-submenu '("Edit") bookmark-xemacs-menu
-;				   "Goto Line..."))))
-;      )
-  
-;  ;; Emacs menubar stuff
-;  (defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions"))
-;  (defalias 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map))
+;; Emacs menubar stuff.
+
+;;;###autoload
+(defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions"))
+
+;;;###autoload
+(defalias 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map))
+
+;; make bookmarks appear toward the right side of the menu.
+(if (boundp 'menu-bar-final-items)
+    (if menu-bar-final-items 
+        (setq menu-bar-final-items
+              (cons 'bookmark menu-bar-final-items)))
+  (setq menu-bar-final-items '(bookmark)))
+
+;;;###autoload
+(define-key menu-bar-bookmark-map [load]
+  '("Load a Bookmark File..." . bookmark-load))
+
+;;;###autoload
+(define-key menu-bar-bookmark-map [write]
+  '("Save Bookmarks As..." . bookmark-write))
+
+;;;###autoload
+(define-key menu-bar-bookmark-map [save]
+  '("Save Bookmarks" . bookmark-save))
 
-;  ;; make bookmarks appear toward the right side of the menu.
-;  (if (boundp 'menu-bar-final-items)
-;      (if menu-bar-final-items 
-;	  (setq menu-bar-final-items
-;		(cons 'bookmark menu-bar-final-items)))
-;    (setq menu-bar-final-items '(bookmark)))
-  
-;  (define-key menu-bar-bookmark-map [load]
-;    '("Load a bookmark file" . bookmark-load))
-;  (define-key menu-bar-bookmark-map [write]
-;    '("Save bookmarks as..." . bookmark-write))
-;  (define-key menu-bar-bookmark-map [save]
-;    '("Save bookmarks" . bookmark-save))
-;  (define-key menu-bar-bookmark-map [edit]
-;    '("Edit Bookmark List" . bookmark-bmenu-list))
-;  (define-key menu-bar-bookmark-map [delete]
-;    '("Delete bookmark" . bookmark-menu-delete))
-;  (define-key menu-bar-bookmark-map [rename]
-;    '("Rename bookmark" . bookmark-menu-rename))
-;  (define-key menu-bar-bookmark-map [locate]
-;    '("Insert location" . bookmark-menu-locate))
-;  (define-key menu-bar-bookmark-map [insert]
-;    '("Insert contents" . bookmark-menu-insert))
-;  (define-key menu-bar-bookmark-map [set]
-;    '("Set bookmark" . bookmark-set))
-;  (define-key menu-bar-bookmark-map [jump] 
-;    '("Jump to bookmark" . bookmark-menu-jump)))
+;;;###autoload
+(define-key menu-bar-bookmark-map [edit]
+  '("Edit Bookmark List" . bookmark-bmenu-list))
+
+;;;###autoload
+(define-key menu-bar-bookmark-map [delete]
+  '("Delete Bookmark" . bookmark-menu-delete))
+
+;;;###autoload
+(define-key menu-bar-bookmark-map [rename]
+  '("Rename Bookmark" . bookmark-menu-rename))
 
+;;;###autoload
+(define-key menu-bar-bookmark-map [locate]
+  '("Insert Location" . bookmark-menu-locate))
+
+;;;###autoload
+(define-key menu-bar-bookmark-map [insert]
+  '("Insert Contents" . bookmark-menu-insert))
+
+;;;###autoload
+(define-key menu-bar-bookmark-map [set]
+  '("Set Bookmark" . bookmark-set))
+
+;;;###autoload
+(define-key menu-bar-bookmark-map [jump] 
+  '("Jump to Bookmark" . bookmark-menu-jump))
 
 ;;;; end bookmark menu stuff ;;;;