;;; ffap.el --- find file (or url) at point
-;;
-;; Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
-;;
+
+;; Copyright (C) 1995, 1996, 1997, 2000, 2002, 2003, 2004,
+;; 2005 Free Software Foundation, Inc.
+
;; Author: Michelangelo Grigni <mic@mathcs.emory.edu>
+;; Maintainer: Rajesh Vaidheeswarran <rv@gnu.org>
;; Created: 29 Mar 1993
-;; Keywords: files, hypermedia, matching, mouse
-;; X-URL: ftp://ftp.mathcs.emory.edu:/pub/mic/emacs/
+;; Keywords: files, hypermedia, matching, mouse, convenience
+;; X-URL: ftp://ftp.mathcs.emory.edu/pub/mic/emacs/
;; This file is part of GNU Emacs.
;; 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:
;; README's, MANIFEST's, and so on. Submit bugs or suggestions with
;; M-x ffap-bug.
;;
-;; For the default installation, byte-compile ffap.el somewhere in
-;; your `load-path' and add these two lines to your .emacs file:
+;; For the default installation, add this line to your .emacs file:
;;
-;; (require 'ffap) ; load the package
;; (ffap-bindings) ; do default key bindings
;;
;; ffap-bindings makes the following global key bindings:
;;
-;; C-x C-f find-file-at-point (abbreviated as ffap)
-;; C-x 4 f ffap-other-window
-;; C-x 5 f ffap-other-frame
+;; C-x C-f find-file-at-point (abbreviated as ffap)
+;; C-x C-r ffap-read-only
+;; C-x C-v ffap-alternate-file
+;;
+;; C-x d dired-at-point
+;; C-x C-d ffap-list-directory
+;;
+;; C-x 4 f ffap-other-window
+;; C-x 4 r ffap-read-only-other-window
+;; C-x 4 d ffap-dired-other-window
+;;
+;; C-x 5 f ffap-other-frame
+;; C-x 5 r ffap-read-only-other-frame
+;; C-x 5 d ffap-dired-other-frame
+;;
;; S-mouse-3 ffap-at-mouse
;; C-S-mouse-3 ffap-menu
;;
;; (setq ffap-alist nil) ; faster, dumber prompting
;; (setq ffap-machine-p-known 'accept) ; no pinging
;; (setq ffap-url-regexp nil) ; disable URL features in ffap
+;; (setq ffap-shell-prompt-regexp nil) ; disable shell prompt stripping
;;
-;; ffap uses w3 (if found) or else browse-url to fetch URL's. For
-;; a hairier `ffap-url-fetcher', try ffap-url.el (same ftp site).
+;; ffap uses `browse-url' (if found, else `w3-fetch') to fetch URL's.
+;; For a hairier `ffap-url-fetcher', try ffap-url.el (same ftp site).
;; Also, you can add `ffap-menu-rescan' to various hooks to fontify
;; the file and URL references within a buffer.
\f
;;; Todo list:
;; * use kpsewhich
-;; * let "/path/file#key" jump to key (tag or regexp) in /path/file
+;; * let "/dir/file#key" jump to key (tag or regexp) in /dir/file
;; * find file of symbol if TAGS is loaded (like above)
;; * break long menus into multiple panes (like imenu?)
;; * notice node in "(dired)Virtual Dired" (quotes, parentheses, whitespace)
-;; * notice "machine.dom blah blah blah path/file" (how?)
+;; * notice "machine.dom blah blah blah dir/file" (how?)
;; * as w3 becomes standard, rewrite to rely more on its functions
;; * regexp options for ffap-string-at-point, like font-lock (MCOOK)
;; * v19: could replace `ffap-locate-file' with a quieter `locate-library'
(provide 'ffap)
-;; The code is organized in pages, separated by formfeed characters.
-;; See the next two pages for standard customization ideas.
+;; Please do not delete this variable, it is checked in bug reports.
+(defconst ffap-version "1.9-fsf <97/06/25 13:21:41 mic>"
+ "The version of ffap: \"Major.Minor-Build <Timestamp>\"")
-\f
-;;; User Variables:
(defgroup ffap nil
"Find file or URL at point."
- :group 'matching)
+ :link '(url-link :tag "URL" "ftp://ftp.mathcs.emory.edu/pub/mic/emacs/")
+ :group 'matching
+ :group 'convenience)
+
+;; The code is organized in pages, separated by formfeed characters.
+;; See the next two pages for standard customization ideas.
+\f
+;;; User Variables:
(defun ffap-soft-value (name &optional default)
"Return value of symbol with NAME, if it is interned.
(let ((sym (intern-soft name)))
(if (and sym (boundp sym)) (symbol-value sym) default)))
+(defcustom ffap-shell-prompt-regexp
+ ;; This used to test for some shell prompts that don't have a space
+ ;; after them. The common root shell prompt (#) is not listed since it
+ ;; also doubles up as a valid URL character.
+ "[$%><]*"
+ "Paths matching this regexp are stripped off the shell prompt
+If nil, ffap doesn't do shell prompt stripping."
+ :type '(choice (const :tag "Disable" nil)
+ (const :tag "Standard" "[$%><]*")
+ regexp)
+ :group 'ffap)
+
(defcustom ffap-ftp-regexp
;; This used to test for ange-ftp or efs being present, but it should be
;; harmless (and simpler) to give it this value unconditionally.
"\\`/[^/:]+:"
- "*Paths matching this regexp are treated as remote ftp paths by ffap.
-If nil, ffap neither recognizes nor generates such paths."
+ "*File names matching this regexp are treated as remote ffap.
+If nil, ffap neither recognizes nor generates such names."
:type '(choice (const :tag "Disable" nil)
(const :tag "Standard" "\\`/[^/:]+:")
regexp)
:group 'ffap)
(defcustom ffap-url-unwrap-local t
- "*If non-nil, convert \"file:\" url to local path before prompting."
+ "*If non-nil, convert `file:' URL to local file name before prompting."
:type 'boolean
:group 'ffap)
(defcustom ffap-url-unwrap-remote t
- "*If non-nil, convert \"ftp:\" url to remote path before prompting.
+ "*If non-nil, convert `ftp:' URL to remote file name before prompting.
This is ignored if `ffap-ftp-regexp' is nil."
:type 'boolean
:group 'ffap)
(defcustom ffap-ftp-default-user "anonymous"
- "*User name in ftp paths generated by `ffap-host-to-path'.
+ "*User name in ftp file names generated by `ffap-host-to-path'.
Note this name may be omitted if it equals the default
\(either `efs-default-user' or `ange-ftp-default-user'\)."
:type 'string
;; Remote file access built into file system? HP rfa or Andrew afs:
"\\`/\\(afs\\|net\\)/."
;; afs only: (and (file-exists-p "/afs") "\\`/afs/.")
- "*Matching paths are treated as remote. nil to disable."
+ "*Matching file names are treated as remote. Use nil to disable."
:type 'regexp
:group 'ffap)
"\\`\\("
"news\\(post\\)?:\\|mailto:\\|file:" ; no host ok
"\\|"
- "\\(ftp\\|http\\|telnet\\|gopher\\|www\\|wais\\)://" ; needs host
+ "\\(ftp\\|https?\\|telnet\\|gopher\\|www\\|wais\\)://" ; needs host
"\\)." ; require one more character
)
"Regexp matching URL's. nil to disable URL features in ffap.")
;; through this section for features that you like, put an appropriate
;; enabler in your .emacs file.
-(defcustom ffap-dired-wildcards nil
- ;; Suggestion from RHOGEE, 07 Jul 1994. Disabled, dired is still
- ;; available by "C-x C-d <pattern>", and valid filenames may
- ;; sometimes contain wildcard characters.
+(defcustom ffap-dired-wildcards "[*?][^/]*\\'"
"*A regexp matching filename wildcard characters, or nil.
+
If `find-file-at-point' gets a filename matching this pattern,
-it passes it on to `dired' instead of `find-file'."
+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'."
:type '(choice (const :tag "Disable" nil)
(const :tag "Enable" "[*?][^/]*\\'")
;; regexp -- probably not useful
)
: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'.
:group 'ffap)
(put 'ffap-file-finder 'risky-local-variable t)
+(defcustom ffap-directory-finder 'dired
+ "*The command called by `dired-at-point' to find a directory."
+ :type 'function
+ :group 'ffap)
+(put 'ffap-directory-finder 'risky-local-variable t)
+
(defcustom ffap-url-fetcher
- (cond ((fboundp 'w3-fetch) 'w3-fetch)
- ((fboundp 'browse-url-netscape) 'browse-url-netscape)
- (t 'w3-fetch))
+ (if (fboundp 'browse-url)
+ 'browse-url ; rely on browse-url-browser-function
+ 'w3-fetch)
;; Remote control references:
;; http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/remote-control.html
;; http://home.netscape.com/newsref/std/x-remote.html
"*A function of one argument, called by ffap to fetch an URL.
-Reasonable choices are `w3-fetch' or `browse-url-netscape'.
-For a fancier alternative, get ffap-url.el."
+Reasonable choices are `w3-fetch' or a `browse-url-*' function.
+For a fancy alternative, get `ffap-url.el'."
:type '(choice (const w3-fetch)
+ (const browse-url) ; in recent versions of browse-url
(const browse-url-netscape)
(const browse-url-mosaic)
function)
(put 'ffap-url-fetcher 'risky-local-variable t)
\f
-;;; Compatibility (XEmacs code suppressed in this version):
-
-(progn
- (defalias 'ffap-make-overlay 'make-overlay)
- (defalias 'ffap-delete-overlay 'delete-overlay) ; reusable
- (defalias 'ffap-move-overlay 'move-overlay)
- (defalias 'ffap-overlay-put 'overlay-put) ; 'face
- (defalias 'ffap-find-face 'internal-find-face)
- (defun ffap-mouse-event nil ; current mouse event, or nil
- (and (listp last-nonmenu-event) last-nonmenu-event))
- (defun ffap-event-buffer (event) (window-buffer (car (event-start event))))
- )
+;;; 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.
+
+(defun ffap-mouse-event nil ; current mouse event, or nil
+ (and (listp last-nonmenu-event) last-nonmenu-event))
+(defun ffap-event-buffer (event)
+ (window-buffer (car (event-start event))))
\f
;;; Find Next Thing in buffer (`ffap-next'):
;; particular, if `Pinging...' is broken or takes too long on your
;; machine, try setting these all to accept or reject.
(defcustom ffap-machine-p-local 'reject ; this happens often
- "*A symbol, one of: `ping', `accept', `reject'.
-What `ffap-machine-p' does with hostnames that have no domain."
+ "*What `ffap-machine-p' does with hostnames that have no domain.
+Value should be a symbol, one of `ping', `accept', and `reject'."
:type '(choice (const ping)
(const accept)
(const reject))
:group 'ffap)
-(defcustom ffap-machine-p-known 'ping ; 'accept for speed
- "*A symbol, one of: ping, accept, reject.
-What `ffap-machine-p' does with hostnames that have a known domain
-\(see mail-extr.el for the known domains\)."
+(defcustom ffap-machine-p-known 'ping ; `accept' for higher speed
+ "*What `ffap-machine-p' does with hostnames that have a known domain.
+Value should be a symbol, one of `ping', `accept', and `reject'.
+See `mail-extr.el' for the known domains."
:type '(choice (const ping)
(const accept)
(const reject))
:group 'ffap)
(defcustom ffap-machine-p-unknown 'reject
- "*A symbol, one of: ping, accept, reject.
-What `ffap-machine-p' does with hostnames that have an unknown domain
-\(see mail-extr.el for the known domains\)."
+ "*What `ffap-machine-p' does with hostnames that have an unknown domain.
+Value should be a symbol, one of `ping', `accept', and `reject'.
+See `mail-extr.el' for the known domains."
:type '(choice (const ping)
(const accept)
(const reject))
(defun ffap-what-domain (domain)
;; Like what-domain in mail-extr.el, returns string or nil.
(require 'mail-extr)
- (get (intern-soft (downcase domain) mail-extr-all-top-level-domains)
- 'domain-name))
+ (let ((ob (or (ffap-soft-value "mail-extr-all-top-level-domains")
+ (ffap-soft-value "all-top-level-domains")))) ; XEmacs
+ (and ob (get (intern-soft (downcase domain) ob) 'domain-name))))
(defun ffap-machine-p (host &optional service quiet strategy)
"Decide whether HOST is the name of a real, reachable machine.
(cond
((eq strategy 'accept) 'accept)
((eq strategy 'reject) nil)
+ ((not (fboundp 'open-network-stream)) nil)
;; assume (eq strategy 'ping)
(t
(or quiet
\f
;;; Possibly Remote Resources:
-(defun ffap-replace-path-component (fullname name)
+(defun ffap-replace-file-component (fullname name)
"In remote FULLNAME, replace path with NAME. May return nil."
;; Use ange-ftp or efs if loaded, but do not load them otherwise.
(let (found)
ange-ftp-replace-name-component
))
(and found
- (fset 'ffap-replace-path-component found)
+ (fset 'ffap-replace-file-component found)
(funcall found fullname name))))
-;; (ffap-replace-path-component "/who@foo.com:/whatever" "/new")
-
-(defun ffap-file-exists-string (file)
- ;; With certain packages (ange-ftp, jka-compr?) file-exists-p
- ;; sometimes returns a nicer string than it is given. Otherwise, it
- ;; just returns nil or t.
- "Return FILE \(maybe modified\) if it exists, else nil."
- (and file ; quietly reject nil
- (let ((exists (file-exists-p file)))
- (and exists (if (stringp exists) exists file)))))
-
+;; (ffap-replace-file-component "/who@foo.com:/whatever" "/new")
+
+(defun ffap-file-suffix (file)
+ "Return trailing `.foo' suffix of FILE, or nil if none."
+ (let ((pos (string-match "\\.[^./]*\\'" file)))
+ (and pos (substring file pos nil))))
+
+(defvar ffap-compression-suffixes '(".gz" ".Z") ; .z is mostly dead
+ "List of suffixes tried by `ffap-file-exists-string'.")
+
+(defun ffap-file-exists-string (file &optional nomodify)
+ ;; Early jka-compr versions modified file-exists-p to return the
+ ;; filename, maybe modified by adding a suffix like ".gz". That
+ ;; broke the interface of file-exists-p, so it was later dropped.
+ ;; Here we document and simulate the old behavior.
+ "Return FILE (maybe modified) if the file exists, else nil.
+When using jka-compr (a.k.a. `auto-compression-mode'), the returned
+name may have a suffix added from `ffap-compression-suffixes'.
+The optional NOMODIFY argument suppresses the extra search."
+ (cond
+ ((not file) nil) ; quietly reject nil
+ ((file-exists-p file) file) ; try unmodified first
+ ;; three reasons to suppress search:
+ (nomodify nil)
+ ((not (rassq 'jka-compr-handler file-name-handler-alist)) nil)
+ ((member (ffap-file-suffix file) ffap-compression-suffixes) nil)
+ (t ; ok, do the search
+ (let ((list ffap-compression-suffixes) try ret)
+ (while list
+ (if (file-exists-p (setq try (concat file (car list))))
+ (setq ret try list nil)
+ (setq list (cdr list))))
+ ret))))
(defun ffap-file-remote-p (filename)
- "If FILENAME looks remote, return it \(maybe slightly improved\)."
+ "If FILENAME looks remote, return it (maybe slightly improved)."
;; (ffap-file-remote-p "/user@foo.bar.com:/pub")
- ;; (ffap-file-remote-p "/cssun.mathcs.emory.edu://path")
+ ;; (ffap-file-remote-p "/cssun.mathcs.emory.edu://dir")
;; (ffap-file-remote-p "/ffap.el:80")
(or (and ffap-ftp-regexp
(string-match ffap-ftp-regexp filename)
- ;; Convert "/host.com://path" to "/host:/path", to handle a dieing
- ;; practice of advertising ftp paths as "host.dom://path".
+ ;; Convert "/host.com://dir" to "/host:/dir", to handle a dieing
+ ;; practice of advertising ftp files as "host.dom://filename".
(if (string-match "//" filename)
;; (replace-match "/" nil nil filename)
(concat (substring filename 0 (1+ (match-beginning 0)))
(let ((mach (ffap-string-at-point 'machine)))
(and (ffap-machine-p mach) mach)))
-(defsubst ffap-host-to-path (host)
+(defsubst ffap-host-to-filename (host)
"Convert HOST to something like \"/USER@HOST:\" or \"/HOST:\".
Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"."
(if (equal host "localhost")
(concat "/" user (and user "@") host ":"))))
(defun ffap-fixup-machine (mach)
- ;; Convert a hostname into an url, an ftp path, or nil.
+ ;; Convert a hostname into an url, an ftp file name, or nil.
(cond
((not (and ffap-url-regexp (stringp mach))) nil)
;; gopher.well.com
((and (string-match "\\`w\\(ww\\|eb\\)[-.]" mach))
(concat "http://" mach "/"))
;; More cases? Maybe "telnet:" for archie?
- (ffap-ftp-regexp (ffap-host-to-path mach))
+ (ffap-ftp-regexp (ffap-host-to-filename mach))
))
(defvar ffap-newsgroup-regexp "^[a-z]+\\.[-+a-z_0-9.]+$"
(progn
;; errs: htb symbol may be unbound, or not a hash-table.
;; gnus-gethash is just a macro for intern-soft.
- (and (intern-soft string (symbol-value htb))
+ (and (symbol-value htb)
+ (intern-soft string (symbol-value htb))
(setq ret string htbs nil))
;; If we made it this far, gnus is running, so ignore "heads":
(setq heads nil))
"Return URL as a remote file, or nil. Ignores `ffap-url-regexp'."
(and (string-match "\\`\\(ftp\\|file\\)://\\([^:/]+\\):?\\(/.*\\)" url)
(concat
- (ffap-host-to-path (substring url (match-beginning 2) (match-end 2)))
+ (ffap-host-to-filename (substring url (match-beginning 2) (match-end 2)))
(substring url (match-beginning 3) (match-end 3)))))
;; Test: (ffap-url-unwrap-remote "ftp://foo.com/bar.boz")
((and ffap-url-unwrap-local (ffap-url-unwrap-local url)))
((and ffap-url-unwrap-remote ffap-ftp-regexp
(ffap-url-unwrap-remote url)))
- ;; This might autoload the url package, oh well:
- (t (let ((normal (and (fboundp 'url-normalize-url)
- (url-normalize-url url))))
- ;; In case url-normalize-url is confused:
- (or (and normal (not (zerop (length normal))) normal)
- url)))))
+ ((fboundp 'url-normalize-url) ; may autoload url (part of w3)
+ (url-normalize-url url))
+ (url)))
\f
-;;; Path Handling:
+;;; File Name Handling:
;;
;; The upcoming ffap-alist actions need various utilities to prepare
-;; and search paths of directories. Too many features here.
+;; and search directories. Too many features here.
;; (defun ffap-last (l) (while (cdr l) (setq l (cdr l))) l)
;; (defun ffap-splice (func inlist)
(list dir))))
path)))
-(defvar ffap-locate-jka-suffixes t
- "List of compression suffixes tried by `ffap-locate-file'.
-
-If not a list, it will be initialized by `ffap-locate-file', depending
-on whether you use jka-compr (a.k.a. `auto-compression-mode').
-Typical values are nil or '(\".gz\" \".Z\").") ; .z is dead
-
-(defun ffap-locate-file (file &optional nosuffix path)
- ;; Note the Emacs 20 version of locate-library could almost
- ;; replace this function, except that it does not let us overrride
- ;; the list of suffixes.
+(defun ffap-locate-file (file &optional nosuffix path dir-ok)
+ ;; The Emacs 20 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.
Returns path to file that \(load FILE\) would load, or nil.
Optional NOSUFFIX, if nil or t, is like the fourth argument
for load: whether to try the suffixes (\".elc\" \".el\" \"\").
If a nonempty list, it is a list of suffixes to try instead.
-Optional PATH is a list of directories instead of `load-path'."
+Optional PATH is a list of directories instead of `load-path'.
+Optional DIR-OK means that returning a directory is allowed,
+DIR-OK is already implicit if FILE looks like a directory.
+
+This uses ffap-file-exists-string, which may try adding suffixes from
+`ffap-compression-suffixes'."
(or path (setq path load-path))
+ (or dir-ok (setq dir-ok (equal "" (file-name-nondirectory file))))
(if (file-name-absolute-p file)
(setq path (list (file-name-directory file))
file (file-name-nondirectory file)))
(cond
((consp nosuffix) nosuffix)
(nosuffix '(""))
- (t '(".elc" ".el" "")))))
- ;; Note we no longer check for old versions of jka-compr, that
- ;; would aggressively try to convert any foo to foo.gz.
- (or (listp ffap-locate-jka-suffixes)
- (setq ffap-locate-jka-suffixes
- (and (rassq 'jka-compr-handler file-name-handler-alist)
- '(".gz" ".Z")))) ; ".z" is dead, "" is implicit
- (if ffap-locate-jka-suffixes ;
- (setq suffixes-to-try
- (apply 'nconc
- (mapcar
- (function
- (lambda (suf)
- (cons suf
- (mapcar
- (function (lambda (x) (concat suf x)))
- ffap-locate-jka-suffixes))))
- suffixes-to-try))))
- (let (found suffixes)
- (while (and path (not found))
- (setq suffixes suffixes-to-try)
- (while (and suffixes (not found))
- (let ((try (expand-file-name
- (concat file (car suffixes))
- (car path))))
- (if (and (file-exists-p try) (not (file-directory-p try)))
- (setq found try)))
- (setq suffixes (cdr suffixes)))
- (setq path (cdr path)))
- found)))
+ (t '(".elc" ".el" ""))))
+ suffixes try found)
+ (while path
+ (setq suffixes suffixes-to-try)
+ (while suffixes
+ (setq try (ffap-file-exists-string
+ (expand-file-name
+ (concat file (car suffixes)) (car path))))
+ (if (and try (or dir-ok (not (file-directory-p try))))
+ (setq found try suffixes nil path nil)
+ (setq suffixes (cdr suffixes))))
+ (setq path (cdr path)))
+ found))
\f
;;; Action List (`ffap-alist'):
("\\`[-a-z]+\\'" . ffap-info-3) ; (emacs)Top [only in the parentheses]
("\\.elc?\\'" . ffap-el) ; simple.el, simple.elc
(emacs-lisp-mode . ffap-el-mode) ; rmail, gnus, simple, custom
+ ;; (lisp-interaction-mode . ffap-el-mode) ; maybe
(finder-mode . ffap-el-mode) ; type {C-h p} and try it
(help-mode . ffap-el-mode) ; maybe useful
(c++-mode . ffap-c-mode) ; search ffap-c-path
(put 'ffap-alist 'risky-local-variable t)
+;; Example `ffap-alist' modifications:
+;;
+;; (setq ffap-alist ; remove a feature in `ffap-alist'
+;; (delete (assoc 'c-mode ffap-alist) ffap-alist))
+;;
+;; (setq ffap-alist ; add something to `ffap-alist'
+;; (cons
+;; (cons "^YSN[0-9]+$"
+;; (defun ffap-ysn (name)
+;; (concat
+;; "http://www.physics.uiuc.edu/"
+;; "ysn/httpd/htdocs/ysnarchive/issuefiles/"
+;; (substring name 3) ".html")))
+;; ffap-alist))
+
\f
;;; Action Definitions:
;;
(member (ffap-string-around) '("||" "|\n")))
(concat
;; lispdir.el may not be loaded yet:
- (ffap-host-to-path
+ (ffap-host-to-filename
(ffap-soft-value "elisp-archive-host"
"archive.cis.ohio-state.edu"))
(file-name-as-directory
(substring name 2))))
(defvar ffap-rfc-path
- (concat (ffap-host-to-path "ds.internic.net") "/rfc/rfc%s.txt"))
+ (concat (ffap-host-to-filename "ds.internic.net") "/rfc/rfc%s.txt"))
(defun ffap-rfc (name)
(format ffap-rfc-path
;; Slightly controversial decisions:
;; * strip trailing "@" and ":"
;; * no commas (good for latex)
- (file "--:$+<>@-Z_a-z~" "<@" "@>;.,!?:")
+ (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:
(math-mode ",-:$+<>@-Z_a-z~`" "<" "@>;.,!?`:")
)
"Alist of \(MODE CHARS BEG END\), where MODE is a symbol,
-possibly a `major-mode' or some symbol internal to ffap
-\(such as 'file, 'url, 'machine, and 'nocolon\).
+possibly a major-mode name, or one of the symbol
+`file', `url', `machine', and `nocolon'.
`ffap-string-at-point' uses the data fields as follows:
1. find a maximal string of CHARS around point,
2. strip BEG chars before point from the beginning,
(defun ffap-string-at-point (&optional mode)
"Return a string of characters from around point.
-MODE (defaults to `major-mode') is a symbol used to lookup string
+MODE (defaults to value of `major-mode') is a symbol used to look up string
syntax parameters in `ffap-string-at-point-mode-alist'.
-If MODE is not found, we fall back on the symbol 'file.
+If MODE is not found, we use `file' instead of MODE.
+If the region is active, return a string from the region.
Sets `ffap-string-at-point' and `ffap-string-at-point-region'."
(let* ((args
(cdr
(assq 'file ffap-string-at-point-mode-alist))))
(pt (point))
(str
- (buffer-substring
- (save-excursion
- (skip-chars-backward (car args))
- (skip-chars-forward (nth 1 args) pt)
- (setcar ffap-string-at-point-region (point)))
- (save-excursion
- (skip-chars-forward (car args))
- (skip-chars-backward (nth 2 args) pt)
- (setcar (cdr ffap-string-at-point-region) (point))))))
+ (if (and transient-mark-mode mark-active)
+ (buffer-substring
+ (setcar ffap-string-at-point-region (region-beginning))
+ (setcar (cdr ffap-string-at-point-region) (region-end)))
+ (buffer-substring
+ (save-excursion
+ (skip-chars-backward (car args))
+ (skip-chars-forward (nth 1 args) pt)
+ (setcar ffap-string-at-point-region (point)))
+ (save-excursion
+ (skip-chars-forward (car args))
+ (skip-chars-backward (nth 2 args) pt)
+ (setcar (cdr ffap-string-at-point-region) (point)))))))
(set-text-properties 0 (length str) nil str)
(setq ffap-string-at-point str)))
;; Icky regexp avoids: default: 123: foo::bar cs:pub
;; It does match on: mic@cs: cs:/pub mathcs.emory.edu: (point at end)
"\\`\\([^:@]+@[^:@]+:\\|[^@.:]+\\.[^@:]+:\\|[^:]+:[~/]\\)\\([^:]\\|\\'\\)")
- "Strings matching this are coerced to ftp paths by ffap.
+ "Strings matching this are coerced to ftp file names by ffap.
That is, ffap just prepends \"/\". Set to nil to disable.")
(defun ffap-file-at-point nil
which may actually result in an url rather than a filename."
;; Note: this function does not need to look for url's, just
;; filenames. On the other hand, it is responsible for converting
- ;; a pseudo-url "site.com://path" to an ftp path
+ ;; a pseudo-url "site.com://dir" to an ftp file name
(let* ((case-fold-search t) ; url prefixes are case-insensitive
(data (match-data))
(string (ffap-string-at-point)) ; uses mode alist
(default-directory default-directory))
(unwind-protect
(cond
- ;; Immediate rejects (/ and // are too common in C++):
- ((member name '("" "/" "//")) nil)
- ;; Immediately test local filenames. If default-directory is
- ;; remote, you probably already have a connection.
- ((and (not abs) (ffap-file-exists-string name)))
+ ;; Immediate rejects (/ and // and /* are too common in C/C++):
+ ((member name '("" "/" "//" "/*" ".")) nil)
+ ;; Immediately test local filenames. If default-directory is
+ ;; remote, you probably already have a connection.
+ ((and (not abs) (ffap-file-exists-string name)))
+ ;; Try stripping off line numbers; good for compilation/grep output.
+ ((and (not abs) (string-match ":[0-9]" name)
+ (ffap-file-exists-string (substring name 0 (match-beginning 0)))))
+ ;; Try stripping off prominent (non-root - #) shell prompts
+ ;; if the ffap-shell-prompt-regexp is non-nil.
+ ((and ffap-shell-prompt-regexp
+ (not abs) (string-match ffap-shell-prompt-regexp name)
+ (ffap-file-exists-string (substring name (match-end 0)))))
;; Accept remote names without actual checking (too slow):
((if abs
(ffap-file-remote-p name)
- ;; Try adding a leading "/" (common omission in ftp paths):
+ ;; Try adding a leading "/" (common omission in ftp file names):
(and
ffap-ftp-sans-slash-regexp
(string-match ffap-ftp-sans-slash-regexp name)
try))
;; Alist failed? Try to guess an active remote connection
;; from buffer variables, and try once more, both as an
- ;; absolute and relative path on that remote host.
+ ;; absolute and relative file name on that remote host.
((let* (ffap-rfs-regexp ; suppress
(remote-dir
(cond
(or
(and (string-match "\\`\\(/?~?ftp\\)/" name)
(ffap-file-exists-string
- (ffap-replace-path-component
+ (ffap-replace-file-component
remote-dir (substring name (match-end 1)))))
(ffap-file-exists-string
- (ffap-replace-path-component remote-dir name))))))
+ (ffap-replace-file-component remote-dir name))))))
+ ((and ffap-dired-wildcards
+ (string-match ffap-dired-wildcards name)
+ abs
+ (ffap-file-exists-string (file-name-directory
+ (directory-file-name name)))
+ name))
+ ;; Try all parent directories by deleting the trailing directory
+ ;; name until existing directory is found or name stops changing
+ ((let ((dir name))
+ (while (and dir
+ (not (ffap-file-exists-string dir))
+ (not (equal dir (setq dir (file-name-directory
+ (directory-file-name dir)))))))
+ (ffap-file-exists-string dir)))
)
- (store-match-data data))))
-
+ (set-match-data data))))
\f
;;; Prompting (`ffap-read-file-or-url'):
;;
(or (ffap-url-p guess)
(progn
(or (ffap-file-remote-p guess)
- (setq guess (abbreviate-file-name (expand-file-name guess))))
+ (setq guess
+ (abbreviate-file-name (expand-file-name guess))
+ ))
(setq dir (file-name-directory guess))))
- (setq guess
- (completing-read
- prompt
- 'ffap-read-file-or-url-internal
- dir
- nil
- (if dir (cons guess (length dir)) guess)
- (list 'file-name-history)
- ))
+ (let ((minibuffer-completing-file-name t))
+ (setq guess
+ (completing-read
+ prompt
+ 'ffap-read-file-or-url-internal
+ dir
+ nil
+ (if dir (cons guess (length dir)) guess)
+ (list 'file-name-history)
+ (and buffer-file-name
+ (abbreviate-file-name buffer-file-name)))))
;; Do file substitution like (interactive "F"), suggested by MCOOK.
(or (ffap-url-p guess) (setq guess (substitute-in-file-name guess)))
;; Should not do it on url's, where $ is a common (VMS?) character.
(t t))))
(defun ffap-read-file-or-url-internal (string dir action)
+ (unless dir
+ (setq dir default-directory))
+ (unless string
+ (setq string default-directory))
(if (ffap-url-p string)
(ffap-read-url-internal string dir action)
(read-file-name-internal string dir action)))
;; This code assumes that you load ffap.el after complete.el.
;;
;; We must inform complete about whether our completion function
-;; will do filename style completion. For earlier versions of
-;; complete.el, this requires a defadvice. For recent versions
-;; there may be a special variable for this purpose.
+;; will do filename style completion.
(defun ffap-complete-as-file-p nil
;; Will `minibuffer-completion-table' complete the minibuffer
;; Note: t and non-nil mean somewhat different reasons.
(if (eq minibuffer-completion-table 'ffap-read-file-or-url-internal)
(not (ffap-url-p (buffer-string))) ; t
- (memq minibuffer-completion-table
- '(read-file-name-internal read-directory-name-internal)) ; list
- ))
+ (and minibuffer-completing-file-name '(t)))) ;list
(and
(featurep 'complete)
(if (boundp 'PC-completion-as-file-name-predicate)
;; modern version of complete.el, just set the variable:
- (setq PC-completion-as-file-name-predicate 'ffap-complete-as-file-p)
- (require 'advice)
- (defadvice PC-do-completion (around ffap-fix act)
- "Work with ffap."
- (let ((minibuffer-completion-table
- (if (eq t (ffap-complete-as-file-p))
- 'read-file-name-internal
- minibuffer-completion-table)))
- ad-do-it))))
+ (setq PC-completion-as-file-name-predicate 'ffap-complete-as-file-p)))
\f
;;; Highlighting (`ffap-highlight'):
;;
;; Based on overlay highlighting in Emacs 19.28 isearch.el.
-(defvar ffap-highlight (and window-system t)
+(defvar ffap-highlight t
"If non-nil, ffap highlights the current buffer substring.")
(defvar ffap-highlight-overlay nil
(cond
(remove
(and ffap-highlight-overlay
- (ffap-delete-overlay ffap-highlight-overlay)))
+ (delete-overlay ffap-highlight-overlay))
+ )
((not ffap-highlight) nil)
(ffap-highlight-overlay
- (ffap-move-overlay ffap-highlight-overlay
- (car ffap-string-at-point-region)
- (nth 1 ffap-string-at-point-region)
- (current-buffer)))
+ (move-overlay
+ ffap-highlight-overlay
+ (car ffap-string-at-point-region)
+ (nth 1 ffap-string-at-point-region)
+ (current-buffer)))
(t
(setq ffap-highlight-overlay
- (apply 'ffap-make-overlay ffap-string-at-point-region))
- (ffap-overlay-put ffap-highlight-overlay 'face
- (if (ffap-find-face 'ffap)
- 'ffap 'highlight)))))
+ (apply 'make-overlay ffap-string-at-point-region))
+ (overlay-put ffap-highlight-overlay 'face
+ (if (facep 'ffap) 'ffap 'highlight)))))
\f
-;;; The big cheese (`ffap'):
+;;; Main Entrance (`find-file-at-point' == `ffap'):
(defun ffap-guesser nil
"Return file or URL or nil, guessed from text around point."
;; Does guess and prompt step for find-file-at-point.
;; Extra complication for the temporary highlighting.
(unwind-protect
- (ffap-read-file-or-url
- (if ffap-url-regexp "Find file or URL: " "Find file: ")
- (prog1
- (setq guess (or guess (ffap-guesser)))
- (and guess (ffap-highlight))
- ))
+ ;; This catch will let ffap-alist entries do their own prompting
+ ;; and then maybe skip over this prompt (ff-paths, for example).
+ (catch 'ffap-prompter
+ (ffap-read-file-or-url
+ (if ffap-url-regexp "Find file or URL: " "Find file: ")
+ (prog1
+ (setq guess (or guess (ffap-guesser))) ; using ffap-alist here
+ (and guess (ffap-highlight))
+ )))
(ffap-highlight t)))
;;;###autoload
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)
((ffap-url-p filename)
(let (current-prefix-arg) ; w3 2.3.25 bug, reported by KPC
(funcall ffap-url-fetcher filename)))
- ;; This junk more properly belongs in a modified ffap-file-finder:
- ((and ffap-dired-wildcards
+ ((and ffap-pass-wildcards-to-dired
+ ffap-dired-wildcards
(string-match ffap-dired-wildcards filename))
- (dired filename))
+ (funcall ffap-directory-finder filename))
+ ((and ffap-dired-wildcards
+ (string-match ffap-dired-wildcards filename)
+ find-file-wildcards
+ ;; Check if it's find-file that supports wildcards arg
+ (memq ffap-file-finder '(find-file find-alternate-file)))
+ (funcall ffap-file-finder (expand-file-name filename) t))
((or (not ffap-newfile-prompt)
(file-exists-p filename)
(y-or-n-p "File does not exist, create buffer? "))
filename))))))
;; Shortcut: allow {M-x ffap} rather than {M-x find-file-at-point}.
-;; The defun is for autoload.el; the defalias takes over at load time.
;;;###autoload
-(defun ffap (&optional filename)
- "A short alias for the find-file-at-point command.")
(defalias 'ffap 'find-file-at-point)
\f
(make-variable-buffer-local 'ffap-menu-alist)
(defvar ffap-menu-text-plist
- (and window-system
- '(face bold mouse-face highlight) ; keymap <mousy-map>
- )
+ (cond
+ ((display-mouse-p) '(face bold mouse-face highlight)) ; keymap <mousy-map>
+ (t nil))
"Text properties applied to strings found by `ffap-menu-rescan'.
These properties may be used to fontify the menu references.")
Arguments are TITLE, ALIST, and CONT \(a continuation function\).
This uses either a menu or the minibuffer depending on invocation.
The TITLE string is used as either the prompt or menu title.
-Each \(string . data\) ALIST entry defines a choice.
+Each ALIST entry looks like (STRING . DATA) and defines one choice.
Function CONT is applied to the entry chosen by the user."
;; Note: this function is used with a different continuation
;; by the ffap-url add-on package.
(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)
;;;###autoload
(defun ffap-at-mouse (e)
"Find file or url guessed from text around mouse click.
-Interactively, calls `ffap-at-mouse-fallback' if nothing is found.
-Returns t or nil to indicate success."
+Interactively, calls `ffap-at-mouse-fallback' if no guess is found.
+Return value:
+ * if a guess string is found, return it (after finding it)
+ * if the fallback is called, return whatever it returns
+ * otherwise, nil"
(interactive "e")
(let ((guess
;; Maybe less surprising without the save-excursion?
(sit-for 0) ; display
(message "Finding `%s'" guess)
(find-file-at-point guess)
- t) ; success: return non-nil
+ guess) ; success: return non-nil
(ffap-highlight t)))
((interactive-p)
(if ffap-at-mouse-fallback
(call-interactively ffap-at-mouse-fallback)
- (message "No file or url found at mouse click.")))
+ (message "No file or url found at mouse click.")
+ nil)) ; no fallback, return nil
;; failure: return nil
)))
\f
-;;; ffap-other-* commands:
-;;
-;; Requested by KPC.
+;;; ffap-other-*, ffap-read-only-*, ffap-alternate-* commands:
;; There could be a real `ffap-noselect' function, but we would need
;; at least two new user variables, and there is no w3-fetch-noselect.
"Like `ffap', but put buffer in another window.
Only intended for interactive use."
(interactive)
- (switch-to-buffer-other-window
- (save-window-excursion (call-interactively 'ffap) (current-buffer))))
+ (let (value)
+ (switch-to-buffer-other-window
+ (save-window-excursion
+ (setq value (call-interactively 'ffap))
+ (unless (or (bufferp value) (bufferp (car-safe value)))
+ (setq value (current-buffer)))
+ (current-buffer)))
+ value))
(defun ffap-other-frame nil
"Like `ffap', but put buffer in another frame.
Only intended for interactive use."
(interactive)
;; Extra code works around dedicated windows (noted by JENS, 7/96):
- (let* ((win (selected-window)) (wdp (window-dedicated-p win)))
+ (let* ((win (selected-window))
+ (wdp (window-dedicated-p win))
+ value)
(unwind-protect
(progn
(set-window-dedicated-p win nil)
(switch-to-buffer-other-frame
(save-window-excursion
- (call-interactively 'ffap)
+ (setq value (call-interactively 'ffap))
+ (unless (or (bufferp value) (bufferp (car-safe value)))
+ (setq value (current-buffer)))
(current-buffer))))
- (set-window-dedicated-p win wdp))))
+ (set-window-dedicated-p win wdp))
+ value))
+
+(defun ffap-read-only ()
+ "Like `ffap', but mark buffer as read-only.
+Only intended for interactive use."
+ (interactive)
+ (let ((value (call-interactively 'ffap)))
+ (unless (or (bufferp value) (bufferp (car-safe value)))
+ (setq value (current-buffer)))
+ (mapc (lambda (b) (with-current-buffer b (toggle-read-only 1)))
+ (if (listp value) value (list value)))
+ value))
+
+(defun ffap-read-only-other-window ()
+ "Like `ffap', but put buffer in another window and mark as read-only.
+Only intended for interactive use."
+ (interactive)
+ (let ((value (ffap-other-window)))
+ (mapc (lambda (b) (with-current-buffer b (toggle-read-only 1)))
+ (if (listp value) value (list value)))
+ value))
+
+(defun ffap-read-only-other-frame ()
+ "Like `ffap', but put buffer in another frame and mark as read-only.
+Only intended for interactive use."
+ (interactive)
+ (let ((value (ffap-other-frame)))
+ (mapc (lambda (b) (with-current-buffer b (toggle-read-only 1)))
+ (if (listp value) value (list value)))
+ value))
+
+(defun ffap-alternate-file ()
+ "Like `ffap' and `find-alternate-file'.
+Only intended for interactive use."
+ (interactive)
+ (let ((ffap-file-finder 'find-alternate-file))
+ (call-interactively 'ffap)))
\f
;;; Bug Reporter:
(let ((reporter-prompt-for-summary-p t))
(reporter-submit-bug-report
"Michelangelo Grigni <mic@mathcs.emory.edu>"
- "ffap" ; version? just rely on Emacs version
+ "ffap"
(mapcar 'intern (all-completions "ffap-" obarray 'boundp)))))
(fset 'ffap-submit-bug 'ffap-bug) ; another likely name
(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
"Run `ffap-menu' in the gnus article buffer."
(interactive) (ffap-gnus-wrapper '(ffap-menu)))
+\f
+(defcustom dired-at-point-require-prefix nil
+ "*If set, reverses the prefix argument to `dired-at-point'.
+This is nil so neophytes notice ffap. Experts may prefer to disable
+ffap most of the time."
+ :type 'boolean
+ :group 'ffap
+ :version "20.3")
+
+;;;###autoload
+(defun dired-at-point (&optional filename)
+ "Start Dired, defaulting to file at point. See `ffap'."
+ (interactive)
+ (if (and (interactive-p)
+ (if dired-at-point-require-prefix
+ (not current-prefix-arg)
+ current-prefix-arg))
+ (let (current-prefix-arg) ; already interpreted
+ (call-interactively ffap-directory-finder))
+ (or filename (setq filename (dired-at-point-prompter)))
+ (cond
+ ((ffap-url-p filename)
+ (funcall ffap-url-fetcher filename))
+ ((and ffap-dired-wildcards
+ (string-match ffap-dired-wildcards filename))
+ (funcall ffap-directory-finder filename))
+ ((file-exists-p filename)
+ (if (file-directory-p filename)
+ (funcall ffap-directory-finder
+ (expand-file-name filename))
+ (funcall ffap-directory-finder
+ (concat (expand-file-name filename) "*"))))
+ ((and (file-writable-p
+ (or (file-name-directory (directory-file-name filename))
+ filename))
+ (y-or-n-p "Directory does not exist, create it? "))
+ (make-directory filename)
+ (funcall ffap-directory-finder filename))
+ ((error "No such file or directory `%s'" filename)))))
+
+(defun dired-at-point-prompter (&optional guess)
+ ;; Does guess and prompt step for find-file-at-point.
+ ;; Extra complication for the temporary highlighting.
+ (unwind-protect
+ (ffap-read-file-or-url
+ (if ffap-url-regexp "Dired file or URL: " "Dired file: ")
+ (prog1
+ (setq guess (or guess
+ (let ((guess (ffap-guesser)))
+ (if (or (not guess)
+ (ffap-url-p guess)
+ (ffap-file-remote-p guess))
+ guess
+ (setq guess (abbreviate-file-name
+ (expand-file-name guess)))
+ (cond
+ ;; Interpret local directory as a directory.
+ ((file-directory-p guess)
+ (file-name-as-directory guess))
+ ;; Get directory component from local files.
+ ((file-regular-p guess)
+ (file-name-directory guess))
+ (guess))))
+ ))
+ (and guess (ffap-highlight))))
+ (ffap-highlight t)))
+\f
+;;; ffap-dired-other-*, ffap-list-directory commands:
+
+(defun ffap-dired-other-window ()
+ "Like `dired-at-point', but put buffer in another window.
+Only intended for interactive use."
+ (interactive)
+ (let (value)
+ (switch-to-buffer-other-window
+ (save-window-excursion
+ (setq value (call-interactively 'dired-at-point))
+ (current-buffer)))
+ value))
+
+(defun ffap-dired-other-frame ()
+ "Like `dired-at-point', but put buffer in another frame.
+Only intended for interactive use."
+ (interactive)
+ ;; Extra code works around dedicated windows (noted by JENS, 7/96):
+ (let* ((win (selected-window))
+ (wdp (window-dedicated-p win))
+ value)
+ (unwind-protect
+ (progn
+ (set-window-dedicated-p win nil)
+ (switch-to-buffer-other-frame
+ (save-window-excursion
+ (setq value (call-interactively 'dired-at-point))
+ (current-buffer))))
+ (set-window-dedicated-p win wdp))
+ value))
+
+(defun ffap-list-directory ()
+ "Like `dired-at-point' and `list-directory'.
+Only intended for interactive use."
+ (interactive)
+ (let ((ffap-directory-finder 'list-directory))
+ (call-interactively 'dired-at-point)))
+
\f
;;; Offer default global bindings (`ffap-bindings'):
(defvar ffap-bindings
- '(
- (global-set-key [S-mouse-3] 'ffap-at-mouse)
- (global-set-key [C-S-mouse-3] 'ffap-menu)
- (global-set-key "\C-x\C-f" 'find-file-at-point)
- (global-set-key "\C-x4f" 'ffap-other-window)
- (global-set-key "\C-x5f" 'ffap-other-frame)
- (add-hook 'gnus-summary-mode-hook 'ffap-gnus-hook)
- (add-hook 'gnus-article-mode-hook 'ffap-gnus-hook)
- (add-hook 'vm-mode-hook 'ffap-ro-mode-hook)
- (add-hook 'rmail-mode-hook 'ffap-ro-mode-hook)
- ;; (setq dired-x-hands-off-my-keys t) ; the default
- )
- "List of binding forms evaluated by function `ffap-bindings'.
-A reasonable ffap installation needs just these two lines:
- (require 'ffap)
+ '(
+ (global-set-key [S-mouse-3] 'ffap-at-mouse)
+ (global-set-key [C-S-mouse-3] 'ffap-menu)
+
+ (global-set-key "\C-x\C-f" 'find-file-at-point)
+ (global-set-key "\C-x\C-r" 'ffap-read-only)
+ (global-set-key "\C-x\C-v" 'ffap-alternate-file)
+
+ (global-set-key "\C-x4f" 'ffap-other-window)
+ (global-set-key "\C-x5f" 'ffap-other-frame)
+ (global-set-key "\C-x4r" 'ffap-read-only-other-window)
+ (global-set-key "\C-x5r" 'ffap-read-only-other-frame)
+
+ (global-set-key "\C-xd" 'dired-at-point)
+ (global-set-key "\C-x4d" 'ffap-dired-other-window)
+ (global-set-key "\C-x5d" 'ffap-dired-other-frame)
+ (global-set-key "\C-x\C-d" 'ffap-list-directory)
+
+ (add-hook 'gnus-summary-mode-hook 'ffap-gnus-hook)
+ (add-hook 'gnus-article-mode-hook 'ffap-gnus-hook)
+ (add-hook 'vm-mode-hook 'ffap-ro-mode-hook)
+ (add-hook 'rmail-mode-hook 'ffap-ro-mode-hook)
+ ;; (setq dired-x-hands-off-my-keys t) ; the default
+ )
+ "List of binding forms evaluated by function `ffap-bindings'.
+A reasonable ffap installation needs just this one line:
(ffap-bindings)
Of course if you do not like these bindings, just roll your own!")
+;;;###autoload
(defun ffap-bindings nil
"Evaluate the forms in variable `ffap-bindings'."
+ (interactive)
(eval (cons 'progn ffap-bindings)))
-;; Example modifications:
-;;
-;; (setq ffap-alist ; remove a feature in `ffap-alist'
-;; (delete (assoc 'c-mode ffap-alist) ffap-alist))
-;;
-;; (setq ffap-alist ; add something to `ffap-alist'
-;; (cons
-;; (cons "^YSN[0-9]+$"
-;; (defun ffap-ysn (name)
-;; (concat
-;; "http://www.physics.uiuc.edu/"
-;; "ysn/httpd/htdocs/ysnarchive/issuefiles/"
-;; (substring name 3) ".html")))
-;; ffap-alist))
-
\f
+
+;;; arch-tag: 9dd3e88a-5dec-4607-bd57-60ae9ede8ebc
;;; ffap.el ends here