Browse code
feat(emacs): command to center a defun
Showing 1 changed files
... | ... |
@@ -821,4 +821,12 @@ With a prefix ARG invalidates the cache first." |
821 | 821 |
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)) |
822 | 822 |
(put 'list-timers 'disabled nil) |
823 | 823 |
|
824 |
+(defun fwoar/center-defun () |
|
825 |
+ (interactive) |
|
826 |
+ (cl-destructuring-bind (a . b) (bounds-of-thing-at-point 'defun) |
|
827 |
+ (save-excursion |
|
828 |
+ (let ((s (progn (goto-char a) (line-number-at-pos))) |
|
829 |
+ (e (progn (goto-char b) (line-number-at-pos)))) |
|
830 |
+ (evil-scroll-line-to-center (+ s -1 (ceiling (- e s) 2))))))) |
|
831 |
+ |
|
824 | 832 |
(run-with-idle-timer 5 t 'garbage-collect) |