From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Nagy Newsgroups: gmane.emacs.devel Subject: Definition reasoning of revert-buffer-function, should it be defvar-local? Date: Tue, 10 Aug 2021 13:51:38 +0000 Message-ID: <874kbxwgmu.fsf@posteo.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="31031"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 10 15:54:45 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mDSDN-0007pl-AG for ged-emacs-devel@m.gmane-mx.org; Tue, 10 Aug 2021 15:54:45 +0200 Original-Received: from localhost ([::1]:35146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDSDM-0000PZ-5G for ged-emacs-devel@m.gmane-mx.org; Tue, 10 Aug 2021 09:54:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDSC1-00071b-0L for emacs-devel@gnu.org; Tue, 10 Aug 2021 09:53:21 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:57475) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDSBy-0002Bx-IS for emacs-devel@gnu.org; Tue, 10 Aug 2021 09:53:20 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 4E611240028 for ; Tue, 10 Aug 2021 15:53:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1628603595; bh=iwhHPySZXQARVnrdOiuyExqkCnRiGaetnqAuojfhMsg=; h=From:To:Subject:Date:From; b=MX5Lxh+Mmrc7fyRvQyHYrW3EtMuGlJ14r4Zm0uMo/r9Yhg8iQeaE4sk6tROJK/8me UUox5i3cwpG6SBtwxytarJ+XY3oaopX0o3vyPAInQno/QVI11mrhKTLPhxiv4yj92G +6962rFd0Y0XVcee3CZ0pFE9HCKz4EZuni/hgbjz1+FJucTV0WFOshAwc+4wEgtxZb QCfsMSS9+7l6XoxBNhgTqSgZF5uxLzkEE/iye0DWvYHA5GTxGlAV589qkXPnYO0OOQ WLNN/tHT/Eqx73KPVeJhWYL5nlBxDiV6YWMZ1FFvEj67dGDvetVMsz9E4FUfgT+9go RmWSDmq0t+HMQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4GkZCt5Cd2z9rxM for ; Tue, 10 Aug 2021 15:53:14 +0200 (CEST) Received-SPF: pass client-ip=185.67.36.65; envelope-from=danielnagy@posteo.de; helo=mout01.posteo.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:272273 Archived-At: Hello, I want to understand the reasoning behind the definition and the intention of the variable `revert-buffer-function`. In `files.el` I see the following definition: > (put 'revert-buffer-function 'permanent-local t) > (defvar revert-buffer-function #'revert-buffer--default) The first line suggests to me, that the intention of the variable is that it is supposed to be buffer-local, but `defvar-local` was not used. This means, that if I open a new buffer and `(setq revert-buffer-function #'something)` then that variable is assigned globally, breaking its behaviour. I know that I can use `setq-local`, but using `defvar-local` would prevent accidents. My question is, why was `defvar-local` not used? Should we change it ? Should we change all these constructs where it says `(put ... 'permanent-local t)(defvar ...)`? In `bookmark.el` I can also see the invocation `(setq revert-buffer-function ...)` but that instance does not leak out its value to global Emacs because its mode is derived from `tabulated-list-mode` and that already uses `setq-local` to make the value buffer-local. Thank you already for your help. For the more curious, this question sparked during this GitHub issue: https://github.com/magit/magit/issues/4432 Best, Daniel