From: Protesilaos Stavrou <info@protesilaos.com>
To: Pankaj Jangid <pankaj@codeisgreat.org>
Cc: emacs-devel@gnu.org
Subject: Modus themes toggle (was: night-mode?)
Date: Sat, 21 Nov 2020 07:00:26 +0200 [thread overview]
Message-ID: <87v9dzz4lx.fsf_-_@protesilaos.com> (raw)
In-Reply-To: <m23613zbai.fsf@codeisgreat.org> (Pankaj Jangid's message of "Sat, 21 Nov 2020 08:06:05 +0530")
[-- Attachment #1: Type: text/plain, Size: 1283 bytes --]
On 2020-11-21, 08:06 +0530, Pankaj Jangid <pankaj@codeisgreat.org> wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>> Based on previous discussions, I think we should add some way to toggle
>> the dark/light mode. I'm not completely sure what the interface should
>> look like, nor what'd be the better implementation, but see the patch
>> below for a first cut to add a `night-mode` command, which does
>> basically the "inverse video" by swapping the foreground and the
>> background of the default face (and then resetting the background-mode
>> accordingly, of course).
>
> Your's is a more generic solution I guess. But after inclusion of
> `modus-themes', I just use this snippet,
>
> (defun modus-theme-toggle ()
> "Toggle between modus-operandi and modus-vivendi themes."
> (interactive)
> (if (member 'modus-operandi custom-enabled-themes)
> (progn
> (disable-theme 'modus-operandi)
> (load-theme 'modus-vivendi t))
> (disable-theme 'modus-vivendi)
> (load-theme 'modus-operandi t)))
Just to note that I am in the process of refactoring aspects of the
Modus themes. There will be a toggle command on offer. Please find the
current version of it attached (note that I may still change things).
--
Protesilaos Stavrou
protesilaos.com
[-- Attachment #2: modus-themes-toggle-tentative.el --]
[-- Type: text/plain, Size: 1345 bytes --]
(defvar modus-themes-after-load-theme-hook nil
"Hook that runs after the `modus-themes-toggle' routines.")
(defun modus-themes--light ()
"Load `modus-operandi' and disable `modus-vivendi'."
(disable-theme 'modus-vivendi)
(load-theme 'modus-operandi)
(run-hooks 'modus-themes-after-load-theme-hook))
(defun modus-themes--dark ()
"Load `modus-vivendi' and disable `modus-operandi'."
(disable-theme 'modus-operandi)
(load-theme 'modus-vivendi)
(run-hooks 'modus-themes-after-load-theme-hook))
(defun modus-themes--load-prompt ()
"Helper for `modus-themes-toggle'."
(let ((theme
(intern
(completing-read "Load Modus theme (will disable all others): "
'(modus-operandi modus-vivendi) nil t))))
(mapc #'disable-theme custom-enabled-themes)
(pcase theme
('modus-operandi (modus-themes--light))
('modus-vivendi (modus-themes--dark)))))
;;;###autoload
(defun modus-themes-toggle ()
"Toggle between `modus-operandi' and `modus-vivendi' themes.
Also runs `modus-themes-after-load-theme-hook' by virtue of
calling the internal `modus-themes--light' and
`modus-themes--dark' functions."
(interactive)
(pcase (car custom-enabled-themes)
('modus-operandi (modus-themes--dark))
('modus-vivendi (modus-themes--light))
(_ (modus-themes--load-prompt))))
next prev parent reply other threads:[~2020-11-21 5:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 21:25 night-mode? Stefan Monnier
2020-11-21 2:36 ` night-mode? Pankaj Jangid
2020-11-21 5:00 ` Protesilaos Stavrou [this message]
2020-11-21 7:22 ` Modus themes toggle Pankaj Jangid
2020-11-21 19:21 ` night-mode? Juri Linkov
2020-11-21 21:20 ` night-mode? Stefan Monnier
2020-11-22 8:40 ` night-mode? Juri Linkov
2020-11-22 15:09 ` night-mode? Stefan Monnier
2020-11-22 15:16 ` night-mode? Eli Zaretskii
2020-11-22 16:09 ` night-mode? Jean Louis
2020-11-22 19:55 ` night-mode? Stefan Monnier
2020-11-22 16:38 ` night-mode? Arthur Miller
2020-11-22 17:27 ` night-mode? Jean Louis
2020-11-23 7:21 ` night-mode? Arthur Miller
2020-11-23 8:36 ` night-mode? Jean Louis
2020-11-23 17:06 ` night-mode? Arthur Miller
2020-11-23 19:38 ` night-mode? Jean Louis
2020-11-24 8:55 ` night-mode? Arthur Miller
2020-11-24 9:47 ` night-mode? Jean Louis
[not found] ` <87r1onmjpx.fsf@gmail.com>
[not found] ` <jwvtutiy783.fsf-monnier+emacs@gnu.org>
2020-11-22 0:03 ` night-mode? Caio Henrique
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v9dzz4lx.fsf_-_@protesilaos.com \
--to=info@protesilaos.com \
--cc=emacs-devel@gnu.org \
--cc=pankaj@codeisgreat.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).