From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Julian Gilbey Newsgroups: gmane.emacs.bugs 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 Message-ID: <20201126170912.GA680140@d-and-j.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7193"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44864@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 26 18:57:39 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1kiLWU-0001k1-He for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Nov 2020 18:57:38 +0100 Original-Received: from localhost ([::1]:48428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kiLWT-00069A-Fb for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Nov 2020 12:57:37 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kiLTz-0004LV-0X for bug-gnu-emacs@gnu.org; Thu, 26 Nov 2020 12:55:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59493) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kiLTy-0000wG-OA for bug-gnu-emacs@gnu.org; Thu, 26 Nov 2020 12:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kiLTy-0001Ti-M4 for bug-gnu-emacs@gnu.org; Thu, 26 Nov 2020 12:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Julian Gilbey Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Nov 2020 17:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44864 X-GNU-PR-Package: emacs Original-Received: via spool by 44864-submit@debbugs.gnu.org id=B44864.16064132645602 (code B ref 44864); Thu, 26 Nov 2020 17:55:02 +0000 Original-Received: (at 44864) by debbugs.gnu.org; 26 Nov 2020 17:54:24 +0000 Original-Received: from localhost ([127.0.0.1]:42799 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kiLTK-0001SF-6m for submit@debbugs.gnu.org; Thu, 26 Nov 2020 12:54:24 -0500 Original-Received: from d-and-j.net ([78.32.133.108]:50472 helo=erdos.d-and-j.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kiKll-0006gV-9c for 44864@debbugs.gnu.org; Thu, 26 Nov 2020 12:09:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=d-and-j.net ; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=dwHxS6fXjxdJCcNmfoyzMHrO39OWQcAf57XBXTUUIjs=; b=Doh8mU4rg+A4SyGYuf75IYUXFK IMTSa9DfpkEQcIrnCebNN1HaNP09QwRgaP92N0xCrSUl6S+y7FRJJ0J+xvEU2Ub4cSKvbOR67awSJ ilDGIZnm2YEb7A6/HTc+WpLmACyPJCdAKjB3lGacz/A+N93zGAZpUZvNZi6Dtn8AUGCw=; Original-Received: from jdg by erdos.d-and-j.net with local (Exim 4.94) (envelope-from ) id 1kiKlc-002rKr-Hh; Thu, 26 Nov 2020 17:09:12 +0000 Content-Disposition: inline In-Reply-To: X-Mailman-Approved-At: Thu, 26 Nov 2020 12:54:21 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:194362 Archived-At: 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