all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juanma Barranquero <lekktu@gmail.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: after-find-file-from-revert-buffer
Date: Wed, 6 Apr 2011 02:28:12 +0200	[thread overview]
Message-ID: <BANLkTinS+bUrmct-K5yjM4UPSLeyoKN4tw@mail.gmail.com> (raw)

I'm using lexical-binding = 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))
           (/= (char-after (1- (point-max))) ?\n)
           (not (and (eq selective-display t)
                     (= (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,

    Juanma



             reply	other threads:[~2011-04-06  0:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-06  0:28 Juanma Barranquero [this message]
2011-04-06  1:34 ` after-find-file-from-revert-buffer Stefan Monnier
2011-04-06  1:42   ` after-find-file-from-revert-buffer Juanma Barranquero
2011-04-06 15:17     ` after-find-file-from-revert-buffer Stefan Monnier
2011-04-06 17:43       ` after-find-file-from-revert-buffer Juanma Barranquero
2011-04-06 15:18   ` after-find-file-from-revert-buffer Juanma Barranquero
2011-04-06 16:51     ` after-find-file-from-revert-buffer Stefan Monnier
2011-04-06 17:03       ` after-find-file-from-revert-buffer Juanma Barranquero
2011-04-06 17:32         ` after-find-file-from-revert-buffer Stefan Monnier

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

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

  git send-email \
    --in-reply-to=BANLkTinS+bUrmct-K5yjM4UPSLeyoKN4tw@mail.gmail.com \
    --to=lekktu@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.