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 11:13:27 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34114"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 29.0.50 To: 54399@debbugs.gnu.org, larsi@gnus.org, Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 12 12:31:36 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 1neDo8-0008l7-0b for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Apr 2022 12:31:36 +0200 Original-Received: from localhost ([::1]:49486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1neDo6-0000to-0z for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Apr 2022 06:31:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1neDna-0000tc-Vi for bug-gnu-emacs@gnu.org; Tue, 12 Apr 2022 06:31:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1neDna-0007SK-IC for bug-gnu-emacs@gnu.org; Tue, 12 Apr 2022 06:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1neDna-0000xH-EC for bug-gnu-emacs@gnu.org; Tue, 12 Apr 2022 06:31:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Ignacio Casso Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Apr 2022 10:31: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.16497594392194 (code B ref 54399); Tue, 12 Apr 2022 10:31:02 +0000 Original-Received: (at 54399) by debbugs.gnu.org; 12 Apr 2022 10:30:39 +0000 Original-Received: from localhost ([127.0.0.1]:47685 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neDnC-0000Yn-Ov for submit@debbugs.gnu.org; Tue, 12 Apr 2022 06:30:39 -0400 Original-Received: from mail-am6eur05olkn2055.outbound.protection.outlook.com ([40.92.91.55]:4704 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neDn9-0000PO-SU for 54399@debbugs.gnu.org; Tue, 12 Apr 2022 06:30:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QE/o6DRIwZJ3zev2/t/LwRvcnNcS99uStorrWz6h4uKPwEWoi+8tbz2OmKU1Mq85EV8ShTskshyxO4tbs7egg6cwDp+0i03i9UbnrkwJc7YjM71tMRw7STf6aipNm3hwRqnPqt8lvo9eSmMPV+L/vh/zpvKYMdyks6U4FLAzJXenOfnCvBrdIeo0JFapG0VVeBhhwus0w1JFL/Ii/FsGJMnVuCXiakI13AjymmCxRht0eFc4boAV5Oum+5OitHOm5DXsRzzoOZDEZVGgAmLd21Dk9rEJv4rfKdkHIbLYQhzg9oSoOQpu8uQ5ukD3heLKLWb1spOrfA+UhypAGeByYw== 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=2VV0xl4QLRWR0OFcxMhNBAMvELZDb0I6j4EKFjau0qg=; b=Fr0VwfRBfuNr5gyGAiDAhOSw5vAo/+gH+SuEW4/oGTy1nZ3TKCzN0CoQeKPNw86Q2YbgnZJazi4gjWNxSKAHzHyqiqicrDkzOY3+sBbz8V1CGj9F3IYUTGJ3Kv2Yv8weOVltmullvvy7URQrsBH2ny4BguI6FnyaOBXyhIMPvmgd44BUXRloI3r4oTttGC1KETJ66t1Zt3Z+xjgAsU0x6mZlpkklrWueuKv9GgswSYBbHD7vasXw/zJPFWltBnruFl1hkppQ8YvPss4Ei1uNc9gtZFsQ1tOOHX2gT/rYjneN7qd2dpvT3Jy1+ow3GfkM0XbelqNquwqPrHA4NEoyGQ== 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=2VV0xl4QLRWR0OFcxMhNBAMvELZDb0I6j4EKFjau0qg=; b=ERui0bJYTMPSjyW6jhsJBC8fzvOdVm6F/oE9cdNOk3ypWfzX0DTsggavGsrQMM7JJVdg0NDWasPIjkle4MSd1YdVNsCFDh64MGSj3kly5qIgPlYr+n4yXn8+4mYFlxv8l7THfx6qx4Th6u/GmChfMuGomk4PhGAukfa4qxkXbGDhGpb5bZyy51nmIYkwmlDX3oTKKz+5KKrMsZ2ml98XoMSGQDPjPksuhQDQV+J7WS9T9YP9OadQWxgGLOo78DeiAY4+ezxNo7U71WqL+DIE00jOvTcMp2orjQTFb28Xaf3YgmbFURVfQv1G+vDT0I7bexSEOhnUcWk+SvW+5nhWYQ== Original-Received: from PAXPR06MB7760.eurprd06.prod.outlook.com (2603:10a6:102:155::8) by AM5PR0601MB2353.eurprd06.prod.outlook.com (2603:10a6:203:70::13) 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 10:30:29 +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 10:30:29 +0000 X-TMN: [VGG1XADRDIjOjWEqVs6Nr5fyusO0jPHf] X-ClientProxiedBy: PAZP264CA0192.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:236::31) To PAXPR06MB7760.eurprd06.prod.outlook.com (2603:10a6:102:155::8) X-Microsoft-Original-Message-ID: <87bkx6iog2.fsf@hotmail.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9245b8e4-29b1-4ee9-7775-08da1c6f7623 X-MS-TrafficTypeDiagnostic: AM5PR0601MB2353:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g14mG+lfcMJfAgRTsM8wLHNjB80PB1wljIOp61j/GlEASOb2rvRD0QogWmJWh3czgkqWtKEGsh40OKyzEWZ6vX5oorCFMSbqIUJYWUoz2WO9/wKnub3pIiaXU8w4KC8PMNKHNEvoNOT4T/efqyEoYntMuebgGtZB7Cqq5YIwB9kaIemvvDrlDHsTi8NN/GxDn03lyBFswBZsV4G+rDJIEsxoUZ6fm92w3lcW36IyuD8Dmiz0BaJ1fmvcnkK+XdLL7hmw/i2/K4uRNZNPdmuQgWp2EqC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S9jYs46LCxvrQYz7y+idHnMCaZPxf5n2VOcLMkZyP3c02bscsOdINLqiRWqEyZKRgejb cola6mSs6hC82fsN1sx9Gof3Rqo3vwN8NWffNYh4S41Q4JoBlK48IICvhmKxL3AcTmiUVFNVgNgQP1CBouVhx+2Jg4Cty9o7Mh X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6e454.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 9245b8e4-29b1-4ee9-7775-08da1c6f7623 X-MS-Exchange-CrossTenant-AuthSource: PAXPR06MB7760.eurprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2022 10:30:29.4070 (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: AM5PR0601MB2353 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:229754 Archived-At: > I think custom.el already uses `set-default-toplevel-value' where > appropriate by default. So my request is (1) to correct the docstrings > in custom.el to reflect so, so that users know to use it instead of > `set-default', and (2) Add some warnings somewhere, although I'm not > sure where. > > I personally can not think of a single case in which someone would want > to use `set-default' instead of `set-default-toplevel-value'. If I > understand them correctly, they both do the same outside a let binding, > and I don't see why someone would want the `set-default' behavior inside > the let binding. In fact, I guess most people assume that `set-default' > behaves like `set-default-toplevel-value' (I did at least). > > So I would at least talk about this in the docstrings of `set-default', > and also `default-value' and `default-boundp' which suffer the same > problem. In fact, now that I see it, the docstring of the later is just > wrong. The others just don't mention let bindings and only talk about > buffer-local bindings, but that one explicitly says that the function > can be used to know if a variable has a non-void value outside of a > let-binding, and with dynamic binding that doesn't work (see snippet > below). > > (setq lexical-binding nil) > (let ((another-fresh-var 1)) > (default-boundp 'another-fresh-var)) ;; I expect nil, it returns t Hello, I was revisiting this bug report and writing a patch to correct and update some docstrings, both in custom.el and for `default-value', `set-default' and `default-boundp'. But for the last three, I'm no longer sure if the errors are in the implementation or the docstrings, since I have found more strange cases while experimenting. In a few words, those functions behave differently inside let bindings depending on whether the current buffer has or not a local value for the variable, which I find a little bit inconsistent. If it has, they behave as they "toplevel" counterparts (`default-toplevel-value', `set-default-toplevel-value'). If they don't, they behave as I explained in previous emails. I describe those cases below, with code snippets and comments. Note that the behavior also depends on whether lexical binding is enabled or not. I use dynamic binding in these examples. ;;;; `default-value' ;; default defined, buffer-local undefined (defvar var1 "default") (let ((var1 "inside let")) (default-value 'var1)) ;; returns "inside let" ;; default defined, buffer-local defined (defvar var2 "default") (setq-local var2 "buffer-local") (let ((var2 "inside let")) (default-value 'var2)) ;; returns "default" ;; default undefined, buffer-local undefined (let ((var3 "inside let")) (default-value 'var3)) ;; returns "inside let" ;; default undefined, buffer-local defined (setq-local var4 "buffer-local") (let ((var4 "inside let")) (default-value 'var4)) ;; void-variable error ;;;; `default-boundp' ;; default defined, buffer-local undefined (defvar var5 "default") (let ((var5 "inside let")) (default-boundp 'var5)) ;; returns t ;; default defined, buffer-local defined (defvar var6 "default") (setq-local var6 "buffer-local") (let ((var6 "inside let")) (default-boundp 'var6)) ;; returns t ;; default undefined, buffer-local undefined (let ((var7 "inside let")) (default-boundp 'var7)) ;; returns t ;; default undefined, buffer-local defined (setq-local var8 "buffer-local") (let ((var8 "inside let")) (default-boundp 'var8)) ;; returns nil ;;;; `set-default' ;; default defined, buffer-local undefined (defvar var9 "default") (let ((var9 "inside let")) (set-default 'var9 "new-default") var9) ;; returns "new-default" var9 ;; returns "default" (default-value 'var9) ;; returns "default" ;; default defined, buffer-local defined (defvar var10 "default") (setq-local var10 "buffer-local") (let ((var10 "inside let")) (set-default 'var10 "new-default") var10) ;; returns "inside let" var10 ;; returns "buffer-local" (default-value 'var10) ;; returns "new-default" ;; default undefined, buffer-local undefined (let ((var11 "inside let")) (set-default 'var11 "new-default") var11) ;; returns "new-default" var11 ;; void-variable error (default-value 'var11) ;; void-variable error ;; default undefined, buffer-local defined (setq-local var12 "buffer-local") (let ((var12 "inside let")) (set-default 'var12 "new-default") var12) ;; returns "inside let" var12 ;; returns "buffer-local" (default-value 'var12) ;; returns "new-default" 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 later I don't think I could help, since that code is too low level for me.