*** empty log message ***
[bpt/emacs.git] / lisp / bookmark.el
index 511c237..1aaefcb 100644 (file)
@@ -121,7 +121,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)
+  :type '(choice (const nil) integer (other t))
   :group 'bookmark)
 
 
@@ -149,7 +149,8 @@ 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))
+  :type '(choice (const nil) (const never) (const nospecial)
+                (other t))
   :group 'bookmark)
 
 
@@ -214,13 +215,6 @@ following in your `.emacs' file:
     ;; 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)))
 
 \f
 ;;; Keymap stuff:
@@ -1083,6 +1077,22 @@ of the old one in the permanent bookmark record."
              (bookmark-show-annotation bookmark)))))
 
 
+(defun bookmark-file-or-variation-thereof (file)
+  "Return FILE (a string) if it exists in any reasonable variation, else nil.
+Reasonable variations are FILE.gz, FILE.Z, FILE.info, FILE.info.gz, etc."
+  (cond 
+   ((file-exists-p file)                       file)
+   ((file-exists-p (concat file ".Z"))         (concat file ".Z"))
+   ((file-exists-p (concat file ".gz"))        (concat file ".gz"))
+   ((file-exists-p (concat file ".z"))         (concat file ".z"))
+   ((file-exists-p (concat file ".info"))      (concat file ".info"))
+   ((file-exists-p (concat file ".info.gz"))   (concat file ".info.gz"))
+   ((file-exists-p (concat file ".info.Z"))    (concat file ".info.Z"))
+   ((file-exists-p (concat file ".info.z"))    (concat file ".info.z"))
+   ((vc-backend file)                          file) ; maybe VC has it?
+   (t                                          nil)))
+
+
 (defun bookmark-jump-noselect (str)
   ;; a leetle helper for bookmark-jump :-)
   ;; returns (BUFFER . POINT)
@@ -1094,47 +1104,33 @@ of the old one in the permanent bookmark record."
          (info-node              (bookmark-get-info-node str))
          (orig-file              file)
          )
-    (if (or
-         (file-exists-p file)
-         ;; else try some common compression extensions
-         ;; and Emacs better handle it right!
-         ;; Sigh: I think it may *not* be handled at the moment.  What
-         ;; to do about this?
-         (setq file
-               (or
-                (let ((altname (concat file ".Z")))
-                  (and (file-exists-p altname)
-                       altname))
-                (let ((altname (concat file ".gz")))
-                  (and (file-exists-p altname)
-                       altname))
-                (let ((altname (concat file ".z")))
-                  (and (file-exists-p altname)
-                       altname)))))
+    (if (setq file (bookmark-file-or-variation-thereof file))
         (save-excursion
-          (if info-node
-              ;; Info nodes must be visited with care.
-              (progn
-                (require 'info)
-                (Info-find-node file info-node))
-            ;; Else no Info.  Can do an ordinary find-file:
-            (set-buffer (find-file-noselect file))
-            (goto-char place))
-
-          ;; Go searching forward first.  Then, if forward-str exists and
-          ;; was found in the file, we can search backward for behind-str.
-          ;; Rationale is that if text was inserted between the two in the
-          ;; file, it's better to be put before it so you can read it,
-          ;; rather than after and remain perhaps unaware of the changes.
-          (if forward-str
-              (if (search-forward forward-str (point-max) t)
-                  (goto-char (match-beginning 0))))
-          (if behind-str
-              (if (search-backward behind-str (point-min) t)
-                  (goto-char (match-end 0))))
-          ;; added by db
-          (setq bookmark-current-bookmark str)
-          (cons (current-buffer) (point)))
+          (save-window-excursion
+            (if info-node
+                ;; Info nodes must be visited with care.
+                (progn
+                  (require 'info)
+                  (Info-find-node file info-node))
+              ;; Else no Info.  Can do an ordinary find-file:
+              (set-buffer (find-file-noselect file))
+              (goto-char place))
+
+            ;; Go searching forward first.  Then, if forward-str exists and
+            ;; was found in the file, we can search backward for behind-str.
+            ;; Rationale is that if text was inserted between the two in the
+            ;; file, it's better to be put before it so you can read it,
+            ;; rather than after and remain perhaps unaware of the changes.
+            (if forward-str
+                (if (search-forward forward-str (point-max) t)
+                    (goto-char (match-beginning 0))))
+            (if behind-str
+                (if (search-backward behind-str (point-min) t)
+                    (goto-char (match-end 0))))
+            ;; added by db
+            (setq bookmark-current-bookmark str)
+            (cons (current-buffer) (point))))
+
       ;; Else unable to find the marked file, so ask if user wants to
       ;; relocate the bookmark, else remind them to consider deletion.
       (ding)
@@ -1179,7 +1175,7 @@ minibuffer history list `bookmark-history'."
   (let ((start (point)))
     (prog1
        (insert (bookmark-location bookmark)) ; *Return this line*
-      (if window-system
+      (if (and (display-color-p) (display-mouse-p))
          (put-text-property start 
                             (save-excursion (re-search-backward
                                              "[^ \t]")
@@ -1482,7 +1478,7 @@ method buffers use to resolve name collisions."
     nil
   (setq bookmark-bmenu-mode-map (make-keymap))
   (suppress-keymap bookmark-bmenu-mode-map t)
-  (define-key bookmark-bmenu-mode-map "q" 'bookmark-bmenu-quit)
+  (define-key bookmark-bmenu-mode-map "q" 'quit-window)
   (define-key bookmark-bmenu-mode-map "v" 'bookmark-bmenu-select)
   (define-key bookmark-bmenu-mode-map "w" 'bookmark-bmenu-locate)
   (define-key bookmark-bmenu-mode-map "2" 'bookmark-bmenu-2-window)
@@ -1490,6 +1486,7 @@ method buffers use to resolve name collisions."
   (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 "\C-m" '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)
@@ -1564,7 +1561,7 @@ deletion, or > if it is flagged for displaying."
            (insert "  "))
         (let ((start (point)))
           (insert (bookmark-name-from-full-record full-record))
-          (if window-system
+          (if (and (display-color-p) (display-mouse-p))
               (put-text-property start 
                                  (save-excursion (re-search-backward
                                                   "[^ \t]")
@@ -1660,7 +1657,7 @@ Optional argument SHOW means show them unconditionally."
              (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
+               (if (and (display-color-p) (display-mouse-p))
                    (remove-text-properties start (point)
                                            '(mouse-face))))
              (delete-region (point) (progn (end-of-line) (point)))
@@ -1691,7 +1688,7 @@ Optional argument SHOW means show them unconditionally."
                 (bookmark-kill-line)
                (let ((start (point)))
                  (insert (car bookmark-bmenu-hidden-bookmarks))
-                 (if window-system
+                 (if (and (display-color-p) (display-mouse-p))
                      (put-text-property start 
                                         (save-excursion (re-search-backward
                                                          "[^ \t]")
@@ -1896,7 +1893,10 @@ With a prefix arg, prompts for a file to save them in."
   "Make the other window select this line's bookmark.
 The current window remains selected."
   (interactive)
-  (let ((bookmark (bookmark-bmenu-bookmark)))
+  (let ((bookmark (bookmark-bmenu-bookmark))
+        (pop-up-windows t)
+        same-window-buffer-names 
+        same-window-regexps)
     (if (bookmark-bmenu-check-position)
        (let* ((pair (bookmark-jump-noselect bookmark))
                (buff (car pair))
@@ -1942,14 +1942,6 @@ The current window remains selected."
        (bookmark-edit-annotation bookmark))))
 
 
-(defun bookmark-bmenu-quit ()
-  "Quit the bookmark menu."
-  (interactive)
-  (let ((buffer (current-buffer)))
-    (switch-to-buffer (other-buffer))
-    (bury-buffer buffer)))
-
-
 (defun bookmark-bmenu-unmark (&optional backup)
   "Cancel all requested operations on bookmark on this line and move down.
 Optional BACKUP means move up."