diff options
author | Basil L. Contovounesios <contovob@tcd.ie> | 2021-03-02 14:35:50 +0000 |
---|---|---|
committer | Basil L. Contovounesios <contovob@tcd.ie> | 2021-03-04 15:40:35 +0000 |
commit | 8e759d60cc234d4beb471dbb46f91d8ca3a20066 (patch) | |
tree | 812b6f56f6d5c1b14e83223f875fbaf58a076fcc /doc/lispref/customize.texi | |
parent | 358c6c9b95a5fd77edb1538f5fec5021a03de94a (diff) | |
download | emacs-8e759d60cc234d4beb471dbb46f91d8ca3a20066.tar.gz emacs-8e759d60cc234d4beb471dbb46f91d8ca3a20066.tar.bz2 emacs-8e759d60cc234d4beb471dbb46f91d8ca3a20066.zip |
Decouple require-theme from load-theme
* lisp/custom.el (require-theme): Refashion after 'require', as a
function for loading only named features. Do not call
load-theme (bug#45068).
* etc/NEWS: Update its announcement accordingly.
* doc/lispref/customize.texi (Custom Themes): Document it.
* etc/themes/modus-operandi-theme.el:
* etc/themes/modus-vivendi-theme.el: Remove redundant calls to
'provide'.
* test/lisp/custom-tests.el (custom-tests--with-temp-dir): New
macro.
(custom-theme--load-path): Use it.
(custom-tests-require-theme): New test.
Diffstat (limited to 'doc/lispref/customize.texi')
-rw-r--r-- | doc/lispref/customize.texi | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi index 8fd12f79026..bc35982c172 100644 --- a/doc/lispref/customize.texi +++ b/doc/lispref/customize.texi @@ -1474,7 +1474,7 @@ To protect against loading themes containing malicious code, Emacs displays the source file and asks for confirmation from the user before loading any non-built-in theme for the first time. As such, themes are not ordinarily byte-compiled, and source files -always take precedence when Emacs is looking for a theme to load. +usually take precedence when Emacs is looking for a theme to load. The following functions are useful for programmatically enabling and disabling themes: @@ -1508,6 +1508,30 @@ confirmation before loading the theme, unless the optional argument @var{no-confirm} is non-@code{nil}. @end deffn +@defun require-theme feature &optional noerror +This function searches @code{custom-theme-load-path} for a file that +provides @var{feature} and then loads it. This is like the function +@code{require} (@pxref{Named Features}), except it searches +@code{custom-theme-load-path} instead of @code{load-path} +(@pxref{Library Search}). This can be useful in Custom themes that +need to load supporting Lisp files when @code{require} is unsuitable +for that. + +If @var{feature}, which should be a symbol, is not already present in +the current Emacs session according to @code{featurep}, then +@code{require-theme} searches for a file named @var{feature} with an +added @samp{.elc} or @samp{.el} suffix, in that order, in the +directories specified by @code{custom-theme-load-path}. + +If a file providing @var{feature} is successfully found and loaded, +then @code{require-theme} returns @var{feature}. The optional +argument @var{noerror} determines what happens if the search or +loading fails. If it is @code{nil}, the function signals an error; +otherwise, it returns @code{nil}. If the file loads successfully but +does not provide @var{feature}, then @code{require-theme} signals an +error; this cannot be suppressed. +@end defun + @deffn Command enable-theme theme This function enables the Custom theme named @var{theme}. It signals an error if no such theme has been loaded. |