Implement convenience commands modus-themes-select-{dark,light}

This commit is contained in:
Protesilaos Stavrou 2025-11-22 14:14:49 +02:00
parent 26d60d3e6b
commit c270cd8f5e
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA
3 changed files with 250 additions and 177 deletions

View file

@ -569,6 +569,16 @@ customization::).
modus-themes-load-theme internally (*note Option for which themes to
toggle::). The aforementioned hold true for them as well.
Convenience commands for loading only dark or light themes are:
modus-themes-select-dark [ Part of 5.2.0-dev. ]
modus-themes-select-light [ Part of 5.2.0-dev. ]
modus-themes-load-random-dark
modus-themes-load-random-light
* Menu:
* The require-theme for built-in Emacs themes::
@ -802,11 +812,13 @@ Brief: Disable all other themes when loading a Modus theme.
When the value is non-nil, the commands modus-themes-toggle,
modus-themes-rotate, modus-themes-load-random, and
modus-themes-select, as well as the modus-themes-load-theme
function, will disable all other themes while loading the specified
Modus theme (*note Option for which themes to toggle::). This is done
to ensure that Emacs does not blend two or more themes: such blends lead
to awkward results that undermine the work of the designer.
modus-themes-select, as well as the modus-themes-load-theme function
(and any related convenience wrappers like
modus-themes-load-random-dark), will disable all other themes while
loading the specified Modus theme (*note Option for which themes to
toggle::). This is done to ensure that Emacs does not blend two or more
themes: such blends lead to awkward results that undermine the work of
the designer.
When the value is nil, the aforementioned commands and function
will only disable other themes within the Modus collection.
@ -6983,58 +6995,70 @@ B.1 Function index
* Menu:
* modus-themes-contrast: DIY Measure color contrast.
(line 6)
(line 6)
* modus-themes-define-derivative-command: Create convenience commands to load a derivative theme.
(line 10)
(line 10)
* modus-themes-get-all-known-themes: Determine what counts as a Modus theme.
(line 10)
(line 10)
* modus-themes-get-color-value: Get a single color from the palette with modus-themes-get-color-value.
(line 6)
(line 6)
* modus-themes-get-themes: Option for which themes to rotate.
(line 17)
(line 17)
* modus-themes-get-themes <1>: Determine what counts as a Modus theme.
(line 16)
(line 16)
* modus-themes-include-derivatives-mode: Determine what counts as a Modus theme.
(line 47)
* modus-themes-list-colors: Preview theme colors. (line 6)
* modus-themes-list-colors-current: Preview theme colors. (line 11)
* modus-themes-load-random: Enable and load. (line 94)
* modus-themes-load-random <1>: Disable other themes. (line 15)
* modus-themes-load-theme: Enable and load. (line 80)
* modus-themes-load-theme <1>: Disable other themes. (line 15)
* modus-themes-preview-colors: Preview theme colors. (line 19)
* modus-themes-preview-colors-current: Preview theme colors. (line 19)
(line 47)
* modus-themes-list-colors: Preview theme colors.
(line 6)
* modus-themes-list-colors-current: Preview theme colors.
(line 11)
* modus-themes-load-random: Enable and load. (line 94)
* modus-themes-load-random <1>: Disable other themes.
(line 15)
* modus-themes-load-random-dark: Enable and load. (line 105)
* modus-themes-load-random-light: Enable and load. (line 107)
* modus-themes-load-theme: Enable and load. (line 80)
* modus-themes-load-theme <1>: Disable other themes.
(line 15)
* modus-themes-preview-colors: Preview theme colors.
(line 19)
* modus-themes-preview-colors-current: Preview theme colors.
(line 19)
* modus-themes-preview-mode: Commands for the preview palette buffer.
(line 6)
(line 6)
* modus-themes-preview-mode-copy-color: Commands for the preview palette buffer.
(line 20)
(line 20)
* modus-themes-preview-mode-copy-entry: Commands for the preview palette buffer.
(line 27)
(line 27)
* modus-themes-preview-mode-mark: Commands for the preview palette buffer.
(line 34)
(line 34)
* modus-themes-preview-mode-mark-all: Commands for the preview palette buffer.
(line 34)
(line 34)
* modus-themes-preview-mode-unmark: Commands for the preview palette buffer.
(line 34)
(line 34)
* modus-themes-preview-mode-unmark-all: Commands for the preview palette buffer.
(line 34)
* modus-themes-rotate: Enable and load. (line 94)
* modus-themes-rotate <1>: Disable other themes. (line 15)
(line 34)
* modus-themes-rotate: Enable and load. (line 94)
* modus-themes-rotate <1>: Disable other themes.
(line 15)
* modus-themes-rotate <2>: Option for which themes to rotate.
(line 6)
* modus-themes-select: Enable and load. (line 94)
* modus-themes-select <1>: Enable and load. (line 94)
* modus-themes-select <2>: Disable other themes. (line 15)
(line 6)
* modus-themes-select: Enable and load. (line 94)
* modus-themes-select <1>: Disable other themes.
(line 15)
* modus-themes-select-dark: Enable and load. (line 101)
* modus-themes-select-light: Enable and load. (line 103)
* modus-themes-theme: Build on top of the Modus themes.
(line 20)
* modus-themes-toggle: Enable and load. (line 94)
* modus-themes-toggle <1>: Disable other themes. (line 15)
(line 20)
* modus-themes-toggle: Enable and load. (line 94)
* modus-themes-toggle <1>: Disable other themes.
(line 15)
* modus-themes-toggle <2>: Option for which themes to toggle.
(line 6)
(line 6)
* modus-themes-wcag-formula: DIY Measure color contrast.
(line 6)
(line 6)
* modus-themes-with-colors: Use theme colors in code with modus-themes-with-colors.
(line 10)
(line 10)

File: modus-themes.info, Node: Variable index, Next: Concept index, Prev: Function index, Up: Indices
@ -7183,129 +7207,129 @@ Node: Debian 11 Bullseye15376
Node: GNU Guix15784
Node: Dealing with byte compilation errors16067
Node: Enable and load17225
Node: The require-theme for built-in Emacs themes21220
Node: Sample configuration22137
Node: Differences between loading and enabling24413
Node: Customization options26478
Node: Disable other themes30247
Node: Bold constructs31521
Node: Italic constructs32393
Node: Option for which themes to toggle33221
Node: Option for which themes to rotate33984
Node: Mixed fonts34981
Node: Command prompts36035
Node: Completion UIs37876
Node: Org mode blocks40725
Node: Heading styles41368
Node: UI typeface45794
Node: Palette overrides46767
Node: Palette extension51124
Node: Preview theme colors53600
Node: Commands for the preview palette buffer55255
Node: Use colors from the Modus themes palette57333
Node: Get a single color from the palette with modus-themes-get-color-value58197
Node: Use theme colors in code with modus-themes-with-colors60558
Node: Advanced customization62812
Node: DIY Palette override presets64590
Node: DIY Add support for engrave-faces67424
Node: DIY Stylistic variants using palette overrides77407
Node: DIY Make the mode line borderless79466
Node: DIY Make the active mode line colorful80841
Node: DIY Make the tab bar more or less colorful83059
Node: DIY Make the fringe invisible or another color84996
Node: DIY Make links use subtle or no underlines86193
Node: DIY Make prompts more or less colorful87311
Node: DIY Make completion matches more or less colorful88634
Node: DIY Make comments yellow and strings green92193
Node: DIY Make code syntax use the old alt-syntax style93900
Node: DIY Make use of alternative styles for code syntax97013
Node: DIY Make matching parenthesis more or less intense100475
Node: DIY Make box buttons more or less gray101847
Node: DIY Make TODO and DONE more or less intense102860
Node: DIY Make headings more or less colorful104361
Node: DIY Make Org block colors more or less colorful106478
Node: DIY Make Org agenda more or less colorful110850
Node: DIY Make inline code in prose use alternative styles114025
Node: DIY Make mail citations and headers more or less colorful116265
Node: DIY Make the region preserve text colors plus other styles118665
Node: DIY Make mouse highlights more or less colorful120221
Node: DIY Make language underlines less colorful121234
Node: DIY Make line numbers use alternative styles122386
Node: DIY Make diffs use only a foreground124029
Node: DIY Make deuteranopia diffs red and blue instead of yellow and blue126916
Node: DIY More accurate colors in terminal emulators129388
Node: DIY Range of color with terminal emulators130696
Node: DIY Per-theme customization settings133483
Node: DIY Do not extend the region background134916
Node: DIY Add padding to the mode line135714
Node: DIY Remap face with local value138642
Node: DIY Font configurations for Org and others141181
Ref: DIY Font configurations for Org and others-Footnote-1144164
Node: DIY Configure bold and italic faces144351
Node: DIY Custom Org todo keyword and priority faces148973
Node: DIY Custom Org emphasis faces152714
Node: DIY Use colored Org source blocks per language157591
Node: DIY Measure color contrast162231
Node: DIY Load theme depending on time of day164948
Node: DIY Backdrop for pdf-tools165976
Node: DIY Toggle themes without reloading them169137
Node: DIY Use more spacious margins or padding in Emacs frames170446
Node: DIY Custom hl-todo colors174683
Node: DIY Add support for solaire-mode176500
Node: DIY Add support for meow-mode179592
Node: DIY Add support for combobulate181402
Node: DIY Use a hook at the post-load-theme phase185025
Node: DIY A theme-agnostic hook for theme loading187146
Node: Build on top of the Modus themes189777
Node: Complete example of a Modus derivative theme195950
Node: Complete example of a package that is derived from Modus196890
Node: Complete example of a private theme derived from Modus199829
Node: Complete example of a custom theme with its own palette201395
Node: Determine what counts as a Modus theme205936
Node: Create convenience commands to load a derivative theme209346
Node: Face coverage211563
Node: Supported packages212025
Node: Indirectly covered packages217891
Node: Notes on individual packages219247
Node: Note on calendarel weekday and weekend colors220349
Node: Note on git-gutter in Doom Emacs221499
Node: Note on php-mode multiline comments224001
Node: Note on underlines in compilation buffers224763
Node: Note on inline Latex in Org buffers225637
Node: Note on dimmerel226249
Node: Note on display-fill-column-indicator-mode227736
Node: Note on highlight-parenthesesel229189
Node: Note on mmm-modeel background colors235268
Node: Note for prism237622
Node: Note on company-mode overlay pop-up240836
Ref: Note on company-mode overlay pop-up-Footnote-1241566
Ref: Note on company-mode overlay pop-up-Footnote-2241633
Node: Note on ERC escaped color sequences241688
Ref: Note on ERC escaped color sequences-Footnote-1243118
Node: Note on powerline or spaceline243228
Node: Note on SHR colors243644
Node: Note on SHR fonts244066
Node: Note on Ement colors and fonts244755
Node: Note on pdf-tools link hints246261
Node: Note on the Notmuch logo248719
Node: Note on goto-address-mode faces249253
Node: Frequently Asked Questions250373
Node: Is the contrast ratio about adjacent colors?251004
Node: What does it mean to avoid exaggerations?252513
Node: Why are colors mostly variants of blue magenta cyan?254363
Node: What is the best setup for legibility?258697
Node: Are these color schemes?261339
Node: Port the Modus themes to other platforms?264993
Node: Contributing267827
Node: Sources of the themes268226
Node: Issues you can help with269122
Node: Patches require copyright assignment to the FSF270514
Node: Acknowledgements272736
Node: GNU Free Documentation License277346
Node: Indices302509
Node: Function index302688
Node: Variable index306883
Node: Concept index311246
Node: The require-theme for built-in Emacs themes21504
Node: Sample configuration22421
Node: Differences between loading and enabling24697
Node: Customization options26762
Node: Disable other themes30531
Node: Bold constructs31885
Node: Italic constructs32757
Node: Option for which themes to toggle33585
Node: Option for which themes to rotate34348
Node: Mixed fonts35345
Node: Command prompts36399
Node: Completion UIs38240
Node: Org mode blocks41089
Node: Heading styles41732
Node: UI typeface46158
Node: Palette overrides47131
Node: Palette extension51488
Node: Preview theme colors53964
Node: Commands for the preview palette buffer55619
Node: Use colors from the Modus themes palette57697
Node: Get a single color from the palette with modus-themes-get-color-value58561
Node: Use theme colors in code with modus-themes-with-colors60922
Node: Advanced customization63176
Node: DIY Palette override presets64954
Node: DIY Add support for engrave-faces67788
Node: DIY Stylistic variants using palette overrides77771
Node: DIY Make the mode line borderless79830
Node: DIY Make the active mode line colorful81205
Node: DIY Make the tab bar more or less colorful83423
Node: DIY Make the fringe invisible or another color85360
Node: DIY Make links use subtle or no underlines86557
Node: DIY Make prompts more or less colorful87675
Node: DIY Make completion matches more or less colorful88998
Node: DIY Make comments yellow and strings green92557
Node: DIY Make code syntax use the old alt-syntax style94264
Node: DIY Make use of alternative styles for code syntax97377
Node: DIY Make matching parenthesis more or less intense100839
Node: DIY Make box buttons more or less gray102211
Node: DIY Make TODO and DONE more or less intense103224
Node: DIY Make headings more or less colorful104725
Node: DIY Make Org block colors more or less colorful106842
Node: DIY Make Org agenda more or less colorful111214
Node: DIY Make inline code in prose use alternative styles114389
Node: DIY Make mail citations and headers more or less colorful116629
Node: DIY Make the region preserve text colors plus other styles119029
Node: DIY Make mouse highlights more or less colorful120585
Node: DIY Make language underlines less colorful121598
Node: DIY Make line numbers use alternative styles122750
Node: DIY Make diffs use only a foreground124393
Node: DIY Make deuteranopia diffs red and blue instead of yellow and blue127280
Node: DIY More accurate colors in terminal emulators129752
Node: DIY Range of color with terminal emulators131060
Node: DIY Per-theme customization settings133847
Node: DIY Do not extend the region background135280
Node: DIY Add padding to the mode line136078
Node: DIY Remap face with local value139006
Node: DIY Font configurations for Org and others141545
Ref: DIY Font configurations for Org and others-Footnote-1144528
Node: DIY Configure bold and italic faces144715
Node: DIY Custom Org todo keyword and priority faces149337
Node: DIY Custom Org emphasis faces153078
Node: DIY Use colored Org source blocks per language157955
Node: DIY Measure color contrast162595
Node: DIY Load theme depending on time of day165312
Node: DIY Backdrop for pdf-tools166340
Node: DIY Toggle themes without reloading them169501
Node: DIY Use more spacious margins or padding in Emacs frames170810
Node: DIY Custom hl-todo colors175047
Node: DIY Add support for solaire-mode176864
Node: DIY Add support for meow-mode179956
Node: DIY Add support for combobulate181766
Node: DIY Use a hook at the post-load-theme phase185389
Node: DIY A theme-agnostic hook for theme loading187510
Node: Build on top of the Modus themes190141
Node: Complete example of a Modus derivative theme196314
Node: Complete example of a package that is derived from Modus197254
Node: Complete example of a private theme derived from Modus200193
Node: Complete example of a custom theme with its own palette201759
Node: Determine what counts as a Modus theme206300
Node: Create convenience commands to load a derivative theme209710
Node: Face coverage211927
Node: Supported packages212389
Node: Indirectly covered packages218255
Node: Notes on individual packages219611
Node: Note on calendarel weekday and weekend colors220713
Node: Note on git-gutter in Doom Emacs221863
Node: Note on php-mode multiline comments224365
Node: Note on underlines in compilation buffers225127
Node: Note on inline Latex in Org buffers226001
Node: Note on dimmerel226613
Node: Note on display-fill-column-indicator-mode228100
Node: Note on highlight-parenthesesel229553
Node: Note on mmm-modeel background colors235632
Node: Note for prism237986
Node: Note on company-mode overlay pop-up241200
Ref: Note on company-mode overlay pop-up-Footnote-1241930
Ref: Note on company-mode overlay pop-up-Footnote-2241997
Node: Note on ERC escaped color sequences242052
Ref: Note on ERC escaped color sequences-Footnote-1243482
Node: Note on powerline or spaceline243592
Node: Note on SHR colors244008
Node: Note on SHR fonts244430
Node: Note on Ement colors and fonts245119
Node: Note on pdf-tools link hints246625
Node: Note on the Notmuch logo249083
Node: Note on goto-address-mode faces249617
Node: Frequently Asked Questions250737
Node: Is the contrast ratio about adjacent colors?251368
Node: What does it mean to avoid exaggerations?252877
Node: Why are colors mostly variants of blue magenta cyan?254727
Node: What is the best setup for legibility?259061
Node: Are these color schemes?261703
Node: Port the Modus themes to other platforms?265357
Node: Contributing268191
Node: Sources of the themes268590
Node: Issues you can help with269486
Node: Patches require copyright assignment to the FSF270878
Node: Acknowledgements273100
Node: GNU Free Documentation License277710
Node: Indices302873
Node: Function index303052
Node: Variable index308033
Node: Concept index312396

End Tag Table

View file

@ -367,12 +367,25 @@ customizations ([[#h:f4651d55-8c07-46aa-b52b-bed1e53463bb][Advanced customizatio
#+findex: modus-themes-select
#+findex: modus-themes-rotate
#+findex: modus-themes-load-random
#+findex: modus-themes-select
The commands ~modus-themes-toggle~, ~modus-themes-rotate~,
~modus-themes-load-random~, and ~modus-themes-select~ use
~modus-themes-load-theme~ internally ([[#h:4fbfed66-5a89-447a-a07d-a03f6819c5bd][Option for which themes to toggle]]).
The aforementioned hold true for them as well.
Convenience commands for loading only dark or light themes are:
#+findex: modus-themes-select-dark
- ~modus-themes-select-dark~ [ Part of {{{development-version}}}. ]
#+findex: modus-themes-select-light
- ~modus-themes-select-light~ [ Part of {{{development-version}}}. ]
#+findex: modus-themes-load-random-dark
- ~modus-themes-load-random-dark~
#+findex: modus-themes-load-random-light
- ~modus-themes-load-random-light~
** The ~require-theme~ for built-in Emacs themes
:PROPERTIES:
:CUSTOM_ID: h:b66b128d-54a4-4265-b59f-4d1ea2feb073
@ -597,10 +610,12 @@ Possible values:
When the value is non-~nil~, the commands ~modus-themes-toggle~,
~modus-themes-rotate~, ~modus-themes-load-random~, and
~modus-themes-select~, as well as the ~modus-themes-load-theme~
function, will disable all other themes while loading the specified
Modus theme ([[#h:4fbfed66-5a89-447a-a07d-a03f6819c5bd][Option for which themes to toggle]]). This is done to
ensure that Emacs does not blend two or more themes: such blends lead
to awkward results that undermine the work of the designer.
function (and any related convenience wrappers like
~modus-themes-load-random-dark~), will disable all other themes while
loading the specified Modus theme ([[#h:4fbfed66-5a89-447a-a07d-a03f6819c5bd][Option for which themes to toggle]]).
This is done to ensure that Emacs does not blend two or more themes:
such blends lead to awkward results that undermine the work of the
designer.
When the value is ~nil~, the aforementioned commands and function will
only disable other themes within the Modus collection.

View file

@ -3977,28 +3977,54 @@ symbol, which is safe when used as a face attribute's value."
`(metadata (category . ,category))
(complete-with-action action candidates string pred))))
(defun modus-themes--completion-table-candidates ()
"Render `modus-themes-get-themes' as a completion table."
(modus-themes--completion-table 'theme (modus-themes-get-themes)))
(defun modus-themes--completion-table-candidates (themes)
"Render THEMES as a completion table."
(modus-themes--completion-table 'theme themes))
(defun modus-themes-select-prompt (&optional prompt)
(defun modus-themes-select-prompt (&optional prompt background-mode)
"Minibuffer prompt to select a Modus theme.
With optional PROMPT string, use it as the first argument of
`format-prompt'. Else use a generic prompt."
`format-prompt'. Else use a generic prompt.
With optional BACKGROUND-MODE as either `dark' or `light' limit the
themes accordingly."
(let ((completion-extra-properties `(:annotation-function ,#'modus-themes--annotate-theme)))
(intern
(completing-read
(format-prompt (or prompt "Select theme") nil)
(modus-themes--completion-table-candidates)
(if background-mode
(modus-themes-filter-by-background-mode
(modus-themes-get-themes)
background-mode)
(modus-themes-get-themes))
nil t nil
'modus-themes--select-theme-history))))
;;;###autoload
(defun modus-themes-select (theme)
"Load a Modus THEME using minibuffer completion.
With optional prefix argument, prompt to limit the set of themes to
either dark or light variants.
Run `modus-themes-after-load-theme-hook' after loading the theme.
Disable other themes per `modus-themes-disable-other-themes'."
(interactive (list (modus-themes-select-prompt)))
(interactive
(list
(if current-prefix-arg
(modus-themes-select-prompt nil (modus-themes-background-mode-prompt))
(modus-themes-select-prompt))))
(modus-themes-load-theme theme))
;;;###autoload
(defun modus-themes-select-dark (theme)
"Like `modus-themes-select' for a dark THEME."
(interactive (list (modus-themes-select-prompt nil 'dark)))
(modus-themes-load-theme theme))
;;;###autoload
(defun modus-themes-select-light (theme)
"Like `modus-themes-select' for a light THEME."
(interactive (list (modus-themes-select-prompt nil 'light)))
(modus-themes-load-theme theme))
;;;;; Toggle between two themes
@ -4096,9 +4122,9 @@ THEMES."
(defun modus-themes-load-random (&optional background-mode)
"Load a Modus theme at random, excluding the current one.
With optional BACKGROUND-MODE as a prefix argument, prompt to limit the set of
themes to either dark or light variants. When called from Lisp, BACKGROUND-MODE
is either the `dark' or `light' symbol.
With optional BACKGROUND-MODE as a prefix argument, prompt to limit the
set of themes to either dark or light variants. When called from Lisp,
BACKGROUND-MODE is either the `dark' or `light' symbol.
Run `modus-themes-after-load-theme-hook' after loading a theme."
(interactive
@ -5362,12 +5388,15 @@ FG and BG are the main colors."
`(flymake-error ((,c :underline (:style wave :color ,underline-err))))
`(flymake-error-echo ((,c :foreground ,err)))
`(flymake-error-echo-at-eol ((,c :inherit modus-themes-slant :foreground ,err :height 0.85 :box ,border)))
`(flymake-error-fringe ((,c :background ,bg-prominent-err :foreground ,fg-prominent-err)))
`(flymake-note ((,c :underline (:style wave :color ,underline-note))))
`(flymake-note-echo ((,c :foreground ,info)))
`(flymake-note-echo-at-eol ((,c :inherit modus-themes-slant :foreground ,info :height 0.85 :box ,border)))
`(flymake-note-fringe ((,c :background ,bg-prominent-note :foreground ,fg-prominent-note)))
`(flymake-warning ((,c :underline (:style wave :color ,underline-warning))))
`(flymake-warning-echo ((,c :foreground ,warning)))
`(flymake-warning-echo-at-eol ((,c :inherit modus-themes-slant :foreground ,warning :height 0.85 :box ,border)))
`(flymake-warning-fringe ((,c :background ,bg-prominent-warning :foreground ,fg-prominent-warning)))
;;;;; flyspell
`(flyspell-duplicate ((,c :underline (:style wave :color ,underline-warning))))
`(flyspell-incorrect ((,c :underline (:style wave :color ,underline-err))))
@ -5605,6 +5634,11 @@ FG and BG are the main colors."
`(hbut-face ((,c :inherit modus-themes-button)))
`(hbut-flash ((,c :background ,bg-search-replace)))
`(ibut-face ((,c :background ,bg-link-symbolic :foreground ,fg-link-symbolic :underline ,underline-link-symbolic)))
;;;;; ibuffer
`(ibuffer-deletion ((,c :inherit bold :background ,bg-mark-delete :foreground ,fg-mark-delete)))
`(ibuffer-filter-group-name ((,c :inherit bold)))
`(ibuffer-marked ((,c :inherit bold :background ,bg-mark-select :foreground ,fg-mark-select)))
`(ibuffer-title ((,c :inherit bold)))
;;;;; icomplete
`(icomplete-first-match ((,c :inherit modus-themes-completion-match-0)))
`(icomplete-vertical-selected-prefix-indicator-face ((,c :inherit modus-themes-bold :foreground ,keybind)))