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: after-find-file-from-revert-buffer Date: Wed, 6 Apr 2011 02:28:12 +0200 Message-ID: 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 1302049752 27017 80.91.229.12 (6 Apr 2011 00:29:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 6 Apr 2011 00:29:12 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 06 02:29:08 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 1Q7GcJ-0005OH-Fw for ged-emacs-devel@m.gmane.org; Wed, 06 Apr 2011 02:29:03 +0200 Original-Received: from localhost ([127.0.0.1]:51828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7GcI-0007EV-Bf for ged-emacs-devel@m.gmane.org; Tue, 05 Apr 2011 20:29:02 -0400 Original-Received: from [140.186.70.92] (port=34176 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7GcB-00078T-Au for emacs-devel@gnu.org; Tue, 05 Apr 2011 20:28:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7GcA-0004SW-BL for emacs-devel@gnu.org; Tue, 05 Apr 2011 20:28:55 -0400 Original-Received: from mail-gy0-f169.google.com ([209.85.160.169]:44361) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q7GcA-0004SS-7d for emacs-devel@gnu.org; Tue, 05 Apr 2011 20:28:54 -0400 Original-Received: by gyd8 with SMTP id 8so464310gyd.0 for ; Tue, 05 Apr 2011 17:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=ADiLKC4+G/4PwR7FW1D8dLp31ugwppjvQm6HF7z13Tw=; b=Rll2d1O65RbgReOP4gjLAJblnLqwsALUSLE3d//tVp4N6cLAZvuSjrHIRvYXSGcz/2 gkIVZzzFcuUeS9XKRnFPiHhGUW+nbE6FL+68RFmm8qAwFx9eBe6oyGy0dl1tz4cAn2EZ lviPQNLwN7L63aMaABmYygsyuAsImbKFwdQAM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; b=askIJdcIhJ5l0l+gJKB6bwjyPM0VG/TjylJo0hn6tegE+V5updvIJ/jWIAIIw7MgER Mqu1ojpD/gnLbsoyKCz4yUqOReQGdZH3dXkkh1pWbfLcZxuicT9ggFs3HKIPLzMOEQOd qS+3mkKcWgEatBL7FPeHzGBuhgU4CcGgpWQcE= Original-Received: by 10.146.255.41 with SMTP id c41mr341892yai.27.1302049733570; Tue, 05 Apr 2011 17:28:53 -0700 (PDT) Original-Received: by 10.147.182.17 with HTTP; Tue, 5 Apr 2011 17:28:12 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.160.169 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:138197 Archived-At: I'm using lexical-binding =3D t to detect cases of unused arguments and variables, unwanted shadowing of global variables, etc. (I'm not planning to convert more packages to lexical-binding, just doing part of the footwork in case someone wants to do it later.) In function `after-find-file', one of the parameters is AFTER-FIND-FILE-FROM-REVERT-BUFFER, whose purpose is to bind that (undocumented) variable so code run from inside `after-find-file' can detect whether the function was called from revert-buffer or not. Its only use, now and since the parameter's and variable's introduction sixteen years ago, is in the `saveplace-find-file-hook' function, run from `find-file-hook', to decide whether to move the cursor or not. So I want to rename the argument to CALLED-FROM-REVERT-BUFFER-P, and use a let inside `after-find-file' (let ((after-find-file-from-revert-buffer called-from-revert-buffer-p)) ;; whatever ...) To strictly keep the current semantics, the "whatever" inside that `let' should be all the current code of `after-find-file'. But that seems ugly and wasteful, and I think we can go forth with just let-binding the inside of the final (unless nomodes ...) form: (unless nomodes (let ((after-find-file-from-revert-buffer called-from-revert-buffer-p)) (when (and view-read-only view-mode) (view-mode-disable)) (normal-mode t) ;; If requested, add a newline at the end of the file. (and (memq require-final-newline '(visit visit-save)) (> (point-max) (point-min)) (/=3D (char-after (1- (point-max))) ?\n) (not (and (eq selective-display t) (=3D (char-after (1- (point-max))) ?\r))) (save-excursion (goto-char (point-max)) (insert "\n"))) (when (and buffer-read-only view-read-only (not (eq (get major-mode 'mode-class) 'special))) (view-mode-enter)) (run-hooks 'find-file-hook)))) Additionally, we could document the variable, or find another, less ugly way to pass that information back to saveplace.el and remove the variable altogether. Comments? TIA, =C2=A0 =C2=A0 Juanma