Commit dc9a226c authored by Chong Yidong's avatar Chong Yidong

Don't always set ruler-mode-header-line-format-old (Bug#5370).

* ruler-mode.el (ruler--save-header-line-format): New fun.
(ruler-mode): Use it as a setter function, so as not to overwrite
ruler-mode-header-line-format-old if Ruler mode is on (Bug#5370).
parent bf935339
2010-06-30 Chong Yidong <cyd@stupidchicken.com>
* ruler-mode.el (ruler--save-header-line-format): New fun.
(ruler-mode): Use it as a setter function, so as not to overwrite
ruler-mode-header-line-format-old if Ruler mode is on (Bug#5370).
2010-06-29 Chong Yidong <cyd@stupidchicken.com>
* vc/vc.el (vc-deduce-backend): New fun. Handle diff buffers.
......
......@@ -549,22 +549,38 @@ This variable is expected to be made buffer-local by modes.")
"`header-line-format' used in ruler mode.
Call `ruler-mode-ruler-function' to compute the ruler value.")
;;;###autoload
(defvar ruler-mode nil
"Non-nil if Ruler mode is enabled.
Use the command `ruler-mode' to change this variable.")
(make-variable-buffer-local 'ruler-mode)
(defun ruler--save-header-line-format ()
"Install the header line format for Ruler mode.
Unless if Ruler mode is already enabled, save the old header line
format first."
(when enable
(when (and (not ruler-mode)
(local-variable-p 'header-line-format)
(not (local-variable-p 'ruler-mode-header-line-format-old)))
(set (make-local-variable 'ruler-mode-header-line-format-old)
header-line-format))
(setq header-line-format ruler-mode-header-line-format)))
;;;###autoload
(define-minor-mode ruler-mode
"Display a ruler in the header line if ARG > 0."
"Toggle Ruler mode.
In Ruler mode, Emacs displays a ruler in the header line."
nil nil
ruler-mode-map
:group 'ruler-mode
:variable (ruler-mode
. (lambda (enable)
(when enable
(ruler--save-header-line-format))
(setq ruler-mode enable)))
(if ruler-mode
(progn
;; When `ruler-mode' is on save previous header line format
;; and install the ruler header line format.
(when (and (local-variable-p 'header-line-format)
(not (local-variable-p 'ruler-mode-header-line-format-old)))
(set (make-local-variable 'ruler-mode-header-line-format-old)
header-line-format))
(setq header-line-format ruler-mode-header-line-format)
(add-hook 'post-command-hook 'force-mode-line-update nil t))
(add-hook 'post-command-hook 'force-mode-line-update nil t)
;; When `ruler-mode' is off restore previous header line format if
;; the current one is the ruler header line format.
(when (eq header-line-format ruler-mode-header-line-format)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment