From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#27348: 24.5; [PATCH] let defvars benefit from defcustom keywords and persistence Date: Mon, 12 Jun 2017 14:34:35 -0700 (PDT) Message-ID: <85d6df89-9c08-4927-9b10-93a0b43808a7@default> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="__149730327705166159abhmp0009.oracle.com" X-Trace: blaine.gmane.org 1497303312 30623 195.159.176.226 (12 Jun 2017 21:35:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Jun 2017 21:35:12 +0000 (UTC) To: 27348@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 12 23:35:07 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKWzL-0007jC-Bp for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Jun 2017 23:35:07 +0200 Original-Received: from localhost ([::1]:40116 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKWzQ-0006wg-Nf for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Jun 2017 17:35:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKWzJ-0006vf-Uj for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2017 17:35:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKWzG-0003jG-Qp for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2017 17:35:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41439) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKWzG-0003ij-Mh for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2017 17:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dKWzG-000201-D1 for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2017 17:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Jun 2017 21:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 27348 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.14973032987664 (code B ref -1); Mon, 12 Jun 2017 21:35:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Jun 2017 21:34:58 +0000 Original-Received: from localhost ([127.0.0.1]:44115 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKWzC-0001zX-7N for submit@debbugs.gnu.org; Mon, 12 Jun 2017 17:34:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36048) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKWzA-0001zF-TB for submit@debbugs.gnu.org; Mon, 12 Jun 2017 17:34:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKWz4-0003cG-AH for submit@debbugs.gnu.org; Mon, 12 Jun 2017 17:34:51 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:51427) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dKWz4-0003c8-6d for submit@debbugs.gnu.org; Mon, 12 Jun 2017 17:34:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKWz2-0006uq-NQ for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2017 17:34:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKWyz-0003bL-JC for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2017 17:34:48 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:51285) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dKWyz-0003ab-5O for bug-gnu-emacs@gnu.org; Mon, 12 Jun 2017 17:34:45 -0400 Original-Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v5CLYf2r022046 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 12 Jun 2017 21:34:41 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v5CLYeGT030439 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 12 Jun 2017 21:34:41 GMT Original-Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v5CLYbTj015995 for ; Mon, 12 Jun 2017 21:34:39 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6767.5000 (x86)] X-Source-IP: userv0022.oracle.com [156.151.31.74] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:133537 Archived-At: --__149730327705166159abhmp0009.oracle.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable This is an enhancement request, with a patch. [NOTE: I suggested this enhancement to emacs-devel in 2009. There was exactly one reply, with only this text: "YAGNI". http://lists.gnu.org/archive/html/emacs-devel/2009-10/msg00668.html http://lists.gnu.org/archive/html/emacs-devel/2015-10/msg01481.html] The ability to type-check, provide :set and :initialize trigger functions, automatically :require libraries, add links to doc, associate with one or more :groups, etc. - these are useful things to be able to do with at least some defvars, not just with defcustoms. Similarly, the ability to persist non-option variables in a user's custom file can be useful. In sum, this enhancement makes it possible to uncouple interactive customization from the other features that `custom.el' offers, in particular, type-checking and persistence, and to provide the latter for non-option variables. Patch description: 1. New `defcustom' keyword `:not-custom-var'. If non-nil, the variable does not satisfy `custom-variable-p'. This means that users cannot customize it interactively, and it is not available for other interactive use (completion, `set-variable', inclusion in `apropos-user-option' output, etc.). Anyone and any code can still use `custom*' and other functions that do not check `custom-variable-p', to treat such a variable as a defcustom. Similarly, users can still use `M-:', `C-x C-e' etc. to customize it. See also #5, below. 2. New `defcustom' keyword `:not-custom-var'. It causes property `not-custom-var' to be put on the variable symbol. This property is what governs the behavior of `custom-variable-p'. 3. New macro `defvarc'. It just invokes `defcustom', passing non-nil `:not-custom-var'. The idea is to have a macro with a name similar to `defvar'. Using it can make the non-customizable nature more apparent than using `defcustom' with explicit `:not-custom-var'. [Another possibility would be to directly modify `defvar', so that it optionally accepts `defcustom' keywords etc., but maybe that would not be acceptable immediately. (For one thing, the cases of no initial value and no doc, `(defvar foo)' and `(defvar foo 4)', would still need to be supported.)] 4. `custom-variable-p' respects not only whether the variable has a non-nil `not-custom-var' property but also whether (new) global variable `custom-vars-all-customizable' is non-nil. If either is true then the variable is not customizable (the predicate returns nil). 5. New macro `with-user-vars'. It temporarily allows a set of variables to be customizable. It takes as its first argument either a list of variables or the symbol `all', meaning all variables. For `all', it just binds `custom-vars-all-customizable' to `t'. For a list of variables, it sets property `not-custom-var' to `t' for each one. (The original property values are restored when done.) I'm open as to how such a feature gets implemented. That includes names of things (`defvarc', for example) and whether or not to include this or that part. And I'm open to changes to the particular code in the patch. There might be better ways to realize such a feature - what I came up with is a pretty simple, naive approach. FWIW: I haven't understood why apparently no one else has thought this kind of thing could improve Emacs. I've long thought that the power of defcustom keywords and persistence should be freed from their coupling with interactive customizing. That combination is great, of course, but it should not be obligatory - I see no reason why a non-user variable should not take advantage of defcustom features. In GNU Emacs 24.5.1 (i686-pc-mingw32) of 2015-04-11 on LEG570 Windowing system distributor `Microsoft Corp.', version 6.1.7601 Configured using: `configure --prefix=3D/c/usr --host=3Di686-pc-mingw32' --__149730327705166159abhmp0009.oracle.com Content-Type: application/octet-stream; name="custom-2017-06-12.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="custom-2017-06-12.patch" ZGlmZiAtdSBjdXN0b20tMjAxNy0wNi0xMi5lbCBjdXN0b20tcGF0Y2hlZC5lbAotLS0gY3VzdG9t LTIwMTctMDYtMTIuZWwJMjAxNy0wNi0xMiAxMDo0NTowNy4xMTY4NjgzMDAgLTA3MDAKKysrIGN1 c3RvbS1wYXRjaGVkLmVsCTIwMTctMDYtMTIgMTM6NTQ6MDYuMDI0NTY3MzAwIC0wNzAwCkBAIC00 Nyw2ICs0NywxMCBAQAogKGRlZnZhciBjdXN0b20tY3VycmVudC1ncm91cC1hbGlzdCBuaWwKICAg IkFsaXN0IG9mIChGSUxFIC4gR1JPVVApIGluZGljYXRpb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pCisg ICAgICAgIChzLnAgICAgKG1ha2Utc3ltYm9sICJzLnAiKSkpCisgICAgYChsZXQgKCgsc3ltYnMg ICcsc3ltYm9scykpCisgICAgICAgKGlmIChlcSAnYWxsICxzeW1icykKKyAgICAgICAgICAgKGxl dCAoKGN1c3RvbS12YXJzLWFsbC1jdXN0b21pemFibGUgIHQpKSAsQGJvZHkpCisgICAgICAgICAo bGV0ICgoLGJpbmRzICAobWFwY2FyIChsYW1iZGEgKCxzeW1iKSAoY29ucyAsc3ltYiAoZ2V0ICxz eW1iICdub3QtY3VzdG9tLXZhcikpKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAs c3ltYnMpKSkKKyAgICAgICAgICAgKHVud2luZC1wcm90ZWN0CisgICAgICAgICAgICAgICAgKHBy b2duIChkb2xpc3QgKCxzeW1iICAsc3ltYnMpIChwdXQgLHN5bWIgJ25vdC1jdXN0b20tdmFyIG5p bCkpCisgICAgICAgICAgICAgICAgICAgICAgICxAYm9keSkKKyAgICAgICAgICAgICAoZG9saXN0 ICgscy5wICAsYmluZHMpCisgICAgICAgICAgICAgICAocHV0IChjYXIgLHMucCkgJ25vdC1jdXN0 b20tdmFyIChjZHIgLHMucCkpKSkpKSkpKQorCiA7OzsgVGhlIGBkZWZmYWNlJyBNYWNyby4KIAog KGRlZm1hY3JvIGRlZmZhY2UgKGZhY2Ugc3BlYyBkb2MgJnJlc3QgYXJncykKQEAgLTUzOCw2ICs1 NzMsOCBAQAogCSAocHV0IHN5bWJvbCAnY3VzdG9tLXRhZyB2YWx1ZSkpCiAJKChlcSBrZXl3b3Jk IDpzZXQtYWZ0ZXIpCiAJIChjdXN0b20tYWRkLWRlcGVuZGVuY2llcyBzeW1ib2wgdmFsdWUpKQor ICAgICAgICAoKGVxIGtleXdvcmQgOm5vdC1jdXN0b20tdmFyKQorICAgICAgICAgKHB1dCBzeW1i b2wgJ25vdC1jdXN0b20tdmFyIHZhbHVlKSkKIAkodAogCSAoZXJyb3IgIlVua25v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