Mercurial > emacs
annotate lisp/ffap.el @ 17645:b85205cfba13
(rmail-ignored-headers): Add References, Mime-Version,
Lines, Content-Transfer-Encoding.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 04 May 1997 17:38:57 +0000 |
parents | e687d30cbf1a |
children | fcbe987b332a |
rev | line source |
---|---|
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
1 ;;; ffap.el --- find file or URL at point |
13531 | 2 |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
3 ;; Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. |
14169 | 4 |
5 ;; Author: Michelangelo Grigni <mic@mathcs.emory.edu> | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
6 ;; Created: 29 Mar 1993 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
7 ;; Keywords: files, hypermedia, matching, mouse |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
8 ;; X-Latest: ftp://ftp.mathcs.emory.edu:/pub/mic/emacs/ |
13531 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
13531 | 26 |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
27 |
13531 | 28 ;;; Commentary: |
29 ;; | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
30 ;; Command find-file-at-point replaces find-file. With a prefix, it |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
31 ;; behaves exactly like find-file. Without a prefix, it first tries |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
32 ;; to guess a default file or URL from the text around the point |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
33 ;; (`ffap-require-prefix' swaps these behaviors). This is useful for |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
34 ;; following references in situations such as mail or news buffers, |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
35 ;; README's, MANIFEST's, and so on. Submit bugs or suggestions with |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
36 ;; M-x ffap-bug. |
13531 | 37 ;; |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
38 ;; For the default installation, byte-compile ffap.el somewhere in |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
39 ;; your `load-path' and add these two lines to your .emacs file: |
13531 | 40 ;; |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
41 ;; (require 'ffap) ; load the package |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
42 ;; (ffap-bindings) ; do default key bindings |
13531 | 43 ;; |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
44 ;; ffap-bindings makes the following global key bindings: |
13531 | 45 ;; |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
46 ;; C-x C-f find-file-at-point (abbreviated as ffap) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
47 ;; C-x 4 f ffap-other-window |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
48 ;; C-x 5 f ffap-other-frame |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
49 ;; S-mouse-3 ffap-at-mouse |
13531 | 50 ;; |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
51 ;; ffap-bindings also adds hooks to make the following local bindings |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
52 ;; in vm, gnus, and rmail: |
13531 | 53 ;; |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
54 ;; M-l ffap-next, or ffap-gnus-next in gnus |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
55 ;; M-m ffap-menu, or ffap-gnus-menu in gnus |
13531 | 56 ;; |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
57 ;; If you do not like these bindings, modify the variable |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
58 ;; `ffap-bindings', or write your own. |
13531 | 59 ;; |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
60 ;; If you use ange-ftp, browse-url, complete, efs, or w3, it is best |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
61 ;; to load or autoload them before ffap. If you use ff-paths, load it |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
62 ;; afterwards. Try apropos {C-h a ffap RET} to get a list of the many |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
63 ;; option variables. In particular, if ffap is slow, try these: |
13531 | 64 ;; |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
65 ;; (setq ffap-alist nil) ; faster, dumber prompting |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
66 ;; (setq ffap-machine-p-known 'accept) ; no pinging |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
67 ;; (setq ffap-url-regexp nil) ; disable URL features in ffap |
13531 | 68 ;; |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
69 ;; ffap uses w3 (if found) or else browse-url to fetch URL's. For |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
70 ;; a hairier `ffap-url-fetcher', try ffap-url.el (same ftp site). |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
71 ;; Also, you can add `ffap-menu-rescan' to various hooks to fontify |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
72 ;; the file and URL references within a buffer. |
13531 | 73 |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
74 ;;; Todo list: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
75 ;; * recognize paths inside /usr/bin:/bin:/etc, ./ffap.el:80: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
76 ;; * let "/path/file#key" jump to key (offset or regexp) in /path/file |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
77 ;; * find file of symbol if TAGS is loaded (like above) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
78 ;; * break up long menus into multiple panes (like imenu?) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
79 ;; * notice node in "(dired)Virtual Dired" (handle the space?) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
80 ;; * notice "machine.dom blah blah blah path/file" (how?) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
81 ;; * if w3 becomes standard, could rewrite to use its functions |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
82 ;; * regexp options for ffap-string-at-point, like font-lock (MCOOK) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
83 ;; * v19: could replace `ffap-locate-file' with a quieter `locate-library' |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
84 ;; * support for custom.el |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
85 ;; + handle "$(HOME)" in Makefiles? |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
86 ;; + modify `font-lock-keywords' to do fontification |
13531 | 87 |
88 | |
89 ;;; Code: | |
90 | |
91 (provide 'ffap) | |
92 | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
93 ;; Versions: This file is tested with Emacs 19.30. It mostly works |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
94 ;; with XEmacs, but get ffap-xe.el for the popup menu. Emacs 18 is |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
95 ;; now abandoned (get ffap-15.el instead). |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
96 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
97 (defvar ffap-xemacs (and (string-match "X[Ee]macs" emacs-version) t) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
98 "Whether ffap thinks it is running under XEmacs.") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
99 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
100 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
101 |
13531 | 102 ;;; User Variables: |
103 | |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
104 (defgroup ffap nil |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
105 "Find file or URL at point." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
106 :group 'matching) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
107 |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
108 |
13531 | 109 ;; This function is used inside defvars: |
110 (defun ffap-soft-value (name &optional default) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
111 "Return value of symbol with NAME, if it is interned. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
112 Otherwise return nil (or the optional DEFAULT value)." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
113 ;; Bug: (ffap-soft-value "nil" 5) --> 5 |
13531 | 114 (let ((sym (intern-soft name))) |
115 (if (and sym (boundp sym)) (symbol-value sym) default))) | |
116 | |
117 | |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
118 (defcustom ffap-ftp-regexp |
13531 | 119 (and |
120 (or (featurep 'ange-ftp) | |
121 (featurep 'efs) | |
122 (and (boundp 'file-name-handler-alist) ; v19 | |
123 (or (rassq 'ange-ftp-hook-function file-name-handler-alist) | |
124 (rassq 'efs-file-handler-function file-name-handler-alist)))) | |
125 ;; Apparently this is good enough for both ange-ftp and efs: | |
126 "\\`/[^/:]+:") | |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
127 "*Treat paths matching this as remote ftp paths. nil to disable. |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
128 nil also disables the generation of such paths by ffap." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
129 :type '(choice (const :tag "Disable" nil) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
130 regexp) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
131 :group 'ffap) |
13531 | 132 |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
133 (defcustom ffap-url-unwrap-local t |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
134 "*If non-nil, convert \"file:\" URL to local path before prompting." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
135 :type 'boolean |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
136 :group 'ffap) |
13531 | 137 |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
138 (defcustom ffap-url-unwrap-remote t |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
139 "*If non-nil, convert \"ftp:\" URL to remote path before prompting. |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
140 This is ignored if `ffap-ftp-regexp' is nil." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
141 :type 'boolean |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
142 :group 'ffap) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
143 |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
144 (defcustom ffap-ftp-default-user |
13531 | 145 (if (or (equal (ffap-soft-value "ange-ftp-default-user") "anonymous") |
146 (equal (ffap-soft-value "efs-default-user") "anonymous")) | |
147 nil | |
148 "anonymous") | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
149 "*User name in ftp paths generated by `ffap-host-to-path'. |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
150 nil to rely on `efs-default-user' or `ange-ftp-default-user'." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
151 :type '(choice (const :tag "Default" nil) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
152 string) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
153 :group 'ffap) |
13531 | 154 |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
155 (defcustom ffap-rfs-regexp |
13531 | 156 ;; Remote file access built into file system? HP rfa or Andrew afs: |
157 "\\`/\\(afs\\|net\\)/." | |
158 ;; afs only: (and (file-exists-p "/afs") "\\`/afs/.") | |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
159 "*Matching paths are treated as remote. nil to disable." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
160 :type 'regexp |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
161 :group 'ffap) |
13531 | 162 |
163 (defvar ffap-url-regexp | |
164 ;; Could just use `url-nonrelative-link' of w3, if loaded. | |
165 ;; This regexp is not exhaustive, it just matches common cases. | |
166 (concat | |
167 "\\`\\(" | |
168 "news\\(post\\)?:\\|mailto:\\|file:" ; no host ok | |
169 "\\|" | |
170 "\\(ftp\\|http\\|telnet\\|gopher\\|www\\|wais\\)://" ; needs host | |
171 "\\)." ; require one more character | |
172 ) | |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
173 "Regexp matching URL's. nil to disable URL features in ffap.") |
13531 | 174 |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
175 (defcustom ffap-foo-at-bar-prefix "mailto" |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
176 "*Presumed URL prefix type of strings like \"<foo.9z@bar>\". |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
177 Sensible values are nil, \"news\", or \"mailto\"." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
178 :type 'string |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
179 :group 'ffap) |
13531 | 180 |
181 | |
182 ;;; Peanut Gallery: | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
183 ;; |
13531 | 184 ;; Users of ffap occasionally suggest new features. If I consider |
185 ;; those features interesting but not clear winners (a matter of | |
186 ;; personal taste) I try to leave options to enable them. Read | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
187 ;; through this section for features that you like, put an appropriate |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
188 ;; enabler in your .emacs file. |
13531 | 189 |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
190 (defcustom ffap-dired-wildcards nil ; "[*?][^/]*$" |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
191 ;; Suggestion from RHOGEE, 07 Jul 1994. Disabled, dired is still |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
192 ;; available by "C-x C-d <pattern>", and valid filenames may |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
193 ;; sometimes contain wildcard characters. |
13531 | 194 "*A regexp matching filename wildcard characters, or nil. |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
195 If `find-file-at-point' gets a filename matching this pattern, |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
196 it passes it on to `dired' instead of `find-file'." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
197 :type '(choice (const :tag "off" nil) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
198 regexp) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
199 :group 'ffap) |
13531 | 200 |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
201 (defcustom ffap-newfile-prompt nil ; t |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
202 ;; Suggestion from RHOGEE, 11 Jul 1994. Disabled, I think this is |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
203 ;; better handled by `find-file-not-found-hooks'. |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
204 "*Whether `find-file-at-point' prompts about a nonexistent file." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
205 :type 'boolean |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
206 :group 'ffap) |
13531 | 207 |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
208 (defcustom ffap-require-prefix nil |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
209 ;; Suggestion from RHOGEE, 20 Oct 1994. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
210 "*If set, reverses the prefix argument to `find-file-at-point'. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
211 This is nil so neophytes notice ffap. Experts may prefer to disable |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
212 ffap most of the time." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
213 :type 'boolean |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
214 :group 'ffap) |
13531 | 215 |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
216 (defcustom ffap-file-finder 'find-file |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
217 "*The command called by `find-file-at-point' to find a file." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
218 :type 'function |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
219 :group 'ffap) |
13531 | 220 (put 'ffap-file-finder 'risky-local-variable t) |
221 | |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
222 (defcustom ffap-url-fetcher |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
223 (cond ((fboundp 'w3-fetch) 'w3-fetch) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
224 ((fboundp 'browse-url-netscape) 'browse-url-netscape) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
225 (t 'w3-fetch)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
226 ;; Remote control references: |
13531 | 227 ;; http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/remote-control.html |
228 ;; http://home.netscape.com/newsref/std/x-remote.html | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
229 "*A function of one argument, called by ffap to fetch an URL. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
230 Reasonable choices are `w3-fetch' or `browse-url-netscape'. |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
231 For a fancier alternative, get ffap-url.el." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
232 :type 'function |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
233 :group 'ffap) |
13531 | 234 (put 'ffap-url-fetcher 'risky-local-variable t) |
235 | |
236 | |
237 ;;; Command ffap-next: | |
238 ;; | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
239 ;; Original ffap-next-url (URL's only) from RPECK 30 Mar 1995. Since |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
240 ;; then, broke it up into ffap-next-guess (noninteractive) and |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
241 ;; ffap-next (a command). It now work on files as well as url's. |
13531 | 242 |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
243 (defcustom ffap-next-regexp |
13531 | 244 ;; If you want ffap-next to find URL's only, try this: |
245 ;; (and ffap-url-regexp (string-match "\\\\`" ffap-url-regexp) | |
246 ;; (concat "\\<" (substring ffap-url-regexp 2)))) | |
247 ;; | |
248 ;; It pays to put a big fancy regexp here, since ffap-guesser is | |
249 ;; much more time-consuming than regexp searching: | |
250 "[/:.~a-zA-Z]/\\|@[a-zA-Z][-a-zA-Z0-9]*\\." | |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
251 "*Regular expression governing movements of `ffap-next'." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
252 :type 'regexp |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
253 :group 'ffap) |
13531 | 254 |
255 (defvar ffap-next-guess nil "Last value returned by `ffap-next-guess'.") | |
256 (defun ffap-next-guess (&optional back lim) | |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
257 "Move point to next file or URL, and return it as a string. |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
258 If nothing is found, leave point at limit and return nil. |
13531 | 259 Optional BACK argument makes search backwards. |
260 Optional LIM argument limits the search. | |
261 Only considers strings that match `ffap-next-regexp'." | |
262 (or lim (setq lim (if back (point-min) (point-max)))) | |
263 (let (guess) | |
264 (while (not (or guess (eq (point) lim))) | |
265 (funcall (if back 're-search-backward 're-search-forward) | |
266 ffap-next-regexp lim 'move) | |
267 (setq guess (ffap-guesser))) | |
268 ;; Go to end, so we do not get same guess twice: | |
269 (goto-char (nth (if back 0 1) ffap-string-at-point-region)) | |
270 (setq ffap-next-guess guess))) | |
271 | |
272 ;;;###autoload | |
273 (defun ffap-next (&optional back wrap) | |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
274 "Search buffer for next file or URL, and run ffap. |
13531 | 275 Optional argument BACK says to search backwards. |
276 Optional argument WRAP says to try wrapping around if necessary. | |
277 Interactively: use a single prefix to search backwards, | |
278 double prefix to wrap forward, triple to wrap backwards. | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
279 Actual search is done by `ffap-next-guess'." |
13531 | 280 (interactive |
281 (cdr (assq (prefix-numeric-value current-prefix-arg) | |
282 '((1) (4 t) (16 nil t) (64 t t))))) | |
283 (let ((pt (point)) | |
284 (guess (ffap-next-guess back))) | |
285 ;; Try wraparound if necessary: | |
286 (and (not guess) wrap | |
287 (goto-char (if back (point-max) (point-min))) | |
288 (setq guess (ffap-next-guess back pt))) | |
289 (if guess | |
290 (progn | |
291 (sit-for 0) ; display point movement | |
292 (find-file-at-point (ffap-prompter guess))) | |
293 (goto-char pt) ; restore point | |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
294 (message "No %sfiles or URL's found" |
13531 | 295 (if wrap "" "more "))))) |
296 | |
297 (defun ffap-next-url (&optional back wrap) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
298 "Like `ffap-next', but search with `ffap-url-regexp'." |
13531 | 299 (interactive) |
300 (let ((ffap-next-regexp ffap-url-regexp)) | |
301 (if (interactive-p) | |
302 (call-interactively 'ffap-next) | |
303 (ffap-next back wrap)))) | |
304 | |
305 | |
306 ;;; Remote machines and paths: | |
307 | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
308 (defun ffap-replace-path-component (fullname name) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
309 "In remote FULLNAME, replace path with NAME. May return nil." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
310 ;; Use ange-ftp or efs if loaded, but do not load them otherwise. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
311 (let (found) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
312 (mapcar |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
313 (function (lambda (sym) (and (fboundp sym) (setq found sym)))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
314 '( |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
315 efs-replace-path-component |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
316 ange-ftp-replace-path-component |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
317 ange-ftp-replace-name-component |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
318 )) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
319 (and found |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
320 (fset 'ffap-replace-path-component found) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
321 (funcall found fullname name)))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
322 ;; (ffap-replace-path-component "/who@foo.com:/whatever" "/new") |
13531 | 323 |
324 (defun ffap-file-exists-string (file) | |
325 ;; With certain packages (ange-ftp, jka-compr?) file-exists-p | |
326 ;; sometimes returns a nicer string than it is given. Otherwise, it | |
327 ;; just returns nil or t. | |
328 "Return FILE \(maybe modified\) if it exists, else nil." | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
329 (and file ; quietly reject nil |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
330 (let ((exists (file-exists-p file))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
331 (and exists (if (stringp exists) exists file))))) |
13531 | 332 |
333 ;; I cannot decide a "best" strategy here, so these are variables. In | |
334 ;; particular, if `Pinging...' is broken or takes too long on your | |
335 ;; machine, try setting these all to accept or reject. | |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
336 (defcustom ffap-machine-p-local 'reject ; this happens often |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
337 "*A symbol, one of: ping, accept, reject. |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
338 What `ffap-machine-p' does with hostnames that have no domain." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
339 :type '(choice (const ping) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
340 (const accept) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
341 (const reject)) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
342 :group 'ffap) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
343 (defcustom ffap-machine-p-known 'ping ; 'accept for speed |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
344 "*A symbol, one of: ping, accept, reject. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
345 What `ffap-machine-p' does with hostnames that have a known domain |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
346 \(see mail-extr.el for the known domains\)." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
347 :type '(choice (const ping) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
348 (const accept) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
349 (const reject)) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
350 :group 'ffap) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
351 (defcustom ffap-machine-p-unknown 'reject |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
352 "*A symbol, one of: ping, accept, reject. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
353 What `ffap-machine-p' does with hostnames that have an unknown domain |
17635
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
354 \(see mail-extr.el for the known domains\)." |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
355 :type '(choice (const ping) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
356 (const accept) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
357 (const reject)) |
e687d30cbf1a
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16286
diff
changeset
|
358 :group 'ffap) |
13531 | 359 |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
360 (defun ffap-what-domain (domain) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
361 ;; Like what-domain in mail-extr.el, returns string or nil. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
362 (require 'mail-extr) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
363 (defvar mail-extr-all-top-level-domains |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
364 (ffap-soft-value "all-top-level-domains" obarray)) ; XEmacs, old Emacs |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
365 (get (intern-soft (downcase domain) mail-extr-all-top-level-domains) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
366 'domain-name)) |
13531 | 367 |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
368 (defun ffap-machine-p (host &optional service quiet strategy) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
369 "Decide whether HOST is the name of a real, reachable machine. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
370 Depending on the domain (none, known, or unknown), follow the strategy |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
371 named by the variable `ffap-machine-p-local', `ffap-machine-p-known', |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
372 or `ffap-machine-p-unknown'. Pinging uses `open-network-stream'. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
373 Optional SERVICE specifies the port used \(default \"discard\"\). |
13531 | 374 Optional QUIET flag suppresses the \"Pinging...\" message. |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
375 Optional STRATEGY overrides the three variables above. |
13531 | 376 Returned values: |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
377 t means that HOST answered. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
378 'accept means the relevant variable told us to accept. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
379 \"mesg\" means HOST exists, but does not respond for some reason." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
380 ;; Try some (Emory local): |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
381 ;; (ffap-machine-p "ftp" nil nil 'ping) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
382 ;; (ffap-machine-p "nonesuch" nil nil 'ping) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
383 ;; (ffap-machine-p "ftp.mathcs.emory.edu" nil nil 'ping) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
384 ;; (ffap-machine-p "mathcs" 5678 nil 'ping) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
385 ;; (ffap-machine-p "foo.bonk" nil nil 'ping) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
386 ;; (ffap-machine-p "foo.bonk.com" nil nil 'ping) |
13531 | 387 (if (or (string-match "[^-a-zA-Z0-9.]" host) ; Illegal chars (?) |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
388 (not (string-match "[^0-9]" host))) ; 1: a number? 2: quick reject |
13531 | 389 nil |
390 (let* ((domain | |
391 (and (string-match "\\.[^.]*$" host) | |
392 (downcase (substring host (1+ (match-beginning 0)))))) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
393 (what-domain (if domain (ffap-what-domain domain) "Local"))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
394 (or strategy |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
395 (setq strategy |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
396 (cond ((not domain) ffap-machine-p-local) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
397 ((not what-domain) ffap-machine-p-unknown) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
398 (t ffap-machine-p-known)))) |
13531 | 399 (cond |
400 ((eq strategy 'accept) 'accept) | |
401 ((eq strategy 'reject) nil) | |
402 ;; assume (eq strategy 'ping) | |
403 (t | |
404 (or quiet | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
405 (if (stringp what-domain) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
406 (message "Pinging %s (%s)..." host what-domain) |
13531 | 407 (message "Pinging %s ..." host))) |
408 (condition-case error | |
409 (progn | |
410 (delete-process | |
411 (open-network-stream | |
412 "ffap-machine-p" nil host (or service "discard"))) | |
413 t) | |
414 (error | |
415 (let ((mesg (car (cdr error)))) | |
416 (cond | |
417 ;; v18: | |
418 ((string-match "^Unknown host" mesg) nil) | |
419 ((string-match "not responding$" mesg) mesg) | |
420 ;; v19: | |
421 ;; (file-error "connection failed" "permission denied" | |
422 ;; "nonesuch" "ffap-machine-p") | |
423 ;; (file-error "connection failed" "host is unreachable" | |
424 ;; "gopher.house.gov" "ffap-machine-p") | |
425 ;; (file-error "connection failed" "address already in use" | |
426 ;; "ftp.uu.net" "ffap-machine-p") | |
427 ((equal mesg "connection failed") | |
428 (if (equal (nth 2 error) "permission denied") | |
429 nil ; host does not exist | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
430 ;; Other errors mean the host exists: |
13531 | 431 (nth 2 error))) |
432 ;; Could be "Unknown service": | |
433 (t (signal (car error) (cdr error)))))))))))) | |
434 | |
435 (defun ffap-file-remote-p (filename) | |
436 "If FILENAME looks remote, return it \(maybe slightly improved\)." | |
437 ;; (ffap-file-remote-p "/user@foo.bar.com:/pub") | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
438 ;; (ffap-file-remote-p "/cssun.mathcs.emory.edu://path") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
439 ;; (ffap-file-remote-p "/ffap.el:80") |
13531 | 440 (or (and ffap-ftp-regexp |
441 (string-match ffap-ftp-regexp filename) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
442 ;; Convert "/host.com://path" to "/host:/path", to handle a dieing |
13531 | 443 ;; practice of advertising ftp paths as "host.dom://path". |
444 (if (string-match "//" filename) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
445 ;; (replace-match "/" nil nil filename) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
446 (concat (substring filename 0 (1+ (match-beginning 0))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
447 (substring filename (match-end 0))) |
13531 | 448 filename)) |
449 (and ffap-rfs-regexp | |
450 (string-match ffap-rfs-regexp filename) | |
451 filename))) | |
452 | |
453 (defun ffap-machine-at-point nil | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
454 "Return machine name at point if it exists, or nil." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
455 (let ((mach (ffap-string-at-point 'machine))) |
13531 | 456 (and (ffap-machine-p mach) mach))) |
457 | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
458 (defsubst ffap-host-to-path (host) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
459 "Convert HOST to something like \"/anonymous@HOST:\". |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
460 Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
461 (if (equal host "localhost") "" |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
462 (concat "/" |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
463 ffap-ftp-default-user (and ffap-ftp-default-user "@") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
464 host ":"))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
465 |
13531 | 466 (defun ffap-fixup-machine (mach) |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
467 ;; Convert a hostname into an url, an ftp path, or nil. |
13531 | 468 (cond |
469 ((not (and ffap-url-regexp (stringp mach))) nil) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
470 ;; gopher.well.com |
13531 | 471 ((string-match "\\`gopher[-.]" mach) ; or "info"? |
472 (concat "gopher://" mach "/")) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
473 ;; www.ncsa.uiuc.edu |
13531 | 474 ((and (string-match "\\`w\\(ww\\|eb\\)[-.]" mach)) |
475 (concat "http://" mach "/")) | |
476 ;; More cases? Maybe "telnet:" for archie? | |
477 (ffap-ftp-regexp (ffap-host-to-path mach)) | |
478 )) | |
479 | |
480 (defun ffap-newsgroup-p (string) | |
481 "Return STRING if it looks like a newsgroup name, else nil." | |
482 (and | |
483 (string-match ffap-newsgroup-regexp string) | |
484 (let ((htbs '(gnus-active-hashtb gnus-newsrc-hashtb gnus-killed-hashtb)) | |
485 (heads ffap-newsgroup-heads) | |
486 htb ret) | |
487 (while htbs | |
488 (setq htb (car htbs) htbs (cdr htbs)) | |
489 (condition-case nil | |
490 (progn | |
491 ;; errs: htb symbol may be unbound, or not a hash-table. | |
492 ;; gnus-gethash is just a macro for intern-soft. | |
493 (and (intern-soft string (symbol-value htb)) | |
494 (setq ret string htbs nil)) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
495 ;; If we made it this far, gnus is running, so ignore "heads": |
13531 | 496 (setq heads nil)) |
497 (error nil))) | |
498 (or ret (not heads) | |
499 (let ((head (string-match "\\`\\([a-z]+\\)\\." string))) | |
500 (and head (setq head (substring string 0 (match-end 1))) | |
501 (member head heads) | |
502 (setq ret string)))) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
503 ;; Is there ever a need to modify string as a newsgroup name? |
13531 | 504 ret))) |
505 (defvar ffap-newsgroup-regexp "^[a-z]+\\.[-+a-z_0-9.]+$" | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
506 "Strings not matching this fail `ffap-newsgroup-p'.") |
13531 | 507 (defvar ffap-newsgroup-heads ; entirely inadequate |
508 '("alt" "comp" "gnu" "misc" "news" "sci" "soc" "talk") | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
509 "Used by `ffap-newsgroup-p' if gnus is not running.") |
13531 | 510 |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
511 (defsubst ffap-url-p (string) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
512 "If STRING looks like an url, return it (maybe improved), else nil." |
13531 | 513 (let ((case-fold-search t)) |
514 (and ffap-url-regexp (string-match ffap-url-regexp string) | |
515 ;; I lied, no improvement: | |
516 string))) | |
517 | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
518 ;; Broke these out of ffap-fixup-url, for use of ffap-url package. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
519 (defsubst ffap-url-unwrap-local (url) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
520 "Return URL as a local file, or nil. Ignores `ffap-url-regexp'." |
13531 | 521 (and (string-match "\\`\\(file\\|ftp\\):/?\\([^/]\\|\\'\\)" url) |
522 (substring url (1+ (match-end 1))))) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
523 (defsubst ffap-url-unwrap-remote (url) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
524 "Return URL as a remote file, or nil. Ignores `ffap-url-regexp'." |
13531 | 525 (and (string-match "\\`\\(ftp\\|file\\)://\\([^:/]+\\):?\\(/.*\\)" url) |
526 (concat | |
527 (ffap-host-to-path (substring url (match-beginning 2) (match-end 2))) | |
528 (substring url (match-beginning 3) (match-end 3))))) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
529 ;; Test: (ffap-url-unwrap-remote "ftp://foo.com/bar.boz") |
13531 | 530 |
531 (defun ffap-fixup-url (url) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
532 "Clean up URL and return it, maybe as a file name." |
13531 | 533 (cond |
534 ((not (stringp url)) nil) | |
535 ((and ffap-url-unwrap-local (ffap-url-unwrap-local url))) | |
536 ((and ffap-url-unwrap-remote ffap-ftp-regexp | |
537 (ffap-url-unwrap-remote url))) | |
538 ;; Do not load w3 just for this: | |
539 (t (let ((normal (and (fboundp 'url-normalize-url) | |
540 (url-normalize-url url)))) | |
541 ;; In case url-normalize-url is confused: | |
542 (or (and normal (not (zerop (length normal))) normal) | |
543 url))))) | |
544 | |
545 | |
546 ;;; `ffap-alist': | |
547 ;; | |
548 ;; Search actions depending on the major-mode or extensions of the | |
549 ;; current name. Note all the little defun's could be broken out, at | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
550 ;; some loss of locality. A good example of featuritis. |
13531 | 551 |
552 ;; First, some helpers for functions in `ffap-alist': | |
553 | |
554 (defun ffap-list-env (env &optional empty) | |
555 ;; Replace this with parse-colon-path (lisp/files.el)? | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
556 "Directory list parsed from path envinronment variable ENV. |
13531 | 557 Optional EMPTY is default if (getenv ENV) is undefined, and is also |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
558 substituted for the first empty-string component, if there is one. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
559 Uses `path-separator' to separate the path into directories." |
13531 | 560 ;; Derived from psg-list-env in RHOGEE's ff-paths and |
561 ;; bib-cite packages. The `empty' argument is intended to mimic | |
562 ;; the semantics of TeX/BibTeX variables, it is substituted for | |
563 ;; any empty string entry. | |
564 (if (or empty (getenv env)) ; should return something | |
565 (let ((start 0) match dir ret) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
566 (setq env (concat (getenv env) path-separator)) |
13905
7df0a9cb269a
(ffap-list-env): Use `path-separator' rather than ":".
Richard M. Stallman <rms@gnu.org>
parents:
13531
diff
changeset
|
567 (while (setq match (string-match path-separator env start)) |
13531 | 568 (setq dir (substring env start match) start (1+ match)) |
569 ;;(and (file-directory-p dir) (not (member dir ret)) ...) | |
570 (setq ret (cons dir ret))) | |
571 (setq ret (nreverse ret)) | |
572 (and empty (setq match (member "" ret)) | |
573 (progn | |
574 (setcdr match (append (cdr-safe empty) (cdr match))) | |
575 (setcar match (or (car-safe empty) empty)))) | |
576 ret))) | |
577 | |
578 (defun ffap-reduce-path (path) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
579 "Remove duplicates and non-directories from PATH list." |
13531 | 580 (let (ret tem) |
581 (while path | |
582 (setq tem path path (cdr path)) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
583 (if (equal (car tem) ".") (setcar tem "")) |
13531 | 584 (or (member (car tem) ret) |
585 (not (file-directory-p (car tem))) | |
586 (progn (setcdr tem ret) (setq ret tem)))) | |
587 (nreverse ret))) | |
588 | |
589 (defun ffap-add-subdirs (path) | |
590 "Return PATH augmented with its immediate subdirectories." | |
591 ;; (ffap-add-subdirs '("/notexist" "~")) | |
592 (let (ret subs) | |
593 (while path | |
594 (mapcar | |
595 (function | |
596 (lambda (f) (and (file-directory-p f) (setq ret (cons f ret))))) | |
597 (condition-case nil | |
598 (directory-files (car path) t "[^.]") | |
599 (error nil))) | |
600 (setq ret (cons (car path) ret) | |
601 path (cdr path))) | |
602 (nreverse ret))) | |
603 | |
604 (defvar ffap-alist | |
605 ;; A big mess! Parts are probably useless. | |
606 (list | |
607 (cons "\\.info\\'" | |
608 (defun ffap-info (name) | |
16065
595d0ac6eff6
(ffap-locate-file): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14874
diff
changeset
|
609 (locate-library |
13531 | 610 name '("" ".info") |
611 (or (ffap-soft-value "Info-directory-list") | |
612 (ffap-soft-value "Info-default-directory-list") | |
613 ;; v18: | |
614 (list (ffap-soft-value "Info-directory" "~/info/")))))) | |
615 ;; Since so many info files do not have .info extension, also do this: | |
616 (cons "\\`info/" | |
617 (defun ffap-info-2 (name) (ffap-info (substring name 5)))) | |
618 (cons "\\`[-a-z]+\\'" | |
619 ;; This ignores the node! "(emacs)Top" same as "(emacs)Intro" | |
620 (defun ffap-info-3 (name) | |
621 (and (equal (ffap-string-around) "()") (ffap-info name)))) | |
622 (cons "\\.elc?\\'" | |
16065
595d0ac6eff6
(ffap-locate-file): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14874
diff
changeset
|
623 (defun ffap-el (name) (locate-library name t))) |
13531 | 624 (cons 'emacs-lisp-mode |
625 (defun ffap-el-mode (name) | |
626 ;; We do not bother with "" here, since it was considered above. | |
627 ;; Also ignore "elc", for speed (who else reads elc files?) | |
628 (and (not (string-match "\\.el\\'" name)) | |
16065
595d0ac6eff6
(ffap-locate-file): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14874
diff
changeset
|
629 (locate-library name '(".el"))))) |
13531 | 630 '(finder-mode . ffap-el-mode) ; v19: {C-h p} |
631 '(help-mode . ffap-el-mode) ; v19.29 | |
632 (cons 'c-mode | |
633 (progn | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
634 ;; Need better defaults here! |
13531 | 635 (defvar ffap-c-path '("/usr/include" "/usr/local/include")) |
636 (defun ffap-c-mode (name) | |
16065
595d0ac6eff6
(ffap-locate-file): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14874
diff
changeset
|
637 (locate-library name t ffap-c-path)))) |
13531 | 638 '(c++-mode . ffap-c-mode) |
639 '(cc-mode . ffap-c-mode) | |
640 '("\\.\\([chCH]\\|cc\\|hh\\)\\'" . ffap-c-mode) | |
641 (cons 'tex-mode | |
642 ;; Complicated because auctex may not be loaded yet. | |
643 (progn | |
644 (defvar ffap-tex-path | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
645 t ; delayed initialization |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
646 "Path where `ffap-tex-mode' looks for tex files. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
647 If t, `ffap-tex-init' will initialize this when needed.") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
648 (defun ffap-tex-init nil |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
649 ;; Compute ffap-tex-path if it is now t. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
650 (and (eq t ffap-tex-path) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
651 (message "Initializing ffap-tex-path ...") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
652 (setq ffap-tex-path |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
653 (ffap-reduce-path |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
654 (append |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
655 (list ".") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
656 (ffap-list-env "TEXINPUTS") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
657 ;; (ffap-list-env "BIBINPUTS") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
658 (ffap-add-subdirs |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
659 (ffap-list-env "TEXINPUTS_SUBDIR" |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
660 (ffap-soft-value |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
661 "TeX-macro-global" |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
662 '("/usr/local/lib/tex/macros" |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
663 "/usr/local/lib/tex/inputs") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
664 )))))))) |
13531 | 665 (defun ffap-tex-mode (name) |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
666 (ffap-tex-init) |
16065
595d0ac6eff6
(ffap-locate-file): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14874
diff
changeset
|
667 (locate-library name '(".tex" "") ffap-tex-path)))) |
13531 | 668 (cons 'latex-mode |
669 (defun ffap-latex-mode (name) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
670 (ffap-tex-init) |
13531 | 671 ;; Any real need for "" here? |
16065
595d0ac6eff6
(ffap-locate-file): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14874
diff
changeset
|
672 (locate-library name '(".cls" ".sty" ".tex" "") |
595d0ac6eff6
(ffap-locate-file): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14874
diff
changeset
|
673 ffap-tex-path))) |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
674 (cons "\\.\\(tex\\|sty\\|doc\\|cls\\)\\'" |
13531 | 675 (defun ffap-tex (name) |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
676 (ffap-tex-init) |
16065
595d0ac6eff6
(ffap-locate-file): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14874
diff
changeset
|
677 (locate-library name t ffap-tex-path))) |
13531 | 678 (cons "\\.bib\\'" |
679 (defun ffap-bib (name) | |
16065
595d0ac6eff6
(ffap-locate-file): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14874
diff
changeset
|
680 (locate-library |
13531 | 681 name t |
682 (ffap-list-env "BIBINPUTS" '("/usr/local/lib/tex/macros/bib"))))) | |
683 (cons 'math-mode | |
684 (defun ffap-math-mode (name) | |
685 (while (string-match "`" name) | |
686 (setq name (concat (substring name 0 (match-beginning 0)) | |
687 "/" | |
688 (substring name (match-end 0))))) | |
16065
595d0ac6eff6
(ffap-locate-file): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14874
diff
changeset
|
689 (locate-library |
13531 | 690 name '(".m" "") (ffap-soft-value "Mathematica-search-path")))) |
16065
595d0ac6eff6
(ffap-locate-file): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14874
diff
changeset
|
691 (cons "\\`\\." (defun ffap-home (name) (locate-library name t '("~")))) |
13531 | 692 (cons "\\`~/" |
693 ;; Maybe a "Lisp Code Directory" reference: | |
694 (defun ffap-lcd (name) | |
695 (and | |
696 (or | |
697 ;; lisp-dir-apropos output buffer: | |
698 (string-match "Lisp Code Dir" (buffer-name)) | |
699 ;; Inside an LCD entry like |~/misc/ffap.el.Z|, | |
700 ;; or maybe the holy LCD-Datafile itself: | |
701 (member (ffap-string-around) '("||" "|\n"))) | |
702 (concat | |
703 ;; lispdir.el may not be loaded yet: | |
704 (ffap-host-to-path | |
705 (ffap-soft-value "elisp-archive-host" | |
706 "archive.cis.ohio-state.edu")) | |
707 (file-name-as-directory | |
708 (ffap-soft-value "elisp-archive-directory" | |
709 "/pub/gnu/emacs/elisp-archive/")) | |
710 (substring name 2))))) | |
711 (cons "^[Rr][Ff][Cc][- #]?\\([0-9]+\\)" ; no $ | |
712 (progn | |
713 (defvar ffap-rfc-path | |
714 (concat (ffap-host-to-path "ds.internic.net") "/rfc/rfc%s.txt")) | |
715 (defun ffap-rfc (name) | |
716 (format ffap-rfc-path | |
717 (substring name (match-beginning 1) (match-end 1)))))) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
718 (cons "\\`[^/]*\\'" |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
719 (defun ffap-dired (name) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
720 (let ((pt (point)) dir try) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
721 (save-excursion |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
722 (and (progn |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
723 (beginning-of-line) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
724 (looking-at " *[-d]r[-w][-x][-r][-w][-x][-r][-w][-x] ")) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
725 (re-search-backward "^ *$" nil t) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
726 (re-search-forward "^ *\\([^ \t\n:]*\\):\n *total " pt t) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
727 (file-exists-p |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
728 (setq try |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
729 (expand-file-name |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
730 name |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
731 (buffer-substring |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
732 (match-beginning 1) (match-end 1))))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
733 try))))) |
13531 | 734 ) |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
735 "Alist of \(KEY . FUNCTION\) pairs parsed by `ffap-file-at-point'. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
736 If string NAME at point (maybe \"\") is not a file or url, these pairs |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
737 specify actions to try creating such a string. A pair matches if either |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
738 KEY is a symbol, and it equals `major-mode', or |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
739 KEY is a string, it should matches NAME as a regexp. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
740 On a match, \(FUNCTION NAME\) is called and should return a file, an |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
741 url, or nil. If nil, search the alist for further matches.") |
13531 | 742 |
743 (put 'ffap-alist 'risky-local-variable t) | |
744 | |
745 | |
746 ;;; At-Point Functions: | |
747 | |
748 (defvar ffap-string-at-point-mode-alist | |
749 '( | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
750 ;; The default, used when the `major-mode' is not found. |
13531 | 751 ;; Slightly controversial decisions: |
752 ;; * strip trailing "@" and ":" | |
753 ;; * no commas (good for latex) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
754 (file "--:$+<>@-Z_a-z~" "<@" "@>;.,!?:") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
755 ;; An url, or maybe a email/news message-id: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
756 (url "--:?$+@-Z_a-z~#,%" "^A-Za-z0-9" ":;.,!?") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
757 ;; Find a string that does *not* contain a colon: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
758 (nocolon "--9$+<>@-Z_a-z~" "<@" "@>;.,!?") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
759 ;; A machine: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
760 (machine "-a-zA-Z0-9." "" ".") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
761 ;; Mathematica paths: allow backquotes |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
762 (math-mode ",-:$+<>@-Z_a-z~`" "<" "@>;.,!?`:") |
13531 | 763 ) |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
764 "Alist of \(MODE CHARS BEG END\), where MODE is a symbol, |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
765 possibly a `major-mode' or some symbol internal to ffap |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
766 \(such as 'file, 'url, 'machine, and 'nocolon\). |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
767 `ffap-string-at-point' uses the data fields as follows: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
768 1. find a maximal string of CHARS around point, |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
769 2. strip BEG chars before point from the beginning, |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
770 3. Strip END chars after point from the end.") |
13531 | 771 |
772 (defvar ffap-string-at-point-region '(1 1) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
773 "List (BEG END), last region returned by `ffap-string-at-point'.") |
13531 | 774 |
775 (defvar ffap-string-at-point nil | |
776 ;; Added at suggestion of RHOGEE (for ff-paths), 7/24/95. | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
777 "Last string returned by `ffap-string-at-point'.") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
778 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
779 (defun ffap-string-at-point (&optional mode) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
780 "Return a string of characters from around point. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
781 MODE (defaults to `major-mode') is a symbol used to lookup string |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
782 syntax parameters in `ffap-string-at-point-mode-alist'. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
783 If MODE is not found, we fall back on the symbol 'file. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
784 Sets `ffap-string-at-point' and `ffap-string-at-point-region'." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
785 (let* ((args |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
786 (cdr |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
787 (or (assq (or mode major-mode) ffap-string-at-point-mode-alist) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
788 (assq 'file ffap-string-at-point-mode-alist)))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
789 (pt (point)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
790 (str |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
791 (buffer-substring |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
792 (save-excursion |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
793 (skip-chars-backward (car args)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
794 (skip-chars-forward (nth 1 args) pt) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
795 (setcar ffap-string-at-point-region (point))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
796 (save-excursion |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
797 (skip-chars-forward (car args)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
798 (skip-chars-backward (nth 2 args) pt) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
799 (setcar (cdr ffap-string-at-point-region) (point)))))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
800 (or ffap-xemacs (set-text-properties 0 (length str) nil str)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
801 (setq ffap-string-at-point str))) |
13531 | 802 |
803 (defun ffap-string-around nil | |
804 ;; Sometimes useful to decide how to treat a string. | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
805 "Return string of two chars around last `ffap-string-at-point'. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
806 Assumes the buffer has not changed." |
13531 | 807 (save-excursion |
808 (format "%c%c" | |
809 (progn | |
810 (goto-char (car ffap-string-at-point-region)) | |
811 (preceding-char)) ; maybe 0 | |
812 (progn | |
813 (goto-char (nth 1 ffap-string-at-point-region)) | |
814 (following-char)) ; maybe 0 | |
815 ))) | |
816 | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
817 (defun ffap-copy-string-as-kill (&optional mode) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
818 ;; Requested by MCOOK. Useful? |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
819 "Call `ffap-string-at-point', and copy result to `kill-ring'." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
820 (interactive) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
821 (let ((str (ffap-string-at-point mode))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
822 (if (equal "" str) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
823 (message "No string found around point.") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
824 (kill-new str) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
825 ;; Older: (apply 'copy-region-as-kill ffap-string-at-point-region) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
826 (message "Copied to kill ring: %s" str)))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
827 |
13531 | 828 (defun ffap-url-at-point nil |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
829 "Return url from around point if it exists, or nil." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
830 ;; Could use w3's url-get-url-at-point instead. Both handle "URL:", |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
831 ;; ignore non-relative links, trim punctuation. The other will |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
832 ;; actually look back if point is in whitespace, but I would rather |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
833 ;; ffap be non-rabid in such situations. |
13531 | 834 (and |
835 ffap-url-regexp | |
836 (or | |
837 ;; In a w3 buffer button zone? | |
838 (let (tem) | |
839 (and (eq major-mode 'w3-mode) | |
840 ;; assume: (boundp 'w3-zone-at) (boundp 'w3-zone-data) | |
841 (setq tem (w3-zone-at (point))) | |
842 (consp (setq tem (w3-zone-data tem))) | |
843 (nth 2 tem))) | |
844 ;; Is there a reason not to strip trailing colon? | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
845 (let ((name (ffap-string-at-point 'url))) |
13531 | 846 ;; (case-fold-search t), why? |
847 (cond | |
848 ((string-match "^url:" name) (setq name (substring name 4))) | |
849 ((and (string-match "\\`[^:</>@]+@[^:</>@]+[a-zA-Z]\\'" name) | |
850 ;; "foo@bar": could be "mailto" or "news" (a Message-ID). | |
851 ;; If not adorned with "<>", it must be "mailto". | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
852 ;; Otherwise could be either, so consult `ffap-foo-at-bar-prefix'. |
13531 | 853 (let ((prefix (if (and (equal (ffap-string-around) "<>") |
854 ;; At least a couple of odd characters: | |
855 (string-match "[$.0-9].*[$.0-9].*@" name)) | |
856 ;; Could be news: | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
857 ffap-foo-at-bar-prefix |
13531 | 858 "mailto"))) |
859 (and prefix (setq name (concat prefix ":" name)))))) | |
860 ((ffap-newsgroup-p name) (setq name (concat "news:" name))) | |
861 ((and (string-match "\\`[a-z0-9]+\\'" name) ; <mic> <root> <nobody> | |
862 (equal (ffap-string-around) "<>") | |
863 ;; (ffap-user-p name): | |
864 (not (string-match "~" (expand-file-name (concat "~" name)))) | |
865 ) | |
866 (setq name (concat "mailto:" name))) | |
867 ) | |
868 (and (ffap-url-p name) name) | |
869 )))) | |
870 | |
871 (defvar ffap-gopher-regexp | |
872 "^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$" | |
873 "Regexp Matching a line in a gopher bookmark (maybe indented). | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
874 The two subexpressions are the KEY and VALUE.") |
13531 | 875 |
876 (defun ffap-gopher-at-point nil | |
877 "If point is inside a gopher bookmark block, return its url." | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
878 ;; `gopher-parse-bookmark' from gopher.el is not so robust |
13531 | 879 (save-excursion |
880 (beginning-of-line) | |
881 (if (looking-at ffap-gopher-regexp) | |
882 (progn | |
883 (while (and (looking-at ffap-gopher-regexp) (not (bobp))) | |
884 (forward-line -1)) | |
885 (or (looking-at ffap-gopher-regexp) (forward-line 1)) | |
886 (let ((type "1") name path host (port "70")) | |
887 (while (looking-at ffap-gopher-regexp) | |
888 (let ((var (intern | |
889 (downcase | |
890 (buffer-substring (match-beginning 1) | |
891 (match-end 1))))) | |
892 (val (buffer-substring (match-beginning 2) | |
893 (match-end 2)))) | |
894 (set var val) | |
895 (forward-line 1))) | |
896 (if (and path (string-match "^ftp:.*@" path)) | |
897 (concat "ftp://" | |
898 (substring path 4 (1- (match-end 0))) | |
899 (substring path (match-end 0))) | |
900 (and (= (length type) 1) | |
901 host;; (ffap-machine-p host) | |
902 (concat "gopher://" host | |
903 (if (equal port "70") "" (concat ":" port)) | |
904 "/" type path)))))))) | |
905 | |
906 (defvar ffap-ftp-sans-slash-regexp | |
907 (and | |
908 ffap-ftp-regexp | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
909 ;; Note: by now, we know it is not an url. |
13531 | 910 ;; Icky regexp avoids: default: 123: foo::bar cs:pub |
911 ;; It does match on: mic@cs: cs:/pub mathcs.emory.edu: (point at end) | |
912 "\\`\\([^:@]+@[^:@]+:\\|[^@.:]+\\.[^@:]+:\\|[^:]+:[~/]\\)\\([^:]\\|\\'\\)") | |
913 "Strings matching this are coerced to ftp paths by ffap. | |
914 That is, ffap just prepends \"/\". Set to nil to disable.") | |
915 | |
916 (defun ffap-file-at-point nil | |
917 "Return filename from around point if it exists, or nil. | |
918 Existence test is skipped for names that look remote. | |
919 If the filename is not obvious, it also tries `ffap-alist', | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
920 which may actually result in an url rather than a filename." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
921 ;; Note: this function does not need to look for url's, just |
13531 | 922 ;; filenames. On the other hand, it is responsible for converting |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
923 ;; a pseudo-url "site.com://path" to an ftp path |
13531 | 924 (let* ((case-fold-search t) ; url prefixes are case-insensitive |
925 (data (match-data)) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
926 (string (ffap-string-at-point)) ; uses mode alist |
13531 | 927 (name |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
928 (or (condition-case nil |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
929 (and (not (string-match "//" string)) ; foo.com://bar |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
930 (substitute-in-file-name string)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
931 (error nil)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
932 string)) |
13531 | 933 (abs (file-name-absolute-p name)) |
934 (default-directory default-directory)) | |
935 (unwind-protect | |
936 (cond | |
937 ;; Immediate rejects (/ and // are too common in C++): | |
938 ((member name '("" "/" "//")) nil) | |
939 ;; Immediately test local filenames. If default-directory is | |
940 ;; remote, you probably already have a connection. | |
941 ((and (not abs) (ffap-file-exists-string name))) | |
942 ;; Accept remote names without actual checking (too slow): | |
943 ((if abs | |
944 (ffap-file-remote-p name) | |
945 ;; Try adding a leading "/" (common omission in ftp paths): | |
946 (and | |
947 ffap-ftp-sans-slash-regexp | |
948 (string-match ffap-ftp-sans-slash-regexp name) | |
949 (ffap-file-remote-p (concat "/" name))))) | |
950 ;; Ok, not remote, try the existence test even if it is absolute: | |
951 ((and abs (ffap-file-exists-string name))) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
952 ;; If it contains a colon, get rid of it (and return if exists) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
953 ((and (string-match path-separator name) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
954 (setq name (ffap-string-at-point 'nocolon)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
955 (ffap-file-exists-string name))) |
13531 | 956 ;; File does not exist, try the alist: |
957 ((let ((alist ffap-alist) tem try case-fold-search) | |
958 (while (and alist (not try)) | |
959 (setq tem (car alist) alist (cdr alist)) | |
960 (if (or (eq major-mode (car tem)) | |
961 (and (stringp (car tem)) | |
962 (string-match (car tem) name))) | |
963 (and (setq try (funcall (cdr tem) name)) | |
964 (setq try (or | |
965 (ffap-url-p try) ; not a file! | |
966 (ffap-file-remote-p try) | |
967 (ffap-file-exists-string try)))))) | |
968 try)) | |
969 ;; Alist failed? Try to guess an active remote connection | |
970 ;; from buffer variables, and try once more, both as an | |
971 ;; absolute and relative path on that remote host. | |
972 ((let* (ffap-rfs-regexp ; suppress | |
973 (remote-dir | |
974 (cond | |
975 ((ffap-file-remote-p default-directory)) | |
976 ((and (eq major-mode 'internal-ange-ftp-mode) | |
977 (string-match "^\\*ftp \\(.*\\)@\\(.*\\)\\*$" | |
978 (buffer-name))) | |
979 (concat "/" (substring (buffer-name) 5 -1) ":")) | |
980 ;; This is too often a bad idea: | |
981 ;;((and (eq major-mode 'w3-mode) | |
982 ;; (stringp url-current-server)) | |
983 ;; (host-to-ange-path url-current-server)) | |
984 ))) | |
985 (and remote-dir | |
986 (or | |
987 (and (string-match "\\`\\(/?~?ftp\\)/" name) | |
988 (ffap-file-exists-string | |
989 (ffap-replace-path-component | |
990 remote-dir (substring name (match-end 1))))) | |
991 (ffap-file-exists-string | |
992 (ffap-replace-path-component remote-dir name)))))) | |
993 ) | |
994 (store-match-data data)))) | |
995 | |
996 | |
997 ;;; ffap-read-file-or-url: | |
998 ;; | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
999 ;; We want to complete filenames as in read-file-name, but also url's |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1000 ;; which read-file-name-internal would truncate at the "//" string. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1001 ;; The solution here is to replace read-file-name-internal with |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1002 ;; `ffap-read-file-or-url-internal', which checks the minibuffer |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1003 ;; contents before attempting to complete filenames. |
13531 | 1004 |
1005 (defun ffap-read-file-or-url (prompt guess) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1006 "Read file or url from minibuffer, with PROMPT and initial GUESS." |
13531 | 1007 (or guess (setq guess default-directory)) |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1008 (let (dir) |
13531 | 1009 ;; Tricky: guess may have or be a local directory, like "w3/w3.elc" |
1010 ;; or "w3/" or "../el/ffap.el" or "../../../" | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1011 (or (ffap-url-p guess) |
13531 | 1012 (progn |
1013 (or (ffap-file-remote-p guess) | |
1014 (setq guess (abbreviate-file-name (expand-file-name guess)))) | |
1015 (setq dir (file-name-directory guess)))) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1016 (setq guess |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1017 (completing-read |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1018 prompt |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1019 'ffap-read-file-or-url-internal |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1020 dir |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1021 nil |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1022 (if dir (cons guess (length dir)) guess) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1023 (list 'file-name-history) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1024 )) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1025 ;; Do file substitution like (interactive "F"), suggested by MCOOK. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1026 (or (ffap-url-p guess) (setq guess (substitute-in-file-name guess))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1027 ;; Should not do it on url's, where $ is a common (VMS?) character. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1028 ;; Note: upcoming url.el package ought to handle this automatically. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1029 guess)) |
13531 | 1030 |
1031 (defun ffap-read-url-internal (string dir action) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1032 "Complete url's from history, treating given string as valid." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1033 (let ((hist (ffap-soft-value "url-global-history-hash-table"))) |
13531 | 1034 (cond |
1035 ((not action) | |
1036 (or (try-completion string hist) string)) | |
1037 ((eq action t) | |
1038 (or (all-completions string hist) (list string))) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1039 ;; action == lambda, documented where? Tests whether string is a |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1040 ;; valid "match". Let us always say yes. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1041 (t t)))) |
13531 | 1042 |
1043 (defun ffap-read-file-or-url-internal (string dir action) | |
1044 (if (ffap-url-p string) | |
1045 (ffap-read-url-internal string dir action) | |
1046 (read-file-name-internal string dir action))) | |
1047 | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1048 ;; The rest of this page is just to work with package complete.el. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1049 ;; This code assumes that you load ffap.el after complete.el. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1050 ;; |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1051 ;; We must inform complete about whether our completion function |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1052 ;; will do filename style completion. For earlier versions of |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1053 ;; complete.el, this requires a defadvice. For recent versions |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1054 ;; there may be a special variable for this purpose. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1055 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1056 (defun ffap-complete-as-file-p nil |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1057 ;; Will `minibuffer-completion-table' complete the minibuffer |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1058 ;; contents as a filename? Assumes the minibuffer is current. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1059 ;; Note: t and non-nil mean somewhat different reasons. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1060 (if (eq minibuffer-completion-table 'ffap-read-file-or-url-internal) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1061 (not (ffap-url-p (buffer-string))) ; t |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1062 (memq minibuffer-completion-table |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1063 '(read-file-name-internal read-directory-name-internal)) ; list |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1064 )) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1065 |
13531 | 1066 (and |
1067 (featurep 'complete) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1068 (if (boundp 'PC-completion-as-file-name-predicate) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1069 ;; modern version of complete.el, just set the variable: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1070 (setq PC-completion-as-file-name-predicate 'ffap-complete-as-file-p) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1071 (require 'advice) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1072 (defadvice PC-do-completion (around ffap-fix act) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1073 "Work with ffap." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1074 (let ((minibuffer-completion-table |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1075 (if (eq t (ffap-complete-as-file-p)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1076 'read-file-name-internal |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1077 minibuffer-completion-table))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1078 ad-do-it)))) |
13531 | 1079 |
1080 | |
1081 ;;; Highlighting: | |
1082 ;; | |
1083 ;; Based on overlay highlighting in Emacs 19.28 isearch.el. | |
1084 | |
1085 (defvar ffap-highlight (and window-system t) | |
1086 "If non-nil, ffap highlights the current buffer substring.") | |
1087 | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1088 (defvar ffap-highlight-overlay nil "Overlay used by `ffap-highlight'.") |
13531 | 1089 |
1090 (defun ffap-highlight (&optional remove) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1091 "If `ffap-highlight' is set, highlight the guess in this buffer. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1092 That is, the last buffer substring found by `ffap-string-at-point'. |
13531 | 1093 Optional argument REMOVE means to remove any such highlighting. |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1094 Uses the face `ffap' if it is defined, or else `highlight'." |
13531 | 1095 (cond |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1096 (remove (and ffap-highlight-overlay (delete-overlay ffap-highlight-overlay))) |
13531 | 1097 ((not ffap-highlight) nil) |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1098 (ffap-highlight-overlay |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1099 (move-overlay ffap-highlight-overlay |
13531 | 1100 (car ffap-string-at-point-region) |
1101 (nth 1 ffap-string-at-point-region) | |
1102 (current-buffer))) | |
1103 (t | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1104 (setq ffap-highlight-overlay (apply 'make-overlay ffap-string-at-point-region)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1105 (overlay-put ffap-highlight-overlay 'face |
13531 | 1106 (if (internal-find-face 'ffap nil) |
1107 'ffap 'highlight))))) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1108 |
13531 | 1109 |
1110 ;;; The big enchilada: | |
1111 | |
1112 (defun ffap-guesser nil | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1113 "Return file or url or nil, guessed from text around point." |
13531 | 1114 (or (and ffap-url-regexp |
1115 (ffap-fixup-url (or (ffap-url-at-point) | |
1116 (ffap-gopher-at-point)))) | |
1117 (ffap-file-at-point) ; may yield url! | |
1118 (ffap-fixup-machine (ffap-machine-at-point)))) | |
1119 | |
1120 (defun ffap-prompter (&optional guess) | |
1121 ;; Does guess and prompt step for find-file-at-point. | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1122 ;; Extra complication for the temporary highlighting. |
13531 | 1123 (unwind-protect |
1124 (ffap-read-file-or-url | |
1125 (if ffap-url-regexp "Find file or URL: " "Find file: ") | |
1126 (prog1 | |
1127 (setq guess (or guess (ffap-guesser))) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1128 (and guess (ffap-highlight)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1129 )) |
13531 | 1130 (ffap-highlight t))) |
1131 | |
1132 ;;;###autoload | |
1133 (defun find-file-at-point (&optional filename) | |
1134 "Find FILENAME (or url), guessing default from text around point. | |
1135 If `ffap-dired-wildcards' is set, wildcard patterns are passed to dired. | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1136 See also the functions `ffap-file-at-point', `ffap-url-at-point'. |
13531 | 1137 With a prefix, this command behaves *exactly* like `ffap-file-finder'. |
1138 If `ffap-require-prefix' is set, the prefix meaning is reversed. | |
1139 | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1140 See <ftp://ftp.mathcs.emory.edu/pub/mic/emacs/> for latest version." |
13531 | 1141 (interactive) |
1142 (if (and (interactive-p) | |
1143 (if ffap-require-prefix (not current-prefix-arg) | |
1144 current-prefix-arg)) | |
1145 ;; Do exactly the ffap-file-finder command, even the prompting: | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1146 (let (current-prefix-arg) ; we already interpreted it |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1147 (call-interactively ffap-file-finder)) |
13531 | 1148 (or filename (setq filename (ffap-prompter))) |
1149 (cond | |
1150 ((ffap-url-p filename) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1151 (let (current-prefix-arg) ; w3 2.3.25 bug, reported by KPC |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1152 (funcall ffap-url-fetcher filename))) |
13531 | 1153 ;; This junk more properly belongs in a modified ffap-file-finder: |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1154 ((and ffap-dired-wildcards |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1155 (string-match ffap-dired-wildcards filename)) |
13531 | 1156 (dired filename)) |
1157 ((or (not ffap-newfile-prompt) | |
1158 (file-exists-p filename) | |
1159 (y-or-n-p "File does not exist, create buffer? ")) | |
1160 (funcall ffap-file-finder | |
1161 ;; expand-file-name fixes "~/~/.emacs" bug sent by CHUCKR. | |
1162 (expand-file-name filename))) | |
1163 ;; User does not want to find a non-existent file: | |
1164 ((signal 'file-error (list "Opening file buffer" | |
1165 "no such file or directory" | |
1166 filename)))))) | |
1167 | |
1168 ;; M-x shortcut: | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1169 ;;###autoload |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1170 (defalias 'ffap 'find-file-at-point) |
13531 | 1171 |
1172 | |
1173 ;;; Menu support: | |
1174 ;; | |
1175 ;; Bind ffap-menu to a key if you want, since it also works in tty mode. | |
1176 ;; Or just use it through the ffap-at-mouse binding (next section). | |
1177 | |
1178 (defvar ffap-menu-regexp nil | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1179 "*If non-nil, overrides `ffap-next-regexp' during `ffap-menu'. |
13531 | 1180 Make this more restrictive for faster menu building. |
1181 For example, try \":/\" for url (and some ftp) references.") | |
1182 | |
1183 (defvar ffap-menu-alist nil | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1184 "Buffer local cache of menu presented by `ffap-menu'.") |
13531 | 1185 (make-variable-buffer-local 'ffap-menu-alist) |
1186 | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1187 (defvar ffap-menu-text-plist |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1188 (and window-system |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1189 ;; These choices emulate goto-addr: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1190 (if ffap-xemacs |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1191 '(face bold highlight t) ; keymap <map> |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1192 '(face bold mouse-face highlight) ; keymap <mousy-map> |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1193 )) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1194 "Text properties applied to strings found by `ffap-menu-rescan'. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1195 These properties may be used to fontify the menu references.") |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1196 |
13531 | 1197 ;;;###autoload |
1198 (defun ffap-menu (&optional rescan) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1199 "Put up a menu of files and urls mentioned in this buffer. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1200 Then set mark, jump to choice, and try to fetch it. The menu is |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1201 cached in `ffap-menu-alist', and rebuilt by `ffap-menu-rescan'. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1202 The optional RESCAN argument \(a prefix, interactively\) forces |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1203 a rebuild. Searches with `ffap-menu-regexp'." |
13531 | 1204 (interactive "P") |
1205 ;; (require 'imenu) -- no longer used, but roughly emulated | |
1206 (if (or (not ffap-menu-alist) rescan | |
1207 ;; or if the first entry is wrong: | |
1208 (and ffap-menu-alist | |
1209 (let ((first (car ffap-menu-alist))) | |
1210 (save-excursion | |
1211 (goto-char (cdr first)) | |
1212 (not (equal (car first) (ffap-guesser))))))) | |
1213 (ffap-menu-rescan)) | |
1214 ;; Tail recursive: | |
1215 (ffap-menu-ask | |
1216 (if ffap-url-regexp "Find file or URL" "Find file") | |
1217 (cons (cons "*Rescan Buffer*" -1) ffap-menu-alist) | |
1218 'ffap-menu-cont)) | |
1219 | |
1220 (defun ffap-menu-cont (choice) ; continuation of ffap-menu | |
1221 (if (< (cdr choice) 0) | |
1222 (ffap-menu t) ; *Rescan* | |
1223 (push-mark) | |
1224 (goto-char (cdr choice)) | |
1225 ;; Momentary highlight: | |
1226 (unwind-protect | |
1227 (progn | |
1228 (and ffap-highlight (ffap-guesser) (ffap-highlight)) | |
1229 (sit-for 0) ; display | |
1230 (find-file-at-point (car choice))) | |
1231 (ffap-highlight t)))) | |
1232 | |
1233 (defun ffap-menu-ask (title alist cont) | |
1234 "Prompt from a menu of choices, and then apply some action. | |
1235 Arguments are TITLE, ALIST, and CONT (a continuation). | |
1236 This uses either a menu or the minibuffer depending on invocation. | |
1237 The TITLE string is used as either the prompt or menu title. | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1238 Each \(string . data\) ALIST entry defines a choice \(data is ignored\). |
13531 | 1239 Once the user makes a choice, function CONT is applied to the entry. |
1240 Always returns nil." | |
1241 ;; Bug: minibuffer prompting assumes the strings are unique. | |
1242 (let ((choice | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1243 (if (and (fboundp 'x-popup-menu) ; Emacs 19 or XEmacs 19.13 |
13531 | 1244 (boundp 'last-nonmenu-event) ; not in XEmacs 19.13 |
1245 (listp last-nonmenu-event)) | |
1246 (x-popup-menu | |
1247 t | |
1248 (list "" | |
1249 (cons title | |
1250 (mapcar | |
1251 (function (lambda (i) (cons (car i) i))) | |
1252 alist)))) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1253 ;; Immediately popup completion buffer: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1254 (prog1 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1255 (let ((minibuffer-setup-hook 'minibuffer-completion-help)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1256 ;; BUG: this code assumes that "" is not a valid choice |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1257 (completing-read |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1258 (format "%s (default %s): " title (car (car alist))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1259 alist nil t |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1260 ;; (cons (car (car alist)) 0) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1261 nil |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1262 )) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1263 ;; Redraw original screen: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1264 (sit-for 0))))) |
13531 | 1265 ;; Defaulting: convert "" to (car (car alist)) |
1266 (and (equal choice "") (setq choice (car (car alist)))) | |
1267 (and (stringp choice) (setq choice (assoc choice alist))) | |
1268 (if choice (funcall cont choice) (message "No choice made!"))) | |
1269 nil) ; return nothing | |
1270 | |
1271 (defun ffap-menu-rescan nil | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1272 "Search buffer for `ffap-menu-regexp' to build `ffap-menu-alist'. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1273 Applies `ffap-menu-text-plist' text properties at all matches." |
13531 | 1274 (interactive) |
1275 (let ((ffap-next-regexp (or ffap-menu-regexp ffap-next-regexp)) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1276 (range (- (point-max) (point-min))) item |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1277 buffer-read-only ; to set text-properties |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1278 ;; Avoid repeated searches of the *mode-alist: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1279 (major-mode (if (assq major-mode ffap-string-at-point-mode-alist) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1280 major-mode |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1281 'file)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1282 ) |
13531 | 1283 (setq ffap-menu-alist nil) |
1284 (save-excursion | |
1285 (goto-char (point-min)) | |
1286 (while (setq item (ffap-next-guess)) | |
1287 (setq ffap-menu-alist (cons (cons item (point)) ffap-menu-alist)) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1288 (add-text-properties (car ffap-string-at-point-region) (point) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1289 ffap-menu-text-plist) |
13531 | 1290 (message "Scanning...%2d%% <%s>" |
1291 (/ (* 100 (- (point) (point-min))) range) item)))) | |
1292 (message "Scanning...done") | |
1293 ;; Remove duplicates. | |
1294 (setq ffap-menu-alist ; sort by item | |
1295 (sort ffap-menu-alist | |
1296 (function | |
1297 (lambda (a b) (string-lessp (car a) (car b)))))) | |
1298 (let ((ptr ffap-menu-alist)) | |
1299 (while (cdr ptr) | |
1300 (if (equal (car (car ptr)) (car (car (cdr ptr)))) | |
1301 (setcdr ptr (cdr (cdr ptr))) | |
1302 (setq ptr (cdr ptr))))) | |
1303 (setq ffap-menu-alist ; sort by position | |
1304 (sort ffap-menu-alist | |
1305 (function | |
1306 (lambda (a b) (< (cdr a) (cdr b))))))) | |
1307 | |
1308 | |
1309 ;;; Mouse Support: | |
1310 ;; | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1311 ;; See the suggested binding in ffap-bindings (near eof). |
13531 | 1312 |
1313 (defvar ffap-at-mouse-fallback 'ffap-menu | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1314 "Invoked by `ffap-at-mouse' if no file or url at click. |
13531 | 1315 A command symbol, or nil for nothing.") |
1316 (put 'ffap-at-mouse-fallback 'risky-local-variable t) | |
1317 | |
1318 (defun ffap-at-mouse (e) | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1319 "Find file or url guessed from text around mouse point. |
13531 | 1320 If none is found, call `ffap-at-mouse-fallback'." |
1321 (interactive "e") | |
1322 (let ((guess | |
1323 ;; Maybe less surprising without the save-excursion? | |
1324 (save-excursion | |
1325 (mouse-set-point e) | |
1326 ;; Would like to do nothing unless click was *on* text. How? | |
1327 ;; (cdr (posn-col-row (event-start e))) is always same as | |
1328 ;; current column. For posn-x-y, need pixel-width! | |
1329 (ffap-guesser)))) | |
1330 (cond | |
1331 (guess | |
1332 (ffap-highlight) | |
1333 (unwind-protect | |
1334 (progn | |
1335 (sit-for 0) ; display | |
1336 (message "Guessing `%s'" guess) | |
1337 (find-file-at-point guess)) | |
1338 (ffap-highlight t))) | |
1339 ((and (interactive-p) | |
1340 ffap-at-mouse-fallback) | |
1341 (call-interactively ffap-at-mouse-fallback)) | |
1342 ((message "No file or URL found at mouse click."))))) | |
1343 | |
1344 | |
1345 ;;; ffap-other-* commands | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1346 ;; Suggested by KPC. |
13531 | 1347 |
1348 (defun ffap-other-window nil | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1349 "Like `ffap', but put buffer in another window." |
13531 | 1350 (interactive) |
1351 (switch-to-buffer-other-window | |
1352 (save-window-excursion (call-interactively 'ffap) (current-buffer)))) | |
1353 | |
1354 (defun ffap-other-frame nil | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1355 "Like `ffap', but put buffer in another frame." |
13531 | 1356 (interactive) |
1357 (switch-to-buffer-other-frame | |
1358 (save-window-excursion (call-interactively 'ffap) (current-buffer)))) | |
1359 | |
1360 | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1361 ;;; Bug Reporter: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1362 |
13531 | 1363 (defun ffap-bug nil |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1364 "Submit a bug report for the ffap package." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1365 ;; Important: keep the version string here in synch with that at top |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1366 ;; of file! Could use lisp-mnt from Emacs 19, but that would depend |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1367 ;; on being able to find the ffap.el source file. |
13531 | 1368 (interactive) |
1369 (require 'reporter) | |
1370 (let ((reporter-prompt-for-summary-p t)) | |
1371 (reporter-submit-bug-report | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1372 "Michelangelo Grigni <mic@mathcs.emory.edu>" |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1373 "ffap 1.6" |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1374 (mapcar 'intern (all-completions "ffap-" obarray 'boundp))))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1375 |
13531 | 1376 (fset 'ffap-submit-bug 'ffap-bug) ; another likely name |
1377 | |
1378 | |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1379 ;;; Hooks for Gnus, VM, Rmail: |
13531 | 1380 ;; |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1381 ;; If you do not like these bindings, write versions with whatever |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1382 ;; bindings you would prefer. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1383 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1384 (defun ffap-ro-mode-hook nil |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1385 "Bind `ffap-next' and `ffap-menu' to M-l and M-m, resp." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1386 (local-set-key "\M-l" 'ffap-next) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1387 (local-set-key "\M-m" 'ffap-menu) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1388 ) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1389 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1390 (defun ffap-gnus-hook nil |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1391 "Bind `ffap-gnus-next' and `ffap-gnus-menu' to M-l and M-m, resp." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1392 (set (make-local-variable 'ffap-foo-at-bar-prefix) "news") ; message-id's |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1393 ;; Note "l", "L", "m", "M" are taken: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1394 (local-set-key "\M-l" 'ffap-gnus-next) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1395 (local-set-key "\M-m" 'ffap-gnus-menu)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1396 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1397 (defun ffap-gnus-wrapper (form) ; used by both commands below |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1398 (and (eq (current-buffer) (get-buffer gnus-summary-buffer)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1399 (gnus-summary-select-article)) ; get article of current line |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1400 ;; Preserve selected buffer, but do not do save-window-excursion, |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1401 ;; since we want to see any window created by the form. Temporarily |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1402 ;; select the article buffer, so we can see any point movement. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1403 (let ((sb (window-buffer (selected-window)))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1404 (gnus-configure-windows 'article) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1405 (pop-to-buffer gnus-article-buffer) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1406 (widen) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1407 ;; Skip headers for ffap-gnus-next (which will wrap around) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1408 (if (eq (point) (point-min)) (search-forward "\n\n" nil t)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1409 (unwind-protect |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1410 (eval form) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1411 (pop-to-buffer sb)))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1412 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1413 (defun ffap-gnus-next nil |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1414 "Run `ffap-next' in the gnus article buffer." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1415 (interactive) (ffap-gnus-wrapper '(ffap-next nil t))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1416 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1417 (defun ffap-gnus-menu nil |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1418 "Run `ffap-menu' in the gnus article buffer." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1419 (interactive) (ffap-gnus-wrapper '(ffap-menu))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1420 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1421 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1422 ;;; ffap-bindings: offer default global bindings |
13531 | 1423 |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1424 (defvar ffap-bindings |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1425 (nconc |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1426 (cond |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1427 ((not (eq window-system 'x)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1428 nil) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1429 ;; GNU coding standards say packages should not bind S-mouse-*. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1430 ;; Is it ok to simply suggest such a binding to the user? |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1431 (ffap-xemacs |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1432 '((global-set-key '(shift button3) 'ffap-at-mouse))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1433 (t |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1434 '((global-set-key [S-down-mouse-3] 'ffap-at-mouse)))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1435 '( |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1436 (global-set-key "\C-x\C-f" 'find-file-at-point) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1437 (global-set-key "\C-x4f" 'ffap-other-window) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1438 (global-set-key "\C-x5f" 'ffap-other-frame) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1439 (add-hook 'gnus-summary-mode-hook 'ffap-gnus-hook) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1440 (add-hook 'gnus-article-mode-hook 'ffap-gnus-hook) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1441 (add-hook 'vm-mode-hook 'ffap-ro-mode-hook) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1442 (add-hook 'rmail-mode-hook 'ffap-ro-mode-hook) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1443 ;; (setq dired-x-hands-off-my-keys t) ; the default |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1444 )) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1445 "List of forms evaluated by function `ffap-bindings'. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1446 A reasonable ffap installation needs just these two lines: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1447 (require 'ffap) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1448 (ffap-bindings) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1449 These are only suggestions, they may be modified or ignored.") |
13531 | 1450 |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1451 (defun ffap-bindings nil |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1452 "Evaluate the forms in variable `ffap-bindings'." |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1453 (eval (cons 'progn ffap-bindings))) |
13531 | 1454 |
14874
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1455 ;; Example modifications: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1456 ;; |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1457 ;; (setq ffap-alist ; remove a feature in `ffap-alist' |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1458 ;; (delete (assoc 'c-mode ffap-alist) ffap-alist)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1459 ;; |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1460 ;; (setq ffap-alist ; add something to `ffap-alist' |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1461 ;; (cons |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1462 ;; (cons "^[Yy][Ss][Nn][0-9]+$" |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1463 ;; (defun ffap-ysn (name) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1464 ;; (concat |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1465 ;; "http://snorri.chem.washington.edu/ysnarchive/issuefiles/" |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1466 ;; (substring name 3) ".html"))) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1467 ;; ffap-alist)) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1468 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1469 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1470 ;;; XEmacs: |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1471 ;; Extended suppport in another file, for copyright reasons. |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1472 (or (not ffap-xemacs) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1473 (load "ffap-xe" t t) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1474 (message "ffap warning: ffap-xe.el not found")) |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1475 |
cecaaaec6fd6
Doc fixes. Reorganized. Retired v18 support.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1476 |
13531 | 1477 ;;; ffap.el ends here |