Next: Introduction [Contents][Index]
This manual documents the usage of the "Compat" Emacs lisp library, the forward-compatibility library for Emacs Lisp, corresponding to version 30.0.1.0.
Copyright © 2022-2024 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being “A GNU Manual,” and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled “GNU Free Documentation License.”
(a) The FSF’s Back-Cover Text is: “You have the freedom to copy and modify this GNU manual.”
Next: Support, Previous: "Compat" Manual, Up: "Compat" Manual [Contents][Index]
Next: Usage, Up: Introduction [Contents][Index]
The objective of Compat is to provide "forwards compatibility" library for Emacs Lisp. By using Compat, an Elisp package does not have to make the decision to either use new and useful functionality or support old versions of Emacs.
The library provides support back until Emacs 24.4. The intended audience are package developers that are interested in using newer developments, without having to break compatibility.
Next: Limitations, Previous: Overview, Up: Introduction [Contents][Index]
The intended use-case for this library is for package developers to add as a dependency in the header. The version of the Compat library mirrors the version of Emacs releases. The current version of Compat corresponds to the current Emacs release.
;; Package-Requires: ((emacs "24.4") (compat "30.0.1.0"))
There is no need to depend on emacs 24.4
specifically. One can
choose any newer version, if features not provided by Compat
necessitate it, for example bug fixes or UI improvements.
In any file where compatibility forms are used, a
(require 'compat)
should be added early on. This will load all necessary Compat
definitions. Compat loads the seq
library which is preloaded
by default on Emacs 29. Note that if Compat is installed on a recent
version of Emacs, all of the definitions are disabled at compile time,
such that no negative performance impact is incurred.
A minimal version of Compat will be present in Emacs version 30 and
newer. Packages which are part of Emacs itself and want to take
advantage of Compat, can also use (require 'compat)
. The
advantage of the inclusion of a minimal Compat in Emacs is that Compat
will not be installed if you require a version newer or equal than the
current Emacs version. For example, if a package depending on Emacs
25.1 and Compat 29.1 is installed on Emacs 30.1, Compat will not be
pulled in as dependency, since Emacs 30.1 already provides the
required functionality.
Compat provides replacement functions with extended functionality for
functions that are already defined, e.g., sort
or assoc
.
These functions may have changed their calling convention (additional
optional arguments) or may have changed their behavior. These
functions must be looked up explicitly with compat-function
or
called explicitly with compat-call
. We call them Extended
Definitions. In contrast, newly Added Definitions can be
called as usual. The Compat manual explicitly documents the calling
convention of each compatibility function.
(compat-call assoc key alist testfn) ;; Call extended `assoc' (mapcan fun seq) ;; Call newly added `mapcan'
This macro calls the compatibility function fun with args.
Many functions provided by Compat can be called directly without this
macro. However in the case where Compat provides an alternative
version of an existing function, the function call has to go through
compat-call
. This happens for example when the calling
convention of a function has changed.
This macro returns the compatibility function symbol for fun.
See compat-call
for a more convenient macro to directly call
compatibility functions.
If Compat is used in Emacs core packages, the macros
compat-call
and compat-function
will be available in
Emacs version 30 and newer.
The macros compat-call
and compat-function
are
introduced by Compat, since Compat does not advise or override
existing functions. Generally Compat is written in defensive style
which is supposed to reduce potential breakage, and to increase the
chances of staying binary compatible across releases. The extensive
test coverage ensures that we can maintain high quality, which is
crucial for Compat which is not restricted to a namespace like usual
libraries.
If you intend to use a compatibility function in your code it is recommended that you take a look at the test suite compat-tests.el. There you can see the supported calling conventions, which are guaranteed to work on the supported Emacs versions. We ensure this using continuous integration. All functions provided by Compat are covered by the test suite. There is a link to the corresponding test on the first line of each definition.
You may want to subscribe to the compat-announce mailing list to be notified when new versions are released or relevant changes are made. We also provide a development mailing list (~pkal/compat-devel@lists.sr.ht).
Previous: Usage, Up: Introduction [Contents][Index]
The Compat library has a number of limitations. Complete backwards compatibility cannot be provided due to the scope of Compat and for technical reasons. The scope is intentionally restricted in order to limit the size of Compat and to ensure that the library stays maintainable.
Emacs version 24.4 is chosen as the oldest version supported by Compat, since Elisp has seen significant changes at that version. Since 24.4 Emacs major versions consistently bump the major version number. On the library level, subr-x was introduced in 24.4. Most popular Emacs packages already require 24.4 or even newer versions of Emacs. Supporting for more historical Emacs versions would complicate maintenance while only few packages and users would benefit.
Below we list a number of reasons why certain functionality cannot be provided. Note that in some special cases exceptions can be made and functions can still be added to Compat even if they satisfy the criteria from the list. In case you miss functionality which you think should belong here, a report would be much appreciated.
setopt
is such an example.
compat-function
and compat-call
macros. In this manual we call such
definitions Extended Definitions. An example is the function
plist-get
. Note that extended functions are subject to closer
scrutiny, since their usage via compat-call
is not completely
painless. If a particular extended function does not see much usage
or the extension yields only marginal benefits, we may not provide it
as part of Compat.
compat-call
. Such extended definitions would
increase the maintenance burden of Compat. At the same time the
benefits would be small given that Compat does not override existing
definitions.
Next: Development, Previous: Introduction, Up: "Compat" Manual [Contents][Index]
This section goes into the features that Compat manages and doesn’t manage to provide for each Emacs version.
Next: Emacs 26.1, Up: Support [Contents][Index]
The following functions and macros are implemented in Emacs 25.1. These functions are made available by Compat on Emacs versions older than 25.1.
The value of this user option is a symbol that specifies the style
Emacs should use for single quotes in the wording of help and
messages. If the option’s value is curve
, the style is
‘like this’ with curved single quotes. If the value is
straight
, the style is 'like this' with straight
apostrophes. If the value is grave
, quotes are not translated
and the style is `like this' with grave accent and apostrophe, the
standard style before Emacs version 25. The default value nil
acts like curve
if curved single quotes seem to be displayable,
and like grave
otherwise.
This option is useful on platforms that have problems with curved quotes. You can customize it freely according to your personal preference.
Return the boundaries of the region. Value is a list of one or more
cons cells of the form (start . end)
. It will have more than
one cons cell when the region is non-contiguous, see
region-noncontiguous-p
and extract-rectangle-bounds
.
Return non-nil if the region contains several pieces. An example is a rectangular region handled as a list of separate contiguous regions for each line.
This macro is like save-excursion
, but also saves and restores
the mark location and mark-active
. This macro does what
save-excursion
did before Emacs 25.1.
This function acts like format
, except it also converts any
grave accents (`) and apostrophes (') in string as per
the value of text-quoting-style
.
Typically grave accent and apostrophe in the format translate to matching curved quotes, e.g., "Missing `%s'" might result in "Missing ‘foo’". See (elisp)Text Quoting Style, for how to influence or inhibit this translation.
This function returns non-nil
if filename ends with a
directory separator character. This is the forward slash ‘/’ on
GNU and other POSIX-like systems; MS-Windows and MS-DOS recognize both
the forward slash and the backslash ‘\’ as directory separators.
This function returns the result of comparing string1 and
string2 in the opposite order, i.e., it is equivalent to calling
(string-lessp string2 string1)
.
This macro evaluates the body forms with the default permissions
for new files temporarily set to modes (whose value is as for
set-file-modes
above). When finished, it restores the original
default file permissions, and returns the value of the last form in
body.
This is useful for creating private files, for example.
This function is similar to assq
. It finds the first association
(key . value)
by comparing key with
alist elements, and, if found, returns the value of that
association. If no association is found, the function returns
default.
This is a generalized variable (see (elisp)Generalized Variables)
that can be used to change a value with setf
. When using it to
set a value, optional argument remove non-nil
means to
remove key’s association from alist if the new value is
eql
to default.
As with let*
, bindings will consist of
(symbol value-form)
entries that are evaluated and
bound sequentially. If all value-form evaluate to
non-nil
values, then then is evaluated as were the case
with a regular let*
expression, with all the variables bound.
If any value-form evaluates to nil
, else is
evaluated, without any bound variables.
A binding may also optionally drop the symbol, and simplify to
(value-form)
if only the test is of interest.
For the sake of backwards compatibility, it is possible to write a single binding without a binding list:
(if-let* (symbol (test)) foo bar) ≡ (if-let* ((symbol (test))) foo bar)
As with when
, if one is only interested in the case where all
bindings are non-nil. Otherwise bindings are interpreted
just as they are by if-let*
.
Check whether hash-table is empty (has 0 elements).
Combine forms into a single expression by “threading” each element as the first argument of their successor. Elements of forms can either be an list of an atom.
For example, consider the threading expression and it’s equivalent macro expansion:
(thread-first 5 (+ 20) (/ 25) - (+ 40)) ≡ (+ (- (/ (+ 5 20) 25)) 40)
Note how the single -
got converted into a list before threading.
This example uses arithmetic functions, but thread-first
is not
restricted to arithmetic or side-effect free code.
Combine forms into a single expression by “threading” each element as the last argument of their successor. Elements of forms can either be an list of an atom.
For example, consider the threading expression and it’s equivalent macro expansion:
(thread-first 5 (+ 20) (/ 25) - (+ 40)) ≡ (+ 40 (- (/ 25 (+ 20 5))))
Note how the single -
got converted into a list before threading.
This example uses arithmetic functions, but thread-last
is not
restricted to arithmetic or side-effect free code.
This function expands macros like macroexpand
, but it only
performs one step of the expansion: if the result is another macro call,
macroexpand-1
will not expand it.
See (elisp)Expansion.
Return an expression e such that (eval e)
is v.
Parse a function body into (declarations . exps)
.
This function creates and returns a bool-vector whose elements are the arguments, objects.
See (elisp)Bool-Vectors.
Compat does not provide support for the following Lisp features implemented in 25.1:
macroexp-macroexpand
.
macroexp-let2*
.
directory-files-recursively
.
pcase
patterns.
prefix-command-echo-keystrokes-functions
and
prefix-command-preserve-state-hook
.
pre-redisplay-functions
.
make-process
.
inhibit-message
.
define-inline
functionality.
string-collate-lessp
and
string-collate-equalp
.
funcall-interactively
.
buffer-substring-with-bidi-context
.
font-info
.
default-font-width
.
window-font-height
and window-font-width
.
window-max-chars-per-line
.
set-binary-mode
.
bufferpos-to-filepos
and
filepos-to-bufferpos
.
thunk
library.
Next: Emacs 27.1, Previous: Emacs 25.1, Up: Support [Contents][Index]
The following functions and macros are implemented in Emacs 26.1. These functions are made available by Compat on Emacs versions older than 26.1.
This function is like assq-delete-all
except that it uses
equal
to compare elements.
This function prompts the user with text in question, which should end in the ‘SPC’ character. The function includes in the prompt the possible responses in answers by appending them to the end of question. The possible responses are provided in answers as an alist whose elements are of the following form:
(long-answer short-answer help-message)
where long-answer is the complete text of the user response, a
string; short-answer is a short form of the same response, a
single character or a function key; and help-message is the text
that describes the meaning of the answer. If the variable
read-answer-short
is non-nil
, the prompt will show the
short variants of the possible answers and the user is expected to
type the single characters/keys shown in the prompt; otherwise the
prompt will show the long variants of the answers, and the user is
expected to type the full text of one of the answers and end by
pressing RET. If use-dialog-box
is non-nil
, and
this function was invoked by mouse events, the question and the
answers will be displayed in a GUI dialog box.
The function returns the text of the long-answer selected by the user, regardless of whether long or short answers were shown in the prompt and typed by the user.
Here is an example of using this function:
(let ((read-answer-short t)) (read-answer "Foo " '(("yes" ?y "perform the action") ("no" ?n "skip to the next") ("all" ?! "perform for the rest without more questions") ("help" ?h "show help") ("quit" ?q "exit"))))
This function applies function to each element of
sequence, like mapcar
, but instead of collecting the
results into a list, it returns a single list with all the elements of
the results (which must be lists), by altering the results (using
nconc
; see (elisp)Rearrangement). Like with
mapcar
, sequence can be of any type except a char-table.
;; Contrast this: (mapcar #'list '(a b c d)) ⇒ ((a) (b) (c) (d)) ;; with this: (mapcan #'list '(a b c d)) ⇒ (a b c d)
See (elisp)List Elements.
This function returns a symbol using make-symbol
, whose name is
made by appending gensym-counter
to prefix and
incrementing that counter, guaranteeing that no two calls to this
function will generate a symbol with the same name. The prefix
defaults to "g"
.
See gensym
.
Return a hash of buffer-or-name. If nil
, this defaults
to the current buffer. As opposed to secure-hash
, this
function computes the hash based on the internal representation of the
buffer, disregarding any coding systems. It’s therefore only useful
when comparing two buffers running in the same Emacs, and is not
guaranteed to return the same hash between different Emacs versions.
It should be somewhat more efficient on larger buffers than
secure-hash
is, and should not allocate more memory.
This macro removes the quotation prefix ‘/:’ from the file name, if any. If name is a remote file name, the local part of name is unquoted.
This macro returns non-nil
, when name is quoted with the
prefix ‘/:’. If name is a remote file name, the local part
of name is checked.
This macro adds the quotation prefix ‘/:’ to the file name. For a local file name, it prefixes name with ‘/:’. If name is a remote file name, the local part of name (see (elisp)Magic File Names) is quoted. If name is already a quoted file name, name is returned unchanged.
(substitute-in-file-name (compat-call file-name-quote "bar/~/foo")) ⇒ "/:bar/~/foo"
(substitute-in-file-name (compat-call file-name-quote "/ssh:host:bar/~/foo")) ⇒ "/ssh:host:/:bar/~/foo"
The macro cannot be used to suppress file name handlers from magic file names (see (elisp)Magic File Names).
This function is similar to make-temp-file
, but it creates a
temporary file as close as possible to default-directory
. If
prefix is a relative file name, and default-directory
is a
remote file name or located on a mounted file systems, the temporary
file is created in the directory returned by the function
temporary-file-directory
. Otherwise, the function
make-temp-file
is used. prefix, dir-flag and
suffix have the same meaning as in make-temp-file
.
(let ((default-directory "/ssh:remotehost:")) (make-nearby-temp-file "foo")) ⇒ "/ssh:remotehost:/tmp/foo232J6v"
A regular expression matching files names that are probably on a mounted file system.
The directory for writing temporary files via
make-nearby-temp-file
. In case of a remote
default-directory
, this is a directory for temporary files on
that remote host. If such a directory does not exist, or
default-directory
ought to be located on a mounted file system
(see mounted-file-systems
), the function returns
default-directory
. For a non-remote and non-mounted
default-directory
, the value of the variable
temporary-file-directory
is returned.
if-let*
is mostly equivalent to if-let
, with the
exception that the legacy (if (var (test)) foo bar)
syntax is not permitted.
when-let*
is mostly equivalent to when-let
, with the
exception that the legacy (when-let (var (test)) foo bar)
syntax is not permitted.
A combination of let* and and, analogous to
when-let*
. If all bindings are non-nil
and
body is nil
, then the result of the and-let*
form
will be the last value bound in bindings.
Please Note: The implementation provided by Compat does not include a bug that was observed with Emacs 26 (see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=31840).
This function returns the local part of filename. This is the part of the file’s name that identifies it on the remote host, and is typically obtained by removing from the remote file name the parts that specify the remote host and the method of accessing it. For example:
(file-local-name "/ssh:user@host:/foo/bar") ⇒ "/foo/bar"
For a remote filename, this function returns a file name which could be used directly as an argument of a remote process (see (elisp)Asynchronous Processes, and see (elisp)Synchronous Processes), and as the program to run on the remote host. If filename is local, this function returns it unchanged.
Ask user a multiple choice question. prompt should be a string that will be displayed as the prompt.
choices is an alist where the first element in each entry is a character to be entered, the second element is a short name for the entry to be displayed while prompting (if there’s room, it might be shortened), and the third, optional entry is a longer explanation that will be displayed in a help buffer if the user requests more help.
Defined in image.el
.
This function can also be used as a generalised variable.
Return the field type as generated by file-attributes
.
Return the field link-number as generated by file-attributes
.
Return the field user-id as generated by file-attributes
.
Return the field group-id as generated by file-attributes
.
Return the field access-time as generated by file-attributes
.
Return the field modification-time as generated by file-attributes
.
Return the field modification-time as generated by file-attributes
.
Return the field size as generated by file-attributes
.
Return the field modes as generated by file-attributes
.
Return the field inode-number as generated by file-attributes
.
Return the field device-number as generated by file-attributes
.
Filter the file attributes attributes, as generated by
file-attributes
, according to attr-names.
Valid attribute names for attr-names are: type, link-number, user-id, group-id, access-time, modification-time, status-change-time, size, modes, inode-number and device-number.
(file-attributes ".") ⇒ (t 1 1000 1000 (25329 18215 325481 96000) (25325 15364 530263 840000) (25325 15364 530263 840000) 788 "drwxr-xr-x" t 137819 40)
(file-attribute-collect (file-attributes ".") 'type 'modes 'inode-number) ⇒ (t "drwxr-xr-x" 137819)
These functions must be called explicitly via compat-call
,
since their calling convention or behavior was extended in Emacs 26.1:
This function creates a temporary file and returns its name. Emacs
creates the temporary file’s name by adding to prefix some
random characters that are different in each Emacs job. The result is
guaranteed to be a newly created file, containing text if that’s
given as a string and empty otherwise. On MS-DOS, this function can
truncate prefix to fit into the 8+3 file-name limits. If
prefix is a relative file name, it is expanded against
temporary-file-directory
.
The compatibility version adds support for handling the optional argument TEXT.
(make-temp-file "foo") ⇒ "/tmp/foo232J6v"
When make-temp-file
returns, the file has been created and is
empty. At that point, you should write the intended contents into the
file.
If dir-flag is non-nil
, make-temp-file
creates an
empty directory instead of an empty file. It returns the file name,
not the directory name, of that directory. See (elisp)Directory Names.
If suffix is non-nil
, make-temp-file
adds it at
the end of the file name.
If text is a string, make-temp-file
inserts it in the file.
To prevent conflicts among different libraries running in the same
Emacs, each Lisp program that uses make-temp-file
should have its
own prefix. The number added to the end of prefix
distinguishes between the same application running in different Emacs
jobs. Additional added characters permit a large number of distinct
names even in one Emacs job.
This function returns the first association for key in
alist, comparing key against the alist elements using
testfn if it is a function, and equal
otherwise
(see (elisp)Equality Predicates). If testfn is a function,
it is called with two arguments: the CAR of an element from
alist and key. The function returns nil
if no
association in alist has a CAR equal to key, as
tested by testfn.
The compatibility version adds support for handling the optional argument testfn.
This function returns the line number in the current buffer
corresponding to the buffer position pos. If pos is
nil
or omitted, the current buffer position is used. If
absolute is nil
, the default, counting starts at
(point-min)
, so the value refers to the contents of the
accessible portion of the (potentially narrowed) buffer. If
absolute is non-nil
, ignore any narrowing and return
See (elisp)Text Lines.
The compatibility version adds support for handling the optional argument absolute.
See (elisp)Association Lists. This function is similar to
assq
. It finds the first association (key . value)
by comparing key with alist elements,
and, if found, returns the value of that association. If no
association is found, the function returns default. Comparison
of key against alist elements uses the function specified
by testfn, defaulting to eq
.
The compatibility version handles the optional argument testfn. It can also be used as a (elisp)Generalized Variables.
Remove the leading text that matches regexp from string. regexp defaults to ‘[ \t\n\r]+’.
The compatibility version handles the optional argument regexp.
Remove the trailing text that matches regexp from string. regexp defaults to ‘[ \t\n\r]+’.
The compatibility version handles the optional argument regexp.
Remove the leading text that matches trim-left and trailing text that matches trim-right from string. Both regexps default to ‘[ \t\n\r]+’.
The compatibility version handles the optional arguments trim-left and trim-right.
Compat does not provide support for the following Lisp features implemented in 26.1:
func-arity
.
secure-hash-algorithms
.
gnutls-available-p
.
mapbacktrace
.
file-name-case-insensitive-p
.
parse-partial-sexp
.
add-variable-watcher
.
undo-amalgamate-change-group
.
char-from-name
length
or member
deal with list
cycles.
frame-list-z-order
.
frame-restack
.
display-buffer
.
window-swap-states
.
string-version-lessp
.
xdg
library.
svg
library (published separately as a :core package).
Next: Emacs 28.1, Previous: Emacs 26.1, Up: Support [Contents][Index]
The following functions and macros are implemented in Emacs 27.1. These functions are made available by Compat on Emacs versions older than 27.1.
This function works like fundamental-mode
, in that it kills all
buffer-local variables, but it also records the major mode in effect,
so that it could subsequently be restored. This function and
major-mode-restore
(described next) are useful when you need to
put a buffer under some specialized mode other than the one Emacs
chooses for it automatically, but would also like to be able to switch
back to the original mode later.
This function restores the major mode recorded by
major-mode-suspend
. If no major mode was recorded, this
function calls normal-mode
, but tries to force it not to choose
any modes in avoided-modes, if that argument is non-nil
.
Set the size of ring to size. If the new size is smaller, then the oldest items in the ring are discarded.
Return the value of the minibuffer input history list. If minibuffer-history-variable points to a buffer-local variable and the minibuffer is active, return the buffer-local value for the buffer that was current when the minibuffer was activated."
Execute the forms in body from the minibuffer in its original window. When used in a minibuffer window, select the window selected just before the minibuffer was activated, and execute the forms.
This function uses the minibuffer to read and return a single
character. Optionally, it ignores any input that is not a member of
chars, a list of accepted characters. The history
argument specifies the history list symbol to use; if it is omitted or
nil
, this function doesn’t use the history.
If you bind help-form
to a non-nil
value while calling
read-char-from-minibuffer
, then pressing help-char
causes it to evaluate help-form
and display the result.
This predicate tests whether its argument is a large integer, and
returns t
if so, nil
otherwise. Unlike small integers,
large integers can be =
or eql
even if they are not
eq
.
This predicate tests whether its argument is a small integer, and
returns t
if so, nil
otherwise. Small integers can be
compared with eq
.
In execution, this is equivalent to (progn body...)
, but
the compiler does not issue warnings for the specified conditions in
body. warnings is an association list of warning symbols
and function/variable symbols they apply to. For instance, if you
wish to call an obsolete function called foo
, but want to
suppress the compilation warning, say:
(with-suppressed-warnings ((obsolete foo)) (foo ...))
This function returns the length of object if it is a proper list,
nil
otherwise (see (elisp)Cons Cells). In addition to
satisfying listp
, a proper list is neither circular nor dotted.
(proper-list-p '(a b c)) ⇒ 3
(proper-list-p '(a b . c)) ⇒ nil
This function returns the Levenshtein distance between the source string string1 and the target string string2. The Levenshtein distance is the number of single-character changes—deletions, insertions, or replacements—required to transform the source string into the target string; it is one possible definition of the edit distance between strings.
Letter-case of the strings is significant for the computed distance, but
their text properties are ignored. If the optional argument
bytecompare is non-nil
, the function calculates the
distance in terms of bytes instead of characters. The byte-wise
comparison uses the internal Emacs representation of characters, so it
will produce inaccurate results for multibyte strings that include raw
bytes (see (elisp)Text Representations); make the strings unibyte
by encoding them (see (elisp)Explicit Encoding) if you need
accurate results with raw bytes.
This construct executes body, ignoring any errors that occur
during its execution. If the execution is without error,
ignore-errors
returns the value of the last form in body;
otherwise, it returns nil
.
Here’s the example at the beginning of this subsection rewritten using
ignore-errors
:
(ignore-errors (delete-file filename))
This is another convenience macro that works the same way as
dolist
does, but also reports loop progress using the functions
described above. As in dotimes-with-progress-reporter
,
reporter-or-message
can be a progress reporter or a string. You
can rewrite the previous example with this macro as follows:
(dolist-with-progress-reporter (k (number-sequence 0 500)) "Collecting some mana for Emacs..." (sit-for 0.01))
See (elisp)Progress.
This function returns a “flattened” copy of tree, that is, a
list containing all the non-nil
terminal nodes, or leaves, of the
tree of cons cells rooted at tree. Leaves in the returned list
are in the same order as in tree.
(flatten-tree '(1 (2 . 3) nil (4 5 (6)) 7)) ⇒(1 2 3 4 5 6 7)
This function returns the boolean exclusive-or of condition1 and
condition2. That is, xor
returns nil
if either both
arguments are nil
, or both are non-nil
. Otherwise, it
returns the value of that argument which is non-nil
.
Note that in contrast to or
, both arguments are always evaluated.
This variable contains a regexp that is guaranteed not to match any string at all. It is particularly useful as default value for variables that may be set to a pattern that actually matches something.
Return the seconds field of a decoded-time
record time.
It can also be used as a (elisp)Generalized
Variables.
Return the minute field of a decoded-time
record time.
It can also be used as a (elisp)Generalized
Variables.
Return the hour field of a decoded-time
record time.
It can also be used as a (elisp)Generalized
Variables.
Return the day field of a decoded-time
record time.
It can also be used as a (elisp)Generalized
Variables.
Return the month field of a decoded-time
record time.
It can also be used as a (elisp)Generalized
Variables.
Return the year field of a decoded-time
record time.
It can also be used as a (elisp)Generalized
Variables.
Return the weekday field of a decoded-time
record time.
It can also be used as a (elisp)Generalized
Variables.
Return the dst (daylight saving time indicator) field of a
decoded-time
record time. It can also be used as a
(elisp)Generalized Variables.
Return the zone field of a decoded-time
record time.
It can also be used as a (elisp)Generalized
Variables.
Return the version number of the package in which this is used.
This returns t
if the two time values t1 and t2 are
equal.
Return the number of days in month in year. For instance, February 2020 has 29 days.
See (elisp)Time Calculations. This function requires the
time-date
feature to be loaded.
Convert a year/ordinal to the equivalent decoded-time structure. ordinal is the number of days since the start of the year, with January 1st being 1.
See (elisp)Time Calculations. This function requires the
time-date
feature to be loaded.
The value of this variable is a list of directories to search for
programs to run in subprocesses. Each element is either the name of a
directory (i.e., a string), or nil
, which stands for the default
directory (which is the value of default-directory
).
See (elisp)executable-find, for the details of this
search.
The value of exec-path
is used by call-process
and
start-process
when the program argument is not an absolute
file name.
Generally, you should not modify exec-path
directly. Instead,
ensure that your PATH
environment variable is set appropriately
before starting Emacs. Trying to modify exec-path
independently
of PATH
can lead to confusing results.
This function returns non-nil
if mode is derived from any
of the major modes given by the symbols modes.
Human-readable string for size bytes, using IEC prefixes.
This function creates an empty file named filename. As
make-directory
, this function creates parent directories if
parents is non-nil
. If filename already exists, this
function signals an error.
Search for the next region that has text property prop set to value according to predicate.
This function is modeled after search-forward
and friends in
that it moves point, but it returns a structure that describes the
match instead of returning it in match-beginning
and friends.
If the text property can’t be found, the function returns nil
.
If it’s found, point is placed at the end of the region that has this
text property match, and a prop-match
structure is returned.
predicate can either be t
(which is a synonym for
equal
), nil
(which means “not equal”), or a predicate
that will be called with two parameters: The first is value, and
the second is the value of the text property we’re inspecting.
If not-current, if point is in a region where we have a match, then skip past that and find the next instance instead.
The prop-match
structure has the following accessors:
prop-match-beginning
(the start of the match),
prop-match-end
(the end of the match), and
prop-match-value
(the value of property at the start of
the match).
In the examples below, imagine that you’re in a buffer that looks like this:
This is a bold and here's bolditalic and this is the end.
That is, the “bold” words are the bold
face, and the
“italic” word is in the italic
face.
With point at the start:
(while (setq match (text-property-search-forward 'face 'bold t)) (push (buffer-substring (prop-match-beginning match) (prop-match-end match)) words))
This will pick out all the words that use the bold
face.
(while (setq match (text-property-search-forward 'face nil t)) (push (buffer-substring (prop-match-beginning match) (prop-match-end match)) words))
This will pick out all the bits that have no face properties, which
will result in the list ‘("This is a " "and here's " "and this is
the end")’ (only reversed, since we used push
).
(while (setq match (text-property-search-forward 'face nil nil)) (push (buffer-substring (prop-match-beginning match) (prop-match-end match)) words))
This will pick out all the regions where face
is set to
something, but this is split up into where the properties change, so
the result here will be ‘("bold" "bold" "italic")’.
For a more realistic example where you might use this, consider that
you have a buffer where certain sections represent URLs, and these are
tagged with shr-url
.
(while (setq match (text-property-search-forward 'shr-url nil nil)) (push (prop-match-value match) urls))
This will give you a list of all those URLs.
This is just like text-property-search-forward
, but searches
backward instead. Point is placed at the beginning of the matched
region instead of the end, though.
These functions must be called explicitly via compat-call
,
since their calling convention or behavior was extended in Emacs 27.1:
This function scrolls the text in the selected window so that point is displayed at a specified vertical position within the window. It does not move point with respect to the text.
This compatibility version adds support for the optional argument redisplay.
This function returns the definition of key in keymap. If the string or vector key is not a valid key sequence according to the prefix keys specified in keymap, it must be too long and have extra events at the end that do not fit into a single key sequence. Then the value is a number, the number of events at the front of key that compose a complete key.
See (elisp)Low-Level Key Binding.
This compatibility version allows for keymap to be a list of keymaps, instead of just a singular keymap.
pairs is a list of variable and value pairs. This macro creates
a buffer-local binding in the current buffer for each of the
variables, and gives them a buffer-local value. It is equivalent to
calling make-local-variable
followed by setq
for each of
the variables. The variables should be unquoted symbols.
(setq-local var1 "value1" var2 "value2")
See (elisp)Creating Buffer-Local.
This compatibility version allows for more than one variable to be set
at once, as can be done with setq
.
This function returns an efficient regular expression that will match any of the strings in the list strings. This is useful when you need to make matching or searching as fast as possible—for example, for Font Lock mode.
The compatibility version of this functions handles the case where
strings in an empty list. In that case, a regular expression is
generated that never matches anything (see regexp-unmatchable
).
Return a string with a human readable representation of file-size.
The optional second argument flavor controls the units and the display format. If flavor is…
si
, each kilobyte is 1000 bytes and the produced suffixes are
k
, M
, G
, T
, etc.
iec
, each kilobyte is 1024 bytes and the produced suffixes are
KiB
, MiB
, GiB
, TiB
, etc.
nil
or omitted, each kilobyte is 1024 bytes and the produced
suffixes are k
, M
, G
, T
, etc.
The compatibility version handles the optional third (space) and
forth (unit) arguments. The argument space can be a
string that is placed between the number and the unit. The argument
unit determines the unit to use. By default it will be an empty
string, unless flavor is iec
, in which case it will be
B
.
This function is like assq-delete-all
except that it accepts
an optional argument test, a predicate function to compare the
keys in alist. If omitted or nil
, test defaults to
equal
. As assq-delete-all
, this function often modifies
the original list structure of alist.
This compatibility version handles the optional third (testfn) argument.
This function searches for the executable file of the named
program and returns the absolute file name of the executable,
including its file-name extensions, if any. It returns nil
if
the file is not found. The function searches in all the directories in
exec-path
, and tries all the file-name extensions in
exec-suffixes
(see (elisp)Subprocess Creation).
If remote is non-nil
, and default-directory
is a
remote directory, program is searched on the respective remote host.
This compatibility version adds support to handle the optional second (remote) argument.
Compat does not provide support for the following Lisp features implemented in 27.1:
base64url-encode-*
.
decoded-time-add
.
decoded-time-set-defaults
.
time-convert
.
benchmark-progn
.
condition-case
to handle t.
file-system-info
.
group-name
.
face-extend-p
and set-face-extend
.
format-spec
modifiers.
define-globalized-minor-mode
.
with-connection-local-variables
and related
functionality.
iso8601
library.
exif
library.
image-converter
library.
Next: Emacs 29.1, Previous: Emacs 27.1, Up: Support [Contents][Index]
The following functions and macros are implemented in Emacs 28.1. These functions are made available by Compat on Emacs versions older than 28.1.
The defcustom
type natnum
introduced in Emacs 28.1 is
made available by Compat.
This function is just like process-lines
, but does not signal
an error if program exits with a non-zero exit status.
Execute program with args, returning its output as a list of lines. If status-handler is non-nil, it must be a function with one argument, which will be called with the exit status of the program before the output is collected. If status-handler is nil, an error is signaled if the program returns with a non-zero exit status.
You should not read the value of the variable
text-quoting-style
directly. Instead, use this function with
the same name to dynamically compute the correct quoting style on the
current terminal in the nil
case described above.
Return the position of the first instance of needle in
haystack, both of which are strings. If start-pos is
non-nil
, start searching from that position in needle.
Return nil
if no match was found. This function only considers
the characters in the strings when doing the comparison; text
properties are ignored. Matching is always case-sensitive.
Return non-nil
if the length of sequence is equal to
length.
Return non-nil
if sequence is shorter than length.
This may be more efficient than computing the length of sequence
if sequence is a long list.
Return non-nil
if sequence is longer than length.
Concatenate components to directory, inserting a slash before the components if directory or the preceding component didn’t end with a slash.
(file-name-concat "/tmp" "foo") ⇒ "/tmp/foo"
A directory or components that are nil
or the empty
string are ignored—they are filtered out first and do not affect the
results in any way.
This is almost the same as using concat
, but dirname (and
the non-final components) may or may not end with slash characters,
and this function will not double those characters.
Suggest to run garbage collection, if enough data has been allocated. This is determined by the positive numerical argument factor, that would proportionally increase the likelihood of garbage collection taking place.
This compatibility function does nothing and ignores any suggestion.
This function replaces all occurrences of from-string with to-string in in-string and returns the result. It may return one of its arguments unchanged, a constant string or a new string. Case is significant, and text properties are ignored.
This function ignores any arguments and returns t
.
Make a string appropriate for usage as a visual separator line. If length is nil, use the window width.
This is like insert-buffer-substring
, but works in the opposite
direction: The text is copied from the current buffer into
to-buffer. The block of text is copied to the current point in
to-buffer, and point (in that buffer) is advanced to after the
end of the copied text. Is start
/end
is nil
, the
entire text in the current buffer is copied over.
See (elisp)Insertion.
This function works similarly to replace-regexp-in-region
,
but searches for, and replaces, literal strings instead of
regular expressions.
This function copies string and searches it for matches for
regexp, and replaces them with rep. It returns the
modified copy. If start is non-nil
, the search for
matches starts at that index in string, and the returned value
does not include the first start characters of string.
To get the whole transformed string, concatenate the first
start characters of string with the return value.
This function uses replace-match
to do the replacement, and it
passes the optional arguments fixedcase, literal and
subexp along to replace-match
.
Instead of a string, rep can be a function. In that case,
replace-regexp-in-string
calls rep for each match,
passing the text of the match as its sole argument. It collects the
value rep returns and passes that to replace-match
as the
replacement string. The match data at this point are the result
of matching regexp against a substring of string.
This returns non-nil
if there’s either a buffer-local binding
of variable (a symbol) in buffer buffer, or variable
has a global binding.
This macro ensures that default-directory
is bound to an
existing directory before executing body. If
default-directory
already exists, that’s preferred, and
otherwise some other directory is used. This macro can be useful, for
instance, when calling an external command that requires that it’s
running in a directory that exists. The chosen directory is not
guaranteed to be writable.
This special form is like let
, but it binds all variables
dynamically. This is rarely useful—you usually want to bind normal
variables lexically, and special variables (i.e., variables that are
defined with defvar
) dynamically, and this is what let
does.
dlet
can be useful when interfacing with old code that assumes
that certain variables are dynamically bound (see (elisp)Dynamic
Binding), but it’s impractical to defvar
these
variables. dlet
will temporarily make the bound variables
special, execute the forms, and then make the variables non-special
again.
This function returns object as a list. If object is already a list, the function returns it; otherwise, the function returns a one-element list containing object.
This is usually useful if you have a variable that may or may not be a list, and you can then say, for instance:
(dolist (elem (ensure-list foo)) (princ elem))
Clean up the whitespace in string by collapsing stretches of whitespace to a single space character, as well as removing all whitespace from the start and the end of string.
Attempt to Word-wrap string so that no lines are longer than length. Filling is done on whitespace boundaries only. If there are individual words that are longer than length, these will not be shortened.
Split string into a list of strings on newline boundaries. If
the optional argument omit-nulls is non-nil
, remove empty
lines from the results. Note that this function returns trailing
newlines on Emacs 28, use compat-call string-lines
instead if
you want consistent behavior.
Pad string to be of the given length using padding
as the padding character. padding defaults to the space
character. If string is longer than length, no padding is
done. If start is nil
or omitted, the padding is
appended to the characters of string, and if it’s
non-nil
, the padding is prepended to string’s characters.
Remove the final newline, if any, from string.
This special form is a looping construct inspired from the Scheme
language. It is similar to let
: It binds the variables in
bindings, and then evaluates body. However,
named-let
also binds name to a local function whose
formal arguments are the variables in bindings and whose body is
body. This allows body to call itself recursively by
calling name, where the arguments passed to name are used
as the new values of the bound variables in the recursive invocation.
Recursive calls to name that occur in tail positions in body are guaranteed to be optimized as tail calls, which means that they will not consume any additional stack space no matter how deeply the recursion runs. Such recursive calls will effectively jump to the top of the loop with new values for the variables.
This function returns filename with its extension set to extension. A single leading dot in the extension will be stripped if there is one. For example:
(file-name-with-extension "file" "el") ⇒ "file.el" (file-name-with-extension "file" ".el") ⇒ "file.el" (file-name-with-extension "file.c" "el") ⇒ "file.el"
Note that this function will error if filename or
extension are empty, or if the filename is shaped like a
directory (i.e., if directory-name-p
returns non-nil
).
This utility function returns t
if given directory is an
accessible directory and it does not contain any files, i.e., is an
empty directory. It will ignore ‘.’ and ‘..’ on systems
that return them as files in a directory.
Symbolic links to directories count as directories. See file-symlink-p to distinguish symlinks.
Format prompt with default value default according to the
minibuffer-default-prompt-format
variable.
minibuffer-default-prompt-format
is a format string (defaulting
to ‘" (default %s)"’ that says how the “default” bit in prompts
like ‘"Local filename (default somefile): "’ are to be formatted.
To allow the users to customize how this is displayed, code that prompts the user for a value (and has a default) should look something along the lines of this code snippet:
(read-file-name (format-prompt "Local filename" file) nil file)
If format-args is nil
, prompt is used as a literal
string. If format-args is non-nil
, prompt is used
as a format control string, and prompt and format-args are
passed to format
(see (elisp)Formatting Strings).
minibuffer-default-prompt-format
can be ‘""’, in which
case no default values are displayed.
If default is nil
, there is no default value, and
therefore no “default value” string is included in the result value.
If default is a non-nil
list, the first element of the
list is used in the prompt.
Mouse-event equivalent of thing-at-point
. thing can
be symbol
, list
, sexp
, filename
, url
,
… among other things.
When no-properties has a non-nil
value, any text properties
that might have been present in the buffer are stripped away.
Determine start and end locations for thing at mouse click given
by event. Like bounds-of-thing-at-point
, but tries to use
the position in event where the mouse button is clicked to find
the thing nearby.
Activate the region around thing found near the mouse click.
Return the name of the file in which the code is currently being
evaluated, or nil
if it cannot be determined.
Return code equivalent to form
labeled with warning msg
.
This macro sets the environment variables according to variables
temporarily when executing body. The previous values are
restored when the form finishes. The argument variables should
be a list of pairs of strings of the form
(var value)
, where var is the name of the
environment variable and value is that variable’s value.
(with-environment-variables (("LANG" "C") ("LANGUAGE" "en_US:en")) (call-process "ls" nil t))
Whether rgb is more readable against white than black. rgb is a 3-element list (R G B), each component in the range [0,1]. This predicate can be used both for determining a suitable (black or white) contrast color with rgb as background and as foreground.
Convert the textual color specification spec to a color triple
(red green
. Each of red,
green and blue
)blue
is a integer value between 0 and 65535.
The specification spec can be one of the following
#RGB
, where R, G and B are hex numbers of equal length, 1-4 digits each.
rgb:R/G/B
, where R, G, and B are hex numbers, 1-4 digits each.
rgbi:R/G/B
, where R, G and B are floating-point numbers in [0,1].
This function converts a numeric file mode specification in modes into the equivalent symbolic form.
This function returns a list of all the backup file names for
filename, or nil
if there are none. The files are sorted
by modification time, descending, so that the most recent files are
first.
See (elisp)Backup Names.
Return a string containing a lock file name for filename, obeying
lock-file-name-transforms
.
Interpret time as a period and return its length in seconds. For computational purposes, years are 365 days long and months are 30 days long.
Return t
if object is a primitive, built-in function. On
systems with native compilation subrp
does not distinguish
between built-in functions and functions that have been compiled. If
native compilation is not available, this function behaves identically
to subrp
.
This function returns non-nil
if the running Emacs process has
the native-compilation support compiled into it. On systems that load
libgccjit dynamically, it also makes sure that library is
available and can be loaded. Lisp programs that need to know up front
whether native-compilation is available should use this predicate.
Evaluate body with window temporarily made non-dedicated. If window is nil, use the selected window. Return the value of the last form in body.
These functions must be called explicitly via compat-call
,
since their calling convention or behavior was extended in Emacs 28.1:
This function returns the width in columns of the string string,
if it were displayed in the current buffer and the selected window.
Optional arguments from and to specify the substring of
string to consider, and are interpreted as in substring
(see (elisp)Creating Strings).
The return value is an approximation: it only considers the values
returned by char-width
for the constituent characters, always
takes a tab character as taking tab-width
columns, ignores
display properties and fonts, etc.
See (elisp)Size of Displayed Text.
This compatibility version handles the optional arguments from and to.
Return the number of live windows on the selected frame.
The optional argument minibuf specifies whether the minibuffer window is included in the count.
If all-frames is non-nil
, count the windows in all frames
instead just the selected frame.
This compatibility version handles the optional argument all-frames.
Compat does not provide support for the following Lisp features implemented in 28.1:
interactive
or declare
to list applicable
modes.
:interactive
argument to define-minor-mode
and
define-derived-mode
.
:predicate
argument to
define-globalized-minor-mode
.
:success
handler of condition-case
.
benchmark-call
.
json-parse-string
.
pcase-setq
.
custom-add-choice
.
dom-print
and dom-remove-attribute
.
dns-query-asynchronous
.
get-locale-names
.
mail-header-parse-addresses-lax
and
mail-header-parse-address-lax
.
num-processors
.
object-intervals
.
require-theme
.
syntax-class-to-char
.
path-separator
.
null-device
.
macroexp-compiling-p
.
split-string-shell-command
.
string-limit
.
innermost-minibuffer-p
and
minibuffer-innermost-command-loop-p
.
max-mini-window-lines
.
lock-file
and unlock-file
.
multisession
library.
Next: Emacs 30.1, Previous: Emacs 28.1, Up: Support [Contents][Index]
The following functions and macros are implemented in Emacs 29.1. These functions are made available by Compat on Emacs versions older than 29.1. Note that due to upstream changes, it might happen that there will be the need for changes, so use these functions with care.
The defcustom
type key
introduced in Emacs 29.1 is
made available by Compat.
Non-nil means that current buffer originated from an untrusted source. Email clients and some other modes may set this non-nil to mark the buffer contents as untrusted. This variable might be subject to change without notice.
This variable holds a string naming the directory which holds Emacs’s own *.el and *.elc files. This is usually the place where those files are located in the Emacs installation tree, unless Emacs is run from its build directory in which case it points to the lisp subdirectory in the source directory from which Emacs was built.
Count sentences in current buffer from start to end.
This predicate says whether object has readable syntax,
i.e., it can be written out and then read back by the Emacs Lisp
reader. If it can’t, this function returns nil
; if it can,
this function returns a printed representation (via prin1
).
This function works like substitute-command-keys
, but only
replaces quote characters.
Return the *scratch* buffer, creating a new one if needed.
Return non-nil for a non-contiguous region if use-region-p
.
Return the end of the region if use-region-p
.
Return the start of the region if use-region-p
.
Minor modes often set buffer-local variables that affect some features
in Emacs. When a minor mode is switched off, the mode is expected to
restore the previous state of these variables. This convenience macro
helps with doing that: It works much like setq-local
, but
returns an object that can be used to restore these values back to
their previous values/states (using the companion function
buffer-local-restore-state
).
Delete the current line.
Return t
if object is nil
or a list of strings.
Non-nil if and only if object is a valid plist.
This macro provides a simple way to do memoization. code is
evaluated and then stashed in place. If place’s value is
non-nil
, return that value instead of evaluating code.
This special form saves the current bounds of the accessible portion of the buffer, sets the accessible portion to start at start and end at end, evaluates the body forms, and restores the saved bounds. In that case it is equivalent to
(save-restriction (narrow-to-region start end) body)
When the optional argument label, a symbol, is present, the narrowing is labeled. A labeled narrowing differs from a non-labeled one in several ways:
narrow-to-region
and widen
can be used only within the start and end
limits.
with-restriction
and gain
access to other portions of the buffer, use without-restriction
with the same label argument. (Another way to gain access to
other portions of the buffer is to use an indirect buffer
(see (elisp)Indirect Buffers).)
If you use with-restriction
with the optional label
argument, we recommend documenting the label in the doc strings
of the functions which use it, so that other Lisp programs your code
calls could lift the labeled narrowing if and when it needs.
This special form saves the current bounds of the accessible portion of the buffer, widens the buffer, evaluates the body forms, and restores the saved bounds. In that case it is equivalent to
(save-restriction (widen) body)
When the optional argument label is present, the narrowing set
by with-restriction
with the same label argument is
lifted.
Like line-beginning-position
, but ignores fields (and is more
efficient).
Like line-end-position
, but ignores fields (and is more
efficient).
Return non-nil
if char is an uppercase character
according to Unicode.
Sometimes it’s unclear whether an operation will take a long time to execute or not, or it can be inconvenient to implement a progress reporter. This macro can be used in those situations.
(with-delayed-message (2 (format "Gathering data for %s" entry)) (setq data (gather-data entry)))
In this example, if the body takes more than two seconds to execute, the message will be displayed. If it takes a shorter time than that, the message won’t be displayed. In either case, the body is evaluated as normally, and the return value of the final element in the body is the return value of the macro.
The message element is evaluated before body, and is always evaluated, whether the message is displayed or not.
Like funcall
, but display message if function takes
longer than timeout. timeout is a number of seconds, and
can be an integer or a floating point number.
If function takes less time to execute than timeout seconds, message is not displayed.
Sometimes it’s more convenient to make a string into a button without
inserting it into a buffer immediately, for instance when creating
data structures that may then, later, be inserted into a buffer. This
function makes string into such a string, and callback
will be called when the user clicks on the button. The optional
data parameter will be used as the parameter when callback
is called. If nil
, the button is used as the parameter instead.
Make the region between start and end into a button. When clicked, callback will be called with the data as the function argument. If data isn’t present (or is nil), the button itself will be used instead as the function argument. If help-echo, use that as the help-echo property.
This convenience function can be used to get a specific display
property, no matter whether the display
property is a vector, a
list or a simple property. This is like get-text-property
(see (elisp)Examining Properties), but works
on the display
property only.
position is the position in the buffer or string to examine, and
prop is the display
property to return. The optional
object argument should be either a string or a buffer, and
defaults to the current buffer. If the optional properties
argument is non-nil
, it should be a display
property,
and in that case, position and object are ignored. (This
can be useful if you’ve already gotten the display
property
with get-char-property
, for instance (see (elisp)Examining
Properties).
Add display property prop with value to the text from
start to end. If any text in the region has a non-nil
display
property, those properties are retained.
If object is non-nil
, it should be a string or a buffer.
If nil
, this defaults to the current buffer.
This function returns the n first elements of list.
Essentially, it returns the part of list that nthcdr
skips.
take
returns list if shorter than n elements;
it returns nil
if n is zero or negative.
(take 3 '(a b c d)) ⇒ (a b c)
(take 10 '(a b c d)) ⇒ (a b c d)
(take 0 '(a b c d)) ⇒ nil
This is a version of take
that works by destructively modifying
the list structure of the argument. That makes it faster, but the
original value of list may be lost.
ntake
returns list unmodified if shorter than n
elements; it returns nil
if n is zero or negative.
Otherwise, it returns list truncated to its first n
elements.
This means that it is usually a good idea to use the return value and not just rely on the truncation effect unless n is known to be positive.
This function returns t
if object is a function object
that is not in the form of ELisp source code but something like
machine code or byte code instead. More specifically it returns
t
if the function is built-in, or byte-compiled, or
natively-compiled, or a function loaded from a dynamic module.
Checks whether object is a function alias. If it is, it returns
a list of symbols representing the function alias chain, else
nil
. For instance, if a
is an alias for b
, and
b
is an alias for c
:
(function-alias-p 'a) ⇒ (b c)
If there’s a loop in the definitions, an error will be signalled. If
noerror is non-nil
, the non-looping parts of the chain is
returned instead.
string-equal-ignore-case
compares strings ignoring case
differences, like char-equal
when case-fold-search
is
t
.
string-split
is an alias for the function split-string
.
The name follows the convention of other string functions.
This function checks if a buffer designated by buffer-or-name
satisfies a condition
. Optional third argument arg is
passed to the predicate function in condition. A condition can
be one of the following:
nil
if the buffer
matches. If the function expects one argument, it is called with
buffer-or-name as the argument; if it expects 2 arguments, the
first argument is buffer-or-name and the second is arg
(or nil
if arg is omitted).
(oper . expr)
where oper is one
of
not
Satisfied if expr doesn’t satisfy buffer-match-p
with
the same buffer and arg
.
or
Satisfied if expr is a list and any condition in
expr satisfies buffer-match-p
, with the same buffer and
arg
.
and
Satisfied if expr is a list and all conditions in
expr satisfy buffer-match-p
, with the same buffer and
arg
.
derived-mode
Satisfied if the buffer’s major mode derives from expr.
major-mode
Satisfied if the buffer’s major mode is equal to expr. Prefer
using derived-mode
instead when both can work.
""
(empty
string), (and)
(empty conjunction) or always
.
See (elisp)Buffer List.
This function returns a list of all buffers that satisfy a
condition
, as defined for buffer-match-p
. By default
all buffers are considered, but this can be restricted via the second
optional buffer-list
argument. Optional third argument
arg will be used by condition in the same way as
buffer-match-p
does.
See (elisp)Buffer List.
When character compositions are in effect, sequence of characters can be composed for display to form grapheme clusters, for example to display accented characters, or ligatures, or Emoji, or when complex text shaping requires that for some scripts. When that happens, characters no longer map in a simple way to display columns, and display layout decisions with such strings, such as truncating too wide strings, can be a complex job. This function helps in performing such jobs: it splits up its argument string into a list of substrings, where each substring produces a single grapheme cluster that should be displayed as a unit. Lisp programs can then use this list to construct visually-valid substrings of string which will look correctly on display, or compute the width of any substring of string by adding the width of its constituents in the returned list, etc.
For instance, if you want to display a string without the first glyph, you can say:
(apply #'insert (cdr (string-glyph-split string))))
Evaluate body like progn
, but change buffer-modified
status only if buffer text changes. If the buffer was unmodified
before execution of body, and buffer text after execution of
body is identical to what it was before, ensure that buffer is
still marked unmodified afterwards.
Note that only changes in the raw byte sequence of the buffer text, as
stored in the internal representation, are monitored for the purpose of
detecting the lack of changes in buffer text. Any other changes that
are normally perceived as "buffer modifications", such as changes in
text properties, buffer-file-coding-system
, buffer multibyteness,
etc. – will not be noticed, and the buffer will still be marked
unmodified, effectively ignoring those changes.
Return the fields (inodenum device)
as a list from attributes
generated by file-attributes
.
This function splits a file name into its components, and can be
thought of as the inverse of string-join
with the appropriate
directory separator. For example,
(file-name-split "/tmp/foo.txt") ⇒ ("" "tmp" "foo.txt") (string-join (file-name-split "/tmp/foo.txt") "/") ⇒ "/tmp/foo.txt"
This function returns the directory name of the parent directory of
filename. If filename is at the root directory of the
filesystem, it returns nil
. A relative filename is
assumed to be relative to default-directory
, and the return
value will also be relative in that case. If the return value is
non-nil
, it ends in a slash.
This function returns non-nil
if the time stamp of
filename has changed since the last call. When called for the
first time for some filename, it records the last modification
time and size of the file, and returns non-nil
when
filename exists. Thereafter, when called for the same
filename, it compares the current time stamp and size with the
recorded ones, and returns non-nil
only if either the time
stamp or the size (or both) are different. This is useful when a Lisp
program wants to re-read a file whenever it changes. With an optional
argument tag, which must be a symbol, the size and modification
time comparisons are limited to calls with the same tag.
Create a regexp to match directory for
directory-abbrev-alist
.
Apply the abbreviations in directory-abbrev-alist
to filename.
Note that when calling this, you should set case-fold-search
as
appropriate for the filesystem used for filename.
Say whether keys is a valid key. A key is a string consisting of one or more key strokes. The key strokes are separated by single space characters.
Each key stroke is either a single character, or the name of an event, surrounded by angle brackets. In addition, any key stroke may be preceded by one or more modifier keys. Finally, a limited number of characters have a special shorthand syntax.
Here’s some example key sequences.
The key f.
A three key sequence of the keys S, o and m.
A two key sequence of the keys c with the control modifier and then the key o.
The key named "left" with the hyper modifier.
The "return" key with a meta modifier.
The "space" key with both the control and meta modifiers.
These are the characters that have shorthand syntax: NUL, RET, TAB, LFD, ESC, SPC, DEL.
Modifiers have to be specified in this order
Alt (A)-Control (C)-Hyper (H)-Meta (M)-Shift (s)-Super (s)
Convert keys to the internal Emacs key representation. See
key-valid-p
for a description of valid key sequences. Examples
include f, C-c C-c, H-<left>, M-RET or
C-M-<return>.
This function sets the binding for key in keymap. (If
key is more than one event long, the change is actually made in
another keymap reached from keymap.) The argument binding
can be any Lisp object, but only certain types are meaningful. (For a
list of meaningful types, see (elisp)Key Lookup.) The value
returned by keymap-set
is binding.
If key is <t>, this sets the default binding in keymap. When an event has no binding of its own, the Emacs command loop uses the keymap’s default binding, if there is one.
Every prefix of key must be a prefix key (i.e., bound to a keymap)
or undefined; otherwise an error is signaled. If some prefix of
key is undefined, then keymap-set
defines it as a prefix
key so that the rest of key can be defined as specified.
If there was previously no binding for key in keymap, the new binding is added at the beginning of keymap. The order of bindings in a keymap makes no difference for keyboard input, but it does matter for menu keymaps (see (elisp)Menu Keymaps).
This function sets the binding of key in the current global map to binding.
(keymap-global-set key binding) ≡ (keymap-set (current-global-map) key binding)
This function sets the binding of key in the current local keymap to binding.
(keymap-local-set key binding) ≡ (keymap-set (current-local-map) key binding)
This function removes the binding of key from the current global map.
One use of this function is in preparation for defining a longer key that uses key as a prefix—which would not be allowed if key has a non-prefix binding. For example:
(keymap-global-unset "C-l") ⇒ nil
(keymap-global-set "C-l C-l" 'redraw-display) ⇒ nil
This function removes the binding of key from the current local map.
Replace olddef with newdef for any keys in keymap now defined as olddef. In other words, olddef is replaced with newdef wherever it appears. Alternatively, if optional fourth argument oldmap is specified, we redefine in keymap as newdef those keys that are defined as olddef in oldmap.
This function returns the definition of key in keymap. All
the other functions described in this chapter that look up keys use
keymap-lookup
. Here are examples:
(keymap-lookup (current-global-map) "C-x C-f") ⇒ find-file
(keymap-lookup (current-global-map) "C-x C-f 1 2 3 4 5") ⇒ 2
Like keymap-lookup
, but restricting the search for commands bound
to keys to the current local keymap.
Like keymap-lookup
, but restricting the search for commands bound
to keys to the current global keymap.
You can create a keymap with the functions described above, and then
use keymap-set
(see (elisp)Changing Key Bindings) to
specify key bindings in that map. When writing modes, however, you
frequently have to bind a large number of keys at once, and using
keymap-set
on them all can be tedious and error-prone. Instead
you can use define-keymap
, which creates a keymap and binds a
number of keys. Here’s a very basic example:
(define-keymap "n" #'forward-line "f" #'previous-line "C-c C-c" #'quit-window)
This function creates a new sparse keymap, defines the keystrokes in pairs, and returns the new keymap.
pairs is a list of alternating key bindings and key definitions,
as accepted by keymap-set
. In addition, the key can be the
special symbol :menu
, in which case the definition should be a
menu definition as accepted by easy-menu-define
(see (elisp)Easy
Menu). Here’s a brief example of this usage:
(define-keymap :full t "g" #'eww-reload :menu '("Eww" ["Exit" quit-window t] ["Reload" eww-reload t]))
A number of keywords can be used before the key/definition pairs to
change features of the new keymap. If any of the feature keywords is
missing from the define-keymap
call, the default value for that
feature is nil
. Here’s a list of the available feature
keywords:
:full
If non-nil
, create a char-table keymap (as from
make-keymap
) instead of a sparse keymap (as from
make-sparse-keymap
(see (elisp)Creating Keymaps). A sparse
keymap is the default.
:parent
If non-nil
, the value should be a keymap to use as the parent
(see (elisp)Inheritance and Keymaps).
:keymap
If non-nil
, the value should be a keymap. Instead of creating
a new keymap, the specified keymap is modified instead.
:suppress
If non-nil
, the keymap will be suppressed with
suppress-keymap
(see (elisp)Changing Key Bindings). By
default, digits and the minus sign are exempt from suppressing, but if
the value is nodigits
, this suppresses digits and minus-sign like
it does with other characters.
:name
If non-nil
, the value should be a string to use as the menu for
the keymap if you use it as a menu with x-popup-menu
(see (elisp)Pop-Up Menus).
:prefix
If non-nil
, the value should be a symbol to be used as a prefix
command (see (elisp)Prefix Keys). If this is the case, this symbol
is returned by define-keymap
instead of the map itself.
By far, the most common thing to do with a keymap is to bind it to a
variable. This is what virtually all modes do—a mode called
foo
almost always has a variable called foo-mode-map
.
This macro defines name as a variable, passes options
and pairs to define-keymap
, and uses the result as the
default value for the variable.
options is like the keywords in define-keymap
, but
there’s an additional :doc
keyword that provides the doc
string for the defined variable.
Here’s an example:
(defvar-keymap eww-textarea-map :parent text-mode-map "RET" #'forward-line "TAB" #'shr-next-link)
Like when-let
, but repeat until a binding in spec is
nil
. The return value is always nil
.
This is comparable to and-let*
.
This function says whether two window configurations have the same
window layout, but ignores the values of point and the saved scrolling
positions—it can return t
even if those aspects differ.
Bind name to the name of a new temporary file and evaluate body. Delete the temporary file after body exits normally or non-locally. name will be bound to the file name of the temporary file. See the docstring for supported keyword arguments.
Bind name to the name of a new temporary directory and evaluate body. Delete the temporary directory after body exits normally or non-locally.
name is bound to the directory name, not the directory file name. (In other words, it will end with the directory delimiter; on Unix-like systems, it will end with "/".)
The same keyword arguments are supported as in
ert-with-temp-file
(which see), except for :text
.
Return a function that takes any number of arguments, but returns value.
This macro expands to code that executes body with each of the
variables in names bound to a fresh uninterned symbol, or
gensym, in Common Lisp parlance. For macros requiring more than
one gensym, use of cl-with-gensyms
shortens the code and
renders one’s intentions clearer. Compare:
(defmacro my-macro (foo) (let ((bar (gensym "bar")) (baz (gensym "baz")) (quux (gensym "quux"))) `(let ((,bar (+ …))) …))) (defmacro my-macro (foo) (cl-with-gensyms (bar baz quux) `(let ((,bar (+ …))) …)))
This macro is primarily to help the macro programmer ensure that forms supplied by the user of the macro are evaluated just once by its expansion even though the result of evaluating the form is to occur more than once. Less often, this macro is used to ensure that forms supplied by the macro programmer are evaluated just once.
Each variable may be used to refer to the result of evaluating
form in body. cl-once-only
binds each
variable to a fresh uninterned symbol during the evaluation of
body. Then, cl-once-only
wraps the final expansion in
code to evaluate each form and bind the result to the
corresponding uninterned symbol. Thus, when the macro writer
substitutes the value for variable into the expansion they are
effectively referring to the result of evaluating form, rather
than form itself. Another way to put this is that each
variable is bound to an expression for the (singular) result of
evaluating form.
The most common case is where variable is one of the arguments
to the macro being written, so (variable variable)
may be
abbreviated to just variable
.
For example, consider this macro:
(defmacro my-list (x y &rest forms) (let ((x-result (gensym)) (y-result (gensym))) `(let ((,x-result ,x) (,y-result ,y)) (list ,x-result ,y-result ,x-result ,y-result (progn ,@forms))))
In a call like (my-list (pop foo) …)
the intermediate
binding to x-result
ensures that the pop
is not done
twice. But as a result the code is rather complex: the reader must
keep track of how x-result
really just means the first
parameter of the call to the macro, and the required use of multiple
gensyms to avoid variable capture by (progn ,@forms)
obscures
things further. cl-once-only
takes care of these details:
(defmacro my-list (x y &rest forms) (cl-once-only (x y) `(list ,x ,y ,x ,y (progn ,@forms))))
These functions must be called explicitly via compat-call
,
since their calling convention or behavior was extended in Emacs 29.1:
This function adds keymap as a transient keymap, which takes precedence over other keymaps for one (or more) subsequent keys.
Normally, keymap is used just once, to look up the very next
key. If the optional argument keep-pred is t
, the map
stays active as long as the user types keys defined in keymap;
when the user types a key that is not in keymap, the transient
keymap is deactivated and normal key lookup continues for that key.
The keep-pred argument can also be a function. In that case,
the function is called with no arguments, prior to running each
command, while keymap is active; it should return non-nil
if keymap should stay active.
The optional argument on-exit, if non-nil
, specifies a
function that is called, with no arguments, after keymap is
deactivated.
The optional argument message specifies the message to display
after activating the transient map. If message is a string, it
is the format string for the message, and any ‘%k’ specifier in
that string is replaced with the list of keys from the transient map.
Any other non-nil
value of message stands for the default
message format ‘Repeat with %k’.
If the optional argument timeout is non-nil
, it should be
a number that specifies how many seconds of idle time to wait before
deactivating keymap. The value of the variable
set-transient-map-timeout
, if non-nil
, overrides the
value of this argument.
This function works by adding and removing keymap from the
variable overriding-terminal-local-map
, which takes precedence
over all other active keymaps (see (Searching Keymaps)elisp).
Split string into a list of strings on newline boundaries. If
the optional argument omit-nulls is non-nil
, remove empty
lines from the results. If the optional argument keep-newlines
is non-nil
, don’t remove the trailing newlines from the result
strings.
This function is like keymap-set
(see (elisp)Changing Key
Bindings, but understands only the legacy key syntaxes.
In addition, this function also has a remove argument. If it is
non-nil
, the definition will be removed. This is almost the
same as setting the definition to nil
, but makes a difference
if the keymap has a parent, and key is shadowing the same
binding in the parent. With remove, subsequent lookups will
return the binding in the parent, whereas with a nil
definition
the lookups will return nil
.
See (elisp)Low-Level Key Binding.
This compatibility version handles the optional argument remove.
This returns the value of the property property stored in the
property list plist. Comparisons are done with predicate,
and defaults to eq
. It accepts a malformed plist
argument. If property is not found in the plist, it
returns nil
.
See (elisp)Plist Access.
This compatibility version handles the optional argument
predicate. This is a generalized variable (see (elisp)Generalized
Variables) that can be used to change a value with
setf
.
This stores value as the value of the property property in
the property list plist. Comparisons are done with
predicate, and defaults to eq
. It may modify plist
destructively, or it may construct a new list structure without
altering the old. The function returns the modified property list, so
you can store that back in the place where you got plist.
See (elisp)Plist Access.
This compatibility version handles the optional argument predicate.
This returns non-nil
if plist contains the given
property. Comparisons are done with predicate, and
defaults to eq
. Unlike plist-get
, this allows you to
distinguish between a missing property and a property with the value
nil
. The value is actually the tail of plist whose
car
is property.
See (elisp)Plist Access.
This compatibility version handles the optional argument predicate.
Compat does not provide support for the following Lisp features implemented in 29.1:
imagep
.
image-at-point-p
.
function-documentation
.
with-undo-amalgamate
.
string-glyph-split
.
string-limit
.
string-pixel-width
and buffer-text-pixel-size
.
minibuffer-lazy-highlight-setup
.
pp-emacs-lisp-code
.
bidi-string-strip-control-characters
.
current-cpu-time
.
xdg-state-home
, xdg-current-desktop
and xdg-session-type
.
setopt
.
oclosure
library.
textsec
library.
range
library.
string-edit
library.
vtable
library.
pixel-fill
library.
Previous: Emacs 29.1, Up: Support [Contents][Index]
The following functions and macros are implemented in Emacs 30.1. These functions are made available by Compat on Emacs versions older than 30.1. Note that due to upstream changes, it might happen that there will be the need for changes, so use these functions with care.
List of files and directories whose content we trust. Be extra careful
here since trusting means that Emacs might execute the code contained
within those files and directories without an explicit request by the
user. One important case when this might happen is when
flymake-mode
is enabled (for example, when it is added to a mode
hook). Each element of the list should be a string:
- If it ends in "/", it is considered as a directory name and means that
Emacs should trust all the files whose name has this directory as a prefix.
- else it is considered as a file name.
Use abbreviated file names. For example, an entry "~/mycode" means
that Emacs will trust all the files in your directory "mycode". This
variable can also be set to :all
, in which case Emacs will trust all
files, which opens a gaping security hole.
Return non-nil if we trust the contents of the current buffer. Here,
"trust" means that we are willing to run code found inside of it. See
also trusted-files
.
This function returns the Unicode name of char. It returns
nil
if char is not a character or has no Unicode name.
This function removes all symbols from obarray.
This function returns t
if object is a closure, which is
a particular kind of function object. Currently closures are used
for all byte-code functions and all interpreted functions.
This function returns t
if object is an interpreted function.
Return t
if object is a built-in primitive function.
This excludes special forms, since they are not functions.
This function returns non-nil
if a comes before b
in the standard sorting order; this means that it returns nil
when b comes before a, or if they are equal or unordered.
The arguments a and b must have the same type. Specifically:
<
.
string<
and symbols are compared by
comparing their names as strings.
value<
on the first pair of differing elements. If one
sequence runs out of elements before the other, the shorter sequence
comes before the longer.
nil
) will compare before
any live buffer.
nil
.
Examples:
(value< -4 3.5) ⇒ t (value< "dog" "cat") ⇒ nil (value< 'yip 'yip) ⇒ nil (value< '(3 2) '(3 2 0)) ⇒ t (value< [3 2 "a"] [3 2 "b"]) ⇒ t
Note that nil
is treated as either a symbol or an empty list,
depending on what it is compared against:
(value< nil '(0)) ⇒ t (value< 'nib nil) ⇒ t
There is no limit to the length of sequences (lists, vectors and so
on) that can be compared, but value<
may fail with an error if
used to compare circular or deeply nested data structures.
This function is an alias for nthcdr
. It returns the nth
CDR of list. In other words, it skips past the first
n links of list and returns what follows.
Return the buffer with file-truename
equal to filename (a string).
If there is no such live buffer, return nil.
See also find-buffer-visiting
.
Return the buffer with buffer-local variable equal to value. If there is no such live buffer, return nil.
This function works like require
, except if feature is
already loaded (i.e. is already a member of the list in
features
, see below). If feature is already loaded, this
function checks if feature was provided by a file different from
filename, and if so, it by default signals an error. If the
value of the optional argument noerror is reload
, the
function doesn’t signal an error, but instead forcibly reloads
filename; if noerror is some other non-nil
value,
the function emits a warning about feature being already
provided by another file.
Merge lists in a consistent order. lists is a list of
lists of elements. Merge them into a single list containing the same
elements (removing duplicates), obeying their relative positions in
each list. The order of the (sub)lists determines the final order in
those cases where the order within the sublists does not impose a
unique choice. Equality of elements is tested with eql
.
If a consistent order does not exist, call error-function with a remaining list of lists that we do not know how to merge. It should return the candidate to use to continue the merge, which has to be the head of one of the lists. By default we choose the head of the first list.
If non-nil, request lazy highlighting of completion candidates.
Lisp programs (a.k.a. "front ends") that present completion candidates
may opt to bind this variable to a non-nil value when calling
functions (such as completion-all-completions
) which produce
completion candidates. This tells the underlying completion styles
that they do not need to fontify (i.e., propertize with the
face
property) completion candidates in a way that highlights
the matching parts. Then it is the front end which presents the
candidates that becomes responsible for this fontification. The front
end does that by calling the function completion-lazy-hilit
on
each completion candidate that is to be displayed to the user.
Note that only some completion styles take advantage of this variable
for optimization purposes. Other styles will ignore the hint and
fontify eagerly as usual. It is still safe for a front end to call
completion-lazy-hilit
in these situations.
To author a completion style that takes advantage of this variable,
see completion-lazy-hilit-fn
and
completion-pcm--hilit-commonality
.
Fontification function set by lazy-highlighting completions styles.
When a given style wants to enable support for
completion-lazy-hilit
(which see), that style should set this
variable to a function of one argument. It will be called with each
completion candidate, a string, to be displayed to the user, and
should destructively propertize these strings with the face
property.
Return a copy of completion candidate str that is
face-propertized. See documentation of the variable
completion-lazy-hilit
for more details.
Test condition at macro-expansion time. If its value is
non-nil
, expand the macro to then-form, otherwise expand
it to else-forms enclosed in a progn
. else-forms
may be empty.
Here is an example of its use from CC Mode, which prevents a
defadvice
form being compiled in newer versions of Emacs:
(static-if (boundp 'comment-line-break-function) (progn) (defvar c-inside-line-break-advice nil) (defadvice indent-new-comment-line (around c-line-break-advice activate preactivate) "Call `c-indent-new-comment-line' if in CC Mode." (if (or c-inside-line-break-advice (not c-buffer-is-cc-mode)) ad-do-it (let ((c-inside-line-break-advice t)) (c-indent-new-comment-line (ad-get-arg 0))))))
These functions must be called explicitly via compat-call
,
since their calling convention or behavior was extended in Emacs 30.1:
This function sorts sequence, which must be a list or vector, and returns a sorted sequence of the same type. The sort is stable, which means that elements with equal sort keys maintain their relative order. It takes the following optional keyword arguments:
:key keyfunc
Use keyfunc, a function that takes a single element from
sequence and returns its key value, to generate the keys used in
comparison. If this argument is absent or if keyfunc is
nil
then identity
is assumed; that is, the elements
themselves are used as sorting keys.
:lessp predicate
Use predicate to order the keys. predicate is a function
that takes two sort keys as arguments and returns non-nil
if
the first should come before the second. If this argument is absent
or predicate is nil
, then value<
is used, which is
applicable to many different Lisp types and generally sorts in
ascending order.
For consistency, any predicate must obey the following rules:
:reverse flag
If flag is non-nil
, the sorting order is reversed. With
the default :lessp
predicate this means sorting in descending order.
:in-place flag
If flag is non-nil
, then sequence is sorted
in-place (destructively) and returned. If nil
, or if this
argument is not given, a sorted copy of the input is returned and
sequence itself remains unmodified. In-place sorting is
slightly faster, but the original sequence is lost.
If the default behaviour is not suitable for your needs, it is usually
easier and faster to supply a new :key
function than a
different :lessp
predicate. For example, consider sorting
these strings:
(setq numbers '("one" "two" "three" "four" "five" "six")) (sort numbers) ⇒ ("five" "four" "one" "six" "three" "two")
You can sort the strings by length instead by supplying a different key function:
(sort numbers :key #'length) ⇒ ("one" "two" "six" "four" "five" "three")
Note how strings of the same length keep their original order, thanks to
the sorting stability. Now suppose you want to sort by length, but use
the string contents to break ties. The easiest way is to specify a key
function that transforms an element to a value that is sorted this way.
Since value<
orders compound objects (conses, lists,
vectors and records) lexicographically, you could do:
(sort numbers :key (lambda (x) (cons (length x) x))) ⇒ ("one" "six" "two" "five" "four" "three")
because (3 . "six")
is ordered before (3 . "two")
and so on.
For compatibility with previous versions of Emacs, the sort
function can also be called using the fixed two-argument form:
(sort
sequence predicate)
where predicate is the :lessp
argument. When using this
form, sorting is always done in-place.
Get property prop from completion metadata. If the
metadata specifies a completion category, the variables
completion-category-overrides
and
completion-category-defaults
take precedence for
category-specific overrides. If the completion metadata does not
specify the property, the completion-extra-properties
plist is
consulted. Note that the keys of the
completion-extra-properties
plist are keyword symbols, not
plain symbols.
This function returns a copy of the tree tree. If tree is a cons cell, this makes a new cons cell with the same CAR and CDR, then recursively copies the CAR and CDR in the same way.
Normally, when tree is anything other than a cons cell,
copy-tree
simply returns tree. However, if
vectors-and-records is non-nil
, it copies vectors and records
too (and operates recursively on their elements). The tree
argument must not contain cycles.
Compat does not provide support for the following Lisp features implemented in 30.1:
Next: Function Index, Previous: Support, Up: "Compat" Manual [Contents][Index]
Compat is developed on GitHub.
Bug reports, patches and comments are best sent to the issue tracker. These may include issues in the compatibility code, missing definitions or performance issues. We also provide a development mailing list (~pkal/compat-devel@lists.sr.ht).
Please note that as a GNU ELPA package, Compat requires contributors to have signed the FSF copyright assignment, before any non-trivial contribution (roughly 15 lines of code) can be applied.
It is important that you provide tests when you contribute new functionality. Compat has 100% test coverage by the test suite. We use continuous integration to check if patches preserve existing functionality.
Development for the currently stable Emacs version happens in the main branch of the Compat Git repository. ELPA-devel nightly builds are created from this branch. New features, which are not yet ready to be merged directly into the main branch, are developed in feature branches. Furthermore the Git repository has a branch emacs-<version> where the development for the upcoming Emacs release takes place. This branch is separate from the main branch since the new functionality should not be made available (neither via ELPA nor ELPA-devel) before the new Emacs version has been reasonably stabilized, e.g., around the time when the Emacs version branch is created in the Emacs repository on Savannah.
Next: Variable Index, Previous: Development, Up: "Compat" Manual [Contents][Index]
Jump to: | A B C D E F G H I K L M N O P R S T U V W X |
---|
Jump to: | A B C D E F G H I K L M N O P R S T U V W X |
---|
Previous: Function Index, Up: "Compat" Manual [Contents][Index]
Jump to: | C E G L M R S T U |
---|
Jump to: | C E G L M R S T U |
---|