From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ignacio Casso Newsgroups: gmane.emacs.bugs Subject: bug#54399: 27.2; Problems with (let ((custom-variable ...)) (autoload-function ...)) Date: Wed, 13 Apr 2022 14:08:50 +0200 Message-ID: References: <83sfqi498s.fsf@gnu.org> <87ilrdg837.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32041"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 29.0.50 Cc: larsi@gnus.org, 54399@debbugs.gnu.org, monnier@iro.umontreal.ca To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 13 15:13:21 2022 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 1necoC-0008Et-Ob for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Apr 2022 15:13:20 +0200 Original-Received: from localhost ([::1]:48582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1necoB-00075a-2M for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Apr 2022 09:13:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1necnu-00075D-W2 for bug-gnu-emacs@gnu.org; Wed, 13 Apr 2022 09:13:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58175) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1necnu-0006Yq-KR for bug-gnu-emacs@gnu.org; Wed, 13 Apr 2022 09:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1necnu-0001wn-Fv for bug-gnu-emacs@gnu.org; Wed, 13 Apr 2022 09:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ignacio Casso Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Apr 2022 13:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54399 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 54399-submit@debbugs.gnu.org id=B54399.16498555537431 (code B ref 54399); Wed, 13 Apr 2022 13:13:02 +0000 Original-Received: (at 54399) by debbugs.gnu.org; 13 Apr 2022 13:12:33 +0000 Original-Received: from localhost ([127.0.0.1]:52070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1necnQ-0001vm-OH for submit@debbugs.gnu.org; Wed, 13 Apr 2022 09:12:33 -0400 Original-Received: from mail-oln040092075043.outbound.protection.outlook.com ([40.92.75.43]:44100 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1necnO-0001vY-UQ for 54399@debbugs.gnu.org; Wed, 13 Apr 2022 09:12:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nIpXPw8GpGP6F17IWf0QmnizjTMsai+qewLMGlODk4hlXi5xQ2KgfIYyuo0iHObcOkysKmL38YJhHqXtPSPQw71EHuKeZathq32UKV4PYBYpE2DOk4vuKjNugPU5bqltterORprl71HhGOn9lXTnw+fbl5KDfunGaQz4nANIc8aG7lT/pyG5S3s8+9xcZ0SwokLpNGvwDKytvr4pS12OUEd6OMhCAM7jAJwKgkN6u7q4SvG03u82EpySMk7P8u6fkDP+qoSn+Fk+jFTubG0a/1JSFw9DL2YVKedL2i8qFn+OMau6Fu7MkC3QqfRT/qDfuabkVXMs+t0DmLBbKaPN1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2eFd4iXARXSeitnGUYkes9aukYsKTPH/mbskJy/dFAA=; b=W0ZDFIUw2mKbTdh2VXy+c6q1DSnW/RuQSG/RdWjPB/X7ojm1bYZ851rPtsCaWxy7rICDkCpnc/4Cl5gCoW8uIsLTa5otu0C9f4bwcrx+XsopNtRQl/WWos/bi+D/eMOSm0ENMO9Jj5nVDKNdqtOIY/lGwOkXtclPVcgreZPcTXUZDGJ9LR3PvVgDsdDObs6nx6h0O7ODVkEMMCPiw0BV0qaOPR/SvpqaJEndwpNNjNrwbL14Ka90ioYT7OYLgfwaucB1y4ChOD+R3mWJpNw/hJJS2ivMGbBlKGBw/hqGDXTApfwTezKXWkrfQxX1W+/Ht73Yg7liz28Lr8UkhAGOzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2eFd4iXARXSeitnGUYkes9aukYsKTPH/mbskJy/dFAA=; b=UnipKXwukmUnhQcwl2ewraHXuqWs+3lOor0wn9/tuWe2fmRqaSqCLWbqltDUmfn2C3FHBNi1ewF9wYiHgeMH5MiztR9rfCGReRmZZEeJ90/s11P0srAyPdDFHO0EKDcnUJLSM5KmIzYyrZZDfSLpTesho5vkge1+xZO0HeOixjJnmRSDdxmfQ2eLWBh80XuhHnmCbEMAxRoY1cMu45qMxbT0QLFza5Z4nnhb/fDgdPLYFJh8U0BwEmRmEte/+Dm3ouc+BZTRVGpXiViM80JlsocdCJZzTa45pZYcGsp4JLX+UqXZeVy0f3CWFlbdUkbA2Ru2Zg3XwB5q4/xMunnVeg== Original-Received: from PAXPR06MB7760.eurprd06.prod.outlook.com (2603:10a6:102:155::8) by AM6PR06MB4646.eurprd06.prod.outlook.com (2603:10a6:20b:66::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Wed, 13 Apr 2022 13:12:23 +0000 Original-Received: from PAXPR06MB7760.eurprd06.prod.outlook.com ([fe80::c43d:998b:8b75:5e3a]) by PAXPR06MB7760.eurprd06.prod.outlook.com ([fe80::c43d:998b:8b75:5e3a%5]) with mapi id 15.20.5144.030; Wed, 13 Apr 2022 13:12:23 +0000 In-reply-to: <87ilrdg837.fsf@web.de> X-TMN: [5daSP5X7x81ZbD//9GoUBeyXYgpl3Lv+] X-ClientProxiedBy: MR1P264CA0086.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:3f::31) To PAXPR06MB7760.eurprd06.prod.outlook.com (2603:10a6:102:155::8) X-Microsoft-Original-Message-ID: <87sfqht9e6.fsf@hotmail.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3817b653-623c-405f-8c24-08da1d4f3f7b X-MS-TrafficTypeDiagnostic: AM6PR06MB4646:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3pumq0I6YLWMeSU94cQIpXda5ta541SJxe7zijoUI7nL/QTJnKul9jRFewpOVRVc2/Fm9qJUu13FiqRBCrKLcqrYftzh4OaJQZAvDRIGaw5/HAhMlNU5qm1fFb8x/+hQBX6BIZvOsUDNmu4wkRVdRzQuR7o5Wn774knIkA2X3Q6Zc/fBFw537DTU2mhJbDeCbgwmzT/gfJ1TlyCNo1W7SZdwSmlj8frXA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EhriUHRWyIyZIozNW8iP2lc58RPIABA+IZOsJZc+Gqe4Wub5QgjmqcQ5AZI2XXGMldzjgJK3+GYLll8/bhUcLDNB8A139tmcNpBH4l LXjUJr1n8retApfiayZA3O70vW744AaetpP20gjkIfa/0Tpu5qT4gVRlVH00TEPEX0+YEE/7OJQEEF329H8+HKLh2artYIbEIo X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6e454.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 3817b653-623c-405f-8c24-08da1d4f3f7b X-MS-Exchange-CrossTenant-AuthSource: PAXPR06MB7760.eurprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 13:12:23.7434 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR06MB4646 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" Xref: news.gmane.io gmane.emacs.bugs:229822 Archived-At: Michael Heerdegen writes: > Eli Zaretskii writes: > >> > +for this variable. This function may no behave as expected inside let >> ^ ^^ >> Typo: should be "not". Also, only one space between sentences. > Fixed > >> +values for this variable. Let bindings may shadow this default value. > ^^^^^^^^^^^^ > > "Let-bindings" (with a hyphen; appear several times). > Fixed > But the more interesting question is whether the changes per se are all > correct. > Most things are corrections to the docstrings. I explain each change below, as I should probably have done earlier: > (defun custom-initialize-set (symbol exp) > "Initialize SYMBOL based on EXP. > If the symbol doesn't have a default binding already, > -then set it using its `:set' function (or `set-default' if it has none). > +then set it using its `:set' function (or `set-default-toplevel-value' if it has none). > The value is either the value in the symbol's `saved-value' property, > if any, or the value of EXP." > (condition-case nil docstring correction, the function used is actually `set-default-toplevel-value' > (defun custom-initialize-reset (symbol exp) > "Initialize SYMBOL based on EXP. > -Set the symbol, using its `:set' function (or `set-default' if it has none). > +Set the symbol, using its `:set' function (or `set-default-toplevel-value' if it has none). > The value is either the symbol's current value > (as obtained using the `:get' function), if any, > or the value in the symbol's `saved-value' property if any, Same > (defun custom-initialize-changed (symbol exp) > "Initialize SYMBOL with EXP. > Like `custom-initialize-reset', but only use the `:set' function if > not using the standard setting. > -For the standard setting, use `set-default'." > +For the standard setting, use `set-default-toplevel-value'." > (condition-case nil > (let ((def (default-toplevel-value symbol))) > (funcall (or (get symbol 'custom-set) #'set-default-toplevel-value) and > symbol > (eval (car (get symbol 'saved-value))))) > (t > - (set-default symbol (eval exp))))))) > + (set-default-toplevel-value symbol (eval exp))))))) > Everywhere else `set-default-toplevel-value' is used instead, so I have changed it here too. > @@ -262,11 +262,11 @@ defcustom > :set VALUE should be a function to set the value of the symbol > when using the Customize user interface. It takes two arguments, > the symbol to set and the value to give it. The function should > not modify its value argument destructively. The default choice > - of function is `set-default'. > + of function is `set-default-toplevel-value'. Same correction > :get VALUE should be a function to extract the value of symbol. > The function takes one argument, a symbol, and should return > the current value for that symbol. The default choice of function > - is `default-value'. > + is `default-toplevel-value'. Similar correction > @@ -717,7 +717,7 @@ custom-set-default > (if custom-local-buffer > (with-current-buffer custom-local-buffer > (set variable value)) > - (set-default variable value))) > + (set-default-toplevel-value variable value))) Here and in the rest of the changes in custom.el I have made or suggested one of the following changes: `default-value' -> `default-toplevel-value' `set-default' -> `set-default-toplevel-value' `default-boundp' -> (condition-case nil (or (default-toplevel-value) t) (void-variable nil)) But I'm not really sure of when those functions are used, so I don't know whether they are necessary. I actually made the changes just to get the feedback, we can discard them if you don't think that they are an improvement or that it is worth to invest the time in finding out whether they are an improvement. > @@ -752,7 +752,7 @@ customize-mark-to-save > > Return non-nil if the `saved-value' property actually changed." > (custom-load-symbol symbol) > - (let* ((get (or (get symbol 'custom-get) #'default-value)) > + (let* ((get (or (get symbol 'custom-get) #'default-toplevel-value)) > (value (funcall get symbol)) > (saved (get symbol 'saved-value)) > (standard (get symbol 'standard-value)) See last comment > @@ -779,7 +779,7 @@ customize-mark-as-set > > Return non-nil if the `customized-value' property actually changed." > (custom-load-symbol symbol) > - (let* ((get (or (get symbol 'custom-get) #'default-value)) > + (let* ((get (or (get symbol 'custom-get) #'default-toplevel-value)) > (value (funcall get symbol)) > (customized (get symbol 'customized-value)) > (old (or (get symbol 'saved-value) (get symbol 'standard-value)))) See last comment > @@ -1054,12 +1054,12 @@ custom-theme-set-variables > ;; Rogue variable, set it now. > (put symbol 'force-value t) > (funcall set symbol (eval value))) > - ((default-boundp symbol) > + ((default-boundp symbol) ; condition-case + default-toplevel-value? > ;; Something already set this, overwrite it. > (funcall set symbol (eval value)))) > (error > (message "Error setting %s: %s" symbol data))) > - (and (or now (default-boundp symbol)) > + (and (or now (default-boundp symbol)) ; condition-case + default-toplevel-value? > (put symbol 'variable-comment comment))))))) See last comment > > (defvar custom--sort-vars-table) > @@ -1608,8 +1608,8 @@ custom-theme-recalc-variable > (setq valspec (get variable 'standard-value))) > (if (and valspec > (or (get variable 'force-value) > - (default-boundp variable))) > - (funcall (or (get variable 'custom-set) #'set-default) variable > + (default-boundp variable))) ; (condition-case ... default-toplevel-value ...) ? > + (funcall (or (get variable 'custom-set) #'set-default) variable ; set-default-toplevel-value? > (eval (car valspec)))))) See last comment > diff --git a/src/data.c b/src/data.c > index f06b561dcc..b73a997341 100644 > --- a/src/data.c > +++ b/src/data.c > @@ -1927,9 +1927,10 @@ default_value (Lisp_Object symbol) > > DEFUN ("default-boundp", Fdefault_boundp, Sdefault_boundp, 1, 1, 0, > doc: /* Return t if SYMBOL has a non-void default value. > -A variable may have a buffer-local or a `let'-bound local value. This > -function says whether the variable has a non-void value outside of the > -current context. Also see `default-value'. */) > +This is the value that is seen in buffers that do not have their own > +values for this variable. Let-bindings may shadow this default value. > +To take them into account, use `default-toplevel-value' together with > +`condition-case' instead. */) > (Lisp_Object symbol) > { > register Lisp_Object value; Corrected `default-boundp' docstring, which said that it can be used to check if a variable is non-void outside a let-binding context, which is false. I just reverted to Emacs 27's version, which was correct. Also, in this docstring and the ones for `default-value' and `set-default', I update them to suggest using their "toplevel" counterparts when let-bindings need to be taken into account. But I probably use the wrong vocabulary to do so, and that information is already on the pertinent section of the manual, so we can discard these changes too if you don't think they belong in the docstrings. > @@ -1942,7 +1943,9 @@ DEFUN ("default-value", Fdefault_value, Sdefault_value, 1, 1, 0, > doc: /* Return SYMBOL's default value. > This is the value that is seen in buffers that do not have their own values > for this variable. The default value is meaningful for variables with > -local bindings in certain buffers. */) > +local bindings in certain buffers. Let-bindings may shadow this > +default value. To take them into account, use > +`default-toplevel-value' instead. */) > (Lisp_Object symbol) > { > Lisp_Object value = default_value (symbol); See last comment > @@ -2045,7 +2048,10 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value, > DEFUN ("set-default", Fset_default, Sset_default, 2, 2, 0, > doc: /* Set SYMBOL's default value to VALUE. SYMBOL and VALUE are evaluated. > The default value is seen in buffers that do not have their own values > -for this variable. */) > +for this variable. This function may not behave as expected inside let-bindings > +of SYMBOL. To take them into account, use > +`set-default-toplevel-value' instead. */) > + See last comment I've also made some new changes in customize.texi after I sent this patch. They are equivalent to those in the docstring of `defcustom'.