Fix 'command not found' errors for hidden commands

This commit is contained in:
Henrik Lissner 2019-07-22 04:46:14 +02:00
parent c24567a545
commit 1c4215c187
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
15 changed files with 120 additions and 106 deletions

View file

@ -27,7 +27,7 @@
;;; Core functions
;; Don't try to resize popup windows
(advice-add #'balance-windows :around #'+popup*save)
(advice-add #'balance-windows :around #'+popup-save-a)
;;
@ -100,11 +100,11 @@ the command buffer."
(setq evil-command-window-current-buffer nil)))
;; Don't mess with popups
(advice-add #'+evil--window-swap :around #'+popup*save)
(advice-add #'evil-window-move-very-bottom :around #'+popup*save)
(advice-add #'evil-window-move-very-top :around #'+popup*save)
(advice-add #'evil-window-move-far-left :around #'+popup*save)
(advice-add #'evil-window-move-far-right :around #'+popup*save))
(advice-add #'+evil--window-swap :around #'+popup-save-a)
(advice-add #'evil-window-move-very-bottom :around #'+popup-save-a)
(advice-add #'evil-window-move-very-top :around #'+popup-save-a)
(advice-add #'evil-window-move-far-left :around #'+popup-save-a)
(advice-add #'evil-window-move-far-right :around #'+popup-save-a))
;;;###package help-mode
@ -169,7 +169,7 @@ the command buffer."
;;;###package helm
;;;###package helm-ag
(when (featurep! :completion helm)
(setq helm-default-display-buffer-functions '(+popup-display-buffer-stacked-side-window))
(setq helm-default-display-buffer-functions '(+popup-display-buffer-stacked-side-window-fn))
;; Fix #897: "cannot open side window" error when TAB-completing file links
(def-advice! +popup--helm-hide-org-links-popup-a (orig-fn &rest args)
@ -318,13 +318,13 @@ instead of switch-to-buffer-*."
;;;###package pdf-tools
(after! pdf-tools
(setq tablist-context-window-display-action
'((+popup-display-buffer-stacked-side-window)
'((+popup-display-buffer-stacked-side-window-fn)
(side . left)
(slot . 2)
(window-height . 0.3)
(inhibit-same-window . t))
pdf-annot-list-display-buffer-action
'((+popup-display-buffer-stacked-side-window)
'((+popup-display-buffer-stacked-side-window-fn)
(side . left)
(slot . 3)
(inhibit-same-window . t)))
@ -344,8 +344,8 @@ instead of switch-to-buffer-*."
;;;###package wgrep
(progn
;; close the popup after you're done with a wgrep buffer
(advice-add #'wgrep-abort-changes :after #'+popup*close)
(advice-add #'wgrep-finish-edit :after #'+popup*close))
(advice-add #'wgrep-abort-changes :after #'+popup-close-a)
(advice-add #'wgrep-finish-edit :after #'+popup-close-a))
;;;###package which-key
@ -358,7 +358,7 @@ instead of switch-to-buffer-*."
(lambda (act-popup-dim)
(cl-letf (((symbol-function 'display-buffer-in-side-window)
(lambda (buffer alist)
(+popup-display-buffer-stacked-side-window
(+popup-display-buffer-stacked-side-window-fn
buffer (append '((vslot . -9999)) alist)))))
(which-key--show-buffer-side-window act-popup-dim))))))

View file

@ -88,7 +88,7 @@ The mode-line is hidden in popups, by default. To disable this, you can either:
#+BEGIN_SRC emacs-lisp
;; in ~/.doom.d/config.el
(remove-hook '+popup-buffer-mode-hook #'+popup|set-modeline-on-enable)
(remove-hook '+popup-buffer-mode-hook #'+popup-set-modeline-on-enable-h)
#+END_SRC
* Appendix
@ -112,10 +112,10 @@ The mode-line is hidden in popups, by default. To disable this, you can either:
+ ~without-popups!~
+ ~save-popups!~
+ Hooks
+ ~+popup|adjust-fringes~
+ ~+popup-adjust-fringes-h~
+ ~+popup|set-modeline~
+ ~+popup|close-on-escape~
+ ~+popup|cleanup-rules~
+ ~+popup-close-on-escape-h~
+ ~+popup-cleanup-rules-h~
+ Minor modes
+ ~+popup-mode~
+ ~+popup-buffer-mode~

View file

@ -15,7 +15,7 @@
the buffer is visible, then set another timer and try again later."
(when (buffer-live-p buffer)
(let ((inhibit-quit t)
(kill-buffer-hook (remq '+popup|kill-buffer-hook kill-buffer-hook)))
(kill-buffer-hook (remq '+popup-kill-buffer-hook-h kill-buffer-hook)))
(cond ((get-buffer-window buffer t)
(with-current-buffer buffer
(setq +popup--timer
@ -68,7 +68,7 @@ the buffer is visible, then set another timer and try again later."
(signal 'wrong-type-argument (list 'integerp ttl)))
((= ttl 0)
(+popup--kill-buffer buffer 0))
((add-hook 'kill-buffer-hook #'+popup|kill-buffer-hook nil t)
((add-hook 'kill-buffer-hook #'+popup-kill-buffer-hook-h nil t)
(setq +popup--timer
(run-at-time ttl nil #'+popup--kill-buffer
buffer ttl))))))))))
@ -102,7 +102,20 @@ the buffer is visible, then set another timer and try again later."
(setf (alist-get param alist) size))
(setf (alist-get 'window-parameters alist)
parameters)
alist)))
;; Fixes #1305: addresses an edge case where a popup with a :size, :width
;; or :height greater than the current frame's dimensions causes
;; hanging/freezing (a bug in Emacs' `display-buffer' API perhaps?)
(let ((width (cdr (assq 'window-width alist)))
(height (cdr (assq 'window-height alist))))
(setf (alist-get 'window-width alist)
(if (numberp width)
(min width (frame-width))
width))
(setf (alist-get 'window-height alist)
(if (numberp height)
(min height (frame-height))
height))
alist))))
(defun +popup--split-window (window size side)
"Ensure a non-dedicated/popup window is selected when splitting a window."
@ -233,14 +246,14 @@ Uses `shrink-window-if-larger-than-buffer'."
;; Hooks
;;;###autoload
(defun +popup|adjust-fringes ()
(defun +popup-adjust-fringes-h ()
"Hides the fringe in popup windows, restoring them if `+popup-buffer-mode' is
disabled."
(let ((f (if (bound-and-true-p +popup-buffer-mode) 0)))
(set-window-fringes nil f f fringes-outside-margins)))
;;;###autoload
(defun +popup|adjust-margins ()
(defun +popup-adjust-margins-h ()
"Creates padding for the popup window determined by `+popup-margin-width',
restoring it if `+popup-buffer-mode' is disabled."
(when +popup-margin-width
@ -250,7 +263,7 @@ restoring it if `+popup-buffer-mode' is disabled."
(defvar hide-mode-line-format)
;;;###autoload
(defun +popup|set-modeline-on-enable ()
(defun +popup-set-modeline-on-enable-h ()
"Don't show modeline in popup windows without a `modeline' window-parameter.
Possible values for this parameter are:
@ -271,17 +284,17 @@ Any non-nil value besides the above will be used as the raw value for
(funcall modeline)
modeline)))
(hide-mode-line-mode +1)))))))
(put '+popup|set-modeline-on-enable 'permanent-local-hook t)
(put '+popup-set-modeline-on-enable-h 'permanent-local-hook t)
;;;###autoload
(defun +popup|unset-modeline-on-disable ()
(defun +popup-unset-modeline-on-disable-h ()
"Restore the modeline when `+popup-buffer-mode' is deactivated."
(when (and (not (bound-and-true-p +popup-buffer-mode))
(bound-and-true-p hide-mode-line-mode))
(hide-mode-line-mode -1)))
;;;###autoload
(defun +popup|close-on-escape ()
(defun +popup-close-on-escape-h ()
"If called inside a popup, try to close that popup window (see
`+popup/close'). If called outside, try to close all popup windows (see
`+popup/close-all')."
@ -290,7 +303,7 @@ Any non-nil value besides the above will be used as the raw value for
(+popup/close-all)))
;;;###autoload
(defun +popup|cleanup-rules ()
(defun +popup-cleanup-rules-h ()
"Cleans up any duplicate popup rules."
(interactive)
(setq +popup--display-buffer-alist
@ -300,7 +313,7 @@ Any non-nil value besides the above will be used as the raw value for
(setq display-buffer-alist +popup--display-buffer-alist)))
;;;###autoload
(defun +popup|kill-buffer-hook ()
(defun +popup-kill-buffer-hook-h ()
"TODO"
(when-let (window (get-buffer-window))
(when (+popup-window-p window)
@ -319,7 +332,7 @@ Any non-nil value besides the above will be used as the raw value for
"Open this buffer in a popup window."
(interactive)
(let ((+popup-default-display-buffer-actions
'(+popup-display-buffer-stacked-side-window))
'(+popup-display-buffer-stacked-side-window-fn))
(display-buffer-alist +popup--display-buffer-alist)
(buffer (current-buffer)))
(push (+popup--make "." +popup-defaults) display-buffer-alist)
@ -425,21 +438,21 @@ the message buffer in a popup window."
;;
;; Advice
;;; Advice
;;;###autoload
(defun +popup*close (&rest _)
(defun +popup-close-a (&rest _)
"TODO"
(+popup/close nil t))
;;;###autoload
(defun +popup*save (orig-fn &rest args)
(defun +popup-save-a (orig-fn &rest args)
"Sets aside all popups before executing the original function, usually to
prevent the popup(s) from messing up the UI (or vice versa)."
(save-popups! (apply orig-fn args)))
;;;###autoload
(defun +popup-display-buffer-fullframe (buffer alist)
(defun +popup-display-buffer-fullframe-fn (buffer alist)
"Displays the buffer fullscreen."
(let ((wconf (current-window-configuration)))
(when-let (window (or (display-buffer-reuse-window buffer alist)
@ -452,7 +465,7 @@ prevent the popup(s) from messing up the UI (or vice versa)."
window)))
;;;###autoload
(defun +popup-display-buffer-stacked-side-window (buffer alist)
(defun +popup-display-buffer-stacked-side-window-fn (buffer alist)
"A `display-buffer' action that serves as an alternative to
`display-buffer-in-side-window', but allows for stacking popups with the `vslot'
alist entry.
@ -587,16 +600,17 @@ Accepts the same arguments as `display-buffer-in-side-window'. You must set
;; Emacs backwards compatibility
(unless EMACS27+
(defun +popup*set-window-dedicated (window)
(def-advice! +popup-set-window-dedicated-a (window)
"Ensure `window--dispaly-buffer' respects `display-buffer-mark-dedicated'.
This was not so until recent Emacs 27 builds, where it causes breaking errors.
This advice ensures backwards compatibility for Emacs <= 26 users."
:filter-return #'window--display-buffer
(when (and (windowp window) display-buffer-mark-dedicated)
(set-window-dedicated-p window display-buffer-mark-dedicated))
window)
(advice-add #'window--display-buffer :filter-return #'+popup*set-window-dedicated))
window))
;; DEPRECATED
(unless EMACS26+
(defvar window-sides-reversed nil)

View file

@ -74,7 +74,7 @@ PLIST can be made up of any of the following properties:
:side 'bottom|'top|'left|'right
Which side of the frame to open the popup on. This is only respected if
`+popup-display-buffer-stacked-side-window' or `display-buffer-in-side-window'
`+popup-display-buffer-stacked-side-window-fn' or `display-buffer-in-side-window'
is in :actions or `+popup-default-display-buffer-actions'.
:size/:width/:height FLOAT|INT|FN
@ -93,7 +93,7 @@ PLIST can be made up of any of the following properties:
:slot/:vslot INT
(This only applies to popups with a :side and only if :actions is blank or
contains the `+popup-display-buffer-stacked-side-window' action) These control
contains the `+popup-display-buffer-stacked-side-window-fn' action) These control
how multiple popups are laid out. INT can be any integer, positive and
negative.

View file

@ -5,7 +5,7 @@
Modifying this has no effect, unless done before ui/popup loads.")
(defvar +popup-default-display-buffer-actions
'(+popup-display-buffer-stacked-side-window)
'(+popup-display-buffer-stacked-side-window-fn)
"The functions to use to display the popup buffer.")
(defvar +popup-default-alist
@ -55,17 +55,17 @@ adjustment.")
:global t
:keymap +popup-mode-map
(cond (+popup-mode
(add-hook 'doom-escape-hook #'+popup|close-on-escape t)
(add-hook 'doom-escape-hook #'+popup-close-on-escape-h t)
(setq +popup--old-display-buffer-alist display-buffer-alist
display-buffer-alist +popup--display-buffer-alist
window--sides-inhibit-check t)
(dolist (prop +popup-window-parameters)
(push (cons prop 'writable) window-persistent-parameters)))
(t
(remove-hook 'doom-escape-hook #'+popup|close-on-escape)
(remove-hook 'doom-escape-hook #'+popup-close-on-escape-h)
(setq display-buffer-alist +popup--old-display-buffer-alist
window--sides-inhibit-check nil)
(+popup|cleanup-rules)
(+popup-cleanup-rules-h)
(dolist (prop +popup-window-parameters)
(delq (assq prop window-persistent-parameters)
window-persistent-parameters)))))
@ -78,16 +78,16 @@ that window has been changed or closed."
:init-value nil
:keymap +popup-buffer-mode-map
(if (not +popup-buffer-mode)
(remove-hook 'after-change-major-mode-hook #'+popup|set-modeline-on-enable t)
(add-hook 'after-change-major-mode-hook #'+popup|set-modeline-on-enable nil t)
(remove-hook 'after-change-major-mode-hook #'+popup-set-modeline-on-enable-h t)
(add-hook 'after-change-major-mode-hook #'+popup-set-modeline-on-enable-h nil t)
(when (timerp +popup--timer)
(remove-hook 'kill-buffer-hook #'+popup|kill-buffer-hook t)
(remove-hook 'kill-buffer-hook #'+popup-kill-buffer-hook-h t)
(cancel-timer +popup--timer)
(setq +popup--timer nil))))
(put '+popup-buffer-mode 'permanent-local t)
(put '+popup-buffer-mode 'permanent-local-hook t)
(put '+popup|set-modeline-on-enable 'permanent-local-hook t)
(put '+popup-set-modeline-on-enable-h 'permanent-local-hook t)
;;
@ -155,17 +155,18 @@ prevent the popup(s) from messing up the UI (or vice versa)."
:vslot -11 :size 0.35 :select t)
("^\\*info\\*$" ; `Info-mode'
:slot 2 :vslot 2 :size 0.45 :select t)))
'(("^\\*Backtrace" :vslot 99 :size 0.4 :quit nil)
'(("^\\*Warnings" :vslot 99 :size 0.25)
("^\\*Backtrace" :vslot 99 :size 0.4 :quit nil)
("^\\*CPU-Profiler-Report " :side bottom :vslot 100 :slot 1 :height 0.4 :width 0.5 :quit nil)
("^\\*Memory-Profiler-Report " :side bottom :vslot 100 :slot 2 :height 0.4 :width 0.5 :quit nil)))
(add-hook 'doom-init-ui-hook #'+popup-mode :append)
(add-hook! '+popup-buffer-mode-hook
#'(+popup|adjust-fringes
+popup|adjust-margins
+popup|set-modeline-on-enable
+popup|unset-modeline-on-disable))
#'(+popup-adjust-fringes-h
+popup-adjust-margins-h
+popup-set-modeline-on-enable-h
+popup-unset-modeline-on-disable-h))
;;

View file

@ -21,7 +21,7 @@
(before-each
(setq display-buffer-alist nil
+popup--display-buffer-alist nil
+popup-default-display-buffer-actions '(+popup-display-buffer-stacked-side-window)
+popup-default-display-buffer-actions '(+popup-display-buffer-stacked-side-window-fn)
+popup-defaults '(:side bottom :select ignore :ttl nil :slot 1 :vslot 1)))
(after-each
(set-window-configuration wconf))