Mercurial > emacs
comparison lisp/find-file.el @ 11272:79fcaf4e0e75
Many doc fixes.
(ff-upcase-p): Renamed from upcase-p. Callers changed.
(ff-emacs-19): Renamed from ff-gnu-emacs-19.
(ff-string-match): Simplify.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 07 Apr 1995 21:51:51 +0000 |
parents | 4d2a2fe1d8d7 |
children | 7318536fb256 |
comparison
equal
deleted
inserted
replaced
11271:15c71d840a81 | 11272:79fcaf4e0e75 |
---|---|
106 ;; - ff-post-load-hooks - called just after the other file is 'loaded' | 106 ;; - ff-post-load-hooks - called just after the other file is 'loaded' |
107 ;; | 107 ;; |
108 ;; The *load-hooks allow you to place point where you want it in the other | 108 ;; The *load-hooks allow you to place point where you want it in the other |
109 ;; file. | 109 ;; file. |
110 | 110 |
111 ;; LCD Archive Entry: | |
112 ;; find-file|Henry Guillaume|henry@qbd.com.au| | |
113 ;; Find a file associated with this buffer.| | |
114 ;; 21-Dec-1994|4.0|~/misc/find-file.el.Z| | |
115 | |
116 ;; FEEDBACK: | 111 ;; FEEDBACK: |
117 ;; Please send me bug reports, bug fixes, and extensions, so that I can | 112 ;; Please send me bug reports, bug fixes, and extensions, so that I can |
118 ;; merge them into the master source. | 113 ;; merge them into the master source. |
119 | 114 |
120 ;; CREDITS: | 115 ;; CREDITS: |
145 | 140 |
146 (defvar ff-file-created-hooks nil | 141 (defvar ff-file-created-hooks nil |
147 "*List of functions to be called if the other file needs to be created.") | 142 "*List of functions to be called if the other file needs to be created.") |
148 | 143 |
149 (defvar ff-case-fold-search nil | 144 (defvar ff-case-fold-search nil |
150 "*Non-nil means ignore cases in matches (see case-fold-search). | 145 "*Non-nil means ignore cases in matches (see `case-fold-search'). |
151 If you have extensions in different cases, you will want this to be nil.") | 146 If you have extensions in different cases, you will want this to be nil.") |
152 | 147 |
153 (defvar ff-always-in-other-window nil | 148 (defvar ff-always-in-other-window nil |
154 "*If non-nil, always open the other file in another window, unless an | 149 "*If non-nil, find the corresponding file in another window by default. |
155 argument is given to ff-find-other-file.") | 150 To override this, give an argument to `ff-find-other-file'.") |
156 | 151 |
157 (defvar ff-ignore-include nil | 152 (defvar ff-ignore-include nil |
158 "*If non-nil, ignores include lines.") | 153 "*If non-nil, ignore `#include' lines.") |
159 | 154 |
160 (defvar ff-always-try-to-create t | 155 (defvar ff-always-try-to-create t |
161 "*If non-nil, always attempt to create the other file if it was not found.") | 156 "*If non-nil, always attempt to create the other file if it was not found.") |
162 | 157 |
163 (defvar ff-quiet-mode nil | 158 (defvar ff-quiet-mode nil |
164 "*If non-nil, traces which directories are being searched.") | 159 "*If non-nil, trace which directories are being searched.") |
165 | 160 |
166 (defvar ff-special-constructs | 161 (defvar ff-special-constructs |
167 '( | 162 '( |
168 ;; C/C++ include, for NeXTSTEP too | 163 ;; C/C++ include, for NeXTSTEP too |
169 ("^\#\\s *\\(include\\|import\\)\\s +[<\"]\\(.*\\)[>\"]" . | 164 ("^\#\\s *\\(include\\|import\\)\\s +[<\"]\\(.*\\)[>\"]" . |
184 (defvar ff-other-file-alist 'cc-other-file-alist | 179 (defvar ff-other-file-alist 'cc-other-file-alist |
185 "*Alist of extensions to find given the current file's extension. | 180 "*Alist of extensions to find given the current file's extension. |
186 | 181 |
187 This list should contain the most used extensions before the others, | 182 This list should contain the most used extensions before the others, |
188 since the search algorithm searches sequentially through each | 183 since the search algorithm searches sequentially through each |
189 directory specified in ff-search-directories. If a file is not found, | 184 directory specified in `ff-search-directories'. If a file is not found, |
190 a new one is created with the first matching extension (.cc yields .hh). | 185 a new one is created with the first matching extension (`.cc' yields `.hh'). |
191 This alist should be set by the major-mode.") | 186 This alist should be set by the major mode.") |
192 | 187 |
193 (defvar ff-search-directories 'cc-search-directories | 188 (defvar ff-search-directories 'cc-search-directories |
194 "*List of directories to search for a specific file. | 189 "*List of directories to search for a specific file. |
195 | 190 |
196 Set by default to 'cc-search-directories, expanded at run-time. | 191 Set by default to `cc-search-directories', expanded at run-time. |
197 | 192 |
198 This list is searched through with each extension specified in | 193 This list is searched through with each extension specified in |
199 ff-other-file-alist that matches this file's extension. So the | 194 `ff-other-file-alist' that matches this file's extension. So the |
200 longer the list, the longer it'll take to realise that a file | 195 longer the list, the longer it'll take to realise that a file |
201 may not exist. | 196 may not exist. |
202 | 197 |
203 A typical format is | 198 A typical format is |
204 | 199 |
205 '(\".\" \"/usr/include/*\" \"$PROJECT/*/include\") | 200 '(\".\" \"/usr/include/*\" \"$PROJECT/*/include\") |
206 | 201 |
207 Environment variables can be inserted between slashes ('/'). | 202 Environment variables can be inserted between slashes (`/'). |
208 They will be replaced by their definition. If a variable does | 203 They will be replaced by their definition. If a variable does |
209 not exist, it will (silently) be replaced with an empty string. | 204 not exist, it is replaced (silently) with an empty string. |
210 | 205 |
211 The stars are _not_ wildcards: they are searched for together with | 206 The stars are *not* wildcards: they are searched for together with |
212 the preceding slash. The star represents all the subdirectories except | 207 the preceding slash. The star represents all the subdirectories except |
213 '..', and each of these subdirectories will be searched in turn.") | 208 `..', and each of these subdirectories will be searched in turn.") |
214 | 209 |
215 (defvar cc-search-directories | 210 (defvar cc-search-directories |
216 '("." "/usr/include/*" "/usr/local/include/*") | 211 '("." "/usr/include/*" "/usr/local/include/*") |
217 "*See the description of the ff-search-directories variable.") | 212 "*See the description of the `ff-search-directories' variable.") |
218 | 213 |
219 (defvar cc-other-file-alist | 214 (defvar cc-other-file-alist |
220 '( | 215 '( |
221 ("\\.cc$" (".hh" ".h")) | 216 ("\\.cc$" (".hh" ".h")) |
222 ("\\.hh$" (".cc" ".C")) | 217 ("\\.hh$" (".cc" ".C")) |
235 ) | 230 ) |
236 "*Alist of extensions to find given the current file's extension. | 231 "*Alist of extensions to find given the current file's extension. |
237 | 232 |
238 This list should contain the most used extensions before the others, | 233 This list should contain the most used extensions before the others, |
239 since the search algorithm searches sequentially through each directory | 234 since the search algorithm searches sequentially through each directory |
240 specified in ff-search-directories. If a file is not found, a new one | 235 specified in `ff-search-directories'. If a file is not found, a new one |
241 is created with the first matching extension (.cc yields .hh).") | 236 is created with the first matching extension (`.cc' yields `.hh').") |
242 | 237 |
243 (defvar ada-search-directories | 238 (defvar ada-search-directories |
244 '("." "/usr/adainclude" "/usr/local/adainclude") | 239 '("." "/usr/adainclude" "/usr/local/adainclude") |
245 "*See the description for the ff-search-directories variable.") | 240 "*See the description for the `ff-search-directories' variable.") |
246 | 241 |
247 (defvar ada-other-file-alist | 242 (defvar ada-other-file-alist |
248 '( | 243 '( |
249 ("\\.ads$" (".adb")) ;; Ada specs and bodies | 244 ("\\.ads$" (".adb")) ;; Ada specs and bodies |
250 ("\\.adb$" (".ads")) ;; GNAT filename conventions | 245 ("\\.adb$" (".ads")) ;; GNAT filename conventions |
251 ) | 246 ) |
252 "*Alist of extensions to find given the current file's extension. | 247 "*Alist of extensions to find given the current file's extension. |
253 | 248 |
254 This list should contain the most used extensions before the others, | 249 This list should contain the most used extensions before the others, |
255 since the search algorithm searches sequentially through each directory | 250 since the search algorithm searches sequentially through each directory |
256 specified in ada-search-directories. If a file is not found, a new one | 251 specified in `ada-search-directories'. If a file is not found, a new one |
257 is created with the first matching extension (.adb yields .ads). | 252 is created with the first matching extension (`.adb' yields `.ads'). |
258 ") | 253 ") |
259 | 254 |
260 ;;;### autoload | 255 ;;;### autoload |
261 (autoload 'ada-make-filename-from-adaname "ada-mode" | 256 (autoload 'ada-make-filename-from-adaname "ada-mode" |
262 "Determine the filename of a package/procedure from its own Ada name.") | 257 "Determine the filename of a package/procedure from its own Ada name.") |
267 (defvar modula2-other-file-alist | 262 (defvar modula2-other-file-alist |
268 '( | 263 '( |
269 ("\\.mi$" (".md")) ;; Modula-2 module definition | 264 ("\\.mi$" (".md")) ;; Modula-2 module definition |
270 ("\\.md$" (".mi")) ;; and implementation. | 265 ("\\.md$" (".mi")) ;; and implementation. |
271 ) | 266 ) |
272 "*See the description for the ff-search-directories variable.") | 267 "*See the description for the `ff-search-directories' variable.") |
273 | 268 |
274 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 269 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
275 ;; No user definable variables beyond this point! | 270 ;; No user definable variables beyond this point! |
276 ;; ============================================== | 271 ;; ============================================== |
277 | 272 |
290 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 285 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
291 ;; User entry points | 286 ;; User entry points |
292 | 287 |
293 ;;;###autoload | 288 ;;;###autoload |
294 (defun ff-get-other-file (&optional in-other-window) | 289 (defun ff-get-other-file (&optional in-other-window) |
295 "Find the corresponding header or source file to this source or header | 290 "Find the header or source file corresponding to this file. |
296 file. See also the documentation for ff-find-other-file. | 291 See also the documentation for `ff-find-other-file;. |
297 | 292 |
298 If optional IN-OTHER-WINDOW is non-nil, finds the file in another window. | 293 If optional IN-OTHER-WINDOW is non-nil, find the file in another window." |
299 | |
300 Arguments: (&optional in-other-window)" | |
301 (interactive "P") | 294 (interactive "P") |
302 (let ((ignore ff-ignore-include)) | 295 (let ((ignore ff-ignore-include)) |
303 (setq ff-ignore-include t) | 296 (setq ff-ignore-include t) |
304 (ff-find-the-other-file in-other-window) | 297 (ff-find-the-other-file in-other-window) |
305 (setq ff-ignore-include ignore))) | 298 (setq ff-ignore-include ignore))) |
306 | 299 |
307 ;;;###autoload | 300 ;;;###autoload |
308 (defun ff-find-other-file (&optional in-other-window ignore-include) | 301 (defun ff-find-other-file (&optional in-other-window ignore-include) |
309 "Find the corresponding header or source file to this source or header | 302 "Find the header or source file corresponding to this file. |
310 file; being on a #include line pulls in that file. | 303 Being on a `#include' line pulls in that file. |
311 | 304 |
312 If optional IN-OTHER-WINDOW is non-nil, finds the file in the other window. | 305 If optional IN-OTHER-WINDOW is non-nil, find the file in the other window. |
313 If optional IGNORE-INCLUDE is non-nil, ignores being on #include lines. | 306 If optional IGNORE-INCLUDE is non-nil, ignore being on `#include' lines. |
314 | |
315 Arguments: (&optional in-other-window ignore-include) | |
316 | 307 |
317 Variables of interest include: | 308 Variables of interest include: |
318 | 309 |
319 - ff-case-fold-search | 310 - ff-case-fold-search |
320 Non-nil means ignore cases in matches (see case-fold-search). | 311 Non-nil means ignore cases in matches (see case-fold-search). |
366 (setq ff-ignore-include ignore))) | 357 (setq ff-ignore-include ignore))) |
367 | 358 |
368 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 359 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
369 ;; Support functions | 360 ;; Support functions |
370 | 361 |
371 (defun ff-gnu-emacs-19 () | 362 (defun ff-emacs-19 () |
372 (string-match "^19\\.[0-9]+\\.[0-9]+$" emacs-version)) | 363 (string-match "^19\\.[0-9]+\\.[0-9]+$" emacs-version)) |
373 | 364 |
374 (defun ff-xemacs () | 365 (defun ff-xemacs () |
375 (or (string-match "Lucid" emacs-version) | 366 (or (string-match "Lucid" emacs-version) |
376 (string-match "XEmacs" emacs-version))) | 367 (string-match "XEmacs" emacs-version))) |
377 | 368 |
378 (defun ff-find-the-other-file (&optional in-other-window) | 369 (defun ff-find-the-other-file (&optional in-other-window) |
379 "Find the corresponding header or source file to this source or header | 370 "Find the header or source file corresponding to the current file. |
380 file; being on a #include line pulls in that file, but see the help on | 371 Being on a `#include' line pulls in that file, but see the help on |
381 the ff-ignore-include variable. | 372 the `ff-ignore-include' variable. |
382 | 373 |
383 If optional IN-OTHER-WINDOW is non-nil, finds the file in another window. | 374 If optional IN-OTHER-WINDOW is non-nil, find the file in another window." |
384 | |
385 Arguments: (&optional in-other-window)" | |
386 | 375 |
387 (let (match ;; matching regexp for this file | 376 (let (match ;; matching regexp for this file |
388 suffixes ;; set of replacing regexps for the matching regexp | 377 suffixes ;; set of replacing regexps for the matching regexp |
389 action ;; function to generate the names of the other files | 378 action ;; function to generate the names of the other files |
390 fname ;; basename of this file | 379 fname ;; basename of this file |
658 (message "%s found" found)) | 647 (message "%s found" found)) |
659 | 648 |
660 found)) | 649 found)) |
661 | 650 |
662 (defun ff-string-match (regexp string &optional start) | 651 (defun ff-string-match (regexp string &optional start) |
663 "Like string-match (which see), but sets case-fold-search to | 652 "Like string-match (which see), but set `case-fold-search' temporarily. |
664 ff-case-fold-search before searching, and then resets it back again." | 653 The value used comes from `ff-case-fold-search'." |
665 (let ((exact-match case-fold-search) | 654 (let ((case-fold-search ff-case-fold-search)) |
666 match) | |
667 (if regexp | 655 (if regexp |
668 (progn | 656 (string-match regexp string start)))) |
669 (setq case-fold-search ff-case-fold-search) | |
670 (setq match (string-match regexp string start)) | |
671 (setq case-fold-search exact-match))) | |
672 match)) | |
673 | 657 |
674 (defun ff-list-replace-env-vars (search-list) | 658 (defun ff-list-replace-env-vars (search-list) |
675 "Replace environment variables (of the form $VARIABLE) in SEARCH-LIST." | 659 "Replace environment variables (of the form $VARIABLE) in SEARCH-LIST." |
676 (let (list | 660 (let (list |
677 (var (car search-list))) | 661 (var (car search-list))) |
686 (setq list (cons var list)) | 670 (setq list (cons var list)) |
687 (setq var (car search-list))) | 671 (setq var (car search-list))) |
688 (setq search-list (reverse list)))) | 672 (setq search-list (reverse list)))) |
689 | 673 |
690 (defun ff-treat-as-special () | 674 (defun ff-treat-as-special () |
691 "Returns the file to look for if the construct was special, otherwise | 675 "Returns the file to look for if the construct was special, else nil. |
692 returns nil. The construct is defined in the variable ff-special-constructs | 676 The construct is defined in the variable `ff-special-constructs' (which see)." |
693 (which see)." | |
694 (let* (fname | 677 (let* (fname |
695 (list ff-special-constructs) | 678 (list ff-special-constructs) |
696 (elem (car list)) | 679 (elem (car list)) |
697 (regexp (car elem)) | 680 (regexp (car elem)) |
698 (match (cdr elem))) | 681 (match (cdr elem))) |
704 (setq regexp (car elem)) | 687 (setq regexp (car elem)) |
705 (setq match (cdr elem))) | 688 (setq match (cdr elem))) |
706 fname)) | 689 fname)) |
707 | 690 |
708 (defun ff-basename (string) | 691 (defun ff-basename (string) |
709 "Returns the basename of PATHNAME." | 692 "Return the basename of PATHNAME." |
710 (setq string (concat "/" string)) | 693 (setq string (concat "/" string)) |
711 (string-match ".*/\\([^/]+\\)$" string) | 694 (string-match ".*/\\([^/]+\\)$" string) |
712 (setq string (substring string (match-beginning 1) (match-end 1)))) | 695 (setq string (substring string (match-beginning 1) (match-end 1)))) |
713 | 696 |
714 (defun ff-all-dirs-under (here &optional exclude) | 697 (defun ff-all-dirs-under (here &optional exclude) |
715 "Get all the directory files under DIRECTORY. | 698 "Get all the directory files under directory HERE. |
716 Exclude all files in the optional EXCLUDE list." | 699 Exclude all files in the optional EXCLUDE list." |
717 (if (file-directory-p here) | 700 (if (file-directory-p here) |
718 (condition-case nil | 701 (condition-case nil |
719 (progn | 702 (progn |
720 (let ((files (directory-files here t)) | 703 (let ((files (directory-files here t)) |
730 (setq dirlist (reverse dirlist)))) | 713 (setq dirlist (reverse dirlist)))) |
731 (error nil)) | 714 (error nil)) |
732 nil)) | 715 nil)) |
733 | 716 |
734 (defun ff-switch-file (f1 f2 file &optional in-other-window new-file) | 717 (defun ff-switch-file (f1 f2 file &optional in-other-window new-file) |
735 "Calls Function2 or Function1 with FILE as argument, depending on whether | 718 "Call F1 or F2 on FILE, according to IN-OTHER-WINDOW. |
736 (optional) OTHER-WINDOW is set or not. Function1 and Function2 are typically | 719 In addition, this runs various hooks. |
737 find-file / find-file-other-window or switch-to-buffer / switch-to-buffer- | 720 |
738 other-window function pairs. | 721 Either F1 or F2 receives FILE as the sole argument. |
739 | 722 The decision of which one to call is based on IN-OTHER-WINDOW |
740 If optional NEW-FILE is t, then a special hook (ff-file-created-hooks) is | 723 and on the global variable `ff-always-in-other-window'. |
741 called before ff-post-load-hooks. | 724 |
742 | 725 F1 and F2 are typically `find-file' / `find-file-other-window' |
743 Arguments: (function1 function2 file &optional in-other-window new-file) | 726 or `switch-to-buffer' / `switch-to-buffer-other-window' function pairs. |
744 " | 727 |
728 If optional NEW-FILE is t, then a special hook (`ff-file-created-hooks') is | |
729 called before `ff-post-load-hooks'." | |
745 (if ff-pre-load-hooks | 730 (if ff-pre-load-hooks |
746 (run-hooks 'ff-pre-load-hooks)) | 731 (run-hooks 'ff-pre-load-hooks)) |
747 (if (or | 732 (if (or |
748 (and in-other-window (not ff-always-in-other-window)) | 733 (and in-other-window (not ff-always-in-other-window)) |
749 (and (not in-other-window) ff-always-in-other-window)) | 734 (and (not in-other-window) ff-always-in-other-window)) |
754 (run-hooks 'ff-file-created-hooks))) | 739 (run-hooks 'ff-file-created-hooks))) |
755 (if ff-post-load-hooks | 740 (if ff-post-load-hooks |
756 (run-hooks 'ff-post-load-hooks))) | 741 (run-hooks 'ff-post-load-hooks))) |
757 | 742 |
758 (defun ff-find-file (file &optional in-other-window new-file) | 743 (defun ff-find-file (file &optional in-other-window new-file) |
759 "Like find-file (which see), but checks whether the file goes in another | 744 "Like `find-file' (which see), but may put the file in another window." |
760 window or not. | |
761 | |
762 Arguments: (file &optional in-other-window new-file) | |
763 " | |
764 (ff-switch-file 'find-file | 745 (ff-switch-file 'find-file |
765 'find-file-other-window | 746 'find-file-other-window |
766 file in-other-window new-file)) | 747 file in-other-window new-file)) |
767 | 748 |
768 (defun ff-switch-to-buffer (file &optional in-other-window) | 749 (defun ff-switch-to-buffer (file &optional in-other-window) |
769 "Like switch-to-buffer (which see), but checks whether the buffer ends up | 750 "Like `switch-to-buffer' (which see), but may put the buffer in another window." |
770 in another window or not. | 751 |
771 | |
772 Arguments: (file &optional in-other-window) | |
773 " | |
774 (ff-switch-file 'switch-to-buffer | 752 (ff-switch-file 'switch-to-buffer |
775 'switch-to-buffer-other-window | 753 'switch-to-buffer-other-window |
776 file in-other-window nil)) | 754 file in-other-window nil)) |
777 | 755 |
778 (cond | 756 (cond |
779 ((ff-gnu-emacs-19) | 757 ((ff-emacs-19) |
780 (defun ff-goto-click (event) | 758 (defun ff-goto-click (event) |
781 (set-buffer (window-buffer (posn-window (event-end event)))) | 759 (set-buffer (window-buffer (posn-window (event-end event)))) |
782 (goto-char (posn-point (event-end event)))) | 760 (goto-char (posn-point (event-end event)))) |
783 | 761 |
784 ;;;###autoload | 762 ;;;###autoload |
826 (provide 'find-file) | 804 (provide 'find-file) |
827 | 805 |
828 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 806 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
829 ;; This section offers an example of user defined function to select files | 807 ;; This section offers an example of user defined function to select files |
830 | 808 |
831 (defun upcase-p (string &optional start end) | 809 (defun ff-upcase-p (string &optional start end) |
832 "Return t if this string is all uppercase. Given START and/or END, | 810 "Return t if this string is all uppercase. |
833 checks between these characters." | 811 Given START and/or END, checks between these characters." |
834 (let (match str) | 812 (let (match str) |
835 (if (not start) | 813 (if (not start) |
836 (setq start 0)) | 814 (setq start 0)) |
837 (if (not end) | 815 (if (not end) |
838 (setq end (length string))) | 816 (setq end (length string))) |
846 (= (car (cdr match)) (length str))) | 824 (= (car (cdr match)) (length str))) |
847 t | 825 t |
848 nil))) | 826 nil))) |
849 | 827 |
850 (defun ff-cc-hh-converter (arg) | 828 (defun ff-cc-hh-converter (arg) |
851 "Discriminate file extensions and build up a new file list based | 829 "Discriminate file extensions. |
852 possibly on part of the directory name and the name of the file | 830 Build up a new file list based possibly on part of the directory name |
853 passed in." | 831 and the name of the file passed in." |
854 (ff-string-match "\\(.*\\)/\\([^/]+\\)/\\([^.]+\\).\\([^/]+\\)$" arg) | 832 (ff-string-match "\\(.*\\)/\\([^/]+\\)/\\([^.]+\\).\\([^/]+\\)$" arg) |
855 (let ((path (if (match-beginning 1) | 833 (let ((path (if (match-beginning 1) |
856 (substring arg (match-beginning 1) (match-end 1)) nil)) | 834 (substring arg (match-beginning 1) (match-end 1)) nil)) |
857 (dire (if (match-beginning 2) | 835 (dire (if (match-beginning 2) |
858 (substring arg (match-beginning 2) (match-end 2)) nil)) | 836 (substring arg (match-beginning 2) (match-end 2)) nil)) |
871 (concat stub ".h") | 849 (concat stub ".h") |
872 (concat file ".hh") | 850 (concat file ".hh") |
873 (concat file ".h"))) | 851 (concat file ".h"))) |
874 )) | 852 )) |
875 ;; FOO/ZapJunk.hh => fooZapJunk.{cc,C} or ZapJunk.{cc,C} | 853 ;; FOO/ZapJunk.hh => fooZapJunk.{cc,C} or ZapJunk.{cc,C} |
876 ((and (string= extn "hh") (upcase-p dire) file) | 854 ((and (string= extn "hh") (ff-upcase-p dire) file) |
877 (let ((stub (concat (downcase dire) file))) | 855 (let ((stub (concat (downcase dire) file))) |
878 (setq return-list (list (concat stub ".cc") | 856 (setq return-list (list (concat stub ".cc") |
879 (concat stub ".C") | 857 (concat stub ".C") |
880 (concat file ".cc") | 858 (concat file ".cc") |
881 (concat file ".C"))) | 859 (concat file ".C"))) |
907 (defvar ada-package-start-regexp) | 885 (defvar ada-package-start-regexp) |
908 | 886 |
909 ;; bind with (setq ff-pre-load-hooks 'ff-which-function-are-we-in) | 887 ;; bind with (setq ff-pre-load-hooks 'ff-which-function-are-we-in) |
910 ;; | 888 ;; |
911 (defun ff-which-function-are-we-in () | 889 (defun ff-which-function-are-we-in () |
912 "Determine whether we are on a function definition/declaration and | 890 "Return the name of the function whose definition/declaration point is in. |
913 remember the name of that function." | 891 Also remember that name in `ff-function-name'." |
914 | 892 |
915 (setq ff-function-name nil) | 893 (setq ff-function-name nil) |
916 | 894 |
917 (save-excursion | 895 (save-excursion |
918 (if (re-search-backward ada-procedure-start-regexp nil t) | 896 (if (re-search-backward ada-procedure-start-regexp nil t) |
925 )))) | 903 )))) |
926 | 904 |
927 ;; bind with (setq ff-post-load-hooks 'ff-set-point-accordingly) | 905 ;; bind with (setq ff-post-load-hooks 'ff-set-point-accordingly) |
928 ;; | 906 ;; |
929 (defun ff-set-point-accordingly () | 907 (defun ff-set-point-accordingly () |
930 "Find the function specified in ff-function-name, previously | 908 "Find the function specified in `ff-function-name'. |
931 determined by ff-which-function-are-we-in." | 909 That name was previously etermined by `ff-which-function-are-we-in'." |
932 (if ff-function-name | 910 (if ff-function-name |
933 (progn | 911 (progn |
934 (goto-char (point-min)) | 912 (goto-char (point-min)) |
935 (search-forward ff-function-name nil t)))) | 913 (search-forward ff-function-name nil t)))) |
936 | 914 |