Commit 8c17509e authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

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.
parent e0292621
...@@ -108,11 +108,6 @@ ...@@ -108,11 +108,6 @@
;; The *load-hooks allow you to place point where you want it in the other ;; The *load-hooks allow you to place point where you want it in the other
;; file. ;; file.
;; LCD Archive Entry:
;; find-file|Henry Guillaume|henry@qbd.com.au|
;; Find a file associated with this buffer.|
;; 21-Dec-1994|4.0|~/misc/find-file.el.Z|
;; FEEDBACK: ;; FEEDBACK:
;; Please send me bug reports, bug fixes, and extensions, so that I can ;; Please send me bug reports, bug fixes, and extensions, so that I can
;; merge them into the master source. ;; merge them into the master source.
...@@ -147,21 +142,21 @@ ...@@ -147,21 +142,21 @@
"*List of functions to be called if the other file needs to be created.") "*List of functions to be called if the other file needs to be created.")
(defvar ff-case-fold-search nil (defvar ff-case-fold-search nil
"*Non-nil means ignore cases in matches (see case-fold-search). "*Non-nil means ignore cases in matches (see `case-fold-search').
If you have extensions in different cases, you will want this to be nil.") If you have extensions in different cases, you will want this to be nil.")
(defvar ff-always-in-other-window nil (defvar ff-always-in-other-window nil
"*If non-nil, always open the other file in another window, unless an "*If non-nil, find the corresponding file in another window by default.
argument is given to ff-find-other-file.") To override this, give an argument to `ff-find-other-file'.")
(defvar ff-ignore-include nil (defvar ff-ignore-include nil
"*If non-nil, ignores include lines.") "*If non-nil, ignore `#include' lines.")
(defvar ff-always-try-to-create t (defvar ff-always-try-to-create t
"*If non-nil, always attempt to create the other file if it was not found.") "*If non-nil, always attempt to create the other file if it was not found.")
(defvar ff-quiet-mode nil (defvar ff-quiet-mode nil
"*If non-nil, traces which directories are being searched.") "*If non-nil, trace which directories are being searched.")
(defvar ff-special-constructs (defvar ff-special-constructs
'( '(
...@@ -186,17 +181,17 @@ extracting the filename from that construct.") ...@@ -186,17 +181,17 @@ extracting the filename from that construct.")
This list should contain the most used extensions before the others, This list should contain the most used extensions before the others,
since the search algorithm searches sequentially through each since the search algorithm searches sequentially through each
directory specified in ff-search-directories. If a file is not found, directory specified in `ff-search-directories'. If a file is not found,
a new one is created with the first matching extension (.cc yields .hh). a new one is created with the first matching extension (`.cc' yields `.hh').
This alist should be set by the major-mode.") This alist should be set by the major mode.")
(defvar ff-search-directories 'cc-search-directories (defvar ff-search-directories 'cc-search-directories
"*List of directories to search for a specific file. "*List of directories to search for a specific file.
Set by default to 'cc-search-directories, expanded at run-time. Set by default to `cc-search-directories', expanded at run-time.
This list is searched through with each extension specified in This list is searched through with each extension specified in
ff-other-file-alist that matches this file's extension. So the `ff-other-file-alist' that matches this file's extension. So the
longer the list, the longer it'll take to realise that a file longer the list, the longer it'll take to realise that a file
may not exist. may not exist.
...@@ -204,17 +199,17 @@ A typical format is ...@@ -204,17 +199,17 @@ A typical format is
'(\".\" \"/usr/include/*\" \"$PROJECT/*/include\") '(\".\" \"/usr/include/*\" \"$PROJECT/*/include\")
Environment variables can be inserted between slashes ('/'). Environment variables can be inserted between slashes (`/').
They will be replaced by their definition. If a variable does They will be replaced by their definition. If a variable does
not exist, it will (silently) be replaced with an empty string. not exist, it is replaced (silently) with an empty string.
The stars are _not_ wildcards: they are searched for together with The stars are *not* wildcards: they are searched for together with
the preceding slash. The star represents all the subdirectories except the preceding slash. The star represents all the subdirectories except
'..', and each of these subdirectories will be searched in turn.") `..', and each of these subdirectories will be searched in turn.")
(defvar cc-search-directories (defvar cc-search-directories
'("." "/usr/include/*" "/usr/local/include/*") '("." "/usr/include/*" "/usr/local/include/*")
"*See the description of the ff-search-directories variable.") "*See the description of the `ff-search-directories' variable.")
(defvar cc-other-file-alist (defvar cc-other-file-alist
'( '(
...@@ -237,12 +232,12 @@ the preceding slash. The star represents all the subdirectories except ...@@ -237,12 +232,12 @@ the preceding slash. The star represents all the subdirectories except
This list should contain the most used extensions before the others, This list should contain the most used extensions before the others,
since the search algorithm searches sequentially through each directory since the search algorithm searches sequentially through each directory
specified in ff-search-directories. If a file is not found, a new one specified in `ff-search-directories'. If a file is not found, a new one
is created with the first matching extension (.cc yields .hh).") is created with the first matching extension (`.cc' yields `.hh').")
(defvar ada-search-directories (defvar ada-search-directories
'("." "/usr/adainclude" "/usr/local/adainclude") '("." "/usr/adainclude" "/usr/local/adainclude")
"*See the description for the ff-search-directories variable.") "*See the description for the `ff-search-directories' variable.")
(defvar ada-other-file-alist (defvar ada-other-file-alist
'( '(
...@@ -253,8 +248,8 @@ is created with the first matching extension (.cc yields .hh).") ...@@ -253,8 +248,8 @@ is created with the first matching extension (.cc yields .hh).")
This list should contain the most used extensions before the others, This list should contain the most used extensions before the others,
since the search algorithm searches sequentially through each directory since the search algorithm searches sequentially through each directory
specified in ada-search-directories. If a file is not found, a new one specified in `ada-search-directories'. If a file is not found, a new one
is created with the first matching extension (.adb yields .ads). is created with the first matching extension (`.adb' yields `.ads').
") ")
;;;### autoload ;;;### autoload
...@@ -269,7 +264,7 @@ is created with the first matching extension (.adb yields .ads). ...@@ -269,7 +264,7 @@ is created with the first matching extension (.adb yields .ads).
("\\.mi$" (".md")) ;; Modula-2 module definition ("\\.mi$" (".md")) ;; Modula-2 module definition
("\\.md$" (".mi")) ;; and implementation. ("\\.md$" (".mi")) ;; and implementation.
) )
"*See the description for the ff-search-directories variable.") "*See the description for the `ff-search-directories' variable.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; No user definable variables beyond this point! ;; No user definable variables beyond this point!
...@@ -292,12 +287,10 @@ is created with the first matching extension (.adb yields .ads). ...@@ -292,12 +287,10 @@ is created with the first matching extension (.adb yields .ads).
;;;###autoload ;;;###autoload
(defun ff-get-other-file (&optional in-other-window) (defun ff-get-other-file (&optional in-other-window)
"Find the corresponding header or source file to this source or header "Find the header or source file corresponding to this file.
file. See also the documentation for ff-find-other-file. See also the documentation for `ff-find-other-file;.
If optional IN-OTHER-WINDOW is non-nil, finds the file in another window.
Arguments: (&optional in-other-window)" If optional IN-OTHER-WINDOW is non-nil, find the file in another window."
(interactive "P") (interactive "P")
(let ((ignore ff-ignore-include)) (let ((ignore ff-ignore-include))
(setq ff-ignore-include t) (setq ff-ignore-include t)
...@@ -306,13 +299,11 @@ Arguments: (&optional in-other-window)" ...@@ -306,13 +299,11 @@ Arguments: (&optional in-other-window)"
;;;###autoload ;;;###autoload
(defun ff-find-other-file (&optional in-other-window ignore-include) (defun ff-find-other-file (&optional in-other-window ignore-include)
"Find the corresponding header or source file to this source or header "Find the header or source file corresponding to this file.
file; being on a #include line pulls in that file. Being on a `#include' line pulls in that file.
If optional IN-OTHER-WINDOW is non-nil, finds the file in the other window.
If optional IGNORE-INCLUDE is non-nil, ignores being on #include lines.
Arguments: (&optional in-other-window ignore-include) If optional IN-OTHER-WINDOW is non-nil, find the file in the other window.
If optional IGNORE-INCLUDE is non-nil, ignore being on `#include' lines.
Variables of interest include: Variables of interest include:
...@@ -368,7 +359,7 @@ Variables of interest include: ...@@ -368,7 +359,7 @@ Variables of interest include:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Support functions ;; Support functions
(defun ff-gnu-emacs-19 () (defun ff-emacs-19 ()
(string-match "^19\\.[0-9]+\\.[0-9]+$" emacs-version)) (string-match "^19\\.[0-9]+\\.[0-9]+$" emacs-version))
(defun ff-xemacs () (defun ff-xemacs ()
...@@ -376,13 +367,11 @@ Variables of interest include: ...@@ -376,13 +367,11 @@ Variables of interest include:
(string-match "XEmacs" emacs-version))) (string-match "XEmacs" emacs-version)))
(defun ff-find-the-other-file (&optional in-other-window) (defun ff-find-the-other-file (&optional in-other-window)
"Find the corresponding header or source file to this source or header "Find the header or source file corresponding to the current file.
file; being on a #include line pulls in that file, but see the help on Being on a `#include' line pulls in that file, but see the help on
the ff-ignore-include variable. the `ff-ignore-include' variable.
If optional IN-OTHER-WINDOW is non-nil, finds the file in another window. If optional IN-OTHER-WINDOW is non-nil, find the file in another window."
Arguments: (&optional in-other-window)"
(let (match ;; matching regexp for this file (let (match ;; matching regexp for this file
suffixes ;; set of replacing regexps for the matching regexp suffixes ;; set of replacing regexps for the matching regexp
...@@ -660,16 +649,11 @@ Arguments: (search-dirs fname-stub &optional suffix-list) ...@@ -660,16 +649,11 @@ Arguments: (search-dirs fname-stub &optional suffix-list)
found)) found))
(defun ff-string-match (regexp string &optional start) (defun ff-string-match (regexp string &optional start)
"Like string-match (which see), but sets case-fold-search to "Like string-match (which see), but set `case-fold-search' temporarily.
ff-case-fold-search before searching, and then resets it back again." The value used comes from `ff-case-fold-search'."
(let ((exact-match case-fold-search) (let ((case-fold-search ff-case-fold-search))
match)
(if regexp (if regexp
(progn (string-match regexp string start))))
(setq case-fold-search ff-case-fold-search)
(setq match (string-match regexp string start))
(setq case-fold-search exact-match)))
match))
(defun ff-list-replace-env-vars (search-list) (defun ff-list-replace-env-vars (search-list)
"Replace environment variables (of the form $VARIABLE) in SEARCH-LIST." "Replace environment variables (of the form $VARIABLE) in SEARCH-LIST."
...@@ -688,9 +672,8 @@ ff-case-fold-search before searching, and then resets it back again." ...@@ -688,9 +672,8 @@ ff-case-fold-search before searching, and then resets it back again."
(setq search-list (reverse list)))) (setq search-list (reverse list))))
(defun ff-treat-as-special () (defun ff-treat-as-special ()
"Returns the file to look for if the construct was special, otherwise "Returns the file to look for if the construct was special, else nil.
returns nil. The construct is defined in the variable ff-special-constructs The construct is defined in the variable `ff-special-constructs' (which see)."
(which see)."
(let* (fname (let* (fname
(list ff-special-constructs) (list ff-special-constructs)
(elem (car list)) (elem (car list))
...@@ -706,13 +689,13 @@ returns nil. The construct is defined in the variable ff-special-constructs ...@@ -706,13 +689,13 @@ returns nil. The construct is defined in the variable ff-special-constructs
fname)) fname))
(defun ff-basename (string) (defun ff-basename (string)
"Returns the basename of PATHNAME." "Return the basename of PATHNAME."
(setq string (concat "/" string)) (setq string (concat "/" string))
(string-match ".*/\\([^/]+\\)$" string) (string-match ".*/\\([^/]+\\)$" string)
(setq string (substring string (match-beginning 1) (match-end 1)))) (setq string (substring string (match-beginning 1) (match-end 1))))
(defun ff-all-dirs-under (here &optional exclude) (defun ff-all-dirs-under (here &optional exclude)
"Get all the directory files under DIRECTORY. "Get all the directory files under directory HERE.
Exclude all files in the optional EXCLUDE list." Exclude all files in the optional EXCLUDE list."
(if (file-directory-p here) (if (file-directory-p here)
(condition-case nil (condition-case nil
...@@ -732,16 +715,18 @@ Exclude all files in the optional EXCLUDE list." ...@@ -732,16 +715,18 @@ Exclude all files in the optional EXCLUDE list."
nil)) nil))
(defun ff-switch-file (f1 f2 file &optional in-other-window new-file) (defun ff-switch-file (f1 f2 file &optional in-other-window new-file)
"Calls Function2 or Function1 with FILE as argument, depending on whether "Call F1 or F2 on FILE, according to IN-OTHER-WINDOW.
(optional) OTHER-WINDOW is set or not. Function1 and Function2 are typically In addition, this runs various hooks.
find-file / find-file-other-window or switch-to-buffer / switch-to-buffer-
other-window function pairs.
If optional NEW-FILE is t, then a special hook (ff-file-created-hooks) is Either F1 or F2 receives FILE as the sole argument.
called before ff-post-load-hooks. The decision of which one to call is based on IN-OTHER-WINDOW
and on the global variable `ff-always-in-other-window'.
Arguments: (function1 function2 file &optional in-other-window new-file) F1 and F2 are typically `find-file' / `find-file-other-window'
" or `switch-to-buffer' / `switch-to-buffer-other-window' function pairs.
If optional NEW-FILE is t, then a special hook (`ff-file-created-hooks') is
called before `ff-post-load-hooks'."
(if ff-pre-load-hooks (if ff-pre-load-hooks
(run-hooks 'ff-pre-load-hooks)) (run-hooks 'ff-pre-load-hooks))
(if (or (if (or
...@@ -756,27 +741,20 @@ Arguments: (function1 function2 file &optional in-other-window new-file) ...@@ -756,27 +741,20 @@ Arguments: (function1 function2 file &optional in-other-window new-file)
(run-hooks 'ff-post-load-hooks))) (run-hooks 'ff-post-load-hooks)))
(defun ff-find-file (file &optional in-other-window new-file) (defun ff-find-file (file &optional in-other-window new-file)
"Like find-file (which see), but checks whether the file goes in another "Like `find-file' (which see), but may put the file in another window."
window or not.
Arguments: (file &optional in-other-window new-file)
"
(ff-switch-file 'find-file (ff-switch-file 'find-file
'find-file-other-window 'find-file-other-window
file in-other-window new-file)) file in-other-window new-file))
(defun ff-switch-to-buffer (file &optional in-other-window) (defun ff-switch-to-buffer (file &optional in-other-window)
"Like switch-to-buffer (which see), but checks whether the buffer ends up "Like `switch-to-buffer' (which see), but may put the buffer in another window."
in another window or not.
Arguments: (file &optional in-other-window)
"
(ff-switch-file 'switch-to-buffer (ff-switch-file 'switch-to-buffer
'switch-to-buffer-other-window 'switch-to-buffer-other-window
file in-other-window nil)) file in-other-window nil))
(cond (cond
((ff-gnu-emacs-19) ((ff-emacs-19)
(defun ff-goto-click (event) (defun ff-goto-click (event)
(set-buffer (window-buffer (posn-window (event-end event)))) (set-buffer (window-buffer (posn-window (event-end event))))
(goto-char (posn-point (event-end event)))) (goto-char (posn-point (event-end event))))
...@@ -828,9 +806,9 @@ Arguments: (file &optional in-other-window) ...@@ -828,9 +806,9 @@ Arguments: (file &optional in-other-window)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This section offers an example of user defined function to select files ;; This section offers an example of user defined function to select files
(defun upcase-p (string &optional start end) (defun ff-upcase-p (string &optional start end)
"Return t if this string is all uppercase. Given START and/or END, "Return t if this string is all uppercase.
checks between these characters." Given START and/or END, checks between these characters."
(let (match str) (let (match str)
(if (not start) (if (not start)
(setq start 0)) (setq start 0))
...@@ -848,9 +826,9 @@ checks between these characters." ...@@ -848,9 +826,9 @@ checks between these characters."
nil))) nil)))
(defun ff-cc-hh-converter (arg) (defun ff-cc-hh-converter (arg)
"Discriminate file extensions and build up a new file list based "Discriminate file extensions.
possibly on part of the directory name and the name of the file Build up a new file list based possibly on part of the directory name
passed in." and the name of the file passed in."
(ff-string-match "\\(.*\\)/\\([^/]+\\)/\\([^.]+\\).\\([^/]+\\)$" arg) (ff-string-match "\\(.*\\)/\\([^/]+\\)/\\([^.]+\\).\\([^/]+\\)$" arg)
(let ((path (if (match-beginning 1) (let ((path (if (match-beginning 1)
(substring arg (match-beginning 1) (match-end 1)) nil)) (substring arg (match-beginning 1) (match-end 1)) nil))
...@@ -873,7 +851,7 @@ passed in." ...@@ -873,7 +851,7 @@ passed in."
(concat file ".h"))) (concat file ".h")))
)) ))
;; FOO/ZapJunk.hh => fooZapJunk.{cc,C} or ZapJunk.{cc,C} ;; FOO/ZapJunk.hh => fooZapJunk.{cc,C} or ZapJunk.{cc,C}
((and (string= extn "hh") (upcase-p dire) file) ((and (string= extn "hh") (ff-upcase-p dire) file)
(let ((stub (concat (downcase dire) file))) (let ((stub (concat (downcase dire) file)))
(setq return-list (list (concat stub ".cc") (setq return-list (list (concat stub ".cc")
(concat stub ".C") (concat stub ".C")
...@@ -909,8 +887,8 @@ passed in." ...@@ -909,8 +887,8 @@ passed in."
;; bind with (setq ff-pre-load-hooks 'ff-which-function-are-we-in) ;; bind with (setq ff-pre-load-hooks 'ff-which-function-are-we-in)
;; ;;
(defun ff-which-function-are-we-in () (defun ff-which-function-are-we-in ()
"Determine whether we are on a function definition/declaration and "Return the name of the function whose definition/declaration point is in.
remember the name of that function." Also remember that name in `ff-function-name'."
(setq ff-function-name nil) (setq ff-function-name nil)
...@@ -927,8 +905,8 @@ remember the name of that function." ...@@ -927,8 +905,8 @@ remember the name of that function."
;; bind with (setq ff-post-load-hooks 'ff-set-point-accordingly) ;; bind with (setq ff-post-load-hooks 'ff-set-point-accordingly)
;; ;;
(defun ff-set-point-accordingly () (defun ff-set-point-accordingly ()
"Find the function specified in ff-function-name, previously "Find the function specified in `ff-function-name'.
determined by ff-which-function-are-we-in." That name was previously etermined by `ff-which-function-are-we-in'."
(if ff-function-name (if ff-function-name
(progn (progn
(goto-char (point-min)) (goto-char (point-min))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment