From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 012487b: * lisp/display-line-numbers.el (display-line-numbers-type): Autoload it. Date: Mon, 24 Jul 2017 13:29:39 -0400 Message-ID: References: <20170723072843.23485.53761@vcs0.savannah.gnu.org> <20170723072844.877FD22EF0@vcs0.savannah.gnu.org> <87inijxnda.fsf@detlef> <83r2x57orp.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1500917488 21018 195.159.176.226 (24 Jul 2017 17:31:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 24 Jul 2017 17:31:28 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 24 19:31:25 2017 Return-path: Envelope-to: ged-emacs-devel@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 1dZhCN-0004nm-Rh for ged-emacs-devel@m.gmane.org; Mon, 24 Jul 2017 19:31:16 +0200 Original-Received: from localhost ([::1]:56081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZhCS-0002rI-KL for ged-emacs-devel@m.gmane.org; Mon, 24 Jul 2017 13:31:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZhBP-0002om-PO for emacs-devel@gnu.org; Mon, 24 Jul 2017 13:30:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZhB7-0003gW-Lb for emacs-devel@gnu.org; Mon, 24 Jul 2017 13:30:15 -0400 Original-Received: from [195.159.176.226] (port=52727 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZhB7-0003fd-DM for emacs-devel@gnu.org; Mon, 24 Jul 2017 13:29:57 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dZhAu-0000KD-Gc for emacs-devel@gnu.org; Mon, 24 Jul 2017 19:29:44 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 25 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:eX4jUo9EuF+QmWwk7XZkX6EInes= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:216985 Archived-At: >> +;; Following function calls will autoload the library. >> +(defvar display-line-numbers-type) >> + >> (defun menu-bar-display-line-numbers-mode (type) >> (setq display-line-numbers-type type) >> (if global-display-line-numbers-mode > How is this better than the autoload? Autoloading variables is a source of corner-case problems, and autoloading defcustoms even more so. It's not serious enough to ban such autoloads, but it's a good practice to try and avoid them when it can be done cheaply, and to clearly document them when we do need them. > At least the autoload doesn't need a comment to explain why it > is there. I find this very amusing: - my asking Micheal "Why?" is another way to say "I'd have liked to see a comment explaining why we need the autoload". - the comment on the defvar isn't needed anyway: it's pretty clear why the defvar is used, and even if nothing autoloads the library, the code with defvar+setq is correct. Stefan