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.
(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).
(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
(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))
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)))
\f
-(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)
(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
;; 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
(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 "\
(when view-mode
(let ((buffer (window-buffer)))
(unless view-no-disable-on-exit
- (view-mode-disable))
+ (view-mode -1))
(unless exit-only
(cond
(quit-window)))
(when exit-action
- (funcall exit-action buffer))
- (force-mode-line-update)))))
+ (funcall exit-action buffer))))))
\f
(defun View-exit ()
"Exit View mode but stay in current buffer."
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.