unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Julian Gilbey <julian-gnu@d-and-j.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 44864@debbugs.gnu.org
Subject: bug#44864: 27.1; advice.el: ad-with-originals deprecated, but no advice on replacement
Date: Thu, 26 Nov 2020 17:09:12 +0000	[thread overview]
Message-ID: <20201126170912.GA680140@d-and-j.net> (raw)
In-Reply-To: <jwvv9ds9lre.fsf-monnier+emacs@gnu.org>

On Thu, Nov 26, 2020 at 10:39:10AM -0500, Stefan Monnier wrote:
> >             ;; Use file's local variables section to set variables in
> >             ;; this buffer.  (Don't just copy local variables from the
> >             ;; base buffer because it may have set things locally that
> >             ;; we don't want in the other modes.)  We need to prevent
> >             ;; `mode' being processed and re-setting the major mode.
> >             ;; It all goes badly wrong if `hack-one-local-variable' is
> >             ;; advised.  The appropriate mechanism to get round this
> >             ;; appears to be `ad-with-originals', but we don't want to
> >             ;; pull in the advice package unnecessarily.  `flet'-like
> >             ;; mechanisms lose with advice because `fset' acts on the
> >             ;; advice anyway.
> >             (if (featurep 'advice)
> >                 (ad-with-originals (hack-one-local-variable)
> >                   (multi-hack-local-variables))
> >               (multi-hack-local-variables))
> 
> The comment doesn't explain why Dave thought that "It all goes badly
> wrong if `hack-one-local-variable' is advised", so there's not much we
> can do.  AFAIK it will only go wrong with some advice, so he must have
> had some particular pieces of advice in mind.
> 
> `advice.el` is deprecated anyway, so my recommendation is to remove this
> test and just call `multi-hack-local-variables` without paying attention
> to any potential advice there.  If/when you bump into a problem with
> that, then we'll be able to see what should be done (the best option
> might be to change the advice itself).

Thanks Stefan!

That sounds eminently sensible.  Scouring the rest of Dave's file, I
found the following comment at the beginning of the function you've
just quoted from:

(defun multi-install-mode (mode &optional chunk-fn base)
  "Add MODE to the multiple major modes supported by the current buffer.
CHUNK-FN, if non-nil, is a function to select the mode of a chunk,
added to the list `multi-chunk-fns'.  BASE non-nil means that this
is the base mode."
  (unless (memq mode multi-indirect-buffers-alist) ; be idempotent
    ;; This is part of a grim hack for lossage in AUCTeX, which
    ;; bogusly advises `hack-one-local-variable'.  This loses, due to
    ;; the way advice works, when we run `multi-hack-local-variables'
    ;; below -- there ought to be a way round this, probably with CL's
    ;; flet.  Any subsequent use of it then fails because advice has
    ;; captured the now-unbound variable `late-hack'...  Thus ensure
    ;; we've loaded the mode in advance to get any autoloads sorted
    ;; out.  Do it generally in case other modes have similar
    ;; problems.  [The AUCTeX stuff is in support of an undocumented
    ;; feature which is unnecessary and, anyway, wouldn't need advice
    ;; to implement.  Unfortunately the maintainer seems not to
    ;; understand the local variables mechanism and wouldn't remove
    ;; this.  To invoke minor modes, you should just use `mode:' in
    ;; `local variables'.]

And in auctex/tex.el, we have:

(defadvice hack-one-local-variable (after TeX-hack-one-local-variable-after
                                          activate)
  "Call minor mode function if minor mode variable is found."
  (let ((var (ad-get-arg 0))
        (val (ad-get-arg 1)))
    ;; Instead of checking for each mode explicitely `minor-mode-list'
    ;; could be used.  But this may make the byte compiler pop up.
    (when (memq var '(TeX-PDF-mode
                      TeX-source-correlate-mode TeX-interactive-mode
                      TeX-fold-mode LaTeX-math-mode))
      (if (symbol-value val) (funcall var 1) (funcall var 0)))))

So I'm guessing that's what he's referring to.

> > But there is no advice on what to do instead.
> 
> I think that's because `ad-with-originals` was used on it ;-)

Ah, that's beginning to make some sense!

Many thanks,

   Julian





  reply	other threads:[~2020-11-26 17:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-25  9:00 bug#44864: 27.1; advice.el: ad-with-originals deprecated, but no advice on replacement Julian Gilbey
2020-11-26 10:45 ` Lars Ingebrigtsen
2020-11-26 15:39 ` Stefan Monnier
2020-11-26 17:09   ` Julian Gilbey [this message]
2020-11-26 17:54     ` Stefan Monnier
2021-08-27 15:36       ` Lars Ingebrigtsen
2021-09-13 15:29         ` Julian Gilbey
2021-10-14 15:11 ` Lars Ingebrigtsen
2021-10-14 15:43   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201126170912.GA680140@d-and-j.net \
    --to=julian-gnu@d-and-j.net \
    --cc=44864@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).