]> code.delx.au - gnu-emacs/blobdiff - lisp/ffap.el
(normal-splash-screen, fancy-splash-screens-1): Add a reference to the Lisp
[gnu-emacs] / lisp / ffap.el
index ab9d223256f12def5efdd45d563dcde0d21f1656..5ff63bfdec2aff819213f62ec4b138d8b0b73c6d 100644 (file)
@@ -1,6 +1,7 @@
 ;;; ffap.el --- find file (or url) at point
 
-;; Copyright (C) 1995, 96, 97, 2000, 2004  Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 2000, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Michelangelo Grigni <mic@mathcs.emory.edu>
 ;; Maintainer: Rajesh Vaidheeswarran  <rv@gnu.org>
@@ -22,8 +23,8 @@
 
 ;; 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, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 \f
 ;;; Commentary:
@@ -217,10 +218,13 @@ Sensible values are nil, \"news\", or \"mailto\"."
   "*A regexp matching filename wildcard characters, or nil.
 
 If `find-file-at-point' gets a filename matching this pattern,
-it passes it on to `find-file' with non-nil WILDCARDS argument,
-which expands wildcards and visits multiple files.  To visit
-a file whose name contains wildcard characters you can suppress
-wildcard expansion by setting `find-file-wildcards'.
+and `ffap-pass-wildcards-to-dired' is nil, it passes it on to
+`find-file' with non-nil WILDCARDS argument, which expands
+wildcards and visits multiple files.  To visit a file whose name
+contains wildcard characters you can suppress wildcard expansion
+by setting `find-file-wildcards'.  If `find-file-at-point' gets a
+filename matching this pattern and `ffap-pass-wildcards-to-dired'
+is non-nil, it passes it on to `dired'.
 
 If `dired-at-point' gets a filename matching this pattern,
 it passes it on to `dired'."
