From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] scratch/so-long 7273fb2: Add so-long library Date: Sun, 14 Apr 2019 11:14:47 -0400 Message-ID: References: <20190107065207.21793.53271@vcs0.savannah.gnu.org> <20190107065208.BA36C21736@vcs0.savannah.gnu.org> <16bb3884-c2de-b178-afe8-0b13a8b116a8@orcon.net.nz> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="267816"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Phil Sainty Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 14 17:15:13 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hFgqf-0017Ws-Gp for ged-emacs-devel@m.gmane.org; Sun, 14 Apr 2019 17:15:13 +0200 Original-Received: from localhost ([127.0.0.1]:36740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hFgqe-0000tA-5x for ged-emacs-devel@m.gmane.org; Sun, 14 Apr 2019 11:15:12 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hFgqO-0000sY-5g for emacs-devel@gnu.org; Sun, 14 Apr 2019 11:14:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hFgqN-0003gg-18 for emacs-devel@gnu.org; Sun, 14 Apr 2019 11:14:56 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:38932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hFgqM-0003d2-N0 for emacs-devel@gnu.org; Sun, 14 Apr 2019 11:14:54 -0400 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id x3EFElXb010205; Sun, 14 Apr 2019 11:14:47 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 7F4BD6A134; Sun, 14 Apr 2019 11:14:47 -0400 (EDT) In-Reply-To: (Phil Sainty's message of "Mon, 15 Apr 2019 01:09:16 +1200") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6524=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6524> : inlines <7052> : streams <1818645> : uri <2831970> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 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:235444 Archived-At: >> (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