Rewrite popup handling + new minor mode: doom-hide-mode-line-mode
This commit is contained in:
parent
774d61be68
commit
8a666aedfe
15 changed files with 366 additions and 379 deletions
|
@ -19,7 +19,25 @@
|
||||||
:init (add-hook 'quickrun/mode-hook 'linum-mode)
|
:init (add-hook 'quickrun/mode-hook 'linum-mode)
|
||||||
:config
|
:config
|
||||||
(setq quickrun-focus-p nil)
|
(setq quickrun-focus-p nil)
|
||||||
(def-popup! "*quickrun*" :align below :size 10))
|
(def-popup! "*quickrun*" :align below :size 10)
|
||||||
|
|
||||||
|
;;; Popup hacks
|
||||||
|
(defun doom*quickrun-close-popup (&optional _ _ _ _)
|
||||||
|
"Allows us to re-run quickrun from inside the quickrun buffer."
|
||||||
|
(let ((buffer (get-buffer quickrun/buffer-name))
|
||||||
|
window)
|
||||||
|
(when buffer
|
||||||
|
(setq window (get-buffer-window buffer))
|
||||||
|
(shut-up! (quickrun/kill-running-process))
|
||||||
|
(doom/popup-close window nil t))))
|
||||||
|
(advice-add 'quickrun :before 'doom*quickrun-close-popup)
|
||||||
|
(advice-add 'quickrun-region :before 'doom*quickrun-close-popup)
|
||||||
|
|
||||||
|
(defun doom|quickrun-after-run ()
|
||||||
|
"Ensures window is scrolled to BOF"
|
||||||
|
(with-selected-window (get-buffer-window quickrun/buffer-name)
|
||||||
|
(goto-char (point-min))))
|
||||||
|
(add-hook 'quickrun-after-run-hook 'doom|quickrun-after-run))
|
||||||
|
|
||||||
(use-package repl-toggle
|
(use-package repl-toggle
|
||||||
:commands (rtog/toggle-repl rtog/add-repl)
|
:commands (rtog/toggle-repl rtog/add-repl)
|
||||||
|
@ -76,7 +94,37 @@
|
||||||
|
|
||||||
;; TODO does this work with shackle?
|
;; TODO does this work with shackle?
|
||||||
(advice-add 'realgud-cmdbuf-init :after 'doom:def-debug-on)
|
(advice-add 'realgud-cmdbuf-init :after 'doom:def-debug-on)
|
||||||
(advice-add 'realgud:cmd-quit :after 'doom:def-debug-off))
|
(advice-add 'realgud:cmd-quit :after 'doom:def-debug-off)
|
||||||
|
|
||||||
|
;; Monkey-patch `realgud:run-process' to run in a popup.
|
||||||
|
;; TODO Find a more elegant advice-based solution
|
||||||
|
;; FIXME Causes realgud:cmd-* to focus popup on every invocation
|
||||||
|
(defun realgud:run-process(debugger-name script-filename cmd-args minibuffer-history &optional no-reset)
|
||||||
|
(let ((cmd-buf))
|
||||||
|
(setq cmd-buf
|
||||||
|
(apply 'realgud-exec-shell debugger-name script-filename
|
||||||
|
(car cmd-args) no-reset (cdr cmd-args)))
|
||||||
|
(let ((process (get-buffer-process cmd-buf)))
|
||||||
|
(if (and process (eq 'run (process-status process)))
|
||||||
|
(progn
|
||||||
|
(pop-to-buffer cmd-buf)
|
||||||
|
(define-key evil-emacs-state-local-map (kbd "ESC ESC") 'doom/debug-quit)
|
||||||
|
(realgud:track-set-debugger debugger-name)
|
||||||
|
(realgud-cmdbuf-info-in-debugger?= 't)
|
||||||
|
(realgud-cmdbuf-info-cmd-args= cmd-args)
|
||||||
|
(when cmd-buf
|
||||||
|
(switch-to-buffer cmd-buf)
|
||||||
|
(when realgud-cmdbuf-info
|
||||||
|
(let* ((info realgud-cmdbuf-info)
|
||||||
|
(cmd-args (realgud-cmdbuf-info-cmd-args info))
|
||||||
|
(cmd-str (mapconcat 'identity cmd-args " ")))
|
||||||
|
(set minibuffer-history
|
||||||
|
(list-utils-uniq (cons cmd-str (eval minibuffer-history))))))))
|
||||||
|
;; else
|
||||||
|
(progn
|
||||||
|
(if cmd-buf (switch-to-buffer cmd-buf))
|
||||||
|
(message "Error running command: %s" (mapconcat 'identity cmd-args " ")))))
|
||||||
|
cmd-buf)))
|
||||||
|
|
||||||
(provide 'core-eval)
|
(provide 'core-eval)
|
||||||
;;; core-eval.el ends here
|
;;; core-eval.el ends here
|
||||||
|
|
|
@ -69,108 +69,50 @@
|
||||||
(def-popup! "*evil-registers*" :align below :size 0.3)
|
(def-popup! "*evil-registers*" :align below :size 0.3)
|
||||||
(def-popup! "*Command Line*" :align below :size 8 :select t)
|
(def-popup! "*Command Line*" :align below :size 8 :select t)
|
||||||
|
|
||||||
;; Evil hacks
|
;;; Evil hacks
|
||||||
(progn ; evil hacks
|
;; Don't interfere with neotree + auto move to new split
|
||||||
(advice-add 'evil-force-normal-state :after 'doom*evil-esc-quit)
|
(advice-add 'evil-window-split :around 'doom*evil-window-split)
|
||||||
(defun doom*evil-esc-quit ()
|
(advice-add 'evil-window-vsplit :around 'doom*evil-window-vsplit)
|
||||||
"Close popups, disable search highlights and quit the minibuffer if open."
|
;; Integrate evil's command window into shackle
|
||||||
(if (eq major-mode 'help-mode)
|
(advice-add 'evil-command-window :override 'doom*evil-command-window)
|
||||||
(doom/popup-close)
|
(add-hook 'evil-command-window-mode-hook 'doom-hide-mode-line-mode)
|
||||||
(let ((minib-p (minibuffer-window-active-p (minibuffer-window)))
|
;; Close popups, disable search highlights and quit the minibuffer if open
|
||||||
(evil-hl-p (evil-ex-hl-active-p 'evil-ex-search)))
|
(advice-add 'evil-force-normal-state :after 'doom*evil-esc-quit)
|
||||||
(when minib-p (abort-recursive-edit))
|
|
||||||
(when evil-hl-p (evil-ex-nohighlight))
|
|
||||||
;; Close non-repl popups and clean up `doom-popup-windows'
|
|
||||||
(unless (or minib-p evil-hl-p
|
|
||||||
(memq (get-buffer-window) doom-popup-windows))
|
|
||||||
(mapc (lambda (w)
|
|
||||||
(if (window-live-p w)
|
|
||||||
(with-selected-window w
|
|
||||||
(unless (derived-mode-p 'comint-mode)
|
|
||||||
(doom/popup-close w)))
|
|
||||||
(doom/popup-remove w)))
|
|
||||||
doom-popup-windows)))))
|
|
||||||
|
|
||||||
;; Fix harmless (yet disruptive) error reporting w/ hidden buffers caused by
|
;; Fix harmless (yet disruptive) error reporting w/ hidden buffers caused by
|
||||||
;; workgroups killing windows
|
;; workgroups killing windows
|
||||||
;; TODO Delete timer on dead windows
|
;; TODO Delete timer on dead windows?
|
||||||
(defadvice evil-ex-hl-do-update-highlight
|
(defadvice evil-ex-hl-do-update-highlight
|
||||||
(around evil-ex-hidden-buffer-ignore-errors activate)
|
(around evil-ex-hidden-buffer-ignore-errors activate)
|
||||||
(ignore-errors ad-do-it))
|
(ignore-errors ad-do-it))
|
||||||
|
|
||||||
;; Hide keystroke display while isearch is active
|
;; Hide keystroke display while isearch is active
|
||||||
(add-hook! isearch-mode (setq echo-keystrokes 0))
|
(add-hook! isearch-mode (setq echo-keystrokes 0))
|
||||||
(add-hook! isearch-mode-end (setq echo-keystrokes 0.02))
|
(add-hook! isearch-mode-end (setq echo-keystrokes 0.02))
|
||||||
|
|
||||||
(after! evil-snipe
|
(after! evil-snipe
|
||||||
(def-repeat! evil-snipe-f evil-snipe-repeat evil-snipe-repeat-reverse)
|
(def-repeat! evil-snipe-f evil-snipe-repeat evil-snipe-repeat-reverse)
|
||||||
(def-repeat! evil-snipe-F evil-snipe-repeat evil-snipe-repeat-reverse)
|
(def-repeat! evil-snipe-F evil-snipe-repeat evil-snipe-repeat-reverse)
|
||||||
(def-repeat! evil-snipe-t evil-snipe-repeat evil-snipe-repeat-reverse)
|
(def-repeat! evil-snipe-t evil-snipe-repeat evil-snipe-repeat-reverse)
|
||||||
(def-repeat! evil-snipe-T evil-snipe-repeat evil-snipe-repeat-reverse)
|
(def-repeat! evil-snipe-T evil-snipe-repeat evil-snipe-repeat-reverse)
|
||||||
(def-repeat! evil-snipe-s evil-snipe-repeat evil-snipe-repeat-reverse)
|
(def-repeat! evil-snipe-s evil-snipe-repeat evil-snipe-repeat-reverse)
|
||||||
(def-repeat! evil-snipe-S evil-snipe-repeat evil-snipe-repeat-reverse)
|
(def-repeat! evil-snipe-S evil-snipe-repeat evil-snipe-repeat-reverse)
|
||||||
(def-repeat! evil-snipe-x evil-snipe-repeat evil-snipe-repeat-reverse)
|
(def-repeat! evil-snipe-x evil-snipe-repeat evil-snipe-repeat-reverse)
|
||||||
(def-repeat! evil-snipe-X evil-snipe-repeat evil-snipe-repeat-reverse))
|
(def-repeat! evil-snipe-X evil-snipe-repeat evil-snipe-repeat-reverse))
|
||||||
|
(after! evil-visualstar
|
||||||
|
(def-repeat! evil-visualstar/begin-search-forward
|
||||||
|
evil-ex-search-next evil-ex-search-previous)
|
||||||
|
(def-repeat! evil-visualstar/begin-search-backward
|
||||||
|
evil-ex-search-previous evil-ex-search-next))
|
||||||
|
(def-repeat! evil-ex-search-next evil-ex-search-next evil-ex-search-previous)
|
||||||
|
(def-repeat! evil-ex-search-previous evil-ex-search-next evil-ex-search-previous)
|
||||||
|
(def-repeat! evil-ex-search-forward evil-ex-search-next evil-ex-search-previous)
|
||||||
|
(def-repeat! evil-ex-search-backward evil-ex-search-next evil-ex-search-previous)
|
||||||
|
|
||||||
(after! evil-visualstar
|
;; monkey patch `evil-ex-replace-special-filenames' to add most of vim's file
|
||||||
(def-repeat! evil-visualstar/begin-search-forward
|
;; ex substitution flags to evil-mode
|
||||||
evil-ex-search-next evil-ex-search-previous)
|
(advice-add 'evil-ex-replace-special-filenames
|
||||||
(def-repeat! evil-visualstar/begin-search-backward
|
:override 'doom*evil-ex-replace-special-filenames)
|
||||||
evil-ex-search-previous evil-ex-search-next))
|
|
||||||
|
|
||||||
(def-repeat! evil-ex-search-next evil-ex-search-next evil-ex-search-previous)
|
|
||||||
(def-repeat! evil-ex-search-previous evil-ex-search-next evil-ex-search-previous)
|
|
||||||
(def-repeat! evil-ex-search-forward evil-ex-search-next evil-ex-search-previous)
|
|
||||||
(def-repeat! evil-ex-search-backward evil-ex-search-next evil-ex-search-previous)
|
|
||||||
|
|
||||||
;; A monkey patch to add all of vim's file ex substitution flags to evil-mode.
|
|
||||||
(defun evil-ex-replace-special-filenames (file-name)
|
|
||||||
"Replace special symbols in FILE-NAME."
|
|
||||||
(let ((case-fold-search nil)
|
|
||||||
(regexp (concat "\\(?:^\\|[^\\\\]\\)"
|
|
||||||
"\\([#%@]\\)"
|
|
||||||
"\\(\\(?::\\(?:[phtreS~.]\\|g?s[^: $]+\\)\\)*\\)")))
|
|
||||||
(dolist (match (s-match-strings-all regexp file-name))
|
|
||||||
(let ((flags (split-string (caddr match) ":" t))
|
|
||||||
(path (file-relative-name
|
|
||||||
(pcase (cadr match)
|
|
||||||
("@" (doom/project-root))
|
|
||||||
("%" (buffer-file-name))
|
|
||||||
("#" (and (other-buffer) (buffer-file-name (other-buffer)))))
|
|
||||||
default-directory))
|
|
||||||
flag global)
|
|
||||||
(when path
|
|
||||||
(while flags
|
|
||||||
(setq flag (pop flags))
|
|
||||||
(when (string-suffix-p "\\" flag)
|
|
||||||
(setq flag (concat flag (pop flags))))
|
|
||||||
(when (string-prefix-p "gs" flag)
|
|
||||||
(setq global t flag (string-remove-prefix "g" flag)))
|
|
||||||
(setq path
|
|
||||||
(or (pcase (substring flag 0 1)
|
|
||||||
("p" (expand-file-name path))
|
|
||||||
("~" (file-relative-name path "~"))
|
|
||||||
("." (file-relative-name path default-directory))
|
|
||||||
("h" (directory-file-name path))
|
|
||||||
("t" (file-name-nondirectory (directory-file-name path)))
|
|
||||||
("r" (file-name-sans-extension path))
|
|
||||||
("e" (file-name-extension path))
|
|
||||||
("s" (let* ((args (evil-delimited-arguments (substring flag 1) 2))
|
|
||||||
(pattern (evil-transform-vim-style-regexp (car args)))
|
|
||||||
(replace (cadr args)))
|
|
||||||
(replace-regexp-in-string
|
|
||||||
(if global pattern (concat "\\(" pattern "\\).*\\'"))
|
|
||||||
(evil-transform-vim-style-regexp replace) path t t
|
|
||||||
(unless global 1))))
|
|
||||||
("S" (shell-quote-argument path))
|
|
||||||
(t path))
|
|
||||||
"")))
|
|
||||||
(setq file-name
|
|
||||||
(replace-regexp-in-string (format "\\(?:^\\|[^\\\\]\\)\\(%s\\)"
|
|
||||||
(string-trim-left (car match)))
|
|
||||||
path file-name t t 1)))))
|
|
||||||
;; Clean up
|
|
||||||
(setq file-name (replace-regexp-in-string regexp "\\1" file-name t)))))
|
|
||||||
|
|
||||||
;; Extra argument types for highlight buffer (or global) regexp matches
|
;; Extra argument types for highlight buffer (or global) regexp matches
|
||||||
(evil-ex-define-argument-type buffer-match :runner doom/evil-ex-buffer-match)
|
(evil-ex-define-argument-type buffer-match :runner doom/evil-ex-buffer-match)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
;;; core-popup.el --- taming stray windows
|
;;; core-popup.el --- taming stray windows
|
||||||
|
|
||||||
;; I use a slew of hackery to get Emacs to treat 'pop-up' windows in a sane and "modern"
|
;; I use a slew of hackery to get Emacs to treat 'pop-ups' consistently. It goes
|
||||||
;; way (whatever that means). It goes through great lengths to tame helm, flycheck, help
|
;; through great lengths to tame helm, flycheck, help buffers--*even* the beast
|
||||||
;; buffers--*even* the beast that is org-mode.
|
;; that is org-mode.
|
||||||
;;
|
;;
|
||||||
;; Be warned, an update could break any of this.
|
;; Be warned, an update could break any of this.
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
("^\\*.+-Profiler-Report .+\\*$" :align below :size 0.3 :regexp t)
|
("^\\*.+-Profiler-Report .+\\*$" :align below :size 0.3 :regexp t)
|
||||||
("*esup*" :align below :size 0.4 :noselect t)
|
("*esup*" :align below :size 0.4 :noselect t)
|
||||||
("*minor-modes*" :align below :size 0.5 :noselect t)
|
("*minor-modes*" :align below :size 0.5 :noselect t)
|
||||||
("*eval*" :align below :size 20)
|
("*eval*" :align below :size 16 :noselect t)
|
||||||
;; Emacs
|
;; Emacs
|
||||||
("*Pp Eval Output*" :align below :size 0.3)
|
("*Pp Eval Output*" :align below :size 0.3)
|
||||||
("*Apropos*" :align below :size 0.3)
|
("*Apropos*" :align below :size 0.3)
|
||||||
|
@ -30,30 +30,24 @@
|
||||||
("*vc-change-log*" :align below :size 15 :select t)
|
("*vc-change-log*" :align below :size 15 :select t)
|
||||||
(vc-annotate-mode :same t)))
|
(vc-annotate-mode :same t)))
|
||||||
|
|
||||||
(defvar doom-popup-windows '()
|
;; :noesc = Can't be closed with a single ESC
|
||||||
"A list of windows that have been opened via shackle. Do not touch this!")
|
;; :nokill = Won't be killed when closed
|
||||||
(defvar doom-last-popup nil
|
;; :modeline = Show the modeline
|
||||||
"The last (important) popup buffer.")
|
(defvar doom-popup-rules
|
||||||
(defvar doom-prev-buffer nil
|
'(("^\\*doom\\*$" :noesc :nokill :modeline)
|
||||||
"The buffer from which the popup was invoked.")
|
("^\\*doom.*\\*$" :noesc :nokill)
|
||||||
(defvar-local doom-popup-protect nil
|
(compilation-mode :noesc)
|
||||||
"If non-nil, this popup buffer won't be killed when closed.")
|
(help-mode :noesc)
|
||||||
|
(comint-mode :noesc :nokill)
|
||||||
(defvar doom-popup-inescapable-modes
|
(eshell-mode :noesc :nokill)
|
||||||
'(compilation-mode comint-mode "^\\*doom.*\\*$")
|
(messages-buffer-mode :nokill)
|
||||||
"A list of modes that should not be closeable with a single ESC.")
|
(esup-mode :noesc)
|
||||||
(defvar doom-popup-protect-modes
|
(tabulated-list-mode :noesc)))
|
||||||
'(messages-buffer-mode esup-mode help-mode tabulated-list-mode comint-mode)
|
|
||||||
"A list of modes that shouldn't be killed and can be revived.")
|
|
||||||
|
|
||||||
;; There is no shackle-popup hook, so I hacked one in
|
;; There is no shackle-popup hook, so I hacked one in
|
||||||
(defvar doom-popup-pre-hook '() "Hooks run after a popup is opened.")
|
(advice-add 'shackle-display-buffer :around 'doom*popup-init)
|
||||||
(defvar doom-popup-post-hook '() "Hooks run before a popup is opened.")
|
;; Don't mess with popups
|
||||||
(advice-add 'shackle-display-buffer :before 'doom*run-popup-pre-hooks)
|
(advice-add 'balance-windows :around 'doom*save-popup)
|
||||||
(advice-add 'shackle-display-buffer :after 'doom*run-popup-post-hooks)
|
|
||||||
(add-hook 'doom-popup-post-hook 'doom|popup-init) ; Keep track of popups
|
|
||||||
(add-hook 'doom-popup-post-hook 'doom|hide-mode-line) ; No mode line in popups
|
|
||||||
;; Prevents popups from messaging with windows-moving functions
|
|
||||||
(advice-add 'doom/evil-window-move :around 'doom*save-popup))
|
(advice-add 'doom/evil-window-move :around 'doom*save-popup))
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,47 +55,11 @@
|
||||||
;; Hacks
|
;; Hacks
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(defun doom-popup-magit-hacks ()
|
|
||||||
;; Some wrassling must be done to get magit to kill itself, and trigger my
|
|
||||||
;; shackle popup hooks.
|
|
||||||
(setq magit-bury-buffer-function
|
|
||||||
(lambda (&rest _) (doom/popup-close (selected-window)))
|
|
||||||
magit-display-buffer-function
|
|
||||||
(lambda (b)
|
|
||||||
(funcall (if (doom/popup-p (selected-window)) 'switch-to-buffer 'doom/popup-buffer) b)
|
|
||||||
(get-buffer-window b))
|
|
||||||
magit-display-file-buffer-function
|
|
||||||
(lambda (b)
|
|
||||||
(when doom-prev-buffer
|
|
||||||
(select-window (get-buffer-window doom-prev-buffer)))
|
|
||||||
(switch-to-buffer b))))
|
|
||||||
|
|
||||||
(after! evil
|
|
||||||
;; The evil command window has a mind of its own (uses `switch-to-buffer'). We
|
|
||||||
;; monkey patch it to use pop-to-buffer.
|
|
||||||
(defun doom*evil-command-window (hist cmd-key execute-fn)
|
|
||||||
(when (eq major-mode 'evil-command-window-mode)
|
|
||||||
(user-error "Cannot recursively open command line window"))
|
|
||||||
(dolist (win (window-list))
|
|
||||||
(when (equal (buffer-name (window-buffer win))
|
|
||||||
"*Command Line*")
|
|
||||||
(kill-buffer (window-buffer win))
|
|
||||||
(delete-window win)))
|
|
||||||
(setq evil-command-window-current-buffer (current-buffer))
|
|
||||||
(ignore-errors (kill-buffer "*Command Line*"))
|
|
||||||
(with-current-buffer (pop-to-buffer "*Command Line*")
|
|
||||||
(setq-local evil-command-window-execute-fn execute-fn)
|
|
||||||
(setq-local evil-command-window-cmd-key cmd-key)
|
|
||||||
(evil-command-window-mode)
|
|
||||||
(evil-command-window-insert-commands hist)
|
|
||||||
(doom|hide-mode-line)))
|
|
||||||
(advice-add 'evil-command-window :override 'doom*evil-command-window))
|
|
||||||
|
|
||||||
(after! help-mode
|
(after! help-mode
|
||||||
;; Following links in help buffers sometimes uses itself or other-window. We
|
;; Following links in help buffers sometimes uses itself or other-window
|
||||||
;; want it only to replace the buffer we opened the popup from. To do this we
|
;; (annoying!). It should only replace the buffer we opened the popup from. To
|
||||||
;; must redefine these three button types to use `doom/popup-save' and
|
;; fix this these three button types need to be redefined to stow away the
|
||||||
;; `switch-to-buffer' rather than `pop-to-buffer'.
|
;; popups then follow the link from the last buffer, using `doom/popup-save'.
|
||||||
(define-button-type 'help-function-def
|
(define-button-type 'help-function-def
|
||||||
:supertype 'help-xref
|
:supertype 'help-xref
|
||||||
'help-function (lambda (fun file)
|
'help-function (lambda (fun file)
|
||||||
|
@ -111,11 +69,10 @@
|
||||||
(let ((location
|
(let ((location
|
||||||
(find-function-search-for-symbol fun nil file)))
|
(find-function-search-for-symbol fun nil file)))
|
||||||
(doom/popup-save
|
(doom/popup-save
|
||||||
(switch-to-buffer (car location)))
|
(switch-to-buffer (car location) nil t))
|
||||||
(if (cdr location)
|
(if (cdr location)
|
||||||
(goto-char (cdr location))
|
(goto-char (cdr location))
|
||||||
(message "Unable to find location in file"))))
|
(message "Unable to find location in file")))))
|
||||||
'help-echo (purecopy "mouse-2, RET: find function's definition"))
|
|
||||||
|
|
||||||
(define-button-type 'help-variable-def
|
(define-button-type 'help-variable-def
|
||||||
:supertype 'help-xref
|
:supertype 'help-xref
|
||||||
|
@ -124,11 +81,10 @@
|
||||||
(setq file (help-C-file-name var 'var)))
|
(setq file (help-C-file-name var 'var)))
|
||||||
(let ((location (find-variable-noselect var file)))
|
(let ((location (find-variable-noselect var file)))
|
||||||
(doom/popup-save
|
(doom/popup-save
|
||||||
(switch-to-buffer (car location)))
|
(switch-to-buffer (car location) nil t))
|
||||||
(if (cdr location)
|
(if (cdr location)
|
||||||
(goto-char (cdr location))
|
(goto-char (cdr location))
|
||||||
(message "Unable to find location in file"))))
|
(message "Unable to find location in file")))))
|
||||||
'help-echo (purecopy "mouse-2, RET: find variable's definition"))
|
|
||||||
|
|
||||||
(define-button-type 'help-face-def
|
(define-button-type 'help-face-def
|
||||||
:supertype 'help-xref
|
:supertype 'help-xref
|
||||||
|
@ -137,99 +93,10 @@
|
||||||
(let ((location
|
(let ((location
|
||||||
(find-function-search-for-symbol fun 'defface file)))
|
(find-function-search-for-symbol fun 'defface file)))
|
||||||
(doom/popup-save
|
(doom/popup-save
|
||||||
(switch-to-buffer (car location)))
|
(switch-to-buffer (car location) nil t))
|
||||||
(if (cdr location)
|
(if (cdr location)
|
||||||
(goto-char (cdr location))
|
(goto-char (cdr location))
|
||||||
(message "Unable to find location in file"))))
|
(message "Unable to find location in file"))))))
|
||||||
'help-echo (purecopy "mouse-2, RET: find face's definition")))
|
|
||||||
|
|
||||||
(after! quickrun
|
|
||||||
;; This allows us to rerun code from inside a quickrun buffer.
|
|
||||||
(defun doom*quickrun-close-popup (&optional _ _ _ _)
|
|
||||||
(let ((buffer (get-buffer quickrun/buffer-name))
|
|
||||||
window)
|
|
||||||
(when buffer
|
|
||||||
(setq window (get-buffer-window buffer))
|
|
||||||
(shut-up! (quickrun/kill-running-process))
|
|
||||||
(doom/popup-close window nil t))))
|
|
||||||
(advice-add 'quickrun :before 'doom*quickrun-close-popup)
|
|
||||||
(advice-add 'quickrun-region :before 'doom*quickrun-close-popup)
|
|
||||||
|
|
||||||
;; Ensures window is scrolled to BOF
|
|
||||||
(defun doom|quickrun-after-run ()
|
|
||||||
(with-selected-window (get-buffer-window quickrun/buffer-name)
|
|
||||||
(goto-char (point-min))))
|
|
||||||
(add-hook 'quickrun-after-run-hook 'doom|quickrun-after-run)
|
|
||||||
(add-hook 'quickrun/mode-hook 'doom|hide-mode-line))
|
|
||||||
|
|
||||||
(add-hook! org-load
|
|
||||||
;; Ensures org-src-edit yields control of its buffer to shackle.
|
|
||||||
(defun org-src-switch-to-buffer (buffer context)
|
|
||||||
(pop-to-buffer buffer))
|
|
||||||
|
|
||||||
;; And these for org-todo, org-link and org-agenda
|
|
||||||
(defun org-pop-to-buffer-same-window (&optional buffer-or-name norecord label)
|
|
||||||
"Pop to buffer specified by BUFFER-OR-NAME in the selected window."
|
|
||||||
(display-buffer buffer-or-name))
|
|
||||||
|
|
||||||
(defun org-switch-to-buffer-other-window (&rest args)
|
|
||||||
(mapc (lambda (b)
|
|
||||||
(let ((buf (if (stringp b) (get-buffer-create b) b)))
|
|
||||||
(pop-to-buffer buf t t)))
|
|
||||||
args))
|
|
||||||
|
|
||||||
;; Taming Org-agenda!
|
|
||||||
(defun doom/org-agenda-quit ()
|
|
||||||
"Necessary to finagle org-agenda into shackle popups and behave properly on quit."
|
|
||||||
(interactive)
|
|
||||||
(if org-agenda-columns-active
|
|
||||||
(org-columns-quit)
|
|
||||||
(let ((buf (current-buffer)))
|
|
||||||
(and (not (eq org-agenda-window-setup 'current-window))
|
|
||||||
(not (one-window-p))
|
|
||||||
(delete-window))
|
|
||||||
(kill-buffer buf)
|
|
||||||
(setq org-agenda-archives-mode nil
|
|
||||||
org-agenda-buffer nil))))
|
|
||||||
|
|
||||||
(after! org-agenda
|
|
||||||
(map! :map org-agenda-mode-map
|
|
||||||
:e "<escape>" 'doom/org-agenda-quit
|
|
||||||
:e "ESC" 'doom/org-agenda-quit
|
|
||||||
:e [escape] 'doom/org-agenda-quit
|
|
||||||
"q" 'doom/org-agenda-quit
|
|
||||||
"Q" 'doom/org-agenda-quit)))
|
|
||||||
|
|
||||||
(after! realgud
|
|
||||||
;; This allows realgud debuggers to run in a popup.
|
|
||||||
;; TODO Find a more elegant advice-based solution
|
|
||||||
;; FIXME Causes realgud:cmd-* to focus popup on every invocation
|
|
||||||
(defun realgud:run-process(debugger-name script-filename cmd-args minibuffer-history &optional no-reset)
|
|
||||||
(let ((cmd-buf))
|
|
||||||
(setq cmd-buf
|
|
||||||
(apply 'realgud-exec-shell debugger-name script-filename
|
|
||||||
(car cmd-args) no-reset (cdr cmd-args)))
|
|
||||||
(let ((process (get-buffer-process cmd-buf)))
|
|
||||||
(if (and process (eq 'run (process-status process)))
|
|
||||||
(progn
|
|
||||||
(pop-to-buffer cmd-buf)
|
|
||||||
(define-key evil-emacs-state-local-map (kbd "ESC ESC") 'doom/debug-quit)
|
|
||||||
(realgud:track-set-debugger debugger-name)
|
|
||||||
(realgud-cmdbuf-info-in-debugger?= 't)
|
|
||||||
(realgud-cmdbuf-info-cmd-args= cmd-args)
|
|
||||||
(when cmd-buf
|
|
||||||
(switch-to-buffer cmd-buf)
|
|
||||||
(when realgud-cmdbuf-info
|
|
||||||
(let* ((info realgud-cmdbuf-info)
|
|
||||||
(cmd-args (realgud-cmdbuf-info-cmd-args info))
|
|
||||||
(cmd-str (mapconcat 'identity cmd-args " ")))
|
|
||||||
(set minibuffer-history
|
|
||||||
(list-utils-uniq (cons cmd-str (eval minibuffer-history))))))))
|
|
||||||
;; else
|
|
||||||
(progn
|
|
||||||
(if cmd-buf (switch-to-buffer cmd-buf))
|
|
||||||
(message "Error running command: %s" (mapconcat 'identity cmd-args " ")))))
|
|
||||||
cmd-buf)))
|
|
||||||
|
|
||||||
(provide 'core-popup)
|
(provide 'core-popup)
|
||||||
;;; core-popup.el ends here
|
;;; core-popup.el ends here
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
neo-banner-message nil)
|
neo-banner-message nil)
|
||||||
:config
|
:config
|
||||||
(evil-set-initial-state 'neotree-mode 'motion)
|
(evil-set-initial-state 'neotree-mode 'motion)
|
||||||
(add-hook 'neo-after-create-hook 'doom|hide-mode-line)
|
(add-hook 'neo-after-create-hook 'doom-hide-mode-line-mode)
|
||||||
|
|
||||||
;; Don't mess with neotree on wg-related window-config changes
|
;; Don't mess with neotree on wg-related window-config changes
|
||||||
(advice-add 'doom/undo-window-change :around 'doom*save-neotree)
|
(advice-add 'doom/undo-window-change :around 'doom*save-neotree)
|
||||||
|
|
|
@ -69,8 +69,8 @@
|
||||||
(set-fontset-font t 'unicode doom-unicode-font))
|
(set-fontset-font t 'unicode doom-unicode-font))
|
||||||
|
|
||||||
;; Hide mode-line in help/compile window
|
;; Hide mode-line in help/compile window
|
||||||
(add-hook 'help-mode-hook 'doom|hide-mode-line)
|
(add-hook 'help-mode-hook 'doom-hide-mode-line-mode)
|
||||||
(add-hook 'compilation-mode-hook 'doom|hide-mode-line)
|
(add-hook 'compilation-mode-hook 'doom-hide-mode-line-mode)
|
||||||
|
|
||||||
;; On by default in Emacs 25. I'll enable it manually, so disable it globally
|
;; On by default in Emacs 25. I'll enable it manually, so disable it globally
|
||||||
(when (and (> emacs-major-version 24) (featurep 'eldoc))
|
(when (and (> emacs-major-version 24) (featurep 'eldoc))
|
||||||
|
|
|
@ -51,9 +51,23 @@
|
||||||
(use-package magit
|
(use-package magit
|
||||||
:commands (magit-status)
|
:commands (magit-status)
|
||||||
:config
|
:config
|
||||||
(doom-popup-magit-hacks)
|
|
||||||
(def-popup! (:custom (lambda (b &rest _) (derived-mode-p 'magit-mode)))
|
(def-popup! (:custom (lambda (b &rest _) (derived-mode-p 'magit-mode)))
|
||||||
:align below :size 0.5)
|
:align below :size 0.5)
|
||||||
|
|
||||||
|
;; Some wrassling must be done to get magit to kill itself, and trigger
|
||||||
|
;; shackle popup hooks.
|
||||||
|
(setq magit-bury-buffer-function
|
||||||
|
(lambda (&rest _) (doom/popup-close (selected-window)))
|
||||||
|
magit-display-buffer-function
|
||||||
|
(lambda (b)
|
||||||
|
(funcall (if (doom/popup-p (selected-window)) 'switch-to-buffer 'doom/popup-buffer) b)
|
||||||
|
(get-buffer-window b))
|
||||||
|
magit-display-file-buffer-function
|
||||||
|
(lambda (b)
|
||||||
|
(when doom-prev-buffer
|
||||||
|
(select-window (get-buffer-window doom-prev-buffer)))
|
||||||
|
(switch-to-buffer b)))
|
||||||
|
|
||||||
(add-hook 'magit-mode-hook 'turn-off-evil-snipe-override-mode)
|
(add-hook 'magit-mode-hook 'turn-off-evil-snipe-override-mode)
|
||||||
|
|
||||||
(require 'evil-magit)
|
(require 'evil-magit)
|
||||||
|
|
|
@ -170,5 +170,83 @@
|
||||||
(hs-toggle-hiding)
|
(hs-toggle-hiding)
|
||||||
(call-interactively 'evilmi-jump-items)))
|
(call-interactively 'evilmi-jump-items)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun doom*evil-command-window (hist cmd-key execute-fn)
|
||||||
|
"The evil command window has a mind of its own (uses `switch-to-buffer'). We
|
||||||
|
monkey patch it to use pop-to-buffer."
|
||||||
|
(when (eq major-mode 'evil-command-window-mode)
|
||||||
|
(user-error "Cannot recursively open command line window"))
|
||||||
|
(dolist (win (window-list))
|
||||||
|
(when (equal (buffer-name (window-buffer win))
|
||||||
|
"*Command Line*")
|
||||||
|
(kill-buffer (window-buffer win))
|
||||||
|
(delete-window win)))
|
||||||
|
(setq evil-command-window-current-buffer (current-buffer))
|
||||||
|
(ignore-errors (kill-buffer "*Command Line*"))
|
||||||
|
(with-current-buffer (pop-to-buffer "*Command Line*")
|
||||||
|
(setq-local evil-command-window-execute-fn execute-fn)
|
||||||
|
(setq-local evil-command-window-cmd-key cmd-key)
|
||||||
|
(evil-command-window-mode)
|
||||||
|
(evil-command-window-insert-commands hist)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun doom*evil-esc-quit ()
|
||||||
|
"Close popups, disable search highlights and quit the minibuffer if open."
|
||||||
|
(let ((minib-p (minibuffer-window-active-p (minibuffer-window)))
|
||||||
|
(evil-hl-p (evil-ex-hl-active-p 'evil-ex-search)))
|
||||||
|
(when minib-p (abort-recursive-edit))
|
||||||
|
(when evil-hl-p (evil-ex-nohighlight))
|
||||||
|
;; Close non-repl popups and clean up `doom-popup-windows'
|
||||||
|
(unless (or minib-p evil-hl-p (bound-and-true-p doom-popup-mode))
|
||||||
|
(doom/popup-close-all))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun doom*evil-ex-replace-special-filenames (file-name)
|
||||||
|
"Replace special symbols in FILE-NAME."
|
||||||
|
(let ((case-fold-search nil)
|
||||||
|
(regexp (concat "\\(?:^\\|[^\\\\]\\)"
|
||||||
|
"\\([#%@]\\)"
|
||||||
|
"\\(\\(?::\\(?:[phtreS~.]\\|g?s[^: $]+\\)\\)*\\)")))
|
||||||
|
(dolist (match (s-match-strings-all regexp file-name))
|
||||||
|
(let ((flags (split-string (caddr match) ":" t))
|
||||||
|
(path (file-relative-name
|
||||||
|
(pcase (cadr match)
|
||||||
|
("@" (doom/project-root))
|
||||||
|
("%" (buffer-file-name))
|
||||||
|
("#" (and (other-buffer) (buffer-file-name (other-buffer)))))
|
||||||
|
default-directory))
|
||||||
|
flag global)
|
||||||
|
(when path
|
||||||
|
(while flags
|
||||||
|
(setq flag (pop flags))
|
||||||
|
(when (string-suffix-p "\\" flag)
|
||||||
|
(setq flag (concat flag (pop flags))))
|
||||||
|
(when (string-prefix-p "gs" flag)
|
||||||
|
(setq global t flag (string-remove-prefix "g" flag)))
|
||||||
|
(setq path
|
||||||
|
(or (pcase (substring flag 0 1)
|
||||||
|
("p" (expand-file-name path))
|
||||||
|
("~" (file-relative-name path "~"))
|
||||||
|
("." (file-relative-name path default-directory))
|
||||||
|
("h" (directory-file-name path))
|
||||||
|
("t" (file-name-nondirectory (directory-file-name path)))
|
||||||
|
("r" (file-name-sans-extension path))
|
||||||
|
("e" (file-name-extension path))
|
||||||
|
("s" (let* ((args (evil-delimited-arguments (substring flag 1) 2))
|
||||||
|
(pattern (evil-transform-vim-style-regexp (car args)))
|
||||||
|
(replace (cadr args)))
|
||||||
|
(replace-regexp-in-string
|
||||||
|
(if global pattern (concat "\\(" pattern "\\).*\\'"))
|
||||||
|
(evil-transform-vim-style-regexp replace) path t t
|
||||||
|
(unless global 1))))
|
||||||
|
("S" (shell-quote-argument path))
|
||||||
|
(t path))
|
||||||
|
"")))
|
||||||
|
(setq file-name
|
||||||
|
(replace-regexp-in-string (format "\\(?:^\\|[^\\\\]\\)\\(%s\\)"
|
||||||
|
(string-trim-left (car match)))
|
||||||
|
path file-name t t 1)))))
|
||||||
|
(setq file-name (replace-regexp-in-string regexp "\\1" file-name t))))
|
||||||
|
|
||||||
(provide 'defuns-evil)
|
(provide 'defuns-evil)
|
||||||
;;; defuns-evil.el ends here
|
;;; defuns-evil.el ends here
|
||||||
|
|
|
@ -82,8 +82,7 @@ buffers."
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom*helm-hide-header (source &optional force)
|
(defun doom*helm-hide-header (source &optional force)
|
||||||
(setq header-line-format nil)
|
(doom-hide-mode-line-mode +1))
|
||||||
(doom|hide-mode-line))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom*helm-hide-source-header-maybe ()
|
(defun doom*helm-hide-source-header-maybe ()
|
||||||
|
|
|
@ -1,133 +1,159 @@
|
||||||
;;; defuns-popups.el
|
;;; defuns-popups.el
|
||||||
|
|
||||||
|
(defvar doom-last-popup nil
|
||||||
|
"The last popup buffer open (or group thereof).")
|
||||||
|
|
||||||
|
(defvar-local doom-popup-rule nil
|
||||||
|
"A list of rules applied to this popup.")
|
||||||
|
|
||||||
|
(defvar doom-popup-mode-map
|
||||||
|
(let ((map (make-sparse-keymap)))
|
||||||
|
(define-key map [remap doom/kill-real-buffer] 'doom/popup-close)
|
||||||
|
(define-key map [remap evil-window-move-very-bottom] 'ignore)
|
||||||
|
(define-key map [remap evil-window-move-very-top] 'ignore)
|
||||||
|
(define-key map [remap evil-window-move-far-left] 'ignore)
|
||||||
|
(define-key map [remap evil-window-move-far-right] 'ignore)
|
||||||
|
(define-key map [remap evil-window-split] 'ignore)
|
||||||
|
(define-key map [remap evil-window-vsplit] 'ignore)
|
||||||
|
map)
|
||||||
|
"Active keymap in popup windows.")
|
||||||
|
|
||||||
|
(advice-add 'doom/evil-window-move :around 'doom*popup-window-move)
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/popup-remove (window)
|
(defun doom*popup-window-move (orig-fn &rest args)
|
||||||
(setq doom-popup-windows (delete window doom-popup-windows))
|
(unless (doom/popup-p)
|
||||||
(unless (and doom-prev-buffer (not (buffer-live-p doom-prev-buffer)))
|
(apply orig-fn args)))
|
||||||
(setq doom-prev-buffer nil)))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/popup-p (&optional window)
|
(defun doom/popup-p (&optional window)
|
||||||
"Whether WINDOW is a shackle popup window or not."
|
"Whether WINDOW is a shackle popup window or not. If WINDOW is nil, use
|
||||||
(and doom-popup-windows
|
current window."
|
||||||
(--any? (if (window-live-p it) t (doom/popup-remove it) nil)
|
(let ((window (or window (selected-window))))
|
||||||
doom-popup-windows)
|
(and (window-live-p window)
|
||||||
(if window
|
(with-selected-window window (bound-and-true-p doom-popup-mode))
|
||||||
(memq window doom-popup-windows)
|
window)))
|
||||||
t)))
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun doom/popups-p ()
|
||||||
|
"Whether there is a popup window open and alive somewhere."
|
||||||
|
(and doom-last-popup
|
||||||
|
(window-live-p (get-buffer-window doom-last-popup))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defmacro doom/popup-save (&rest body)
|
(defmacro doom/popup-save (&rest body)
|
||||||
`(let ((popup-p (doom/popup-p)))
|
"Close popups before BODY and restore them afterwards."
|
||||||
(when popup-p (doom/popup-close-all t t))
|
`(let ((popup-p (doom/popups-p))
|
||||||
,@body
|
(in-popup-p (doom/popup-p)))
|
||||||
(when popup-p
|
(when popup-p
|
||||||
(save-selected-window
|
(doom/popup-close-all t t))
|
||||||
(doom/popup-last-buffer)))))
|
(prog1
|
||||||
|
,@body
|
||||||
|
(when popup-p
|
||||||
|
(if in-popup-p
|
||||||
|
(doom/popup-last-buffer)
|
||||||
|
(save-excursion (doom/popup-last-buffer)))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/popup-buffer (buffer &optional plist)
|
(defun doom/popup-buffer (buffer &optional plist)
|
||||||
"Display BUFFER in a shackle popup."
|
"Display BUFFER in a shackle popup."
|
||||||
(let* ((buffer-name (if (stringp buffer) buffer (buffer-name buffer)))
|
(let ((buffer-name (cond ((stringp buffer) buffer)
|
||||||
(buffer (get-buffer-create buffer-name)))
|
((bufferp buffer) (buffer-name buffer))
|
||||||
(shackle-display-buffer buffer nil (or plist (shackle-match buffer-name)))
|
(t (error "Not a valid buffer")))))
|
||||||
(setq doom-last-popup buffer)))
|
(shackle-display-buffer
|
||||||
|
(get-buffer-create buffer-name)
|
||||||
|
nil (or plist (shackle-match buffer-name)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/popup-close (&optional window dont-kill dont-redraw)
|
(defun doom/popup-close (&optional window dont-kill dont-redraw)
|
||||||
"Find and close the currently active popup (if available)."
|
"Find and close the currently active popup (if available)."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((dont-kill (or doom-popup-protect dont-kill)))
|
(setq window (or window (selected-window)))
|
||||||
(when (and (not window) (doom/popup-p (selected-window)))
|
(when (doom/popup-p window)
|
||||||
(setq window (selected-window)))
|
(with-selected-window window
|
||||||
(when (and window (window-live-p window))
|
;; If REPL...
|
||||||
;; REPL buffer
|
(when (bound-and-true-p repl-toggle-mode)
|
||||||
(cond ((and (derived-mode-p 'comint-mode)
|
(setq rtog/--last-buffer nil))
|
||||||
(featurep 'repl-toggle)
|
(if (not (or dont-kill (memq :nokill doom-popup-rule)))
|
||||||
repl-toggle-mode)
|
(let ((kill-buffer-query-functions
|
||||||
(setq rtog/--last-buffer nil))
|
(delq 'process-kill-buffer-query-function
|
||||||
((eq major-mode 'messages-buffer-mode)
|
kill-buffer-query-functions)))
|
||||||
(bury-buffer)
|
(kill-buffer (window-buffer window)))
|
||||||
(setq dont-kill t)))
|
(doom-popup-mode -1))
|
||||||
(doom/popup-remove window)
|
|
||||||
(unless dont-kill
|
|
||||||
(let ((kill-buffer-query-functions
|
|
||||||
(delq 'process-kill-buffer-query-function
|
|
||||||
kill-buffer-query-functions)))
|
|
||||||
(kill-buffer (window-buffer window))))
|
|
||||||
(delete-window window)
|
(delete-window window)
|
||||||
(unless (or dont-redraw (>= emacs-major-version 25))
|
(unless (and (< emacs-major-version 25) (not dont-redraw))
|
||||||
(redraw-frame)))))
|
(redraw-frame)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/popup-close-all (&optional dont-kill-buffers dont-redraw)
|
(defun doom/popup-close-all (&optional dont-kill dont-redraw)
|
||||||
"Closes all popup windows (and kills the buffers if DONT-KILL-BUFFERS is non-nil)"
|
"Closes all popups (kill them if DONT-KILL-BUFFERS is non-nil). Then redraw
|
||||||
|
the display (unless DONT-REDRAW is non-nil)."
|
||||||
(interactive)
|
(interactive)
|
||||||
(mapc (lambda (w) (doom/popup-close w dont-kill-buffers t))
|
(mapc (lambda (w) (doom/popup-close w dont-kill t))
|
||||||
doom-popup-windows)
|
(doom/get-visible-windows (buffer-list)))
|
||||||
(unless (or dont-redraw (>= emacs-major-version 25))
|
(when (< emacs-major-version 25)
|
||||||
(redraw-frame))
|
(unless dont-redraw
|
||||||
(setq doom-popup-windows nil))
|
(redraw-frame))))
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun doom/popup-toggle ()
|
|
||||||
"Toggles the popup window, reopening the last popup (if available)."
|
|
||||||
(interactive)
|
|
||||||
(if (doom/popup-p)
|
|
||||||
(doom/popup-close t)
|
|
||||||
(doom/popup-last-buffer)))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/popup-last-buffer ()
|
(defun doom/popup-last-buffer ()
|
||||||
"Pop up the last popup buffer."
|
"Restore the last popup."
|
||||||
(interactive)
|
(interactive)
|
||||||
(unless (and doom-last-popup
|
(unless (buffer-live-p doom-last-popup)
|
||||||
(buffer-live-p doom-last-popup))
|
|
||||||
(setq doom-last-popup nil)
|
(setq doom-last-popup nil)
|
||||||
(error "No popup to restore"))
|
(error "No popup to restore"))
|
||||||
(doom/popup-buffer doom-last-popup))
|
(doom/popup-buffer doom-last-popup))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/popup-messages ()
|
(defun doom/popup-messages ()
|
||||||
"Pop up the *Messages* buffer."
|
"Pop up the messages buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
(doom/popup-buffer "*Messages*")
|
(doom/popup-buffer (messages-buffer))
|
||||||
(with-current-buffer "*Messages*"
|
(goto-char (point-max)))
|
||||||
(doom|hide-mode-line)
|
|
||||||
(goto-char (point-max))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom*run-popup-pre-hooks (&rest _)
|
(defun doom*popup-init (orig-fn &rest args)
|
||||||
(unless (and doom-prev-buffer
|
"Enable `doom-popup-mode' in every popup window and returns the window."
|
||||||
(doom/popup-p (get-buffer-window doom-prev-buffer)))
|
(let ((window (apply orig-fn args)))
|
||||||
(setq doom-prev-buffer (current-buffer))))
|
(with-current-buffer (window-buffer window)
|
||||||
|
(doom-popup-mode +1))
|
||||||
;;;###autoload
|
;; NOTE orig-fn returns a window, so `doom*popup-init' must too
|
||||||
(defun doom*run-popup-post-hooks (&rest _)
|
window))
|
||||||
(with-current-buffer shackle-last-buffer
|
|
||||||
(run-hooks 'doom-popup-post-hook)))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun doom|popup-init ()
|
|
||||||
(add-to-list 'doom-popup-windows (get-buffer-window))
|
|
||||||
(unless (one-window-p)
|
|
||||||
(ignore-errors
|
|
||||||
(local-set-key [escape escape] 'doom/popup-close)
|
|
||||||
(let ((map evil-normal-state-local-map))
|
|
||||||
(define-key map [escape escape] 'doom/popup-close)
|
|
||||||
(unless (and (apply #'derived-mode-p doom-popup-inescapable-modes)
|
|
||||||
(--any? (string-match-p it (buffer-name)) (-filter 'stringp doom-popup-inescapable-modes)))
|
|
||||||
(define-key map [escape] 'doom/popup-close)
|
|
||||||
(define-key map (kbd "ESC") 'doom/popup-close)))
|
|
||||||
(when (or (apply #'derived-mode-p doom-popup-protect-modes)
|
|
||||||
(--any? (string-match-p it buffer-name) (-filter 'stringp doom-popup-protect-modes)))
|
|
||||||
(setq-local doom-popup-protect t)
|
|
||||||
(setq doom-last-popup (current-buffer))))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom*save-popup (orig-fun &rest args)
|
(defun doom*save-popup (orig-fun &rest args)
|
||||||
"Prevents messing up a popup buffer on window changes"
|
"Prevents messing up a popup buffer on window changes"
|
||||||
(doom/popup-save (apply orig-fun args)))
|
(doom/popup-save (apply orig-fun args)))
|
||||||
|
|
||||||
|
(put 'doom-popup-mode 'permanent-local t)
|
||||||
|
(put 'doom-popup-mode-map 'permanent-local t)
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(define-minor-mode doom-popup-mode
|
||||||
|
"Pop ups"
|
||||||
|
:init-value nil
|
||||||
|
:keymap doom-popup-mode-map
|
||||||
|
:global nil
|
||||||
|
(let ((rules (or doom-popup-rule
|
||||||
|
(--any (let ((key (car it)))
|
||||||
|
(when (cond ((symbolp key)
|
||||||
|
(or (eq major-mode key)
|
||||||
|
(derived-mode-p key)))
|
||||||
|
((and (stringp key) buffer-file-name)
|
||||||
|
(string-match-p key buffer-file-name)))
|
||||||
|
(cdr it)))
|
||||||
|
doom-popup-rules))))
|
||||||
|
(setq doom-last-popup (current-buffer))
|
||||||
|
(setq-local doom-popup-rule rules)
|
||||||
|
;; (set-window-dedicated-p (selected-window) doom-popup-mode)
|
||||||
|
(unless (memq :noesc rules)
|
||||||
|
(make-local-variable 'doom-popup-mode-map)
|
||||||
|
(let ((map doom-popup-mode-map))
|
||||||
|
(define-key map [remap evil-force-normal-state] 'doom/popup-close)
|
||||||
|
(define-key map [escape] 'doom/popup-close)
|
||||||
|
(define-key map (kbd "ESC") 'doom/popup-close)))
|
||||||
|
(unless (memq :modeline rules)
|
||||||
|
(doom-hide-mode-line-mode (if doom-popup-mode +1 -1)))))
|
||||||
|
|
||||||
(provide 'defuns-popups)
|
(provide 'defuns-popups)
|
||||||
;;; defuns-popups.el ends here
|
;;; defuns-popups.el ends here
|
||||||
|
|
|
@ -61,10 +61,6 @@
|
||||||
(imenu-list-minor-mode -1))))
|
(imenu-list-minor-mode -1))))
|
||||||
(doom/get-visible-buffers (doom/get-real-buffers))))
|
(doom/get-visible-buffers (doom/get-real-buffers))))
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun doom|hide-mode-line (&rest _)
|
|
||||||
(setq mode-line-format nil))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/eldoc-show-in-mode-line (input)
|
(defun doom/eldoc-show-in-mode-line (input)
|
||||||
"Display string STR in the mode-line next to minibuffer."
|
"Display string STR in the mode-line next to minibuffer."
|
||||||
|
@ -92,5 +88,23 @@
|
||||||
(sit-for eldoc-show-in-mode-line-delay))))
|
(sit-for eldoc-show-in-mode-line-delay))))
|
||||||
(force-mode-line-update)))
|
(force-mode-line-update)))
|
||||||
|
|
||||||
|
(defvar-local doom-hide-mode-line nil)
|
||||||
|
(defvar-local doom--mode-line nil)
|
||||||
|
;;;###autoload
|
||||||
|
(define-minor-mode doom-hide-mode-line-mode
|
||||||
|
"Minor mode to hide the mode-line in the current buffer."
|
||||||
|
:init-value nil
|
||||||
|
:global nil
|
||||||
|
:variable doom-hide-mode-line
|
||||||
|
(if doom-hide-mode-line
|
||||||
|
(setq doom--mode-line mode-line-format
|
||||||
|
mode-line-format nil)
|
||||||
|
(setq mode-line-format doom--mode-line
|
||||||
|
doom--mode-line nil))
|
||||||
|
(force-mode-line-update)
|
||||||
|
;; Apparently force-mode-line-update is not always enough to
|
||||||
|
;; redisplay the mode-line
|
||||||
|
(redraw-display))
|
||||||
|
|
||||||
(provide 'defuns-ui)
|
(provide 'defuns-ui)
|
||||||
;;; defuns-ui.el ends here
|
;;; defuns-ui.el ends here
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
;;; defuns-window.el --- library for acting on windows
|
;;; defuns-window.el --- library for acting on windows
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/evil-window-split ()
|
(defun doom*evil-window-split (orig-fn &rest args)
|
||||||
(interactive)
|
(interactive)
|
||||||
(doom/neotree-save
|
(doom/neotree-save
|
||||||
(call-interactively 'evil-window-split)
|
(apply orig-fn args)
|
||||||
(evil-window-down 1)))
|
(evil-window-down 1)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/evil-window-vsplit ()
|
(defun doom*evil-window-vsplit (orig-fn &rest args)
|
||||||
(interactive)
|
(interactive)
|
||||||
(doom/neotree-save
|
(doom/neotree-save
|
||||||
(call-interactively 'evil-window-vsplit)
|
(apply orig-fn args)
|
||||||
(evil-window-right 1)))
|
(evil-window-right 1)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
|
@ -194,15 +194,15 @@
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/close-window-or-workgroup ()
|
(defun doom/close-window-or-workgroup ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (memq (get-buffer-window) doom-popup-windows)
|
(if (doom/popup-p)
|
||||||
(doom/popup-close)
|
(doom/popup-close)
|
||||||
(doom/kill-real-buffer)
|
(when (doom/kill-real-buffer)
|
||||||
(if (and (one-window-p t)
|
(if (and (one-window-p t)
|
||||||
(> (length (wg-workgroup-list)) 1))
|
(> (length (wg-workgroup-list)) 1))
|
||||||
(if (string= (wg-workgroup-name (wg-current-workgroup)) wg-first-wg-name)
|
(if (string= (wg-workgroup-name (wg-current-workgroup)) wg-first-wg-name)
|
||||||
(evil-window-delete)
|
(evil-window-delete)
|
||||||
(doom:workgroup-delete))
|
(doom:workgroup-delete))
|
||||||
(evil-window-delete))))
|
(evil-window-delete)))))
|
||||||
|
|
||||||
(provide 'defuns-workgroup)
|
(provide 'defuns-workgroup)
|
||||||
;;; defuns-workgroup.el ends here
|
;;; defuns-workgroup.el ends here
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
:n "tr" 'doom/ert-rerun-test
|
:n "tr" 'doom/ert-rerun-test
|
||||||
:n "ta" 'doom/ert-run-all-tests
|
:n "ta" 'doom/ert-run-all-tests
|
||||||
:n "ts" 'doom/ert-run-test)
|
:n "ts" 'doom/ert-run-test)
|
||||||
(add-hook 'ert-results-mode-hook 'doom|hide-mode-line))
|
(add-hook 'ert-results-mode-hook 'doom-hide-mode-line-mode))
|
||||||
|
|
||||||
(provide 'module-elisp)
|
(provide 'module-elisp)
|
||||||
;;; module-elisp.el ends here
|
;;; module-elisp.el ends here
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
:when IS-MAC
|
:when IS-MAC
|
||||||
:commands (processing-mode processing-find-sketch)
|
:commands (processing-mode processing-find-sketch)
|
||||||
:mode "\\.pde$"
|
:mode "\\.pde$"
|
||||||
:init (add-hook 'processing-compilation-mode-hook 'doom|hide-mode-line)
|
:init (add-hook 'processing-compilation-mode-hook 'doom-hide-mode-line-mode)
|
||||||
:config
|
:config
|
||||||
(def-builder! processing-mode processing-sketch-build)
|
(def-builder! processing-mode processing-sketch-build)
|
||||||
(def-popup! "*processing-compilation*" :align below :size 10 :noselect t)
|
(def-popup! "*processing-compilation*" :align below :size 10 :noselect t)
|
||||||
|
|
|
@ -14,9 +14,8 @@
|
||||||
"M-/" 'evil-commentary-line
|
"M-/" 'evil-commentary-line
|
||||||
"A-/" 'evil-commentary-line
|
"A-/" 'evil-commentary-line
|
||||||
"M-b" 'doom:build
|
"M-b" 'doom:build
|
||||||
"A-`" 'os-switch-to-term
|
"C-`" 'doom/popup-last-buffer
|
||||||
"C-`" 'doom/popup-toggle
|
"M-~" 'doom/eshell
|
||||||
"C-~" 'doom:repl
|
|
||||||
;; Text-scaling
|
;; Text-scaling
|
||||||
"M-0" (λ! (text-scale-set 0))
|
"M-0" (λ! (text-scale-set 0))
|
||||||
"M-=" 'text-scale-increase
|
"M-=" 'text-scale-increase
|
||||||
|
@ -304,7 +303,7 @@
|
||||||
;; help-mode
|
;; help-mode
|
||||||
(:after help-mode
|
(:after help-mode
|
||||||
(:map help-map
|
(:map help-map
|
||||||
"e" 'doom/popup-messages)
|
"e" 'view-echo-area-messages)
|
||||||
(:map help-mode-map
|
(:map help-mode-map
|
||||||
:n "]]" 'help-go-forward
|
:n "]]" 'help-go-forward
|
||||||
:n "[[" 'help-go-back
|
:n "[[" 'help-go-back
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue