From: Philip Kaludercic <philipk@posteo.net>
To: 69079@debbugs.gnu.org
Subject: bug#69079: [PATCH] Add 'customize-toggle-option' command
Date: Mon, 12 Feb 2024 17:32:37 +0000 [thread overview]
Message-ID: <87frxx37wq.fsf@posteo.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 113 bytes --]
I have had this option in my own init.el for a while, and think it would
be nice to upstream it. Any comments:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Add 'custom-variable' command. --]
[-- Type: text/x-patch, Size: 1852 bytes --]
From 65cbe5deb81bd5b3bc7ebcc52a98952497dbe1a6 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Mon, 12 Feb 2024 18:29:50 +0100
Subject: [PATCH] Add 'custom-variable' command.
* lisp/cus-edit.el (customize-toggle-option): Add command.
(toggle-option): Add shorter alias for 'customize-toggle-option'.
* etc/NEWS: Document it.
---
etc/NEWS | 4 ++++
lisp/cus-edit.el | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index afc2c22e68b..6fae64728f2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1329,6 +1329,10 @@ in Buffer menu mode.
*** New command 'customize-dirlocals'.
This command pops up a buffer to edit the settings in ".dir-locals.el".
+---
+** New command 'customize-toggle-option'.
+This command can toggle boolean options for the duration of a session.
+
** Calc
+++
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 38b6ec984ab..2f08ffc8ba6 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -1227,6 +1227,26 @@ customize-option
(unless (eq symbol basevar)
(message "`%s' is an alias for `%s'" symbol basevar))))
+;;;###autoload
+(defun customize-toggle-option (opt)
+ "Toggle the value of boolean option OPT for this session."
+ (interactive (let (opts)
+ (mapatoms
+ (lambda (sym)
+ (when (eq (get sym 'custom-type) 'boolean)
+ (push sym opts))))
+ (list (intern (completing-read "Option: " opts)))))
+ (message "%s user options '%s'."
+ (if (funcall (or (get opt 'custom-set) #'set-default)
+ opt (not (funcall (or (get opt 'custom-get)
+ #'symbol-value)
+ opt)))
+ "Enabled" "Disabled")
+ opt))
+
+;;;###autoload
+(defalias 'toggle-option #'customize-toggle-option)
+
;;;###autoload
(defalias 'customize-variable-other-window 'customize-option-other-window)
--
2.43.0
next reply other threads:[~2024-02-12 17:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 17:32 Philip Kaludercic [this message]
2024-02-12 17:47 ` bug#69079: [PATCH] Add 'customize-toggle-option' command Eli Zaretskii
2024-02-12 18:41 ` Drew Adams
2024-02-12 18:56 ` Philip Kaludercic
2024-02-12 19:32 ` Eli Zaretskii
2024-02-13 0:14 ` Philip Kaludercic
2024-02-13 12:40 ` Eli Zaretskii
2024-02-13 12:46 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-13 20:09 ` Philip Kaludercic
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87frxx37wq.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=69079@debbugs.gnu.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.