-
Notifications
You must be signed in to change notification settings - Fork 4
/
my-advice.el
51 lines (44 loc) · 1.8 KB
/
my-advice.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
;; set mark when we go backward-up-list:
(defadvice backward-up-list (around my-backward-up-list-advice activate)
"stuffs"
(push-mark (point) t)
ad-do-it)
(defadvice sp-backward-up-sexp (around my-sp-backward-up-sexp-advice activate)
"stuffs"
(push-mark (point) t)
ad-do-it)
;; (defadvice article-fill-long-lines (around my-article-fill-long-lines-advice activate)
;; "override `fill-column' due to the way article-fill-long-lines
;; uses it"
;; (let ((fill-column (- (window-width (get-buffer-window (current-buffer)))
;; 5)))
;; ad-do-it))
(defadvice shell-command (around my-shell-command-advice activate)
"Put `*Shell Command Output*' buffers into `view-mode'."
ad-do-it
(when (get-buffer "*Shell Command Output*")
(with-current-buffer "*Shell Command Output*"
(view-mode))))
;; Shrink *Occur* buffer if smallish:
(defadvice occur (around my-occur-advice activate)
"Make *Occur* buffer small if possible"
ad-do-it
(m/switch-to-buffer-and-shrink "*Occur*"))
;; Some advice to recenter after moving to next compile error
(defadvice next-error (after my-next-error-after
activate)
"Recenter the page after next-error"
(recenter))
(defmacro my-make-recentering-advice (after-what)
"Macro to define advice to `recenter' after AFTER-WHAT"
(let ((advsymbol (intern (concat "make-recenter-" (symbol-name after-what))))
(after-what-str after-what))
`(defadvice ,after-what (after advsymbol
activate)
"Recenter the page after doing this thing"
;; (message (concat "Running advice for " (symbol-name ',after-what-str)))
(recenter))))
(advice-add #'backward-page :after #'recenter)
(advice-add #'forward-page :after #'recenter)
(my-make-recentering-advice racer-find-definition)
(my-make-recentering-advice xref-pop-marker-stack)