[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] master 012487b: * lisp/display-line-numbers.el (displa

From: Stefan Monnier
Subject: Re: [Emacs-diffs] master 012487b: * lisp/display-line-numbers.el (display-line-numbers-type): Autoload it.
Date: Tue, 25 Jul 2017 09:56:29 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

>>> We are miscommunicating.  By "the problem" I meant the reason(s) why
>>> autoloading a defcustom should be considered undesirable, and by
>>> "proposed solutions" the alternatives for making sure a defcustom'd
>>> variable is defined when it is needed.
>> There is no need for the variable to be defined in order to `setq' it,
>> which is why a simple (defvar foo) is sufficient here.
> In menu-bar.el (the case we are speaking about) and every other package,
> which might be interested to modify this variable prior calling the
> corresponding autoloaded function. I still don't see why it is better,
> to mandate every package using that variable a (defvar foo).

- There is currently no other package in this situation.
  And I don't expect a deluge of such packages either.
- Another package might do (require 'display-line-numbers) anyway.
- In general when a package doesn't want to (require 'bar) but needs
  to let-bind or set some variable bar-baz, the answer is to either live
  with the byte-compiler warning (that's the typical case for code in
  ~/.emacs) or to add a (defvar bar-baz).  It's been that way for ever.

Autoloading the variable is used when you need to know the var's value
(rather than merely set it) and where (require 'bar) is undesirable.

> And if this is better, it must be documented in the manual with a reasoning.

Simple reason: the code worked just fine, so all there was to fix was
a warning, and (defvar bar-baz) is the tool specifically designed to
silence those compiler warnings.

The autoload you added won't cause you to rot in hell the for eternity
(I think), but it's definitely not the best tool to fix the problem at hand.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]