annotate lisp/find-file.el @ 107102:3554839df1fc

Fix setting family and foundry in set-face-attribute (Bug#5536). * faces.el (set-face-attribute): Allow calling internal-set-lisp-face-attribute with 'unspecified family and foundry argument (Bug#5536).
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 06 Feb 2010 23:14:26 -0500
parents 1d1d5d9bd884
children 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; find-file.el --- find a file corresponding to this one given a pattern
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
18127
6316f98dda40 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 18119
diff changeset
3 ;; Author: Henry Guillaume <henri@tibco.com, henry@c032.aone.net.au>
21057
9b9c929675eb Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 18127
diff changeset
4 ;; Maintainer: FSF
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Keywords: c, matching, tools
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
74439
ddcbd2c1b70d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 71923
diff changeset
7 ;; Copyright (C) 1994, 1995, 2001, 2002, 2003, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105965
diff changeset
8 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13896
diff changeset
10 ;; This file is part of GNU Emacs.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79721
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13896
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79721
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79721
diff changeset
15 ;; (at your option) any later version.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13896
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13896
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13896
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13896
diff changeset
20 ;; GNU General Public License for more details.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13896
diff changeset
22 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79721
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; PURPOSE:
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
28 ;; This package features a function called ff-find-other-file, which performs
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
29 ;; the following function:
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; When in a .c file, find the first corresponding .h file in a set
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; of directories and display it, and vice-versa from the .h file.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; Many people maintain their include file in a directory separate to their
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; src directory, and very often you may be editing a file and have a need to
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; visit the "other file". This package searches through a set of directories
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; to find that file.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; THE "OTHER FILE", or "corresponding file", generally has the same basename,
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
40 ;; and just has a different extension as described by the ff-other-file-alist
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; variable:
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; '(("\\.cc$" (".hh" ".h"))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; ("\\.hh$" (".cc" ".C" ".CC" ".cxx" ".cpp")))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; If the current file has a .cc extension, ff-find-other-file will attempt
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; to look for a .hh file, and then a .h file in some directory as described
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; below. The mechanism here is to replace the matched part of the original
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; filename with each of the corresponding extensions in turn.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; Alternatively, there are situations where the filename of the other file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; cannot be determined easily with regexps. For example, a .c file may
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; have two corresponding .h files, for its public and private parts, or
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; the filename for the .c file contains part of the pathname of the .h
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; file, as between src/fooZap.cc and include/FOO/zap.hh. In that case, the
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; format above can be changed to include a function to be called when the
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; current file matches the regexp:
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;;
57719
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
59 ;; '(("\\.cc$" cc--function)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; ("\\.hh$" hh-function))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;;
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
62 ;; These functions must return a list consisting of the possible names of the
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
63 ;; corresponding file, with or without path. There is no real need for more
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; than one function, and one could imagine the following value for cc-other-
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; file-alist:
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; (setq cc-other-file-alist
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; '(("\\.cc$" ff-cc-hh-converter)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; ("\\.hh$" ff-cc-hh-converter)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; ("\\.c$" (".h"))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; ("\\.h$" (".c" ".cc" ".C" ".CC" ".cxx" ".cpp"))))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
72 ;;
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; ff-cc-hh-converter is included at the end of this file as a reference.
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
74 ;;
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; SEARCHING is carried out in a set of directories specified by the
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;; ff-search-directories variable:
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;; ("." "../../src" "../include/*" "/usr/local/*/src/*" "$PROJECT/src")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; This means that the corresponding file will be searched for first in
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; the current directory, then in ../../src, then in one of the directories
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; under ../include, and so on. The star is _not_ a general wildcard
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;; character: it just indicates that the subdirectories of this directory
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;; must each be searched in turn. Environment variables will be expanded in
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; the ff-search-directories variable.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;; If the point is on a #include line, the file to be #included is searched
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; for in the same manner. This can be disabled with the ff-ignore-include
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ;; variable, or by calling ff-get-other-file instead of ff-find-other-file.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 ;; If the file was not found, ff-find-other-file will prompt you for where
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ;; to create the new "corresponding file" (defaults to the current directory),
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
93 ;; unless the variable ff-always-try-to-create is set to nil.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;;
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
95 ;; GIVEN AN ARGUMENT (with the ^U prefix), ff-find-other-file will get the
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
96 ;; other file in another (the other?) window (see find-file-other-window and
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
97 ;; switch-to-buffer-other-window). This can be set on a more permanent basis
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
98 ;; by setting ff-always-in-other-window to t in which case the ^U prefix will
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; do the opposite of what was described above.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ;; THERE ARE FIVE AVAILABLE HOOKS, called in this order if non-nil:
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;;
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
103 ;; - ff-pre-find-hook - called before the search for the other file starts
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
104 ;; - ff-not-found-hook - called when the other file could not be found
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
105 ;; - ff-pre-load-hook - called just before the other file is 'loaded'
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
106 ;; - ff-file-created-hook - called when the other file is created
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
107 ;; - ff-post-load-hook - called just after the other file is 'loaded'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;;
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
109 ;; The *load-hook allow you to place point where you want it in the other
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
110 ;; file.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ;; CREDITS:
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;; Many thanks go to TUSC Computer Systems Pty Ltd for providing an environ-
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ;; ment that made the development of this package possible.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ;; Many thanks also go to all those who provided valuable feedback throughout
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; the development of this package:
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;; Rolf Ebert in particular, Fritz Knabe, Heddy Boubaker, Sebastian Kremer,
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
119 ;; Vasco Lopes Paulo, Mark A. Plaksin, Robert Lang, Trevor West, Kevin
16510
e619a826afdb Enabled commentary for Finder.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
120 ;; Pereira, Benedict Lofstedt & Justin Vallon.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121
16510
e619a826afdb Enabled commentary for Finder.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
122 ;;; Code:
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;; User definable variables:
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
126 (defgroup ff nil
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
127 "Find a file corresponding to this one given a pattern."
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
128 :prefix "ff-"
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
129 :link '(emacs-commentary-link "find-file")
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
130 :group 'find-file)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
132 (defcustom ff-pre-find-hook nil
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
133 "List of functions to be called before the search for the file starts."
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
134 :type 'hook
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
135 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
137 (defcustom ff-pre-load-hook nil
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
138 "List of functions to be called before the other file is loaded."
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
139 :type 'hook
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
140 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
142 (defcustom ff-post-load-hook nil
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
143 "List of functions to be called after the other file is loaded."
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
144 :type 'hook
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
145 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
147 (defcustom ff-not-found-hook nil
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
148 "List of functions to be called if the other file could not be found."
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
149 :type 'hook
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
150 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
152 (defcustom ff-file-created-hook nil
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
153 "List of functions to be called if the other file needs to be created."
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
154 :type 'hook
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
155 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
157 (defcustom ff-case-fold-search nil
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
158 "Non-nil means ignore cases in matches (see `case-fold-search').
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
159 If you have extensions in different cases, you will want this to be nil."
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
160 :type 'boolean
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
161 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
163 (defcustom ff-always-in-other-window nil
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
164 "If non-nil, find the corresponding file in another window by default.
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
165 To override this, give an argument to `ff-find-other-file'."
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
166 :type 'boolean
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
167 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
169 (defcustom ff-ignore-include nil
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
170 "If non-nil, ignore `#include' lines."
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
171 :type 'boolean
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
172 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
174 (defcustom ff-always-try-to-create t
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
175 "If non-nil, always attempt to create the other file if it was not found."
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
176 :type 'boolean
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
177 :group 'ff)
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
178
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
179 (defcustom ff-quiet-mode nil
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
180 "If non-nil, trace which directories are being searched."
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
181 :type 'boolean
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
182 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183
52650
ccb0467830b0 (ff-special-constructs): Add autoload cookie.
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
184 ;;;###autoload
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
185 (defvar ff-special-constructs
105965
3f64b8380468 * textmodes/ispell.el (ispell-skip-region-alist):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 100908
diff changeset
186 `(
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 ;; C/C++ include, for NeXTSTEP too
105965
3f64b8380468 * textmodes/ispell.el (ispell-skip-region-alist):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 100908
diff changeset
188 (,(purecopy "^\#\\s *\\(include\\|import\\)\\s +[<\"]\\(.*\\)[>\"]") .
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (lambda ()
71923
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
190 (buffer-substring (match-beginning 2) (match-end 2))))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 )
71923
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
192 ;; We include `ff-treat-as-special' documentation here so that autoload
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
193 ;; can make it available to be read prior to loading this file.
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
194 "*List of special constructs for `ff-treat-as-special' to recognize.
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
195 Each element, tried in order, has the form (REGEXP . EXTRACT).
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
196 If REGEXP matches the current line (from the beginning of the line),
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
197 `ff-treat-as-special' calls function EXTRACT with no args.
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
198 If EXTRACT returns nil, keep trying. Otherwise, return the
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
199 filename that EXTRACT returned.")
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
47860
621b10466c9a (ff-related-file-alist): New alias.
Richard M. Stallman <rms@gnu.org>
parents: 47354
diff changeset
201 (defvaralias 'ff-related-file-alist 'ff-other-file-alist)
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
202 (defcustom ff-other-file-alist 'cc-other-file-alist
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
203 "Alist of extensions to find given the current file's extension.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 This list should contain the most used extensions before the others,
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 since the search algorithm searches sequentially through each
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
207 directory specified in `ff-search-directories'. If a file is not found,
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
208 a new one is created with the first matching extension (`.cc' yields `.hh').
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
209 This alist should be set by the major mode."
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
210 :type '(choice (repeat (list regexp (choice (repeat string) function)))
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
211 symbol)
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
212 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
214 (defcustom ff-search-directories 'cc-search-directories
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
215 "List of directories to search for a specific file.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
217 Set by default to `cc-search-directories', expanded at run-time.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 This list is searched through with each extension specified in
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
220 `ff-other-file-alist' that matches this file's extension. So the
63505
185136bab53f (ff-search-directories, ff-special-constructs, ff-find-other-file): Fix spelling
Juanma Barranquero <lekktu@gmail.com>
parents: 57719
diff changeset
221 longer the list, the longer it'll take to realize that a file
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 may not exist.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
224 A typical format is
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225
16510
e619a826afdb Enabled commentary for Finder.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
226 '(\".\" \"/usr/include\" \"$PROJECT/*/include\")
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
228 Environment variables can be inserted between slashes (`/').
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
229 They will be replaced by their definition. If a variable does
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
230 not exist, it is replaced (silently) with an empty string.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
232 The stars are *not* wildcards: they are searched for together with
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
233 the preceding slash. The star represents all the subdirectories except
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
234 `..', and each of these subdirectories will be searched in turn."
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
235 :type '(choice (repeat directory) symbol)
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
236 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
238 (defcustom cc-search-directories
16510
e619a826afdb Enabled commentary for Finder.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
239 '("." "/usr/include" "/usr/local/include/*")
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
240 "See the description of the `ff-search-directories' variable."
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
241 :type '(repeat directory)
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
242 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
244 (defcustom cc-other-file-alist
57719
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
245 '(("\\.cc\\'" (".hh" ".h"))
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
246 ("\\.hh\\'" (".cc" ".C"))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247
57719
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
248 ("\\.c\\'" (".h"))
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
249 ("\\.h\\'" (".c" ".cc" ".C" ".CC" ".cxx" ".cpp"))
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
250
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
251 ("\\.C\\'" (".H" ".hh" ".h"))
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
252 ("\\.H\\'" (".C" ".CC"))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253
57719
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
254 ("\\.CC\\'" (".HH" ".H" ".hh" ".h"))
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
255 ("\\.HH\\'" (".CC"))
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
256
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
257 ("\\.c\\+\\+\\'" (".h++" ".hh" ".h"))
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
258 ("\\.h\\+\\+\\'" (".c++"))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259
57719
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
260 ("\\.cpp\\'" (".hpp" ".hh" ".h"))
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
261 ("\\.hpp\\'" (".cpp"))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262
57719
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
263 ("\\.cxx\\'" (".hxx" ".hh" ".h"))
018ef6100fc5 (cc-other-file-alist): Bring it in line with cc-mode's auto-mode-alist entries and use \' instead of $.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 52650
diff changeset
264 ("\\.hxx\\'" (".cxx")))
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
265 "Alist of extensions to find given the current file's extension.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 This list should contain the most used extensions before the others,
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 since the search algorithm searches sequentially through each directory
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
269 specified in `ff-search-directories'. If a file is not found, a new one
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
270 is created with the first matching extension (`.cc' yields `.hh')."
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
271 :type '(repeat (list regexp (choice (repeat string) function)))
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
272 :group 'ff)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
274 (defcustom modula2-other-file-alist
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 '(
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 ("\\.mi$" (".md")) ;; Modula-2 module definition
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 ("\\.md$" (".mi")) ;; and implementation.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 )
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
279 "See the description for the `ff-search-directories' variable."
21087
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
280 :type '(repeat (list regexp (choice (repeat string) function)))
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
281 :group 'ff)
c297faa167f5 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 21057
diff changeset
282
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 ;; No user definable variables beyond this point!
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 ;; ==============================================
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
288 (make-variable-buffer-local 'ff-pre-find-hook)
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
289 (make-variable-buffer-local 'ff-pre-load-hook)
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
290 (make-variable-buffer-local 'ff-post-load-hook)
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
291 (make-variable-buffer-local 'ff-not-found-hook)
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
292 (make-variable-buffer-local 'ff-file-created-hook)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (make-variable-buffer-local 'ff-case-fold-search)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (make-variable-buffer-local 'ff-always-in-other-window)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (make-variable-buffer-local 'ff-ignore-include)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (make-variable-buffer-local 'ff-quiet-mode)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (make-variable-buffer-local 'ff-other-file-alist)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (make-variable-buffer-local 'ff-search-directories)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 ;; User entry points
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 ;;;###autoload
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (defun ff-get-other-file (&optional in-other-window)
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
305 "Find the header or source file corresponding to this file.
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
306 See also the documentation for `ff-find-other-file'.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
308 If optional IN-OTHER-WINDOW is non-nil, find the file in another window."
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (interactive "P")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 (let ((ignore ff-ignore-include))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (setq ff-ignore-include t)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (ff-find-the-other-file in-other-window)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (setq ff-ignore-include ignore)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314
48009
8b3977d58df6 (ff-find-related-file): Fix autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 47860
diff changeset
315 ;;;###autoload
47860
621b10466c9a (ff-related-file-alist): New alias.
Richard M. Stallman <rms@gnu.org>
parents: 47354
diff changeset
316 (defalias 'ff-find-related-file 'ff-find-other-file)
621b10466c9a (ff-related-file-alist): New alias.
Richard M. Stallman <rms@gnu.org>
parents: 47354
diff changeset
317
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 ;;;###autoload
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (defun ff-find-other-file (&optional in-other-window ignore-include)
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
320 "Find the header or source file corresponding to this file.
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
321 Being on a `#include' line pulls in that file.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
323 If optional IN-OTHER-WINDOW is non-nil, find the file in the other window.
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
324 If optional IGNORE-INCLUDE is non-nil, ignore being on `#include' lines.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 Variables of interest include:
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
328 - `ff-case-fold-search'
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
329 Non-nil means ignore cases in matches (see `case-fold-search').
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 If you have extensions in different cases, you will want this to be nil.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
332 - `ff-always-in-other-window'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 If non-nil, always open the other file in another window, unless an
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
334 argument is given to `ff-find-other-file'.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
336 - `ff-ignore-include'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 If non-nil, ignores #include lines.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
339 - `ff-always-try-to-create'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 If non-nil, always attempt to create the other file if it was not found.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
342 - `ff-quiet-mode'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 If non-nil, traces which directories are being searched.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
345 - `ff-special-constructs'
63505
185136bab53f (ff-search-directories, ff-special-constructs, ff-find-other-file): Fix spelling
Juanma Barranquero <lekktu@gmail.com>
parents: 57719
diff changeset
346 A list of regular expressions specifying how to recognize special
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
347 constructs such as include files etc, and an associated method for
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 extracting the filename from that construct.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
350 - `ff-other-file-alist'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 Alist of extensions to find given the current file's extension.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
353 - `ff-search-directories'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 List of directories searched through with each extension specified in
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
355 `ff-other-file-alist' that matches this file's extension.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
357 - `ff-pre-find-hook'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 List of functions to be called before the search for the file starts.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
360 - `ff-pre-load-hook'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 List of functions to be called before the other file is loaded.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
363 - `ff-post-load-hook'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 List of functions to be called after the other file is loaded.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
366 - `ff-not-found-hook'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 List of functions to be called if the other file could not be found.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
369 - `ff-file-created-hook'
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 List of functions to be called if the other file has been created."
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (interactive "P")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (let ((ignore ff-ignore-include))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (setq ff-ignore-include ignore-include)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (ff-find-the-other-file in-other-window)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (setq ff-ignore-include ignore)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 ;; Support functions
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (defun ff-find-the-other-file (&optional in-other-window)
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
381 "Find the header or source file corresponding to the current file.
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
382 Being on a `#include' line pulls in that file, but see the help on
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
383 the `ff-ignore-include' variable.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
385 If optional IN-OTHER-WINDOW is non-nil, find the file in another window."
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (let (match ;; matching regexp for this file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 suffixes ;; set of replacing regexps for the matching regexp
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 action ;; function to generate the names of the other files
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 fname ;; basename of this file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 pos ;; where we start matching filenames
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 stub ;; name of the file without extension
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 alist ;; working copy of the list of file extensions
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 pathname ;; the pathname of the file or the #include line
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 default-name ;; file we should create if none found
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
396 format ;; what we have to match
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
397 found ;; name of the file or buffer found - nil if none
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 dirs ;; local value of ff-search-directories
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 no-match) ;; whether we know about this kind of file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
401 (run-hooks 'ff-pre-find-hook 'ff-pre-find-hooks)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (message "Working...")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (setq dirs
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (if (symbolp ff-search-directories)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (ff-list-replace-env-vars (symbol-value ff-search-directories))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (ff-list-replace-env-vars ff-search-directories)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409
71923
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
410 (setq fname (ff-treat-as-special))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (cond
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 ((and (not ff-ignore-include) fname)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (setq default-name fname)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (setq found (ff-get-file dirs fname nil in-other-window)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 ;; let's just get the corresponding file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (t
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (setq alist (if (symbolp ff-other-file-alist)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (symbol-value ff-other-file-alist)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 ff-other-file-alist)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 pathname (if (buffer-file-name)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (buffer-file-name)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 "/none.none"))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425
38273
910cd30b1586 (ff-find-the-other-file): Use file-name-nondirectory
Eli Zaretskii <eliz@gnu.org>
parents: 30816
diff changeset
426 (setq fname (file-name-nondirectory pathname)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 no-match nil
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 match (car alist))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 ;; find the table entry corresponding to this file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (setq pos (ff-string-match (car match) fname))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (while (and match (if (and pos (>= pos 0)) nil (not pos)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (setq alist (cdr alist))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (setq match (car alist))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (setq pos (ff-string-match (car match) fname)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 ;; no point going on if we haven't found anything
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (if (not match)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (setq no-match t)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 ;; otherwise, suffixes contains what we need
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (setq suffixes (car (cdr match))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 action (car (cdr match))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 found nil)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
446 ;; if we have a function to generate new names,
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 ;; invoke it with the name of the current file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (if (and (atom action) (fboundp action))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 (progn
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (setq suffixes (funcall action (buffer-file-name))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 match (cons (car match) (list suffixes))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 stub nil
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 default-name (car suffixes)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 ;; otherwise build our filename stub
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
456 (cond
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 ;; get around the problem that 0 and nil both mean false!
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 ((= pos 0)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 (setq format "")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (setq stub "")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 )
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 (t
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 (setq format (concat "\\(.+\\)" (car match)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 (string-match format fname)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (setq stub (substring fname (match-beginning 1) (match-end 1)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 ))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 ;; if we find nothing, we should try to get a file like this one
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (setq default-name
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (concat stub (car (car (cdr match))))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 ;; do the real work - find the file
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
475 (setq found
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 (ff-get-file dirs
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 stub
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
478 suffixes
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 in-other-window)))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (cond
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (no-match ;; could not even determine the other file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (message ""))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
485 (t
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (cond
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 ((not found) ;; could not find the other file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
490 (run-hooks 'ff-not-found-hook 'ff-not-found-hooks)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
492 (cond
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (ff-always-try-to-create ;; try to create the file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (let (name pathname)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (setq name
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (expand-file-name
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (read-file-name
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 (format "Find or create %s in: " default-name)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 default-directory default-name nil)))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
501
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (setq pathname
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (if (file-directory-p name)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (concat (file-name-as-directory name) default-name)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (setq found name)))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
506
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (ff-find-file pathname in-other-window t)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (t ;; don't create the file, just whinge
17548
dab7558986cd Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16510
diff changeset
510 (message "No file found for %s" fname))))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (t ;; matching file found
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 nil))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 found)) ;; return buffer-name or filename
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516
42097
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
517 (defun ff-other-file-name ()
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
518 "Return name of the header or source file corresponding to the current file.
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
519 Being on a `#include' line pulls in that file, but see the help on
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
520 the `ff-ignore-include' variable."
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
521
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
522 (let (match ;; matching regexp for this file
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
523 suffixes ;; set of replacing regexps for the matching regexp
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
524 action ;; function to generate the names of the other files
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
525 fname ;; basename of this file
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
526 pos ;; where we start matching filenames
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
527 stub ;; name of the file without extension
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
528 alist ;; working copy of the list of file extensions
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
529 pathname ;; the pathname of the file or the #include line
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
530 default-name ;; file we should create if none found
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
531 format ;; what we have to match
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
532 found ;; name of the file or buffer found - nil if none
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
533 dirs ;; local value of ff-search-directories
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
534 no-match) ;; whether we know about this kind of file
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
535
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
536 (message "Working...")
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
537
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
538 (setq dirs
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
539 (if (symbolp ff-search-directories)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
540 (ff-list-replace-env-vars (symbol-value ff-search-directories))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
541 (ff-list-replace-env-vars ff-search-directories)))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
542
71923
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
543 (setq fname (ff-treat-as-special))
42097
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
544
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
545 (cond
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
546 ((and (not ff-ignore-include) fname)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
547 (setq default-name fname)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
548 (setq found (ff-get-file-name dirs fname nil)))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
549
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
550 ;; let's just get the corresponding file
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
551 (t
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
552 (setq alist (if (symbolp ff-other-file-alist)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
553 (symbol-value ff-other-file-alist)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
554 ff-other-file-alist)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
555 pathname (if (buffer-file-name)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
556 (buffer-file-name)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
557 "/none.none"))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
558
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
559 (setq fname (file-name-nondirectory pathname)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
560 no-match nil
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
561 match (car alist))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
562
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
563 ;; find the table entry corresponding to this file
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
564 (setq pos (ff-string-match (car match) fname))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
565 (while (and match (if (and pos (>= pos 0)) nil (not pos)))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
566 (setq alist (cdr alist))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
567 (setq match (car alist))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
568 (setq pos (ff-string-match (car match) fname)))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
569
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
570 ;; no point going on if we haven't found anything
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
571 (if (not match)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
572 (setq no-match t)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
573
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
574 ;; otherwise, suffixes contains what we need
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
575 (setq suffixes (car (cdr match))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
576 action (car (cdr match))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
577 found nil)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
578
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
579 ;; if we have a function to generate new names,
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
580 ;; invoke it with the name of the current file
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
581 (if (and (atom action) (fboundp action))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
582 (progn
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
583 (setq suffixes (funcall action (buffer-file-name))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
584 match (cons (car match) (list suffixes))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
585 stub nil
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
586 default-name (car suffixes)))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
587
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
588 ;; otherwise build our filename stub
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
589 (cond
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
590
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
591 ;; get around the problem that 0 and nil both mean false!
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
592 ((= pos 0)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
593 (setq format "")
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
594 (setq stub "")
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
595 )
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
596
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
597 (t
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
598 (setq format (concat "\\(.+\\)" (car match)))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
599 (string-match format fname)
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
600 (setq stub (substring fname (match-beginning 1) (match-end 1)))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
601 ))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
602
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
603 ;; if we find nothing, we should try to get a file like this one
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
604 (setq default-name
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
605 (concat stub (car (car (cdr match))))))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
606
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
607 ;; do the real work - find the file
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
608 (setq found
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
609 (ff-get-file-name dirs stub suffixes)))))
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
610 found)) ;; return buffer-name or filename
e12d545c9a48 (ff-other-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 38273
diff changeset
611
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
612 (defun ff-get-file (search-dirs filename &optional suffix-list other-window)
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
613 "Find a file in the SEARCH-DIRS with the given FILENAME (or filename stub).
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
614 If (optional) SUFFIX-LIST is nil, search for FILENAME, otherwise search
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
615 for FILENAME with each of the given suffixes. Get the file or the buffer
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
616 corresponding to the name of the first file found, or nil."
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
617 (let ((filename (ff-get-file-name search-dirs filename suffix-list)))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
618
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
619 (cond
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 ((not filename)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 nil)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622
13896
d23e1ac7b432 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12949
diff changeset
623 ((bufferp (get-file-buffer filename))
d23e1ac7b432 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12949
diff changeset
624 (ff-switch-to-buffer (get-file-buffer filename) other-window)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 filename)
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
626
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 ((file-exists-p filename)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 (ff-find-file filename other-window nil)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 filename)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (t
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 nil))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (defun ff-get-file-name (search-dirs fname-stub &optional suffix-list)
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
635 "Find a file in SEARCH-DIRS with the given name (or stub) FNAME-STUB.
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
636 If (optional) SUFFIX-LIST is nil, search for FNAME-STUB, otherwise
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
637 search for FNAME-STUB with each of the given suffixes. Return the
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
638 name of the first file found."
98750
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
639 (let (dirs ;; working copy of dirs to search
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
640 dir ;; the current dir considered
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
641 file ;; filename being looked for
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
642 rest ;; pathname after first /*
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
643 this-suffix ;; the suffix we are currently considering
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
644 suffixes ;; working copy of suffix-list
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
645 filename ;; built filename
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
646 blist ;; list of live buffers
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
647 buf ;; current buffer in blist
3d5bcaefd8cf * find-file.el (ff-get-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
648 found) ;; whether we have found anything
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (setq suffixes suffix-list)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 ;; suffixes is nil => fname-stub is the file we are looking for
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 ;; otherwise fname-stub is a stub, and we append a suffix
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 (if suffixes
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (setq this-suffix (car suffixes))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 (setq this-suffix "")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (setq suffixes (list "")))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
658
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 ;; find whether the file is in a buffer first
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 (while (and suffixes (not found))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (setq filename (concat fname-stub this-suffix))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (if (not ff-quiet-mode)
17548
dab7558986cd Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16510
diff changeset
664 (message "Finding buffer %s..." filename))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665
17548
dab7558986cd Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16510
diff changeset
666 (if (bufferp (get-file-buffer filename))
dab7558986cd Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16510
diff changeset
667 (setq found (buffer-file-name (get-file-buffer filename))))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (setq blist (buffer-list))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (setq buf (buffer-name (car blist)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (while (and blist (not found))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (if (string-match (concat filename "<[0-9]+>") buf)
16510
e619a826afdb Enabled commentary for Finder.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
674 (setq found (buffer-file-name (car blist))))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 (setq blist (cdr blist))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 (setq buf (buffer-name (car blist))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 (setq suffixes (cdr suffixes))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 (setq this-suffix (car suffixes)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 ;; now look for the real file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 (setq dirs search-dirs)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 (setq dir (car dirs))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 (while (and (not found) dirs)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 (setq suffixes suffix-list)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 ;; if dir does not contain '/*', look for the file
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 (if (and dir (not (string-match "\\([^*]*\\)/\\\*\\(/.*\\)*" dir)))
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
691 (progn
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
692
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 ;; suffixes is nil => fname-stub is the file we are looking for
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 ;; otherwise fname-stub is a stub, and we append a suffix
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 (if suffixes
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (setq this-suffix (car suffixes))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 (setq this-suffix "")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (setq suffixes (list "")))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
699
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 (while (and suffixes (not found))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (setq filename (concat fname-stub this-suffix))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 (setq file (concat dir "/" filename))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
704
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 (if (not ff-quiet-mode)
17548
dab7558986cd Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16510
diff changeset
706 (message "Finding %s..." file))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (if (file-exists-p file)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 (setq found file))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
710
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 (setq suffixes (cdr suffixes))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 (setq this-suffix (car suffixes))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 ;; otherwise dir matches the '/*', so search each dir separately
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 (progn
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 (if (match-beginning 2)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (setq rest (substring dir (match-beginning 2) (match-end 2)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 (setq rest "")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 )
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (setq dir (substring dir (match-beginning 1) (match-end 1)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 (let ((dirlist (ff-all-dirs-under dir '("..")))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 this-dir compl-dirs)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 (setq this-dir (car dirlist))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (while dirlist
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 (setq compl-dirs
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 (append
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 compl-dirs
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 (list (concat this-dir rest))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 ))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 (setq dirlist (cdr dirlist))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 (setq this-dir (car dirlist)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 (if compl-dirs
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 (setq found (ff-get-file-name compl-dirs
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 fname-stub
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 suffix-list))))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 (setq dirs (cdr dirs))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 (setq dir (car dirs)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 (if found
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (message "%s found" found))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 found))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 (defun ff-string-match (regexp string &optional start)
13896
d23e1ac7b432 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12949
diff changeset
748 "Like `string-match', but set `case-fold-search' temporarily.
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
749 The value used comes from `ff-case-fold-search'."
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
750 (let ((case-fold-search ff-case-fold-search))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (if regexp
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
752 (string-match regexp string start))))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 (defun ff-list-replace-env-vars (search-list)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 "Replace environment variables (of the form $VARIABLE) in SEARCH-LIST."
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 (let (list
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (var (car search-list)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (while search-list
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 (if (string-match "\\(.*\\)\\$[({]*\\([a-zA-Z0-9_]+\\)[)}]*\\(.*\\)" var)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 (setq var
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (concat
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 (substring var (match-beginning 1) (match-end 1))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 (getenv (substring var (match-beginning 2) (match-end 2)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 (substring var (match-beginning 3) (match-end 3)))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 (setq search-list (cdr search-list))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 (setq list (cons var list))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 (setq var (car search-list)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 (setq search-list (reverse list))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 (defun ff-treat-as-special ()
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
771 "Return the file to look for if the construct was special, else nil.
71923
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
772 See variable `ff-special-constructs'."
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
773 (save-excursion
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
774 (beginning-of-line 1)
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
775 (let* (fname
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
776 (list ff-special-constructs)
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
777 (elem (car list))
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
778 (regexp (car elem))
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
779 (match (cdr elem)))
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
780 (while (and list (not fname))
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
781 (if (and (looking-at regexp) match)
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
782 (setq fname (funcall match)))
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
783 (setq list (cdr list))
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
784 (setq elem (car list))
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
785 (setq regexp (car elem))
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
786 (setq match (cdr elem)))
6d714c43de54 (ff-special-constructs): Doc fix. Also, for C/C++
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
787 fname)))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 (defun ff-basename (string)
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
790 "Return the basename of pathname STRING."
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 (setq string (concat "/" string))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 (string-match ".*/\\([^/]+\\)$" string)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 (setq string (substring string (match-beginning 1) (match-end 1))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 (defun ff-all-dirs-under (here &optional exclude)
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
796 "Get all the directory files under directory HERE.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 Exclude all files in the optional EXCLUDE list."
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 (if (file-directory-p here)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 (condition-case nil
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 (progn
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 (let ((files (directory-files here t))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 (dirlist (list))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 file)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 (while files
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 (setq file (car files))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 (if (and
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 (file-directory-p file)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 (not (member (ff-basename file) exclude)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 (setq dirlist (cons file dirlist)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 (setq files (cdr files)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 (setq dirlist (reverse dirlist))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 (error nil))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 nil))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 (defun ff-switch-file (f1 f2 file &optional in-other-window new-file)
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
816 "Call F1 or F2 on FILE, according to IN-OTHER-WINDOW.
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
817 In addition, this runs various hooks.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
819 Either F1 or F2 receives FILE as the sole argument.
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
820 The decision of which one to call is based on IN-OTHER-WINDOW
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
821 and on the global variable `ff-always-in-other-window'.
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
823 F1 and F2 are typically `find-file' / `find-file-other-window'
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
824 or `switch-to-buffer' / `switch-to-buffer-other-window' function pairs.
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
825
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
826 If optional NEW-FILE is t, then a special hook (`ff-file-created-hook') is
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
827 called before `ff-post-load-hook'."
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
828 (run-hooks 'ff-pre-load-hook 'ff-pre-load-hooks)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 (if (or
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 (and in-other-window (not ff-always-in-other-window))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 (and (not in-other-window) ff-always-in-other-window))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 (funcall f2 file)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 (funcall f1 file))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 (if new-file
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
835 (run-hooks 'ff-file-created-hook 'ff-file-created-hooks))
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
836 (run-hooks 'ff-post-load-hook 'ff-post-load-hooks))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 (defun ff-find-file (file &optional in-other-window new-file)
13896
d23e1ac7b432 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12949
diff changeset
839 "Like `find-file', but may show the file in another window."
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
840 (ff-switch-file 'find-file
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
841 'find-file-other-window
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 file in-other-window new-file))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843
13896
d23e1ac7b432 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12949
diff changeset
844 (defun ff-switch-to-buffer (buffer-or-name &optional in-other-window)
d23e1ac7b432 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12949
diff changeset
845 "Like `switch-to-buffer', but may show the buffer in another window."
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
847 (ff-switch-file 'switch-to-buffer
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
848 'switch-to-buffer-other-window
13896
d23e1ac7b432 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 12949
diff changeset
849 buffer-or-name in-other-window nil))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850
22192
bf83c23f3300 (ff-emacs-19, ff-xemacs): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 21087
diff changeset
851 ;;;###autoload
bf83c23f3300 (ff-emacs-19, ff-xemacs): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 21087
diff changeset
852 (defun ff-mouse-find-other-file (event)
bf83c23f3300 (ff-emacs-19, ff-xemacs): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 21087
diff changeset
853 "Visit the file you click on."
bf83c23f3300 (ff-emacs-19, ff-xemacs): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 21087
diff changeset
854 (interactive "e")
bf83c23f3300 (ff-emacs-19, ff-xemacs): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 21087
diff changeset
855 (save-excursion
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
856 (mouse-set-point event)
22192
bf83c23f3300 (ff-emacs-19, ff-xemacs): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 21087
diff changeset
857 (ff-find-other-file nil)))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858
22192
bf83c23f3300 (ff-emacs-19, ff-xemacs): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 21087
diff changeset
859 ;;;###autoload
bf83c23f3300 (ff-emacs-19, ff-xemacs): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 21087
diff changeset
860 (defun ff-mouse-find-other-file-other-window (event)
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
861 "Visit the file you click on in another window."
22192
bf83c23f3300 (ff-emacs-19, ff-xemacs): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 21087
diff changeset
862 (interactive "e")
bf83c23f3300 (ff-emacs-19, ff-xemacs): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 21087
diff changeset
863 (save-excursion
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
864 (mouse-set-point event)
22192
bf83c23f3300 (ff-emacs-19, ff-xemacs): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 21087
diff changeset
865 (ff-find-other-file t)))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 ;; This section offers an example of user defined function to select files
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
870 (defun ff-upcase-p (string &optional start end)
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
871 "Return t if STRING is all uppercase.
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
872 Given START and/or END, checks between these characters."
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 (let (match str)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 (if (not start)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 (setq start 0))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 (if (not end)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 (setq end (length string)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 (if (= start end)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 (setq end (1+ end)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 (setq str (substring string start end))
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
881 (if (and
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 (ff-string-match "[A-Z]+" str)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 (setq match (match-data))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 (= (car match) 0)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 (= (car (cdr match)) (length str)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 t
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 nil)))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 (defun ff-cc-hh-converter (arg)
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
890 "Discriminate file extensions.
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
891 Build up a new file list based possibly on part of the directory name
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
892 and the name of the file passed in."
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 (ff-string-match "\\(.*\\)/\\([^/]+\\)/\\([^.]+\\).\\([^/]+\\)$" arg)
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
894 (let ((path (if (match-beginning 1)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 (substring arg (match-beginning 1) (match-end 1)) nil))
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
896 (dire (if (match-beginning 2)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 (substring arg (match-beginning 2) (match-end 2)) nil))
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
898 (file (if (match-beginning 3)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 (substring arg (match-beginning 3) (match-end 3)) nil))
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
900 (extn (if (match-beginning 4)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901 (substring arg (match-beginning 4) (match-end 4)) nil))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 return-list)
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 (cond
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904 ;; fooZapJunk.cc => ZapJunk.{hh,h} or fooZapJunk.{hh,h}
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
905 ((and (string= extn "cc")
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 (ff-string-match "^\\([a-z]+\\)\\([A-Z].+\\)$" file))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 (let ((stub (substring file (match-beginning 2) (match-end 2))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 (setq dire (upcase (substring file (match-beginning 1) (match-end 1))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 (setq return-list (list (concat stub ".hh")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 (concat stub ".h")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 (concat file ".hh")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 (concat file ".h")))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 ))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 ;; FOO/ZapJunk.hh => fooZapJunk.{cc,C} or ZapJunk.{cc,C}
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
915 ((and (string= extn "hh") (ff-upcase-p dire) file)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916 (let ((stub (concat (downcase dire) file)))
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
917 (setq return-list (list (concat stub ".cc")
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 (concat stub ".C")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919 (concat file ".cc")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 (concat file ".C")))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 ))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922 ;; zap.cc => zap.hh or zap.h
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923 ((string= extn "cc")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 (let ((stub file))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 (setq return-list (list (concat stub ".hh")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 (concat stub ".h")))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 ))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 ;; zap.hh => zap.cc or zap.C
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 ((string= extn "hh")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 (let ((stub file))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 (setq return-list (list (concat stub ".cc")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 (concat stub ".C")))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 ))
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
934 (t
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 nil))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48009
diff changeset
936
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 return-list))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 ;; This section offers an example of user defined function to place point.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 ;; The regexps are Ada specific.
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 (defvar ff-function-name nil "Name of the function we are in.")
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
945 ;; bind with (setq ff-pre-load-hook 'ff-which-function-are-we-in)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 ;;
64796
023827894687 (ada-procedure-start-regexp, ada-package-start-regexp): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 64762
diff changeset
947 (defvar ada-procedure-start-regexp)
023827894687 (ada-procedure-start-regexp, ada-package-start-regexp): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 64762
diff changeset
948 (defvar ada-package-start-regexp)
023827894687 (ada-procedure-start-regexp, ada-package-start-regexp): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 64762
diff changeset
949
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 (defun ff-which-function-are-we-in ()
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
951 "Return the name of the function whose definition/declaration point is in.
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
952 Also remember that name in `ff-function-name'."
63921
8c8961dafdc6 (ff-which-function-are-we-in): Clean up.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 63505
diff changeset
953 (setq ff-function-name
8c8961dafdc6 (ff-which-function-are-we-in): Clean up.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 63505
diff changeset
954 (save-excursion
8c8961dafdc6 (ff-which-function-are-we-in): Clean up.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 63505
diff changeset
955 (if (or (re-search-backward ada-procedure-start-regexp nil t)
8c8961dafdc6 (ff-which-function-are-we-in): Clean up.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 63505
diff changeset
956 (re-search-backward ada-package-start-regexp nil t))
8c8961dafdc6 (ff-which-function-are-we-in): Clean up.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 63505
diff changeset
957 (match-string 0)))))
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958
47354
27533450eb3b (ff-pre-find-hook, ff-pre-load-hook, ff-post-load-hook)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44880
diff changeset
959 ;; bind with (setq ff-post-load-hook 'ff-set-point-accordingly)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 ;;
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 (defun ff-set-point-accordingly ()
11272
79fcaf4e0e75 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 11234
diff changeset
962 "Find the function specified in `ff-function-name'.
12567
7318536fb256 (ff-set-point-accordingly): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 11272
diff changeset
963 That name was previously determined by `ff-which-function-are-we-in'."
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 (if ff-function-name
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 (progn
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 (goto-char (point-min))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 (search-forward ff-function-name nil t))))
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
969 (provide 'find-file)
10491
dfc0d2c81c56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970
63921
8c8961dafdc6 (ff-which-function-are-we-in): Clean up.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 63505
diff changeset
971 ;; arch-tag: 5a2fc49e-3b0a-4708-9acf-fb14e471a97a
30816
e06965792db4 Doc fixes. Move provide to end.
Dave Love <fx@gnu.org>
parents: 22192
diff changeset
972 ;;; find-file.el ends here