[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] scratch/so-long 7273fb2: Add so-long library
From: |
Stefan Monnier |
Subject: |
Re: [Emacs-diffs] scratch/so-long 7273fb2: Add so-long library |
Date: |
Sun, 14 Apr 2019 11:14:47 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
>> (advice-add 'hack-local-variables :around #'so-long--hlv)
>> (defun so-long--hlv (orig-fun &optional handle-mode &rest args)
>> ;; The first arg to `hack-local-variables' is HANDLE-MODE since
> Emacs 26.1,
>> ;; and MODE-ONLY in earlier versions. In either case we are
> interested in
>> ;; whether it has the value `t'.
>> (let ((retval (apply orig-fun handle-mode args)))
>> (and (eq handle-mode t)
>> retval ; A file-local mode was set.
>> (so-long-handle-file-local-mode retval))))
>
> This is changing 'after' advice into 'around' advice, which means that
> your version changes the return value, so that's definitely not
> equivalent.
Oops, indeed, sorry.
> I've changed it to explicitly return retval.
Good, thanks.
> Can nadvice not do 'after' advice which knows the arguments?
The arguments, yes, but the just-computed return value, no.
> The "Files with a file-local 'mode'" section of the Commentary says
> much the same, but I'd not yet added that at the time you queried
> this. I think that ought to provide the missing context for readers
> (as otherwise I think all the advice is documented pretty clearly?)
I must admit that I do a lot of hacking on packages I never use, so
I like it when the code explains what it does without requiring the
coder to have read the doc ;-)
>>> Such changes will need to work in Emacs 25 at least, and ideally
>>> back to 24.3
>> advice-add was added to Emacs-24.4 and it is available in GNU ELPA
>> for earlier Emacsen, so it's OK.
> So: Package-Requires: ((emacs "24.3") nadvice), yes?
> No -- experimentally that causes Emacs 26.1 to install nadvice from
> ELPA instead of deferring to the library it already has.
IIUC that's a bug in Emacs-26.1 (and 26.2) because 26.[12] is not aware
that it comes with nadvice-1.0.
It really should have been fixed before Emacs-26.2, but I somehow forgot
to push that commit and it lingered on a machine I only used again
very recently :-(
Stefan