From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#69079: [PATCH] Add 'customize-toggle-option' command Date: Mon, 12 Feb 2024 17:32:37 +0000 Message-ID: <87frxx37wq.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15597"; mail-complaints-to="usenet@ciao.gmane.io" To: 69079@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 12 18:34:22 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rZaCD-0003kc-27 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 12 Feb 2024 18:34:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZaBf-0004Ua-MF; Mon, 12 Feb 2024 12:33:47 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rZaBd-0004U4-Hd for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 12:33:45 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZaBd-0000YD-8t for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 12:33:45 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rZaBt-00049v-VV for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 12:34:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Feb 2024 17:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69079 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.170775919815779 (code B ref -1); Mon, 12 Feb 2024 17:34:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Feb 2024 17:33:18 +0000 Original-Received: from localhost ([127.0.0.1]:44436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZaB8-00046F-RR for submit@debbugs.gnu.org; Mon, 12 Feb 2024 12:33:18 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:52534) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZaB2-00045C-7s for submit@debbugs.gnu.org; Mon, 12 Feb 2024 12:33:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rZaAg-0004La-0l for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 12:32:46 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rZaAd-0000Jl-2T for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 12:32:45 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 8EF16240101 for ; Mon, 12 Feb 2024 18:32:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1707759158; bh=XJyG2QJoKqNoZoJwxLr2YAkZUV2I7KCd4nLlO5ws0us=; h=From:To:Subject:Autocrypt:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=jTp92fFmvKORMD0smvqNqCPIt98K7wpJrPtdQWIdVzgOfV2bflDLmbRPJtVHXe96/ 1eLLQ1GQJN9JqZTKqaRognV0i0W50+vqex0sj4I2aDuwaPz0HcQi9A6zB1bDLEZzSw YjQA2ktZ0YJeroVhaleKv8xsKtD/GrEYZMJBq92nzqxSR4YhcshIxy71uFdSv6VaRG /ZbswH5BaVKNb9Jqx0Ggi4VniQnhVMnSkaiaqHSVyAJC6TbOnIM07VTep4IlqIRzSF HaLcldqmnYnyKj1bEn06cGImeI1HbQGnsNcB5Q+umbzaDM0Nftwftc8qWULXzsZ80O 8f5JNM+iScy6w== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TYWkG0dK9z6txp for ; Mon, 12 Feb 2024 18:32:37 +0100 (CET) Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:279904 Archived-At: --=-=-= Content-Type: text/plain I have had this option in my own init.el for a while, and think it would be nice to upstream it. Any comments: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-'custom-variable'-command.patch Content-Description: [PATCH] Add 'custom-variable' command. >From 65cbe5deb81bd5b3bc7ebcc52a98952497dbe1a6 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic 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 --=-=-=--