* lisp/view.el (view--enable, view--disable): Rename from view-mode-enable

and view-mode-disable and assume it's called from view-mode.
(view-mode-enable, view-mode-disable): Redefine as obsolete
compatibility layer above view-mode.
(view-mode-enter): Call `view-mode'.
* lisp/files.el (after-find-file): Call `view-mode'.
This commit is contained in:
Stefan Monnier 2013-01-03 21:53:48 -05:00
parent 96dd18b110
commit 4a74c81880
6 changed files with 40 additions and 23 deletions

View file

@ -1,5 +1,13 @@
2013-01-04 Stefan Monnier <monnier@iro.umontreal.ca>
* view.el (view--enable, view--disable): Rename from view-mode-enable
and view-mode-disable and assume it's called from view-mode.
(view-mode-enable, view-mode-disable): Redefine as obsolete
compatibility layer above view-mode.
(view-mode-enter): Call `view-mode'.
* files.el (after-find-file): Call `view-mode'.
* doc-view.el (doc-view-scale-internally): New var.
(doc-view-enlarge, doc-view-insert-image): Obey it.
@ -348,6 +356,8 @@
(lm-homepage): New function.
(lm-with-file): Don't be confused if narrowing is in effect.
2012-12-19 Stefan Monnier <monnier@iro.umontreal.ca>
* vc/diff-mode.el (diff-post-command-hook): Don't ignore changes at the
very beginning of a hunk (e.g. killing the first line).

View file

@ -209,7 +209,6 @@ have fast storage with limited space, such as a RAM disk."
(declare-function dired-unmark "dired" (arg))
(declare-function dired-do-flagged-delete "dired" (&optional nomessage))
(declare-function dos-8+3-filename "dos-fns" (filename))
(declare-function view-mode-disable "view" ())
(declare-function dosified-file-name "dos-fns" (file-name))
(defvar file-name-invalid-regexp
@ -2125,7 +2124,7 @@ unless NOMODES is non-nil."
(setq buffer-read-only t))
(unless nomodes
(when (and view-read-only view-mode)
(view-mode-disable))
(view-mode -1))
(normal-mode t)
;; If requested, add a newline at the end of the file.
(and (memq require-final-newline '(visit visit-save))

View file

@ -461,16 +461,13 @@ then \\[View-leave], \\[View-quit] and \\[View-kill-and-leave] will return to th
Entry to view-mode runs the normal hook `view-mode-hook'."
:lighter " View" :keymap view-mode-map
(if view-mode (view-mode-enable) (view-mode-disable)))
(if view-mode (view--enable) (view--disable)))
(defun view-mode-enable (&optional run-view-mode-hook)
"Turn on View mode.
Run `view-mode-hook' when RUN-VIEW-MODE-HOOK is non-nil."
(defun view--enable ()
;; Always leave view mode before changing major mode.
;; This is to guarantee that the buffer-read-only variable is restored.
(add-hook 'change-major-mode-hook 'view-mode-disable nil t)
(setq view-mode t
view-page-size nil
(add-hook 'change-major-mode-hook 'view--disable nil t)
(setq view-page-size nil
view-half-page-size nil
view-old-buffer-read-only buffer-read-only
buffer-read-only t)
@ -481,16 +478,18 @@ Run `view-mode-hook' when RUN-VIEW-MODE-HOOK is non-nil."
(format "continue viewing %s"
(if (buffer-file-name)
(file-name-nondirectory (buffer-file-name))
(buffer-name)))))
(force-mode-line-update)
(when run-view-mode-hook
(run-hooks 'view-mode-hook)))
(buffer-name))))))
(define-obsolete-function-alias 'view-mode-enable 'view-mode "24.4")
(defun view-mode-disable ()
"Turn off View mode."
(remove-hook 'change-major-mode-hook 'view-mode-disable t)
(declare (obsolete view-mode "24.4"))
(view-mode -1))
(defun view--disable ()
(remove-hook 'change-major-mode-hook 'view--disable t)
(and view-overlay (delete-overlay view-overlay))
(force-mode-line-update)
;; Calling toggle-read-only while View mode is enabled
;; sets view-read-only to t as a buffer-local variable
;; after exiting View mode. That arranges that the next toggle-read-only
@ -499,7 +498,6 @@ Run `view-mode-hook' when RUN-VIEW-MODE-HOOK is non-nil."
;; so that View mode stays off if toggle-read-only is called.
(if (local-variable-p 'view-read-only)
(kill-local-variable 'view-read-only))
(setq view-mode nil)
(if (boundp 'Helper-return-blurb)
(setq Helper-return-blurb view-old-Helper-return-blurb))
(if buffer-read-only
@ -562,8 +560,7 @@ This function runs the normal hook `view-mode-hook'."
(setq view-exit-action exit-action))
(unless view-mode
(view-mode-enable t)
(force-mode-line-update)
(view-mode 1)
(unless view-inhibit-help-message
(message "%s"
(substitute-command-keys "\
@ -590,7 +587,7 @@ current buffer. "
(when view-mode
(let ((buffer (window-buffer)))
(unless view-no-disable-on-exit
(view-mode-disable))
(view-mode -1))
(unless exit-only
(cond
@ -601,8 +598,7 @@ current buffer. "
(quit-window)))
(when exit-action
(funcall exit-action buffer))
(force-mode-line-update)))))
(funcall exit-action buffer))))))
(defun View-exit ()
"Exit View mode but stay in current buffer."

View file

@ -261,7 +261,7 @@
* xdisp.c (select_frame_for_redisplay, ensure_selected_frame): Remove.
(redisplay_internal): Don't bother selecting the frame to get the
proper value of frame-local variables.
proper value of frame-local variables (bug#13225).
2012-12-20 Dmitry Antipov <dmantipov@yandex.ru>

View file

@ -86,7 +86,7 @@ Other values of LIMIT are ignored. */)
before it's time to do a QUIT. This must be a power of 2. */
enum { QUIT_COUNT_HEURISTIC = 1 << 16 };
/* Random data-structure functions */
/* Random data-structure functions. */
DEFUN ("length", Flength, Slength, 1, 1, 0,
doc: /* Return the length of vector, list or string SEQUENCE.

View file

@ -5,6 +5,18 @@ setlock -n /tmp/getmail.lock && echo getmail isn\'t running
# adsgsdg
case $X in
foo)
do_something
;;
arg=*) # bug#12953
do_something_else_based_on_arg
;;
*)
default
;;
esac
echo -n $(( 5 << 2 ))
# This should not be treated as a heredoc (bug#12770).
2