@@ -230,6 +234,11 @@ it passes it on to `dired'."
                 )
   :group 'ffap)
 
+(defcustom ffap-pass-wildcards-to-dired nil
+  "*If non-nil, pass filenames matching `ffap-dired-wildcards' to dired."
+  :type 'boolean
+  :group 'ffap)
+
 (defcustom ffap-newfile-prompt nil
   ;; Suggestion from RHOGEE, 11 Jul 1994.  Disabled, I think this is
   ;; better handled by `find-file-not-found-hooks'.
@@ -278,9 +287,9 @@ For a fancy alternative, get `ffap-url.el'."
 \f
 ;;; Compatibility:
 ;;
-;; This version of ffap supports Emacs 20 only, see the ftp site
-;; for a more general version.  The following functions are necessary
-;; "leftovers" from the more general version.
+;; This version of ffap supports only the Emacs it is distributed in.
+;; See the ftp site for a more general version.  The following
+;; functions are necessary "leftovers" from the more general version.
 
 (defun ffap-mouse-event nil            ; current mouse event, or nil
   (and (listp last-nonmenu-event) last-nonmenu-event))
@@ -721,7 +730,7 @@ kpathsea, a library used by some versions of TeX."
          path)))
 
 (defun ffap-locate-file (file &optional nosuffix path dir-ok)
-  ;; The Emacs 20 version of locate-library could almost replace this,
+  ;; The current version of locate-library could almost replace this,
   ;; except it does not let us override the suffix list.  The
   ;; compression-suffixes search moved to ffap-file-exists-string.
   "A generic path-searching function, mimics `load' by default.
@@ -962,7 +971,7 @@ If t, `ffap-tex-init' will initialize this when needed.")
     ;; * no commas (good for latex)
     (file "--:$+<>@-Z_a-z~*?" "<@" "@>;.,!:")
     ;; An url, or maybe a email/news message-id:
-    (url "--:=&?$+@-Z_a-z~#,%;" "^A-Za-z0-9" ":;.,!?")
+    (url "--:=&?$+@-Z_a-z~#,%;*" "^A-Za-z0-9" ":;.,!?")
     ;; Find a string that does *not* contain a colon:
     (nocolon "--9$+<>@-Z_a-z~" "<@" "@>;.,!?")
     ;; A machine:
@@ -1246,7 +1255,8 @@ which may actually result in an url rather than a filename."
                    (abbreviate-file-name (expand-file-name guess))
                    ))
          (setq dir (file-name-directory guess))))
-    (let ((minibuffer-completing-file-name t))
+    (let ((minibuffer-completing-file-name t)
+         (completion-ignore-case read-file-name-completion-ignore-case))
       (setq guess
            (completing-read
             prompt
@@ -1312,6 +1322,12 @@ which may actually result in an url rather than a filename."
 (defvar ffap-highlight t
   "If non-nil, ffap highlights the current buffer substring.")
 
+(defface ffap
+  '((t :inherit highlight))
+  "Face used to highlight the current buffer substring."
+  :group 'ffap
+  :version "22.1")
+
 (defvar ffap-highlight-overlay nil
   "Overlay used by `ffap-highlight'.")
 
@@ -1335,8 +1351,7 @@ Uses the face `ffap' if it is defined, or else `highlight'."
    (t
     (setq ffap-highlight-overlay
          (apply 'make-overlay ffap-string-at-point-region))
-    (overlay-put ffap-highlight-overlay 'face
-                     (if (facep 'ffap) 'ffap 'highlight)))))
+    (overlay-put ffap-highlight-overlay 'face 'ffap))))
 
 \f
 ;;; Main Entrance (`find-file-at-point' == `ffap'):
@@ -1371,9 +1386,7 @@ If `ffap-url-regexp' is not nil, the FILENAME may also be an URL.
 With a prefix, this command behaves exactly like `ffap-file-finder'.
 If `ffap-require-prefix' is set, the prefix meaning is reversed.
 See also the variables `ffap-dired-wildcards', `ffap-newfile-prompt',
-and the functions `ffap-file-at-point' and `ffap-url-at-point'.
-
-See <ftp://ftp.mathcs.emory.edu/pub/mic/emacs/> for latest version."
+and the functions `ffap-file-at-point' and `ffap-url-at-point'."
   (interactive)
   (if (and (interactive-p)
           (if ffap-require-prefix (not current-prefix-arg)
@@ -1386,6 +1399,10 @@ See <ftp://ftp.mathcs.emory.edu/pub/mic/emacs/> for latest version."
      ((ffap-url-p filename)
       (let (current-prefix-arg)                ; w3 2.3.25 bug, reported by KPC
        (funcall ffap-url-fetcher filename)))
+     ((and ffap-pass-wildcards-to-dired
+          ffap-dired-wildcards
+          (string-match ffap-dired-wildcards filename))
+      (funcall ffap-directory-finder filename))
      ((and ffap-dired-wildcards
           (string-match ffap-dired-wildcards filename)
           find-file-wildcards
@@ -1508,7 +1525,9 @@ Applies `ffap-menu-text-plist' text properties at all matches."
   (let ((ffap-next-regexp (or ffap-menu-regexp ffap-next-regexp))
        (range (- (point-max) (point-min)))
        (mod (buffer-modified-p))       ; was buffer modified?
-       buffer-read-only                ; to set text-properties
+       ;; inhibit-read-only works on read-only text properties
+       ;; as well as read-only buffers.
+       (inhibit-read-only t)           ; to set text-properties
        item
        ;; Avoid repeated searches of the *mode-alist:
        (major-mode (if (assq major-mode ffap-string-at-point-mode-alist)
@@ -1699,6 +1718,9 @@ Only intended for interactive use."
   (local-set-key "\M-l" 'ffap-gnus-next)
   (local-set-key "\M-m" 'ffap-gnus-menu))
 
+(defvar gnus-summary-buffer)
+(defvar gnus-article-buffer)
+
 (defun ffap-gnus-wrapper (form)                ; used by both commands below
   (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
        (gnus-summary-select-article))  ; get article of current line