2016-01-30 21:16:10 -05:00
|
|
|
;;; core-popup.el --- taming stray windows
|
2015-11-19 05:50:04 -05:00
|
|
|
|
2016-06-05 23:08:46 -04:00
|
|
|
;; I use a slew of hackery to get Emacs to treat 'pop-ups' consistently. It goes
|
|
|
|
;; through great lengths to tame helm, flycheck, help buffers--*even* the beast
|
|
|
|
;; that is org-mode.
|
2016-03-06 00:44:22 -05:00
|
|
|
;;
|
2016-05-01 01:05:25 -04:00
|
|
|
;; Be warned, an update could break any of this.
|
2016-03-06 00:44:22 -05:00
|
|
|
|
2015-12-21 05:44:44 -05:00
|
|
|
(use-package shackle
|
2015-11-19 05:50:04 -05:00
|
|
|
:config
|
2015-12-21 05:44:44 -05:00
|
|
|
(shackle-mode 1)
|
|
|
|
(setq shackle-rules
|
2016-05-24 21:57:25 -04:00
|
|
|
`(;; Util
|
2016-05-23 17:07:35 -04:00
|
|
|
("^\\*.+-Profiler-Report .+\\*$" :align below :size 0.3 :regexp t)
|
2016-06-04 23:27:53 -04:00
|
|
|
("*esup*" :align below :size 0.4 :noselect t)
|
2016-05-24 22:15:44 -04:00
|
|
|
("*minor-modes*" :align below :size 0.5 :noselect t)
|
2016-06-05 23:08:46 -04:00
|
|
|
("*eval*" :align below :size 16 :noselect t)
|
2016-06-06 23:49:34 -04:00
|
|
|
;; Doom
|
|
|
|
("*doom*" :align below :size 35 :select t)
|
|
|
|
("^\\*doom.+\\*$" :align below :size 12 :noselect t :regexp t)
|
2016-05-24 21:57:25 -04:00
|
|
|
;; Emacs
|
2016-05-24 22:15:44 -04:00
|
|
|
("*Pp Eval Output*" :align below :size 0.3)
|
|
|
|
("*Apropos*" :align below :size 0.3)
|
|
|
|
("*Backtrace*" :align below :size 25 :noselect t)
|
|
|
|
("*Completions*" :align below :size 20 :noselect t)
|
|
|
|
("*Help*" :align below :size 16 :select t)
|
|
|
|
("*Messages*" :align below :size 15 :select t)
|
|
|
|
("*Warnings*" :align below :size 10 :noselect t)
|
|
|
|
(compilation-mode :align below :size 15 :noselect t)
|
|
|
|
(eww-mode :align below :size 30 :select t)
|
2016-06-09 00:21:16 -04:00
|
|
|
("*command-log*" :align right :size 28 :noselect t)
|
2016-05-24 21:57:25 -04:00
|
|
|
;; vcs
|
2016-05-24 22:15:44 -04:00
|
|
|
("*vc-diff*" :align below :size 15 :noselect t)
|
|
|
|
("*vc-change-log*" :align below :size 15 :select t)
|
|
|
|
(vc-annotate-mode :same t)))
|
2015-11-19 05:50:04 -05:00
|
|
|
|
2016-06-05 23:08:46 -04:00
|
|
|
;; :noesc = Can't be closed with a single ESC
|
|
|
|
;; :nokill = Won't be killed when closed
|
|
|
|
;; :modeline = Show the modeline
|
|
|
|
(defvar doom-popup-rules
|
|
|
|
'(("^\\*doom\\*$" :noesc :nokill :modeline)
|
|
|
|
("^\\*doom.*\\*$" :noesc :nokill)
|
|
|
|
(compilation-mode :noesc)
|
|
|
|
(help-mode :noesc)
|
|
|
|
(comint-mode :noesc :nokill)
|
|
|
|
(eshell-mode :noesc :nokill)
|
|
|
|
(messages-buffer-mode :nokill)
|
|
|
|
(esup-mode :noesc)
|
|
|
|
(tabulated-list-mode :noesc)))
|
2016-03-22 18:23:51 -04:00
|
|
|
|
2016-04-26 02:01:39 -04:00
|
|
|
;; There is no shackle-popup hook, so I hacked one in
|
2016-06-05 23:08:46 -04:00
|
|
|
(advice-add 'shackle-display-buffer :around 'doom*popup-init)
|
|
|
|
;; Don't mess with popups
|
|
|
|
(advice-add 'balance-windows :around 'doom*save-popup)
|
2016-05-29 14:05:07 -04:00
|
|
|
(advice-add 'doom/evil-window-move :around 'doom*save-popup))
|
2016-05-20 09:23:46 -04:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Hacks
|
|
|
|
;;
|
|
|
|
|
|
|
|
(after! help-mode
|
2016-06-05 23:08:46 -04:00
|
|
|
;; Following links in help buffers sometimes uses itself or other-window
|
|
|
|
;; (annoying!). It should only replace the buffer we opened the popup from. To
|
|
|
|
;; fix this these three button types need to be redefined to stow away the
|
|
|
|
;; popups then follow the link from the last buffer, using `doom/popup-save'.
|
2016-05-20 09:23:46 -04:00
|
|
|
(define-button-type 'help-function-def
|
|
|
|
:supertype 'help-xref
|
|
|
|
'help-function (lambda (fun file)
|
|
|
|
(require 'find-func)
|
|
|
|
(when (eq file 'C-source)
|
|
|
|
(setq file (help-C-file-name (indirect-function fun) 'fun)))
|
2016-06-09 00:21:53 -04:00
|
|
|
(let ((location (find-function-search-for-symbol fun nil file)))
|
2016-05-20 22:37:58 -04:00
|
|
|
(doom/popup-save
|
2016-06-08 14:40:01 -04:00
|
|
|
(switch-to-buffer (car location) nil t)
|
2016-06-09 00:21:53 -04:00
|
|
|
(if (cdr location)
|
|
|
|
(goto-char (cdr location))
|
|
|
|
(message "Unable to find location in file")))
|
|
|
|
(select-window (get-buffer-window (car location))))))
|
2016-05-20 09:23:46 -04:00
|
|
|
|
|
|
|
(define-button-type 'help-variable-def
|
|
|
|
:supertype 'help-xref
|
|
|
|
'help-function (lambda (var &optional file)
|
|
|
|
(when (eq file 'C-source)
|
|
|
|
(setq file (help-C-file-name var 'var)))
|
|
|
|
(let ((location (find-variable-noselect var file)))
|
2016-05-20 22:37:58 -04:00
|
|
|
(doom/popup-save
|
2016-06-08 14:40:01 -04:00
|
|
|
(switch-to-buffer (car location) nil t)
|
2016-06-09 00:21:53 -04:00
|
|
|
(if (cdr location)
|
|
|
|
(goto-char (cdr location))
|
|
|
|
(message "Unable to find location in file")))
|
|
|
|
(select-window (get-buffer-window (car location))))))
|
2016-05-20 09:23:46 -04:00
|
|
|
|
|
|
|
(define-button-type 'help-face-def
|
|
|
|
:supertype 'help-xref
|
|
|
|
'help-function (lambda (fun file)
|
|
|
|
(require 'find-func)
|
|
|
|
(let ((location
|
|
|
|
(find-function-search-for-symbol fun 'defface file)))
|
2016-05-20 22:37:58 -04:00
|
|
|
(doom/popup-save
|
2016-06-08 14:40:01 -04:00
|
|
|
(switch-to-buffer (car location) nil t)
|
2016-06-09 00:21:53 -04:00
|
|
|
(if (cdr location)
|
|
|
|
(goto-char (cdr location))
|
|
|
|
(message "Unable to find location in file")))
|
|
|
|
(select-window (get-buffer-window (car location)))))))
|
2015-12-21 05:44:44 -05:00
|
|
|
|
2015-11-19 05:50:04 -05:00
|
|
|
(provide 'core-popup)
|
|
|
|
;;; core-popup.el ends here
|