From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: after-find-file-from-revert-buffer Date: Wed, 6 Apr 2011 17:18:33 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1302103251 9221 80.91.229.12 (6 Apr 2011 15:20:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 6 Apr 2011 15:20:51 +0000 (UTC) Cc: Emacs developers To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 06 17:20:47 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q7UXG-0007Gu-C8 for ged-emacs-devel@m.gmane.org; Wed, 06 Apr 2011 17:20:46 +0200 Original-Received: from localhost ([127.0.0.1]:34957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7UVv-000462-Tt for ged-emacs-devel@m.gmane.org; Wed, 06 Apr 2011 11:19:23 -0400 Original-Received: from [140.186.70.92] (port=57702 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7UVn-00044j-0W for emacs-devel@gnu.org; Wed, 06 Apr 2011 11:19:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7UVl-0002ec-Mx for emacs-devel@gnu.org; Wed, 06 Apr 2011 11:19:14 -0400 Original-Received: from mail-gw0-f41.google.com ([74.125.83.41]:57998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q7UVl-0002eV-KA for emacs-devel@gnu.org; Wed, 06 Apr 2011 11:19:13 -0400 Original-Received: by gwaa12 with SMTP id a12so527593gwa.0 for ; Wed, 06 Apr 2011 08:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=KP+j0m7Q+mMh73IbSgGGNoT9C3CfIf70a/T02vmw3f8=; b=OEtYOJ2WV1EtkuDC9q8m132jcW5PLkdd8JIetmpTEszeCMHOqN3phHi9cYudQMybeR Uj/k1uH5K+7a0g4iJ6TJGXNB29zyWMUGP94nfEO6flf+g3nad91Cp7YO08nfjGtRkWtf lHMr2LU2W6quCm+mmZAk9MdtP5y630N3M78KU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=hmnRuH0ieW1/eAFWZ4oJs4TesEQ+Y0aDri771rIrD0ppbRfNoeofkB899LSCv4bl3L fara+I3k48pfX9NnFOvMSVAEkfexzhRvjkyiJJg/VJbYzfZU0FuAGeC7Cld45HH5qJMK VA/v5lpqcCkPuz9xoDb/CuP8HNrkauUkcWjzQ= Original-Received: by 10.236.187.97 with SMTP id x61mr572033yhm.476.1302103153094; Wed, 06 Apr 2011 08:19:13 -0700 (PDT) Original-Received: by 10.147.182.17 with HTTP; Wed, 6 Apr 2011 08:18:33 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.83.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138241 Archived-At: > Removing the variable sounds like the best option. =C2=A0So the question = is > how to get the same behavior in saveplace without using this variable. > Maybe saveplace could setup a local revert-buffer-function instead. The issue is that saveplace does not need or want a revert-buffer-function. What it wants is to piggyback on find-file-hook to restore the point in other buffers, but detect the cases where that's caused by revert-buffer, to avoid unexpectedly moving the point. If the (before|after)-revert-hooks were always run, we could try to use these (though it would be ugly); but a `revert-buffer-function' is free to ignore them. On the other hand, if the `revert-buffer-function' does not call `after-find-file', or if it does but does not pass the AFTER-FIND-FILE-FROM-REVERT-BUFFER parameter, the saveplace hook isn't detecting the revert-buffer call anyway... The only answer I can think is having something like after-find-file-from-revert-buffer, but explicitly for revert-buffer: (defvar revert-buffer-in-progress-p nil "This variable is non-nil whenever a `revert-buffer' operation is in progress, nil otherwise.") (defun revert-buffer (...) (let ((revert-buffer-in-progress t)) ...)) which isn't not much better that which we have today, but at least is better focused: it's cleaner to have a flag to signal use of revert-buffer, than one to signal use of after-find-file inside revert-buffer... =C2=A0 =C2=A0 Juanma P.S. Well, it would be more like @@ -5047,8 +5048,10 @@ (interactive (list (not current-prefix-arg))) (if revert-buffer-function - (funcall revert-buffer-function ignore-auto noconfirm) + (let ((revert-buffer-in-progress-p t)) + (funcall revert-buffer-function ignore-auto noconfirm)) (with-current-buffer (or (buffer-base-buffer (current-buffer)) (current-buffer)) - (let* ((auto-save-p (and (not ignore-auto) + (let* ((revert-buffer-in-progress-p t) + (auto-save-p (and (not ignore-auto) (recent-auto-save-p) buffer-auto-save-file-name