Skip to content

Instantly share code, notes, and snippets.

@southly
Created September 21, 2010 18:39
Show Gist options
  • Select an option

  • Save southly/590252 to your computer and use it in GitHub Desktop.

Select an option

Save southly/590252 to your computer and use it in GitHub Desktop.
#xyzzy recenter-toggle
(defun recenter (&optional arg)
(interactive "p")
(save-excursion
(scroll-window (- (get-window-line)
(cond (arg
(if (minusp arg)
(max (- (window-height) arg) 0)
(min arg (1- (window-height)))))
((eq *last-command* 'recenter)
(cond ((= (get-window-line) (truncate (window-height) 2))
0)
((<= (get-window-line) *scroll-margin*)
(1- (window-height)))
(t
(truncate (window-height) 2))))
(t
(truncate (window-height) 2)))))))
@southly
Copy link
Copy Markdown
Author

southly commented Sep 21, 2010

いつのまにかemacsのrecenterがトグルするようになっているのに気づいたのでてきとーに実装。
ファイルの行数が少ないときの動作が手抜き。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment