Function: ff-find-other-file

ff-find-other-file is an autoloaded, interactive and byte-compiled function defined in find-file.el.gz.

Signature

(ff-find-other-file &optional IN-OTHER-WINDOW IGNORE-INCLUDE EVENT)

Documentation

Find the header or source file corresponding to this file.

Being on a #include line pulls in that file.

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.

If optional EVENT is non-nil (default last-nonmenu-event, move point to the end position of that event before calling the various ff-* hooks.

Variables of interest include:

 - ff-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.

 - ff-always-in-other-window
   If non-nil, always open the other file in another window, unless an
   argument is given to ff-find-other-file.

 - ff-ignore-include
   If non-nil, ignores #include lines.

 - ff-always-try-to-create
   If non-nil, always attempt to create the other file if it was not found.

 - ff-quiet-mode
   If non-nil, does not trace which directories are being searched.

 - ff-special-constructs
   A list of regular expressions specifying how to recognize special
   constructs such as include files etc, and an associated method for
   extracting the filename from that construct.

 - ff-other-file-alist
   Alist of extensions to find given the current file's extension.

 - ff-search-directories
   List of directories searched through with each extension specified in
   ff-other-file-alist that matches this file's extension.

 - ff-pre-find-hook
   List of functions to be called before the search for the file starts.

 - ff-pre-load-hook
   List of functions to be called before the other file is loaded.

 - ff-post-load-hook
   List of functions to be called after the other file is loaded.

 - ff-not-found-hook
   List of functions to be called if the other file could not be found.

 - ff-file-created-hook
   List of functions to be called if the other file has been created.

Key Bindings

Aliases

ff-mouse-find-other-file (obsolete since 28.1) ff-find-related-file

Source Code

;; Defined in /usr/src/emacs/lisp/find-file.el.gz
;;;###autoload
(defun ff-find-other-file (&optional in-other-window ignore-include event)
  "Find the header or source file corresponding to this file.
Being on a `#include' line pulls in that file.

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.

If optional EVENT is non-nil (default `last-nonmenu-event', move
point to the end position of that event before calling the
various ff-* hooks.

Variables of interest include:

 - `ff-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.

 - `ff-always-in-other-window'
   If non-nil, always open the other file in another window, unless an
   argument is given to `ff-find-other-file'.

 - `ff-ignore-include'
   If non-nil, ignores #include lines.

 - `ff-always-try-to-create'
   If non-nil, always attempt to create the other file if it was not found.

 - `ff-quiet-mode'
   If non-nil, does not trace which directories are being searched.

 - `ff-special-constructs'
   A list of regular expressions specifying how to recognize special
   constructs such as include files etc, and an associated method for
   extracting the filename from that construct.

 - `ff-other-file-alist'
   Alist of extensions to find given the current file's extension.

 - `ff-search-directories'
   List of directories searched through with each extension specified in
   `ff-other-file-alist' that matches this file's extension.

 - `ff-pre-find-hook'
   List of functions to be called before the search for the file starts.

 - `ff-pre-load-hook'
   List of functions to be called before the other file is loaded.

 - `ff-post-load-hook'
   List of functions to be called after the other file is loaded.

 - `ff-not-found-hook'
   List of functions to be called if the other file could not be found.

 - `ff-file-created-hook'
   List of functions to be called if the other file has been created."
  (interactive (list current-prefix-arg nil last-nonmenu-event))
  ;; We want to preserve point in the current buffer. But the point of
  ;; ff-find-the-other-file is to make the other file buffer
  ;; current, so we can't use save-excursion here (see bug 48535).
  (let ((start-buffer (current-buffer))
        (start-point (point)))
    (posn-set-point (event-end event))
    (let ((ff-ignore-include ignore-include))
      (ff-find-the-other-file in-other-window))
    (with-current-buffer start-buffer
      (goto-char start-point))))