:version "23.1"
:group 'windows)
+(defun scroll-restore--set (symbol value)
+ (set-default symbol value)
+ (when (and (boundp 'scroll-restore-mode) scroll-restore-mode)
+ (scroll-restore-mode -1)
+ (scroll-restore-mode 1)))
+
(defcustom scroll-restore-commands
+ ;; FIXME: How 'bout using the `scroll-command' property?
'(handle-select-window handle-switch-frame
scroll-up scroll-down
+ scroll-up-command scroll-down-command
scroll-bar-toolkit-scroll mwheel-scroll
scroll-other-window scroll-other-window-down
scroll-bar-scroll-up scroll-bar-scroll-down scroll-bar-drag)
(put cmd 'scroll-restore nil)))
(set-default symbol value)
(dolist (cmd scroll-restore-commands)
- (put cmd 'scroll-restore t)))
- :group 'scroll-restore)
+ (put cmd 'scroll-restore t))))
;; Recenter.
(defcustom scroll-restore-recenter nil
"Non-nil means scrolling back recenters the original position.
Setting this to a non-nil value can be useful to detect the original
position more easily and coherently when scrolling back."
- :type 'boolean
- :group 'scroll-restore)
+ :type 'boolean)
;; Jump back.
(defcustom scroll-restore-jump-back nil
Alternatively you may consider binding the command
`scroll-restore-jump-back' to a key of your choice."
:type 'boolean
- :set #'(lambda (symbol value)
- (set-default symbol value)
- (when (and (boundp 'scroll-restore-mode) scroll-restore-mode)
- (scroll-restore-restart)))
- :group 'scroll-restore)
+ :set #'scroll-restore--set)
;;; Cursor handling.
(defvar scroll-restore-buffer nil
(const :tag "Cursor type" type)
(const :tag "Cursor color" color)
(const :tag "Type and color" t))
- :set #'(lambda (symbol value)
- (set-default symbol value)
- (when (and (boundp 'scroll-restore-mode) scroll-restore-mode)
- (scroll-restore-restart)))
- :group 'scroll-restore)
+ :set #'scroll-restore--set)
(defcustom scroll-restore-cursor-type 'box
"Type of cursor when original position is off-screen.
Applied if and only if `scroll-restore-handle-cursor' is either
-'type or t.
+`type' or t.
Be careful when another application uses that type. Otherwise,
you might get unexpected results when Scroll Restore mode resets
(const :tag "Hollow box" hollow)
(const :tag "Vertical bar" bar)
(const :tag "Horizontal bar" hbar))
- :set #'(lambda (symbol value)
- (set-default symbol value)
- (when (and (boundp 'scroll-restore-mode) scroll-restore-mode)
- (scroll-restore-restart)))
- :group 'scroll-restore)
+ :set #'scroll-restore--set)
(defcustom scroll-restore-cursor-color "DarkCyan"
"Background color of cursor when original position is off-screen.
Applied if and only if `scroll-restore-handle-cursor' is either
-'color or t.
+`color' or t.
Observe that when Emacs changes the color of the cursor, the
change applies to all windows on the associated frame.
reset the color of the cursor whenever its value does not equal
the value of scroll-restore-cursor-color."
:type 'color
- :set #'(lambda (symbol value)
- (set-default symbol value)
- (when (and (boundp 'scroll-restore-mode) scroll-restore-mode)
- (scroll-restore-restart)))
- :group 'scroll-restore)
+ :set #'scroll-restore--set)
;;; Region handling.
+
+;; FIXME: We should try to use pre-redisplay-function instead.
+
(defvar scroll-restore-region-overlay
(let ((overlay (make-overlay (point-min) (point-min))))
(overlay-put overlay 'face 'scroll-restore-region)
option has no effect since Scroll Restore mode cannot track mouse
drags."
:type 'boolean
- :set #'(lambda (symbol value)
- (set-default symbol value)
- (when (and (boundp 'scroll-restore-mode) scroll-restore-mode)
- (scroll-restore-restart)))
- :group 'scroll-restore)
+ :set #'scroll-restore--set)
(defface scroll-restore-region
'((t :inherit region))
- "Face for Scroll Restore region when `scroll-restore-handle-region' is
-non-nil."
- :group 'scroll-restore)
+ "Face for Scroll Restore region when `scroll-restore-handle-region' is
+non-nil.")
;; Note: We can't use `point-before-scroll' for our purposes because
;; that variable is buffer-local. We need a variable that recorded
(goto-char (nth 2 entry))
(error "No jump-back position available"))))
+;;;###autoload
(define-minor-mode scroll-restore-mode
"Toggle Scroll Restore mode.
With arg, turn Scroll Restore mode on if arg is positive, off
(remove-hook 'pre-command-hook 'scroll-restore-pre-command)
(remove-hook 'post-command-hook 'scroll-restore-post-command)))
-(defun scroll-restore-restart ()
- "Restart Scroll Restore mode."
- (scroll-restore-mode -1)
- (scroll-restore-mode 1))
-
(provide 'scroll-restore)
;;; scroll-restore.el ends here