Spelling fixes.
[bpt/emacs.git] / lisp / bookmark.el
index 268a370..4d93e01 100644 (file)
@@ -1,8 +1,6 @@
 ;;; bookmark.el --- set bookmarks, maybe annotate them, jump to them later
 
-;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1993-1997, 2001-2011  Free Software Foundation, Inc.
 
 ;; Author: Karl Fogel <kfogel@red-bean.com>
 ;; Maintainer: Karl Fogel <kfogel@red-bean.com>
@@ -85,7 +83,7 @@ To specify the file in which to save them, modify the variable
   "The `.emacs.bmk' file used to be called this name.")
 
 
-;; defvarred to avoid a compilation warning:
+;; defvared to avoid a compilation warning:
 (defvar bookmark-file nil
   "Old name for `bookmark-default-file'.")
 
@@ -305,7 +303,7 @@ This point is in `bookmark-current-buffer'.")
 ;; need to know anything about the format of bookmark-alist entries.
 ;; Everyone else should go through them.
 
-(defun bookmark-name-from-record (bookmark-record)
+(defun bookmark-name-from-full-record (bookmark-record)
   "Return the name of BOOKMARK-RECORD.  BOOKMARK-RECORD is, e.g.,
 one element from `bookmark-alist'."
   (car bookmark-record))
@@ -314,7 +312,7 @@ one element from `bookmark-alist'."
 (defun bookmark-all-names ()
   "Return a list of all current bookmark names."
   (bookmark-maybe-load-default-file)
-  (mapcar 'bookmark-name-from-record bookmark-alist))
+  (mapcar 'bookmark-name-from-full-record bookmark-alist))
 
 
 (defun bookmark-get-bookmark (bookmark-name-or-record &optional noerror)
@@ -1060,7 +1058,7 @@ compatibility only."
 (defun bookmark-handle-bookmark (bookmark-name-or-record)
   "Call BOOKMARK-NAME-OR-RECORD's handler or `bookmark-default-handler'
 if it has none.  This changes current buffer and point and returns nil,
-or signals a `file-error'. 
+or signals a `file-error'.
 
 If BOOKMARK-NAME-OR-RECORD has no file, this is a no-op.  If
 BOOKMARK-NAME-OR-RECORD has a file, but that file no longer exists,
@@ -1391,13 +1389,13 @@ they conflict with existing bookmark names."
     (dolist (full-record new-list)
       (bookmark-maybe-rename full-record names)
       (setq bookmark-alist (nconc bookmark-alist (list full-record)))
-      (push (bookmark-name-from-record full-record) names))))
+      (push (bookmark-name-from-full-record full-record) names))))
 
 
 (defun bookmark-maybe-rename (full-record names)
   "Rename bookmark FULL-RECORD if its current name is already used.
 This is a helper for `bookmark-import-new-list'."
-  (let ((found-name (bookmark-name-from-record full-record)))
+  (let ((found-name (bookmark-name-from-full-record full-record)))
     (if (member found-name names)
         ;; We've got a conflict, so generate a new name
         (let ((count 2)
@@ -1477,8 +1475,7 @@ method buffers use to resolve name collisions."
 
 (defvar bookmark-bmenu-mode-map
   (let ((map (make-keymap)))
-    (suppress-keymap map t)
-    (define-key map "q" 'quit-window)
+    (set-keymap-parent map special-mode-map)
     (define-key map "v" 'bookmark-bmenu-select)
     (define-key map "w" 'bookmark-bmenu-locate)
     (define-key map "2" 'bookmark-bmenu-2-window)
@@ -1498,7 +1495,6 @@ method buffers use to resolve name collisions."
     (define-key map "n" 'next-line)
     (define-key map "p" 'previous-line)
     (define-key map "\177" 'bookmark-bmenu-backup-unmark)
-    (define-key map "?" 'describe-mode)
     (define-key map "u" 'bookmark-bmenu-unmark)
     (define-key map "m" 'bookmark-bmenu-mark)
     (define-key map "l" 'bookmark-bmenu-load)
@@ -1508,9 +1504,7 @@ method buffers use to resolve name collisions."
     (define-key map "a" 'bookmark-bmenu-show-annotation)
     (define-key map "A" 'bookmark-bmenu-show-all-annotations)
     (define-key map "e" 'bookmark-bmenu-edit-annotation)
-    ;; The original binding of M-g hides the M-g prefix map.
-    ;; If someone has a better idea than M-g s, I'm open to suggestions.
-    (define-key map [?\M-g ?s] 'bookmark-bmenu-search)
+    (define-key map "/" 'bookmark-bmenu-search)
     (define-key map [mouse-2] 'bookmark-bmenu-other-window-with-mouse)
     map))
 
@@ -1545,9 +1539,7 @@ deletion, or > if it is flagged for displaying."
   (bookmark-maybe-load-default-file)
   (let ((buf (get-buffer-create "*Bookmark List*")))
     (if (called-interactively-p 'interactive)
-        (if (or (window-dedicated-p) (window-minibuffer-p))
-            (pop-to-buffer buf)
-          (switch-to-buffer buf))
+        (switch-to-buffer buf)
       (set-buffer buf)))
   (let ((inhibit-read-only t))
     (erase-buffer)
@@ -1555,7 +1547,7 @@ deletion, or > if it is flagged for displaying."
     (add-text-properties (point-min) (point)
                         '(font-lock-face bookmark-menu-heading))
     (dolist (full-record (bookmark-maybe-sort-alist))
-      (let ((name        (bookmark-name-from-record full-record))
+      (let ((name        (bookmark-name-from-full-record full-record))
             (annotation  (bookmark-get-annotation full-record))
             (start       (point))
             end)
@@ -1588,7 +1580,7 @@ deletion, or > if it is flagged for displaying."
 
 
 
-(defun bookmark-bmenu-mode ()
+(define-derived-mode bookmark-bmenu-mode special-mode "Bookmark Menu"
   "Major mode for editing a list of bookmarks.
 Each line describes one of the bookmarks in Emacs.
 Letters do not insert themselves; instead, they are commands.
@@ -1621,13 +1613,8 @@ Bookmark names preceded by a \"*\" have annotations.
   in another buffer.
 \\[bookmark-bmenu-show-all-annotations] -- show the annotations of all bookmarks in another buffer.
 \\[bookmark-bmenu-edit-annotation] -- edit the annotation for the current bookmark."
-  (kill-all-local-variables)
-  (use-local-map bookmark-bmenu-mode-map)
   (setq truncate-lines t)
-  (setq buffer-read-only t)
-  (setq major-mode 'bookmark-bmenu-mode)
-  (setq mode-name "Bookmark Menu")
-  (run-mode-hooks 'bookmark-bmenu-mode-hook))
+  (setq buffer-read-only t))
 
 
 (defun bookmark-bmenu-toggle-filenames (&optional show)
@@ -1745,7 +1732,7 @@ if an annotation exists."
     (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t)
     (delete-region (point-min) (point-max))
     (dolist (full-record bookmark-alist)
-      (let* ((name (bookmark-name-from-record full-record))
+      (let* ((name (bookmark-name-from-full-record full-record))
              (ann  (bookmark-get-annotation full-record)))
         (insert (concat name ":\n"))
         (if (and ann (not (string-equal ann "")))
@@ -1854,7 +1841,7 @@ With a prefix arg, prompts for a file to save them in."
         (menu (current-buffer))
         (pop-up-windows t))
     (delete-other-windows)
-    (switch-to-buffer (other-buffer))
+    (switch-to-buffer (other-buffer) nil t)
     (bookmark--jump-via bmrk 'pop-to-buffer)
     (bury-buffer menu)))
 
@@ -2190,7 +2177,8 @@ This also runs `bookmark-exit-hook'."
        (bookmark-time-to-save-p t)
        (bookmark-save)))
 
-(add-hook 'kill-emacs-hook 'bookmark-exit-hook-internal)
+(unless noninteractive
+  (add-hook 'kill-emacs-hook 'bookmark-exit-hook-internal))
 
 (defun bookmark-unload-function ()
   "Unload the Bookmark library."