101 |
;; |
;; |
102 |
;; THERE ARE FIVE AVAILABLE HOOKS, called in this order if non-nil: |
;; THERE ARE FIVE AVAILABLE HOOKS, called in this order if non-nil: |
103 |
;; |
;; |
104 |
;; - ff-pre-find-hooks - called before the search for the other file starts |
;; - ff-pre-find-hook - called before the search for the other file starts |
105 |
;; - ff-not-found-hooks - called when the other file could not be found |
;; - ff-not-found-hook - called when the other file could not be found |
106 |
;; - ff-pre-load-hooks - called just before the other file is 'loaded' |
;; - ff-pre-load-hook - called just before the other file is 'loaded' |
107 |
;; - ff-file-created-hooks - called when the other file is created |
;; - ff-file-created-hook - called when the other file is created |
108 |
;; - ff-post-load-hooks - called just after the other file is 'loaded' |
;; - ff-post-load-hook - called just after the other file is 'loaded' |
109 |
;; |
;; |
110 |
;; The *load-hooks allow you to place point where you want it in the other |
;; The *load-hook allow you to place point where you want it in the other |
111 |
;; file. |
;; file. |
112 |
|
|
113 |
;; CREDITS: |
;; CREDITS: |
130 |
:link '(emacs-commentary-link "find-file") |
:link '(emacs-commentary-link "find-file") |
131 |
:group 'find-file) |
:group 'find-file) |
132 |
|
|
133 |
(defcustom ff-pre-find-hooks nil |
(defcustom ff-pre-find-hook nil |
134 |
"*List of functions to be called before the search for the file starts." |
"*List of functions to be called before the search for the file starts." |
135 |
:type 'hook |
:type 'hook |
136 |
:group 'ff) |
:group 'ff) |
137 |
|
|
138 |
(defcustom ff-pre-load-hooks nil |
(defcustom ff-pre-load-hook nil |
139 |
"*List of functions to be called before the other file is loaded." |
"*List of functions to be called before the other file is loaded." |
140 |
:type 'hook |
:type 'hook |
141 |
:group 'ff) |
:group 'ff) |
142 |
|
|
143 |
(defcustom ff-post-load-hooks nil |
(defcustom ff-post-load-hook nil |
144 |
"*List of functions to be called after the other file is loaded." |
"*List of functions to be called after the other file is loaded." |
145 |
:type 'hook |
:type 'hook |
146 |
:group 'ff) |
:group 'ff) |
147 |
|
|
148 |
(defcustom ff-not-found-hooks nil |
(defcustom ff-not-found-hook nil |
149 |
"*List of functions to be called if the other file could not be found." |
"*List of functions to be called if the other file could not be found." |
150 |
:type 'hook |
:type 'hook |
151 |
:group 'ff) |
:group 'ff) |
152 |
|
|
153 |
(defcustom ff-file-created-hooks nil |
(defcustom ff-file-created-hook nil |
154 |
"*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." |
155 |
:type 'hook |
:type 'hook |
156 |
:group 'ff) |
:group 'ff) |
284 |
;; No user definable variables beyond this point! |
;; No user definable variables beyond this point! |
285 |
;; ============================================== |
;; ============================================== |
286 |
|
|
287 |
(make-variable-buffer-local 'ff-pre-find-hooks) |
(make-variable-buffer-local 'ff-pre-find-hook) |
288 |
(make-variable-buffer-local 'ff-pre-load-hooks) |
(make-variable-buffer-local 'ff-pre-load-hook) |
289 |
(make-variable-buffer-local 'ff-post-load-hooks) |
(make-variable-buffer-local 'ff-post-load-hook) |
290 |
(make-variable-buffer-local 'ff-not-found-hooks) |
(make-variable-buffer-local 'ff-not-found-hook) |
291 |
(make-variable-buffer-local 'ff-file-created-hooks) |
(make-variable-buffer-local 'ff-file-created-hook) |
292 |
(make-variable-buffer-local 'ff-case-fold-search) |
(make-variable-buffer-local 'ff-case-fold-search) |
293 |
(make-variable-buffer-local 'ff-always-in-other-window) |
(make-variable-buffer-local 'ff-always-in-other-window) |
294 |
(make-variable-buffer-local 'ff-ignore-include) |
(make-variable-buffer-local 'ff-ignore-include) |
350 |
List of directories searched through with each extension specified in |
List of directories searched through with each extension specified in |
351 |
`ff-other-file-alist' that matches this file's extension. |
`ff-other-file-alist' that matches this file's extension. |
352 |
|
|
353 |
- `ff-pre-find-hooks' |
- `ff-pre-find-hook' |
354 |
List of functions to be called before the search for the file starts. |
List of functions to be called before the search for the file starts. |
355 |
|
|
356 |
- `ff-pre-load-hooks' |
- `ff-pre-load-hook' |
357 |
List of functions to be called before the other file is loaded. |
List of functions to be called before the other file is loaded. |
358 |
|
|
359 |
- `ff-post-load-hooks' |
- `ff-post-load-hook' |
360 |
List of functions to be called after the other file is loaded. |
List of functions to be called after the other file is loaded. |
361 |
|
|
362 |
- `ff-not-found-hooks' |
- `ff-not-found-hook' |
363 |
List of functions to be called if the other file could not be found. |
List of functions to be called if the other file could not be found. |
364 |
|
|
365 |
- `ff-file-created-hooks' |
- `ff-file-created-hook' |
366 |
List of functions to be called if the other file has been created." |
List of functions to be called if the other file has been created." |
367 |
(interactive "P") |
(interactive "P") |
368 |
(let ((ignore ff-ignore-include)) |
(let ((ignore ff-ignore-include)) |
394 |
dirs ;; local value of ff-search-directories |
dirs ;; local value of ff-search-directories |
395 |
no-match) ;; whether we know about this kind of file |
no-match) ;; whether we know about this kind of file |
396 |
|
|
397 |
(if ff-pre-find-hooks |
(run-hooks 'ff-pre-find-hook 'ff-pre-find-hooks) |
|
(run-hooks 'ff-pre-find-hooks)) |
|
398 |
|
|
399 |
(message "Working...") |
(message "Working...") |
400 |
|
|
485 |
|
|
486 |
((not found) ;; could not find the other file |
((not found) ;; could not find the other file |
487 |
|
|
488 |
(if ff-not-found-hooks ;; run the hooks |
(run-hooks 'ff-not-found-hook 'ff-not-found-hooks) |
|
(run-hooks 'ff-not-found-hooks)) |
|
489 |
|
|
490 |
(cond |
(cond |
491 |
(ff-always-try-to-create ;; try to create the file |
(ff-always-try-to-create ;; try to create the file |
821 |
F1 and F2 are typically `find-file' / `find-file-other-window' |
F1 and F2 are typically `find-file' / `find-file-other-window' |
822 |
or `switch-to-buffer' / `switch-to-buffer-other-window' function pairs. |
or `switch-to-buffer' / `switch-to-buffer-other-window' function pairs. |
823 |
|
|
824 |
If optional NEW-FILE is t, then a special hook (`ff-file-created-hooks') is |
If optional NEW-FILE is t, then a special hook (`ff-file-created-hook') is |
825 |
called before `ff-post-load-hooks'." |
called before `ff-post-load-hook'." |
826 |
(if ff-pre-load-hooks |
(run-hooks 'ff-pre-load-hook 'ff-pre-load-hooks) |
|
(run-hooks 'ff-pre-load-hooks)) |
|
827 |
(if (or |
(if (or |
828 |
(and in-other-window (not ff-always-in-other-window)) |
(and in-other-window (not ff-always-in-other-window)) |
829 |
(and (not in-other-window) ff-always-in-other-window)) |
(and (not in-other-window) ff-always-in-other-window)) |
830 |
(funcall f2 file) |
(funcall f2 file) |
831 |
(funcall f1 file)) |
(funcall f1 file)) |
832 |
(if new-file |
(if new-file |
833 |
(if ff-file-created-hooks |
(run-hooks 'ff-file-created-hook 'ff-file-created-hooks)) |
834 |
(run-hooks 'ff-file-created-hooks))) |
(run-hooks 'ff-post-load-hook 'ff-post-load-hooks)) |
|
(if ff-post-load-hooks |
|
|
(run-hooks 'ff-post-load-hooks))) |
|
835 |
|
|
836 |
(defun ff-find-file (file &optional in-other-window new-file) |
(defun ff-find-file (file &optional in-other-window new-file) |
837 |
"Like `find-file', but may show the file in another window." |
"Like `find-file', but may show the file in another window." |
942 |
|
|
943 |
;(eval-when-compile (require 'ada-mode)) |
;(eval-when-compile (require 'ada-mode)) |
944 |
|
|
945 |
;; bind with (setq ff-pre-load-hooks 'ff-which-function-are-we-in) |
;; bind with (setq ff-pre-load-hook 'ff-which-function-are-we-in) |
946 |
;; |
;; |
947 |
(defun ff-which-function-are-we-in () |
(defun ff-which-function-are-we-in () |
948 |
"Return the name of the function whose definition/declaration point is in. |
"Return the name of the function whose definition/declaration point is in. |
960 |
(match-end 0))) |
(match-end 0))) |
961 |
)))) |
)))) |
962 |
|
|
963 |
;; bind with (setq ff-post-load-hooks 'ff-set-point-accordingly) |
;; bind with (setq ff-post-load-hook 'ff-set-point-accordingly) |
964 |
;; |
;; |
965 |
(defun ff-set-point-accordingly () |
(defun ff-set-point-accordingly () |
966 |
"Find the function specified in `ff-function-name'. |
"Find the function specified in `ff-function-name'. |