all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* after-find-file-from-revert-buffer
@ 2011-04-06  0:28 Juanma Barranquero
  2011-04-06  1:34 ` after-find-file-from-revert-buffer Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Juanma Barranquero @ 2011-04-06  0:28 UTC (permalink / raw)
  To: Emacs developers

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-04-06 17:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-06  0:28 after-find-file-from-revert-buffer Juanma Barranquero
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

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.