+;; 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:
+;;
+;; Define various default members of `ffap-alist'.
+
+(defun ffap-completable (name)
+ (let* ((dir (or (file-name-directory name) default-directory))
+ (cmp (file-name-completion (file-name-nondirectory name) dir)))
+ (and cmp (concat dir cmp))))
+
+(defun ffap-home (name) (ffap-locate-file name t '("~")))
+
+(defun ffap-info (name)
+ (ffap-locate-file
+ name '("" ".info")
+ (or (ffap-soft-value "Info-directory-list")
+ (ffap-soft-value "Info-default-directory-list")
+ )))
+
+(defun ffap-info-2 (name) (ffap-info (substring name 5)))
+
+(defun ffap-info-3 (name)
+ ;; This ignores the node! "(emacs)Top" same as "(emacs)Intro"
+ (and (equal (ffap-string-around) "()") (ffap-info name)))
+
+(defun ffap-el (name) (ffap-locate-file name t))
+
+(defun ffap-el-mode (name)
+ ;; If name == "foo.el" we will skip it, since ffap-el already
+ ;; searched for it once. (This assumes the default ffap-alist.)
+ (and (not (string-match "\\.el\\'" name))
+ (ffap-locate-file name '(".el"))))
+
+(defvar ffap-c-path
+ ;; Need smarter defaults here! Suggestions welcome.
+ '("/usr/include" "/usr/local/include"))
+(defun ffap-c-mode (name)
+ (ffap-locate-file name t ffap-c-path))
+
+(defvar ffap-fortran-path '("../include" "/usr/include"))
+
+(defun ffap-fortran-mode (name)
+ (ffap-locate-file name t ffap-fortran-path))
+
+(defvar ffap-tex-path
+ t ; delayed initialization
+ "Path where `ffap-tex-mode' looks for tex files.
+If t, `ffap-tex-init' will initialize this when needed.")
+
+(defun ffap-tex-init nil
+ ;; Compute ffap-tex-path if it is now t.
+ (and (eq t ffap-tex-path)
+ ;; this may be slow, so say something
+ (message "Initializing ffap-tex-path ...")
+ (setq ffap-tex-path
+ (ffap-reduce-path
+ (cons
+ "."
+ (ffap-kpathsea-expand-path
+ (append
+ (ffap-list-env "TEXINPUTS")
+ ;; (ffap-list-env "BIBINPUTS")
+ (ffap-soft-value
+ "TeX-macro-global" ; AUCTeX
+ '("/usr/local/lib/tex/macros"
+ "/usr/local/lib/tex/inputs")))))))))
+
+(defun ffap-tex-mode (name)
+ (ffap-tex-init)
+ (ffap-locate-file name '(".tex" "") ffap-tex-path))
+
+(defun ffap-latex-mode (name)
+ (ffap-tex-init)
+ ;; only rare need for ""
+ (ffap-locate-file name '(".cls" ".sty" ".tex" "") ffap-tex-path))
+
+(defun ffap-tex (name)
+ (ffap-tex-init)
+ (ffap-locate-file name t ffap-tex-path))
+
+(defvar ffap-bib-path
+ (ffap-list-env "BIBINPUTS"
+ (ffap-reduce-path
+ '(
+ ;; a few wild guesses, need better
+ "/usr/local/lib/tex/macros/bib" ; Solaris?
+ "/usr/lib/texmf/bibtex/bib" ; Linux?
+ ))))
+
+(defun ffap-bib (name)
+ (ffap-locate-file name t ffap-bib-path))
+
+(defun ffap-dired (name)
+ (let ((pt (point)) dir try)
+ (save-excursion
+ (and (progn
+ (beginning-of-line)
+ (looking-at " *[-d]r[-w][-x][-r][-w][-x][-r][-w][-x] "))
+ (re-search-backward "^ *$" nil t)
+ (re-search-forward "^ *\\([^ \t\n:]*\\):\n *total " pt t)
+ (file-exists-p
+ (setq try
+ (expand-file-name
+ name
+ (buffer-substring
+ (match-beginning 1) (match-end 1)))))
+ try))))
+
+;; Maybe a "Lisp Code Directory" reference:
+(defun ffap-lcd (name)
+ (and
+ (or
+ ;; lisp-dir-apropos output buffer:
+ (string-match "Lisp Code Dir" (buffer-name))
+ ;; Inside an LCD entry like |~/misc/ffap.el.Z|,
+ ;; or maybe the holy LCD-Datafile itself:
+ (member (ffap-string-around) '("||" "|\n")))
+ (concat
+ ;; lispdir.el may not be loaded yet:
+ (ffap-host-to-path
+ (ffap-soft-value "elisp-archive-host"
+ "archive.cis.ohio-state.edu"))
+ (file-name-as-directory
+ (ffap-soft-value "elisp-archive-directory"
+ "/pub/gnu/emacs/elisp-archive/"))
+ (substring name 2))))
+
+(defvar ffap-rfc-path
+ (concat (ffap-host-to-path "ds.internic.net") "/rfc/rfc%s.txt"))
+
+(defun ffap-rfc (name)
+ (format ffap-rfc-path
+ (substring name (match-beginning 1) (match-end 1))))
+