Variable: find-sibling-rules

find-sibling-rules is a customizable variable defined in files.el.gz.

Value

nil

Documentation

Rules for finding "sibling" files.

This is used by the find-sibling-file command.

The value of this variable should a list (RULE1 RULE2 ...), where each RULE has the form (MATCH EXPANSION...).

MATCH is a regular expression that should match a file name which might have a sibling. It can contain sub-expressions that will be used in each EXPANSION as \N and \& replacements.

Each EXPANSION is a string that matches names of files that are to be considered siblings of a file whose name matches MATCH. For instance, to define ".h" files as siblings of any ".c" with the same basename, you could use the following RULE element in the list of rules:

  ("\\\\([^/]+\\\\)\\\\.c\\\\\\='" "\\\\1.h")

MATCH and EXPANSION can also include leading directories. For instance, if you want to treat as siblings same-name files in directory trees corresponding to different versions of Emacs, you could use a RULE like this:

  ("src/emacs/[^/]+/\\\\(.*\\\\)\\\\\\='" "src/emacs/.*/\\\\1\\\\\\='")

In this example, if you're in "src/emacs/emacs-27/lisp/abbrev.el", and a "src/emacs/emacs-28/lisp/abbrev.el" file exists, the latter file will be considered a sibling of the former one.

This variable was added, or its default value changed, in Emacs 29.1.

View in manual

Probably introduced at or before Emacs version 29.1.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defcustom find-sibling-rules nil
  "Rules for finding \"sibling\" files.
This is used by the `find-sibling-file' command.

The value of this variable should a list (RULE1 RULE2 ...), where each
RULE has the form (MATCH EXPANSION...).

MATCH is a regular expression that should match a file name which might
have a sibling.  It can contain sub-expressions that will be used in
each EXPANSION as \\N and \\& replacements.

Each EXPANSION is a string that matches names of files that are to be
considered siblings of a file whose name matches MATCH.  For instance,
to define \".h\" files as siblings of any \".c\" with the same basename,
you could use the following RULE element in the list of rules:

  (\"\\\\([^/]+\\\\)\\\\.c\\\\\\='\" \"\\\\1.h\")

MATCH and EXPANSION can also include leading directories.  For instance,
if you want to treat as siblings same-name files in directory trees
corresponding to different versions of Emacs, you could use a RULE like
this:

  (\"src/emacs/[^/]+/\\\\(.*\\\\)\\\\\\='\" \"src/emacs/.*/\\\\1\\\\\\='\")

In this example, if you're in \"src/emacs/emacs-27/lisp/abbrev.el\",
and a \"src/emacs/emacs-28/lisp/abbrev.el\" file exists, the latter file
will be considered a sibling of the former one."
  :type '(alist :key-type (regexp :tag "Match")
                :value-type (repeat (string :tag "Expansion")))
  :version "29.1")