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: Tue, 12 Apr 2022 15:51:17 +0200 Message-ID: References: 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="36002"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 29.0.50 Cc: Michael Heerdegen , larsi@gnus.org, 54399@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 12 16:06:28 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 1neHA2-0009AI-NO for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Apr 2022 16:06:26 +0200 Original-Received: from localhost ([::1]:58860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1neHA1-0000Df-JO for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Apr 2022 10:06:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1neH9i-00005H-5n for bug-gnu-emacs@gnu.org; Tue, 12 Apr 2022 10:06:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55241) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1neH9d-0007mf-RW for bug-gnu-emacs@gnu.org; Tue, 12 Apr 2022 10:06:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1neH9d-0002T0-Lu for bug-gnu-emacs@gnu.org; Tue, 12 Apr 2022 10:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ignacio Casso Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Apr 2022 14:06:01 +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.16497723239426 (code B ref 54399); Tue, 12 Apr 2022 14:06:01 +0000 Original-Received: (at 54399) by debbugs.gnu.org; 12 Apr 2022 14:05:23 +0000 Original-Received: from localhost ([127.0.0.1]:49138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neH90-0002Ry-SH for submit@debbugs.gnu.org; Tue, 12 Apr 2022 10:05:23 -0400 Original-Received: from mail-oln040092075061.outbound.protection.outlook.com ([40.92.75.61]:47230 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neH8z-0002Rj-HE for 54399@debbugs.gnu.org; Tue, 12 Apr 2022 10:05:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c7Z3JwDtKTOgU6Efx6jcnPYRQgUdjZSpTdMqi35/RtSlQiM8Q2dKJpIiVNcmpspIH7YvR9QFugk0RUGgFzv91F1lUmw22mLRSoDXJl5AQ5Gc6CsRLj3n3fMUhKJEH/n0Z1xDRLPtSuSyLM7GrHtuyRKc3PZ3li+Jc33H7NDnOQVGWSedw45W34bx8P/ocvmlyOCXJPtD5wV1t2k2rjIqOjZoozE79XoMT4Nujb4d/qW7MzVH87/PBrtZmU7htaAxYW2l/vOFecYxu7lr6zS67kjFczwGAYGfdp8rcDHVUzojl9gdZdNC0gxI8BxbdlDqFrNEy47oa2kcmjFtSOX6ew== 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=oaewNLM/BL3Six/IzTPvwKpcMURnFvdU8uRjguaYvdM=; b=X49Crtc1WFjh/OAK4nZvtoQ8UcmqMkTeKXmit8IS4Pd6r0ZufH22FaPtS7vGFlvJEfnX/lrORPEkGX5IuLEIIdJS+wtgaBzO3J6O8rGqS14LBvx5shLe23ocHQciXT8CMrNCFUlkB5Io/PIixpHGyoF+loiG/A47ANmz6TuWIkT+4BwEIi7/tBEP10+mnn20qBmcJ8qc7a+crCOyc4jW3VTAITCBUcunup/0BY7vWs9iSNkltbqMc0vZ9/71etu1/veGzVVWEVe1pJFhXT12tJvXcrNbCWXhkhLhP1LzaW3DlDNkTgahP5chftBsU3UmsAvxEfvEiNhd+g8tm5GPIw== 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=oaewNLM/BL3Six/IzTPvwKpcMURnFvdU8uRjguaYvdM=; b=MU+Hw+xZ6i5MwGxer9Ua64DQ+QgBzNdmcw7qNGWIKUkUc9/XY2RTU5ZqNmoU7/spkKAIZHAb1JUtEQqaNYvX3xcHY4pgl2dvJWTJsBhE/9VZJWnZTdBcAlUziWrKCB2c3gMPlDPBAVXnShU9Nwl58l3AeKWssCdTbM6DXZjCobilJrVtmxlSubBr2c87GpAItdPgnZsCnRX7E40Yd4Cyq7KGSPUiQqZb3zo95QZBkmi20+GQSqSyj2zVwKdxFBxohIOW4CPKB2EfzZL55uAVd6V6NOOoQIv2KUkhMs8HxP8Zk8dcYvVy0HlH824CV0paUzInmDz5HeDy/GhvcTR/5w== Original-Received: from PAXPR06MB7760.eurprd06.prod.outlook.com (2603:10a6:102:155::8) by PA4PR06MB7183.eurprd06.prod.outlook.com (2603:10a6:102:f7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Tue, 12 Apr 2022 14:05:14 +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; Tue, 12 Apr 2022 14:05:14 +0000 In-reply-to: X-TMN: [YumPuMADVSscowCXafqHJCpejAA1Q5IJ] X-ClientProxiedBy: MR1P264CA0039.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:3e::31) To PAXPR06MB7760.eurprd06.prod.outlook.com (2603:10a6:102:155::8) X-Microsoft-Original-Message-ID: <87tuay2y98.fsf@hotmail.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fe7713ea-73c4-4573-1c42-08da1c8d76fb X-MS-TrafficTypeDiagnostic: PA4PR06MB7183:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9H2eGgWYlfQfF7kU+7c9qfHsRUoNjclDnRlWLPLsvucjyo1PmN8XYBNRdBS90x8BtCeDHTHRdJKbHqRKrk2ZureEIwycFoOJcFXxx6DnMtIMJsHKAl0ThUMswFb5s4Qh283jUgFoZUcx7Iy8JJieDnhoc57ZKkrsQHNCHVNhixAa4EssrL/vs+2kFjWk6Agvri8/1DR98T0xliZbgCCgmr28OKIDuxIgizRNaO9JIEEE2ZjTvSNga/BytiLLxP92wA117gLHod5j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BuIzFPV5zKw7UIuTCwSyyKzetKfK52R8qwUvLYFQPBzZA5gaKNA/S3sOQt1D+c0fCwtCF4inoLCku/0TpUEdusw2Oz L/pTPHth5DHCMeL6tSkXAn7rT8SMJGtGW/6K2DbhO65srPu4TQy7pOp0sLVjqXoCuh0EQms7vb+UmssjGYt5KV8ggqZgXhgdTv X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6e454.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: fe7713ea-73c4-4573-1c42-08da1c8d76fb X-MS-Exchange-CrossTenant-AuthSource: PAXPR06MB7760.eurprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2022 14:05:14.7073 (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: PA4PR06MB7183 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:229763 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> Should I go ahead and just update the docstrings so that they reflect >> this behavior, and then close this bug report? Or do you think that the >> code should be changed too? For the latter I don't think I could help, >> since that code is too low level for me. > > If you can send a patch for the docs which addresses your concerns that > would be very helpful. > > > Stefan Here is a first attempt of a patch. It updates the docstrings for those functions and makes some other changes regarding the original `defcustom' issue. For some places were I was not sure if a change was necessary, I just wrote a comment to mark them and maybe discuss later. I also would replace in other files `set-default' with `set-default-toplevel-value', when it is used inside a lambda expression that is passed as :set argument for `defcustom'. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-updated-documentation-regarding-default-toplevel-val.patch Content-Description: Patch for bug#54399 >From 348f43797e3a126471681e1f5be00bc3fd34914d Mon Sep 17 00:00:00 2001 From: Ignacio Date: Tue, 12 Apr 2022 10:48:32 +0200 Subject: [PATCH] updated documentation regarding default toplevel values of variables --- lisp/custom.el | 26 +++++++++++++------------- src/data.c | 16 +++++++++++----- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/lisp/custom.el b/lisp/custom.el index 76c14831ca..e23ca7915a 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -68,7 +68,7 @@ custom-initialize-default (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 @@ -81,7 +81,7 @@ custom-initialize-set (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, @@ -100,7 +100,7 @@ custom-initialize-changed "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) @@ -114,7 +114,7 @@ custom-initialize-changed symbol (eval (car (get symbol 'saved-value))))) (t - (set-default symbol (eval exp))))))) + (set-default-toplevel-value symbol (eval exp))))))) (defvar custom-delayed-init-variables nil "List of variables whose initialization is pending until startup. @@ -262,11 +262,11 @@ defcustom 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'. :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'. :require VALUE should be a feature symbol. If you save a value for this option, then when your init file loads the value, @@ -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))) (defun custom-set-minor-mode (variable value) ":set function for minor mode variables. @@ -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)) @@ -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)))) @@ -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))))))) (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)))))) (defun custom-theme-recalc-face (face) 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; @@ -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); @@ -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 no behave as expected inside let +bindings of SYMBOL. To take them into account, use +`set-default-toplevel-value' instead. */) + (Lisp_Object symbol, Lisp_Object value) { set_default_internal (symbol, value, SET_INTERNAL_SET); -- 2.25.1 --=-=-=--