💥 revise advice naming convention (1/2)
This is first of three big naming convention updates that have been a long time coming. With 2.1 on the horizon, all the breaking updates will batched together in preparation for the long haul. In this commit, we do away with the asterix to communicate that a function is an advice function, and we replace it with the '-a' suffix. e.g. doom*shut-up -> doom-shut-up-a doom*recenter -> doom-recenter-a +evil*static-reindent -> +evil--static-reindent-a The rationale behind this change is: 1. Elisp's own formatting/indenting tools would occasionally struggle with | and * (particularly pp and cl-prettyprint). They have no problem with / and :, fortunately. 2. External syntax highlighters (like pygmentize, discord markdown or github markdown) struggle with it, sometimes refusing to highlight code beyond these symbols. 3. * and | are less expressive than - and -- in communicating the intended visibility, versatility and stability of a function. 4. It complicated the regexps we must use to search for them. 5. They were arbitrary and over-complicated to begin with, decided on haphazardly way back when Doom was simply "my private config". Anyhow, like how predicate functions have the -p suffix, we'll adopt the -a suffix for advice functions, -h for hook functions and -fn for variable functions. Other noteable changes: - Replaces advice-{add,remove}! macro with new def-advice! macro. The old pair weren't as useful. The new def-advice! saves on a lot of space. - Removed "stage" assertions to make sure you were using the right macros in the right place. Turned out to not be necessary, we'll employ better checks later.
This commit is contained in:
parent
e3a102d05a
commit
51d3b1b424
44 changed files with 398 additions and 484 deletions
|
@ -332,15 +332,14 @@
|
||||||
(when doom-modules
|
(when doom-modules
|
||||||
(section! "Checking your enabled modules...")
|
(section! "Checking your enabled modules...")
|
||||||
(let ((indent (+ indent 2)))
|
(let ((indent (+ indent 2)))
|
||||||
(advice-add #'require :around #'doom*shut-up)
|
(advice-add #'require :around #'doom-shut-up-a)
|
||||||
(maphash
|
(maphash
|
||||||
(lambda (key plist)
|
(lambda (key plist)
|
||||||
(let ((prefix (format! (bold "(%s %s) " (car key) (cdr key)))))
|
(let ((prefix (format! (bold "(%s %s) " (car key) (cdr key)))))
|
||||||
(condition-case-unless-debug ex
|
(condition-case-unless-debug ex
|
||||||
(let ((doctor-file (doom-module-path (car key) (cdr key) "doctor.el"))
|
(let ((doctor-file (doom-module-path (car key) (cdr key) "doctor.el"))
|
||||||
(packages-file (doom-module-path (car key) (cdr key) "packages.el")))
|
(packages-file (doom-module-path (car key) (cdr key) "packages.el")))
|
||||||
(cl-loop with doom--stage = 'packages
|
(cl-loop for name in (let (doom-packages
|
||||||
for name in (let (doom-packages
|
|
||||||
doom-disabled-packages)
|
doom-disabled-packages)
|
||||||
(load packages-file 'noerror 'nomessage)
|
(load packages-file 'noerror 'nomessage)
|
||||||
(mapcar #'car doom-packages))
|
(mapcar #'car doom-packages))
|
||||||
|
@ -350,8 +349,7 @@
|
||||||
(package-built-in-p name)
|
(package-built-in-p name)
|
||||||
(package-installed-p name))
|
(package-installed-p name))
|
||||||
do (error! "%s is not installed" name))
|
do (error! "%s is not installed" name))
|
||||||
(let ((doom--stage 'doctor))
|
(load doctor-file 'noerror 'nomessage))
|
||||||
(load doctor-file 'noerror 'nomessage)))
|
|
||||||
(file-missing (error! "%s" (error-message-string ex)))
|
(file-missing (error! "%s" (error-message-string ex)))
|
||||||
(error (error! "Syntax error: %s" ex)))))
|
(error (error! "Syntax error: %s" ex)))))
|
||||||
doom-modules)))))
|
doom-modules)))))
|
||||||
|
|
|
@ -255,41 +255,6 @@ regex PATTERN. Returns the number of killed buffers."
|
||||||
(doom-set-buffer-real (current-buffer) t))
|
(doom-set-buffer-real (current-buffer) t))
|
||||||
|
|
||||||
|
|
||||||
;;
|
|
||||||
;; Advice
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun doom*switch-to-fallback-buffer-maybe (orig-fn)
|
|
||||||
"Advice for `kill-current-buffer'. If in a dedicated window, delete it. If there
|
|
||||||
are no real buffers left OR if all remaining buffers are visible in other
|
|
||||||
windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
|
||||||
`kill-current-buffer'."
|
|
||||||
(let ((buf (current-buffer)))
|
|
||||||
(cond ((window-dedicated-p)
|
|
||||||
(delete-window))
|
|
||||||
((eq buf (doom-fallback-buffer))
|
|
||||||
(message "Can't kill the fallback buffer."))
|
|
||||||
((doom-real-buffer-p buf)
|
|
||||||
(if (and buffer-file-name
|
|
||||||
(buffer-modified-p buf)
|
|
||||||
(not (y-or-n-p
|
|
||||||
(format "Buffer %s is modified; kill anyway?" buf))))
|
|
||||||
(message "Aborted")
|
|
||||||
(set-buffer-modified-p nil)
|
|
||||||
(let (buffer-list-update-hook)
|
|
||||||
(when (or ;; if there aren't more real buffers than visible buffers,
|
|
||||||
;; then there are no real, non-visible buffers left.
|
|
||||||
(not (cl-set-difference (doom-real-buffer-list)
|
|
||||||
(doom-visible-buffers)))
|
|
||||||
;; if we end up back where we start (or previous-buffer
|
|
||||||
;; returns nil), we have nowhere left to go
|
|
||||||
(memq (switch-to-prev-buffer nil t) (list buf 'nil)))
|
|
||||||
(switch-to-buffer (doom-fallback-buffer)))
|
|
||||||
(unless (delq (selected-window) (get-buffer-window-list buf nil t))
|
|
||||||
(kill-buffer buf)))))
|
|
||||||
((funcall orig-fn)))))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Interactive commands
|
;; Interactive commands
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,6 @@ This excludes core packages listed in `doom-core-packages'.
|
||||||
If ALL-P, gather packages unconditionally across all modules, including disabled
|
If ALL-P, gather packages unconditionally across all modules, including disabled
|
||||||
ones."
|
ones."
|
||||||
(let ((noninteractive t)
|
(let ((noninteractive t)
|
||||||
(doom--stage 'packages)
|
|
||||||
(doom-modules (doom-modules))
|
(doom-modules (doom-modules))
|
||||||
doom-packages
|
doom-packages
|
||||||
doom-disabled-packages
|
doom-disabled-packages
|
||||||
|
|
|
@ -27,12 +27,12 @@ are open."
|
||||||
;; Advice
|
;; Advice
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom*recenter (&rest _)
|
(defun doom-recenter-a (&rest _)
|
||||||
"Generic advisor for recentering window (typically :after other functions)."
|
"Generic advisor for recentering window (typically :after other functions)."
|
||||||
(recenter))
|
(recenter))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom*shut-up (orig-fn &rest args)
|
(defun doom-shut-up-a (orig-fn &rest args)
|
||||||
"Generic advisor for silencing noisy functions."
|
"Generic advisor for silencing noisy functions."
|
||||||
(quiet! (apply orig-fn args)))
|
(quiet! (apply orig-fn args)))
|
||||||
|
|
||||||
|
|
|
@ -54,13 +54,13 @@ detected.")
|
||||||
;; Remove hscroll-margin in shells, otherwise it causes jumpiness
|
;; Remove hscroll-margin in shells, otherwise it causes jumpiness
|
||||||
(setq-hook! '(eshell-mode-hook term-mode-hook) hscroll-margin 0)
|
(setq-hook! '(eshell-mode-hook term-mode-hook) hscroll-margin 0)
|
||||||
|
|
||||||
(defun doom*optimize-literal-mode-for-large-files (buffer)
|
(def-advice! doom--optimize-literal-mode-for-large-files-a (buffer)
|
||||||
|
:filter-return #'find-file-noselect-1
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(when find-file-literally
|
(when find-file-literally
|
||||||
(setq buffer-read-only t)
|
(setq buffer-read-only t)
|
||||||
(buffer-disable-undo))
|
(buffer-disable-undo))
|
||||||
buffer))
|
buffer))
|
||||||
(advice-add #'find-file-noselect-1 :filter-return #'doom*optimize-literal-mode-for-large-files)
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -171,11 +171,10 @@ savehist file."
|
||||||
(setq save-place-file (concat doom-cache-dir "saveplace")
|
(setq save-place-file (concat doom-cache-dir "saveplace")
|
||||||
save-place-forget-unreadable-files t
|
save-place-forget-unreadable-files t
|
||||||
save-place-limit 200)
|
save-place-limit 200)
|
||||||
(defun doom*recenter-on-load-saveplace (&rest _)
|
(def-advice! doom--recenter-on-load-saveplace-a (&rest _)
|
||||||
"Recenter on cursor when loading a saved place."
|
"Recenter on cursor when loading a saved place."
|
||||||
|
:after-while #'save-place-find-file-hook
|
||||||
(if buffer-file-name (ignore-errors (recenter))))
|
(if buffer-file-name (ignore-errors (recenter))))
|
||||||
(advice-add #'save-place-find-file-hook
|
|
||||||
:after-while #'doom*recenter-on-load-saveplace)
|
|
||||||
(save-place-mode +1))
|
(save-place-mode +1))
|
||||||
|
|
||||||
(def-package! server
|
(def-package! server
|
||||||
|
@ -202,14 +201,14 @@ savehist file."
|
||||||
(better-jumper-mode +1)
|
(better-jumper-mode +1)
|
||||||
(add-hook 'better-jumper-post-jump-hook #'recenter)
|
(add-hook 'better-jumper-post-jump-hook #'recenter)
|
||||||
|
|
||||||
(defun doom*set-jump (orig-fn &rest args)
|
(defun doom-set-jump-a (orig-fn &rest args)
|
||||||
"Set a jump point and ensure ORIG-FN doesn't set any new jump points."
|
"Set a jump point and ensure ORIG-FN doesn't set any new jump points."
|
||||||
(better-jumper-set-jump (if (markerp (car args)) (car args)))
|
(better-jumper-set-jump (if (markerp (car args)) (car args)))
|
||||||
(let ((evil--jumps-jumping t)
|
(let ((evil--jumps-jumping t)
|
||||||
(better-jumper--jumping t))
|
(better-jumper--jumping t))
|
||||||
(apply orig-fn args)))
|
(apply orig-fn args)))
|
||||||
|
|
||||||
(defun doom*set-jump-maybe (orig-fn &rest args)
|
(defun doom-set-jump-maybe-a (orig-fn &rest args)
|
||||||
"Set a jump point if ORIG-FN returns non-nil."
|
"Set a jump point if ORIG-FN returns non-nil."
|
||||||
(let ((origin (point-marker))
|
(let ((origin (point-marker))
|
||||||
(result
|
(result
|
||||||
|
@ -261,9 +260,10 @@ savehist file."
|
||||||
(push '(t tab-width) dtrt-indent-hook-generic-mapping-list)
|
(push '(t tab-width) dtrt-indent-hook-generic-mapping-list)
|
||||||
|
|
||||||
(defvar dtrt-indent-run-after-smie)
|
(defvar dtrt-indent-run-after-smie)
|
||||||
(defun doom*fix-broken-smie-modes (orig-fn arg)
|
(def-advice! doom--fix-broken-smie-modes-a (orig-fn arg)
|
||||||
"Some smie modes throw errors when trying to guess their indentation, like
|
"Some smie modes throw errors when trying to guess their indentation, like
|
||||||
`nim-mode'. This prevents them from leaving Emacs in a broken state."
|
`nim-mode'. This prevents them from leaving Emacs in a broken state."
|
||||||
|
:around #'dtrt-indent-mode
|
||||||
(let ((dtrt-indent-run-after-smie dtrt-indent-run-after-smie))
|
(let ((dtrt-indent-run-after-smie dtrt-indent-run-after-smie))
|
||||||
(cl-letf* ((old-smie-config-guess (symbol-function 'smie-config-guess))
|
(cl-letf* ((old-smie-config-guess (symbol-function 'smie-config-guess))
|
||||||
((symbol-function 'smie-config-guess)
|
((symbol-function 'smie-config-guess)
|
||||||
|
@ -273,8 +273,7 @@ savehist file."
|
||||||
(message "[WARNING] Indent detection: %s"
|
(message "[WARNING] Indent detection: %s"
|
||||||
(error-message-string e))
|
(error-message-string e))
|
||||||
(message "")))))) ; warn silently
|
(message "")))))) ; warn silently
|
||||||
(funcall orig-fn arg))))
|
(funcall orig-fn arg)))))
|
||||||
(advice-add #'dtrt-indent-mode :around #'doom*fix-broken-smie-modes))
|
|
||||||
|
|
||||||
|
|
||||||
(def-package! helpful
|
(def-package! helpful
|
||||||
|
@ -354,17 +353,16 @@ savehist file."
|
||||||
`(("." . ,(concat doom-cache-dir "undo-tree-hist/"))))
|
`(("." . ,(concat doom-cache-dir "undo-tree-hist/"))))
|
||||||
|
|
||||||
(when (executable-find "zstd")
|
(when (executable-find "zstd")
|
||||||
(defun doom*undo-tree-make-history-save-file-name (file)
|
(def-advice! doom--undo-tree-make-history-save-file-name-a (file)
|
||||||
(concat file ".zst"))
|
:filter-return #'undo-tree-make-history-save-file-name
|
||||||
(advice-add #'undo-tree-make-history-save-file-name :filter-return
|
(concat file ".zst")))
|
||||||
#'doom*undo-tree-make-history-save-file-name))
|
|
||||||
|
|
||||||
(defun doom*strip-text-properties-from-undo-history (&rest _)
|
(def-advice! doom--undo-tree-strip-text-properties-a (&rest _)
|
||||||
|
:before #'undo-list-transfer-to-tree
|
||||||
(dolist (item buffer-undo-list)
|
(dolist (item buffer-undo-list)
|
||||||
(and (consp item)
|
(and (consp item)
|
||||||
(stringp (car item))
|
(stringp (car item))
|
||||||
(setcar item (substring-no-properties (car item))))))
|
(setcar item (substring-no-properties (car item))))))
|
||||||
(advice-add #'undo-list-transfer-to-tree :before #'doom*strip-text-properties-from-undo-history)
|
|
||||||
|
|
||||||
(global-undo-tree-mode +1))
|
(global-undo-tree-mode +1))
|
||||||
|
|
||||||
|
|
|
@ -76,21 +76,6 @@ list is returned as-is."
|
||||||
collect (cadr hook)
|
collect (cadr hook)
|
||||||
else collect (intern (format "%s-hook" (symbol-name hook)))))))
|
else collect (intern (format "%s-hook" (symbol-name hook)))))))
|
||||||
|
|
||||||
(defun doom--assert-stage-p (stage macro)
|
|
||||||
(unless (or (bound-and-true-p byte-compile-current-file)
|
|
||||||
;; Don't complain if we're being evaluated on-the-fly. Since forms
|
|
||||||
;; are often evaluated (by `eval-region') or expanded (by
|
|
||||||
;; macroexpand) in a temp buffer in `emacs-lisp-mode'...
|
|
||||||
(eq major-mode 'emacs-lisp-mode))
|
|
||||||
(cl-assert (eq stage doom--stage)
|
|
||||||
nil
|
|
||||||
"Found %s call in non-%s.el file (%s)"
|
|
||||||
macro (symbol-name stage)
|
|
||||||
(let ((path (FILE!)))
|
|
||||||
(if (file-in-directory-p path doom-emacs-dir)
|
|
||||||
(file-relative-name path doom-emacs-dir)
|
|
||||||
(abbreviate-file-name path))))))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Public library
|
;;; Public library
|
||||||
|
@ -303,32 +288,26 @@ If N and M = 1, there's no benefit to using this macro over `remove-hook'.
|
||||||
(nreverse forms))))
|
(nreverse forms))))
|
||||||
collect `(add-hook ',hook #',fn 'append)))))
|
collect `(add-hook ',hook #',fn 'append)))))
|
||||||
|
|
||||||
(defun advice-add! (symbols where functions)
|
(defmacro def-advice! (symbol arglist docstring where places &rest body)
|
||||||
"Variadic version of `advice-add'.
|
"Define an advice called NAME and add it to PLACES.
|
||||||
|
|
||||||
SYMBOLS and FUNCTIONS can be lists of functions."
|
ARGLIST is as in `defun'. WHERE is a keyword as passed to `advice-add', and
|
||||||
(let ((functions (if (functionp functions)
|
PLACE is the function to which to add the advice, like in `advice-add'.
|
||||||
(list functions)
|
DOCSTRING and BODY are as in `defun'."
|
||||||
functions)))
|
(declare (doc-string 3) (indent defun))
|
||||||
(dolist (s (doom-enlist symbols))
|
(unless (stringp docstring)
|
||||||
(dolist (f (doom-enlist functions))
|
(push places body)
|
||||||
(advice-add s where f)))))
|
(setq places where
|
||||||
|
where docstring
|
||||||
(defun advice-remove! (symbols where-or-fns &optional functions)
|
docstring (format "%s advice for %s." where places)))
|
||||||
"Variadic version of `advice-remove'.
|
`(progn
|
||||||
|
(defun ,symbol ,arglist
|
||||||
WHERE-OR-FNS is ignored if FUNCTIONS is provided. This lets you substitute
|
,docstring
|
||||||
advice-add with advice-remove and evaluate them without having to modify every
|
,@body)
|
||||||
statement."
|
(dolist (target (doom-enlist ,places))
|
||||||
(unless functions
|
(if (eq ,where :remove)
|
||||||
(setq functions where-or-fns
|
(advice-remove target #',symbol)
|
||||||
where-or-fns nil))
|
(advice-add target ,where #',symbol)))))
|
||||||
(let ((functions (if (functionp functions)
|
|
||||||
(list functions)
|
|
||||||
functions)))
|
|
||||||
(dolist (s (doom-enlist symbols))
|
|
||||||
(dolist (f (doom-enlist functions))
|
|
||||||
(advice-remove s f)))))
|
|
||||||
|
|
||||||
(cl-defmacro associate! (mode &key modes match files when)
|
(cl-defmacro associate! (mode &key modes match files when)
|
||||||
"Enables a minor mode if certain conditions are met.
|
"Enables a minor mode if certain conditions are met.
|
||||||
|
|
|
@ -435,7 +435,6 @@ WARNING: If :pre-init or :pre-config hooks return nil, the original
|
||||||
`def-package!''s :init/:config block (respectively) is overwritten, so remember
|
`def-package!''s :init/:config block (respectively) is overwritten, so remember
|
||||||
to have them return non-nil (or exploit that to overwrite Doom's config)."
|
to have them return non-nil (or exploit that to overwrite Doom's config)."
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
(doom--assert-stage-p 'init #'package!)
|
|
||||||
(unless (memq when '(:pre-init :post-init :pre-config :post-config))
|
(unless (memq when '(:pre-init :post-init :pre-config :post-config))
|
||||||
(error "'%s' isn't a valid hook for def-package-hook!" when))
|
(error "'%s' isn't a valid hook for def-package-hook!" when))
|
||||||
`(progn
|
`(progn
|
||||||
|
@ -470,8 +469,7 @@ module."
|
||||||
(let ((doom--current-module ',(cons category module))
|
(let ((doom--current-module ',(cons category module))
|
||||||
(doom--current-flags ',flags))
|
(doom--current-flags ',flags))
|
||||||
(load! "init" module-path :noerror)
|
(load! "init" module-path :noerror)
|
||||||
(let ((doom--stage 'config))
|
(load! "config" module-path :noerror))
|
||||||
(load! "config" module-path :noerror)))
|
|
||||||
('error
|
('error
|
||||||
(lwarn 'doom-modules :error
|
(lwarn 'doom-modules :error
|
||||||
"%s in '%s %s' -> %s"
|
"%s in '%s %s' -> %s"
|
||||||
|
|
|
@ -179,7 +179,6 @@ Accepts the following properties:
|
||||||
Returns t if package is successfully registered, and nil if it was disabled
|
Returns t if package is successfully registered, and nil if it was disabled
|
||||||
elsewhere."
|
elsewhere."
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
(doom--assert-stage-p 'packages #'package!)
|
|
||||||
(let ((old-plist (cdr (assq name doom-packages))))
|
(let ((old-plist (cdr (assq name doom-packages))))
|
||||||
(when recipe
|
(when recipe
|
||||||
(when (cl-evenp (length recipe))
|
(when (cl-evenp (length recipe))
|
||||||
|
@ -218,21 +217,9 @@ elsewhere."
|
||||||
`((add-to-list 'doom-disabled-packages ',name nil 'eq)
|
`((add-to-list 'doom-disabled-packages ',name nil 'eq)
|
||||||
nil))))))
|
nil))))))
|
||||||
|
|
||||||
(defmacro packages! (&rest packages)
|
|
||||||
"A convenience macro for `package!' for declaring multiple packages at once.
|
|
||||||
|
|
||||||
Only use this macro in a module's packages.el file."
|
|
||||||
(doom--assert-stage-p 'packages #'packages!)
|
|
||||||
(macroexp-progn
|
|
||||||
(cl-loop for desc in packages
|
|
||||||
collect (macroexpand `(package! ,@(doom-enlist desc))))))
|
|
||||||
|
|
||||||
(defmacro disable-packages! (&rest packages)
|
(defmacro disable-packages! (&rest packages)
|
||||||
"A convenience macro like `package!', but allows you to disable multiple
|
"A convenience macro for disabling packages in bulk.
|
||||||
packages at once.
|
Only use this macro in a module's (or your private) packages.el file."
|
||||||
|
|
||||||
Only use this macro in a module's packages.el file."
|
|
||||||
(doom--assert-stage-p 'packages #'disable-packages!)
|
|
||||||
(macroexp-progn
|
(macroexp-progn
|
||||||
(cl-loop for pkg in packages
|
(cl-loop for pkg in packages
|
||||||
collect (macroexpand `(package! ,pkg :disable t)))))
|
collect (macroexpand `(package! ,pkg :disable t)))))
|
||||||
|
|
|
@ -44,31 +44,14 @@ Emacs.")
|
||||||
(global-set-key [remap find-tag] #'projectile-find-tag)
|
(global-set-key [remap find-tag] #'projectile-find-tag)
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(defun doom*projectile-cache-timers ()
|
|
||||||
"Persist `projectile-projects-cache-time' across sessions, so that
|
|
||||||
`projectile-files-cache-expire' checks won't reset when restarting Emacs."
|
|
||||||
(projectile-serialize projectile-projects-cache-time doom-projectile-cache-timer-file))
|
|
||||||
(advice-add #'projectile-serialize-cache :before #'doom*projectile-cache-timers)
|
|
||||||
;; Restore it
|
|
||||||
(setq projectile-projects-cache-time (projectile-unserialize doom-projectile-cache-timer-file))
|
|
||||||
|
|
||||||
(add-hook 'dired-before-readin-hook #'projectile-track-known-projects-find-file-hook)
|
|
||||||
(projectile-mode +1)
|
(projectile-mode +1)
|
||||||
|
|
||||||
;; a more generic project root file
|
;; a more generic project root file
|
||||||
(push ".project" projectile-project-root-files-bottom-up)
|
(push ".project" projectile-project-root-files-bottom-up)
|
||||||
(push (abbreviate-file-name doom-local-dir) projectile-globally-ignored-directories)
|
(push (abbreviate-file-name doom-local-dir) projectile-globally-ignored-directories)
|
||||||
|
|
||||||
(defun doom*projectile-default-generic-command (orig-fn &rest args)
|
;; Treat current directory in dired as a "file in a project" and track it
|
||||||
"If projectile can't tell what kind of project you're in, it issues an error
|
(add-hook 'dired-before-readin-hook #'projectile-track-known-projects-find-file-hook)
|
||||||
when using many of projectile's command, e.g. `projectile-compile-command',
|
|
||||||
`projectile-run-project', `projectile-test-project', and
|
|
||||||
`projectile-configure-project', for instance.
|
|
||||||
|
|
||||||
This suppresses the error so these commands will still run, but prompt you for
|
|
||||||
the command instead."
|
|
||||||
(ignore-errors (apply orig-fn args)))
|
|
||||||
(advice-add #'projectile-default-generic-command :around #'doom*projectile-default-generic-command)
|
|
||||||
|
|
||||||
;; Accidentally indexing big directories like $HOME or / will massively bloat
|
;; Accidentally indexing big directories like $HOME or / will massively bloat
|
||||||
;; projectile's cache (into the hundreds of MBs). This purges those entries
|
;; projectile's cache (into the hundreds of MBs). This purges those entries
|
||||||
|
@ -111,16 +94,6 @@ c) are not valid projectile projects."
|
||||||
projectile-project-root-files)
|
projectile-project-root-files)
|
||||||
projectile-project-root-files-bottom-up nil)))
|
projectile-project-root-files-bottom-up nil)))
|
||||||
|
|
||||||
;; Projectile root-searching functions can cause an infinite loop on TRAMP
|
|
||||||
;; connections, so disable them.
|
|
||||||
;; TODO Is this still necessary?
|
|
||||||
(defun doom*projectile-locate-dominating-file (orig-fn file name)
|
|
||||||
"Don't traverse the file system if on a remote connection."
|
|
||||||
(when (and (stringp file)
|
|
||||||
(not (file-remote-p file nil t)))
|
|
||||||
(funcall orig-fn file name)))
|
|
||||||
(advice-add #'projectile-locate-dominating-file :around #'doom*projectile-locate-dominating-file)
|
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
;; If fd exists, use it for git and generic projects. fd is a rust program
|
;; If fd exists, use it for git and generic projects. fd is a rust program
|
||||||
;; that is significantly faster than git ls-files or find, and it respects
|
;; that is significantly faster than git ls-files or find, and it respects
|
||||||
|
@ -143,7 +116,37 @@ c) are not valid projectile projects."
|
||||||
projectile-indexing-method 'alien)
|
projectile-indexing-method 'alien)
|
||||||
;; fix breakage on windows in git projects
|
;; fix breakage on windows in git projects
|
||||||
(unless (executable-find "tr")
|
(unless (executable-find "tr")
|
||||||
(setq projectile-git-submodule-command nil)))))
|
(setq projectile-git-submodule-command nil))))
|
||||||
|
|
||||||
|
(def-advice! doom--projectile-cache-timers-a ()
|
||||||
|
"Persist `projectile-projects-cache-time' across sessions, so that
|
||||||
|
`projectile-files-cache-expire' checks won't reset when restarting Emacs."
|
||||||
|
:before #'projectile-serialize-cache
|
||||||
|
(projectile-serialize projectile-projects-cache-time doom-projectile-cache-timer-file))
|
||||||
|
;; Restore it
|
||||||
|
(setq projectile-projects-cache-time (projectile-unserialize doom-projectile-cache-timer-file))
|
||||||
|
|
||||||
|
(def-advice! doom--projectile-default-generic-command-a (orig-fn &rest args)
|
||||||
|
"If projectile can't tell what kind of project you're in, it issues an error
|
||||||
|
when using many of projectile's command, e.g. `projectile-compile-command',
|
||||||
|
`projectile-run-project', `projectile-test-project', and
|
||||||
|
`projectile-configure-project', for instance.
|
||||||
|
|
||||||
|
This suppresses the error so these commands will still run, but prompt you for
|
||||||
|
the command instead."
|
||||||
|
:around #'projectile-default-generic-command
|
||||||
|
(ignore-errors (apply orig-fn args)))
|
||||||
|
|
||||||
|
;; Projectile root-searching functions can cause an infinite loop on TRAMP
|
||||||
|
;; connections, so disable them.
|
||||||
|
;; TODO Is this still necessary?
|
||||||
|
(def-advice! doom--projectile-locate-dominating-file-a (orig-fn file name)
|
||||||
|
"Don't traverse the file system if on a remote connection."
|
||||||
|
:around #'projectile-locate-dominating-file
|
||||||
|
(when (and (stringp file)
|
||||||
|
(not (file-remote-p file nil t)))
|
||||||
|
(funcall orig-fn file name))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Project-based minor modes
|
;; Project-based minor modes
|
||||||
|
|
123
core/core-ui.el
123
core/core-ui.el
|
@ -102,8 +102,8 @@ behavior). Do not set this directly, this is let-bound in `doom|init-theme'.")
|
||||||
(run-hooks 'doom-switch-frame-hook)
|
(run-hooks 'doom-switch-frame-hook)
|
||||||
(setq doom--last-frame (selected-frame)))))
|
(setq doom--last-frame (selected-frame)))))
|
||||||
|
|
||||||
(defun doom*run-switch-buffer-hooks (orig-fn buffer-or-name &rest args)
|
(defun doom-run-switch-buffer-hooks-a (orig-fn buffer-or-name &rest args)
|
||||||
(let ((gc-cons-threshold doom-gc-cons-upper-limit))
|
(let ((gc-cons-threshold most-positive-fixnum))
|
||||||
(if (or doom-inhibit-switch-buffer-hooks
|
(if (or doom-inhibit-switch-buffer-hooks
|
||||||
(eq (current-buffer) (get-buffer buffer-or-name))
|
(eq (current-buffer) (get-buffer buffer-or-name))
|
||||||
(and (eq orig-fn #'switch-to-buffer) (car args)))
|
(and (eq orig-fn #'switch-to-buffer) (car args)))
|
||||||
|
@ -116,8 +116,8 @@ behavior). Do not set this directly, this is let-bound in `doom|init-theme'.")
|
||||||
(run-hooks 'doom-switch-buffer-hook))
|
(run-hooks 'doom-switch-buffer-hook))
|
||||||
buffer)))))
|
buffer)))))
|
||||||
|
|
||||||
(defun doom*run-switch-to-next-prev-buffer-hooks (orig-fn &rest args)
|
(defun doom-run-switch-to-next-prev-buffer-hooks-a (orig-fn &rest args)
|
||||||
(let ((gc-cons-threshold doom-gc-cons-upper-limit))
|
(let ((gc-cons-threshold most-positive-fixnum))
|
||||||
(if doom-inhibit-switch-buffer-hooks
|
(if doom-inhibit-switch-buffer-hooks
|
||||||
(apply orig-fn args)
|
(apply orig-fn args)
|
||||||
(let ((doom-inhibit-switch-buffer-hooks t))
|
(let ((doom-inhibit-switch-buffer-hooks t))
|
||||||
|
@ -126,13 +126,7 @@ behavior). Do not set this directly, this is let-bound in `doom|init-theme'.")
|
||||||
(run-hooks 'doom-switch-buffer-hook))
|
(run-hooks 'doom-switch-buffer-hook))
|
||||||
buffer)))))
|
buffer)))))
|
||||||
|
|
||||||
(defun doom*run-load-theme-hooks (theme &optional _no-confirm no-enable)
|
(defun doom-protect-fallback-buffer-h ()
|
||||||
"Set up `doom-load-theme-hook' to run after `load-theme' is called."
|
|
||||||
(unless no-enable
|
|
||||||
(setq doom-theme theme)
|
|
||||||
(run-hooks 'doom-load-theme-hook)))
|
|
||||||
|
|
||||||
(defun doom|protect-fallback-buffer ()
|
|
||||||
"Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'."
|
"Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'."
|
||||||
(not (eq (current-buffer) (doom-fallback-buffer))))
|
(not (eq (current-buffer) (doom-fallback-buffer))))
|
||||||
|
|
||||||
|
@ -239,6 +233,39 @@ read-only or not file-visiting."
|
||||||
window-divider-default-right-width 1)
|
window-divider-default-right-width 1)
|
||||||
(add-hook 'doom-init-ui-hook #'window-divider-mode)
|
(add-hook 'doom-init-ui-hook #'window-divider-mode)
|
||||||
|
|
||||||
|
(def-advice! doom-switch-to-fallback-buffer-maybe-a (orig-fn)
|
||||||
|
"Switch to `doom-fallback-buffer' if on last real buffer.
|
||||||
|
|
||||||
|
Advice for `kill-current-buffer'. If in a dedicated window, delete it. If there
|
||||||
|
are no real buffers left OR if all remaining buffers are visible in other
|
||||||
|
windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
||||||
|
`kill-current-buffer'."
|
||||||
|
:around #'kill-current-buffer
|
||||||
|
(let ((buf (current-buffer)))
|
||||||
|
(cond ((window-dedicated-p)
|
||||||
|
(delete-window))
|
||||||
|
((eq buf (doom-fallback-buffer))
|
||||||
|
(message "Can't kill the fallback buffer."))
|
||||||
|
((doom-real-buffer-p buf)
|
||||||
|
(if (and buffer-file-name
|
||||||
|
(buffer-modified-p buf)
|
||||||
|
(not (y-or-n-p
|
||||||
|
(format "Buffer %s is modified; kill anyway?" buf))))
|
||||||
|
(message "Aborted")
|
||||||
|
(set-buffer-modified-p nil)
|
||||||
|
(let (buffer-list-update-hook)
|
||||||
|
(when (or ;; if there aren't more real buffers than visible buffers,
|
||||||
|
;; then there are no real, non-visible buffers left.
|
||||||
|
(not (cl-set-difference (doom-real-buffer-list)
|
||||||
|
(doom-visible-buffers)))
|
||||||
|
;; if we end up back where we start (or previous-buffer
|
||||||
|
;; returns nil), we have nowhere left to go
|
||||||
|
(memq (switch-to-prev-buffer nil t) (list buf 'nil)))
|
||||||
|
(switch-to-buffer (doom-fallback-buffer)))
|
||||||
|
(unless (delq (selected-window) (get-buffer-window-list buf nil t))
|
||||||
|
(kill-buffer buf)))))
|
||||||
|
((funcall orig-fn)))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Built-in packages
|
;;; Built-in packages
|
||||||
|
@ -329,16 +356,14 @@ read-only or not file-visiting."
|
||||||
:commands (all-the-icons-octicon all-the-icons-faicon all-the-icons-fileicon
|
:commands (all-the-icons-octicon all-the-icons-faicon all-the-icons-fileicon
|
||||||
all-the-icons-wicon all-the-icons-material all-the-icons-alltheicon)
|
all-the-icons-wicon all-the-icons-material all-the-icons-alltheicon)
|
||||||
:init
|
:init
|
||||||
(defun doom*disable-all-the-icons-in-tty (orig-fn &rest args)
|
(def-advice! doom--disable-all-the-icons-in-tty-a (orig-fn &rest args)
|
||||||
|
"all-the-icons doesn't work in the terminal, so we \"disable\" them."
|
||||||
|
:around '(all-the-icons-octicon all-the-icons-material
|
||||||
|
all-the-icons-faicon all-the-icons-fileicon
|
||||||
|
all-the-icons-wicon all-the-icons-alltheicon)
|
||||||
(if (display-graphic-p)
|
(if (display-graphic-p)
|
||||||
(apply orig-fn args)
|
(apply orig-fn args)
|
||||||
""))
|
"")))
|
||||||
:config
|
|
||||||
;; all-the-icons doesn't work in the terminal, so we "disable" it.
|
|
||||||
(dolist (fn '(all-the-icons-octicon all-the-icons-material
|
|
||||||
all-the-icons-faicon all-the-icons-fileicon
|
|
||||||
all-the-icons-wicon all-the-icons-alltheicon))
|
|
||||||
(advice-add fn :around #'doom*disable-all-the-icons-in-tty)))
|
|
||||||
|
|
||||||
;;;###package hide-mode-line-mode
|
;;;###package hide-mode-line-mode
|
||||||
(add-hook 'completion-list-mode-hook #'hide-mode-line-mode)
|
(add-hook 'completion-list-mode-hook #'hide-mode-line-mode)
|
||||||
|
@ -482,6 +507,26 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
|
||||||
(let ((doom--prefer-theme-elc t))
|
(let ((doom--prefer-theme-elc t))
|
||||||
(load-theme doom-theme t)))))
|
(load-theme doom-theme t)))))
|
||||||
|
|
||||||
|
(def-advice! doom--run-load-theme-hooks-a (theme &optional _no-confirm no-enable)
|
||||||
|
"Set up `doom-load-theme-hook' to run after `load-theme' is called."
|
||||||
|
:after #'load-theme
|
||||||
|
(unless no-enable
|
||||||
|
(setq doom-theme theme)
|
||||||
|
(run-hooks 'doom-load-theme-hook)))
|
||||||
|
|
||||||
|
(def-advice! doom--prefer-compiled-theme-a (orig-fn &rest args)
|
||||||
|
"Make `load-theme' prioritize the byte-compiled theme for a moderate boost in
|
||||||
|
startup (or theme switch) time, so long as `doom--prefer-theme-elc' is non-nil."
|
||||||
|
:around #'load-theme
|
||||||
|
(if (or (null after-init-time)
|
||||||
|
doom--prefer-theme-elc)
|
||||||
|
(cl-letf* ((old-locate-file (symbol-function 'locate-file))
|
||||||
|
((symbol-function 'locate-file)
|
||||||
|
(lambda (filename path &optional _suffixes predicate)
|
||||||
|
(funcall old-locate-file filename path '("c" "") predicate))))
|
||||||
|
(apply orig-fn args))
|
||||||
|
(apply orig-fn args)))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Bootstrap
|
;;; Bootstrap
|
||||||
|
@ -499,10 +544,10 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
|
||||||
;; + `doom-switch-frame-hook'
|
;; + `doom-switch-frame-hook'
|
||||||
(add-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks)
|
(add-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks)
|
||||||
(add-hook 'focus-in-hook #'doom|run-switch-frame-hooks)
|
(add-hook 'focus-in-hook #'doom|run-switch-frame-hooks)
|
||||||
(advice-add! '(switch-to-next-buffer switch-to-prev-buffer)
|
(dolist (fn '(switch-to-next-buffer switch-to-prev-buffer))
|
||||||
:around #'doom*run-switch-to-next-prev-buffer-hooks)
|
(advice-add fn :around #'doom-run-switch-to-next-prev-buffer-hooks-a))
|
||||||
(advice-add! '(switch-to-buffer display-buffer)
|
(dolist (fn '(switch-to-buffer display-buffer))
|
||||||
:around #'doom*run-switch-buffer-hooks))
|
(advice-add fn :around #'doom-run-switch-buffer-hooks-a)))
|
||||||
|
|
||||||
;; Apply `doom-theme'
|
;; Apply `doom-theme'
|
||||||
(add-hook (if (daemonp)
|
(add-hook (if (daemonp)
|
||||||
|
@ -513,9 +558,6 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
|
||||||
(add-hook 'doom-after-init-modules-hook #'doom|init-fonts)
|
(add-hook 'doom-after-init-modules-hook #'doom|init-fonts)
|
||||||
;; Ensure unicode fonts are set on each frame
|
;; Ensure unicode fonts are set on each frame
|
||||||
(add-hook 'after-make-frame-functions #'doom|init-emoji-fonts)
|
(add-hook 'after-make-frame-functions #'doom|init-emoji-fonts)
|
||||||
;; Setup `doom-load-theme-hook' and ensure `doom-theme' is always set to the
|
|
||||||
;; currently loaded theme
|
|
||||||
(advice-add #'load-theme :after #'doom*run-load-theme-hooks)
|
|
||||||
|
|
||||||
(add-hook 'window-setup-hook #'doom|init-ui)
|
(add-hook 'window-setup-hook #'doom|init-ui)
|
||||||
|
|
||||||
|
@ -527,35 +569,13 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
|
||||||
(unless (fboundp 'define-fringe-bitmap)
|
(unless (fboundp 'define-fringe-bitmap)
|
||||||
(defun define-fringe-bitmap (&rest _)))
|
(defun define-fringe-bitmap (&rest _)))
|
||||||
|
|
||||||
(defun doom*prefer-compiled-theme (orig-fn &rest args)
|
|
||||||
"Make `load-theme' prioritize the byte-compiled theme for a moderate boost in
|
|
||||||
startup (or theme switch) time, so long as `doom--prefer-theme-elc' is non-nil."
|
|
||||||
(if (or (null after-init-time)
|
|
||||||
doom--prefer-theme-elc)
|
|
||||||
(cl-letf* ((old-locate-file (symbol-function 'locate-file))
|
|
||||||
((symbol-function 'locate-file)
|
|
||||||
(lambda (filename path &optional _suffixes predicate)
|
|
||||||
(funcall old-locate-file filename path '("c" "") predicate))))
|
|
||||||
(apply orig-fn args))
|
|
||||||
(apply orig-fn args)))
|
|
||||||
(advice-add #'load-theme :around #'doom*prefer-compiled-theme)
|
|
||||||
|
|
||||||
(after! whitespace
|
(after! whitespace
|
||||||
(defun doom*disable-whitespace-mode-in-childframes (orig-fn)
|
(defun doom-disable-whitespace-mode-in-childframes-a (orig-fn)
|
||||||
"`whitespace-mode' inundates child frames with whitspace markers, so disable
|
"`whitespace-mode' inundates child frames with whitspace markers, so disable
|
||||||
it to fix all that visual noise."
|
it to fix all that visual noise."
|
||||||
(unless (frame-parameter nil 'parent-frame)
|
(unless (frame-parameter nil 'parent-frame)
|
||||||
(funcall orig-fn)))
|
(funcall orig-fn)))
|
||||||
(add-function :around whitespace-enable-predicate #'doom*disable-whitespace-mode-in-childframes)
|
(add-function :around whitespace-enable-predicate #'doom-disable-whitespace-mode-in-childframes-a))
|
||||||
|
|
||||||
(defun doom|disable-whitespace-mode-in-childframes (frame)
|
|
||||||
"`whitespace-mode' inundates child frames with whitspace markers, so disable
|
|
||||||
it to fix all that visual noise."
|
|
||||||
(when (frame-parameter frame 'parent-frame)
|
|
||||||
(with-selected-frame frame
|
|
||||||
(setq-local whitespace-style nil)
|
|
||||||
frame)))
|
|
||||||
(add-hook 'after-make-frame-functions #'doom|disable-whitespace-mode-in-childframes))
|
|
||||||
|
|
||||||
;; Don't allow cursor to enter the prompt
|
;; Don't allow cursor to enter the prompt
|
||||||
(setq minibuffer-prompt-properties '(read-only t intangible t cursor-intangible t face minibuffer-prompt))
|
(setq minibuffer-prompt-properties '(read-only t intangible t cursor-intangible t face minibuffer-prompt))
|
||||||
|
@ -572,8 +592,5 @@ it to fix all that visual noise."
|
||||||
(doom-silence-motion-key backward-delete-char "<backspace>")
|
(doom-silence-motion-key backward-delete-char "<backspace>")
|
||||||
(doom-silence-motion-key delete-char "<delete>")
|
(doom-silence-motion-key delete-char "<delete>")
|
||||||
|
|
||||||
;; Switch to `doom-fallback-buffer' if on last real buffer
|
|
||||||
(advice-add #'kill-current-buffer :around #'doom*switch-to-fallback-buffer-maybe)
|
|
||||||
|
|
||||||
(provide 'core-ui)
|
(provide 'core-ui)
|
||||||
;;; core-ui.el ends here
|
;;; core-ui.el ends here
|
||||||
|
|
|
@ -130,7 +130,6 @@ Doom was setup, which may cause problems.")
|
||||||
(defvar doom--last-emacs-file (concat doom-local-dir "emacs-version.el"))
|
(defvar doom--last-emacs-file (concat doom-local-dir "emacs-version.el"))
|
||||||
(defvar doom--last-emacs-version nil)
|
(defvar doom--last-emacs-version nil)
|
||||||
(defvar doom--refreshed-p nil)
|
(defvar doom--refreshed-p nil)
|
||||||
(defvar doom--stage 'init)
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -62,13 +62,15 @@
|
||||||
(setq a (switch-to-buffer (get-buffer-create "a"))
|
(setq a (switch-to-buffer (get-buffer-create "a"))
|
||||||
b (get-buffer-create "b"))
|
b (get-buffer-create "b"))
|
||||||
(spy-on 'hook)
|
(spy-on 'hook)
|
||||||
(add-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks)
|
(add-hook 'buffer-list-update-hook #'doom-run-switch-window-hooks-h)
|
||||||
(add-hook 'focus-in-hook #'doom|run-switch-frame-hooks)
|
(add-hook 'focus-in-hook #'doom-run-switch-frame-hooks-h)
|
||||||
(advice-add! '(switch-to-buffer display-buffer) :around #'doom*run-switch-buffer-hooks))
|
(dolist (fn '(switch-to-buffer display-buffer))
|
||||||
|
(advice-add fn :around #'doom-run-switch-buffer-hooks-a)))
|
||||||
(after-each
|
(after-each
|
||||||
(remove-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks)
|
(remove-hook 'buffer-list-update-hook #'doom-run-switch-window-hooks-h)
|
||||||
(remove-hook 'focus-in-hook #'doom|run-switch-frame-hooks)
|
(remove-hook 'focus-in-hook #'doom-run-switch-frame-hooks-h)
|
||||||
(advice-remove! '(switch-to-buffer display-buffer) #'doom*run-switch-buffer-hooks)
|
(dolist (fn '(switch-to-buffer display-buffer))
|
||||||
|
(advice-remove fn #'doom-run-switch-buffer-hooks-a))
|
||||||
(kill-buffer a)
|
(kill-buffer a)
|
||||||
(kill-buffer b))
|
(kill-buffer b))
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,9 @@
|
||||||
;; Allow users to switch between backends on the fly. E.g. C-x C-s followed
|
;; Allow users to switch between backends on the fly. E.g. C-x C-s followed
|
||||||
;; by C-x C-n, will switch from `company-yasnippet' to
|
;; by C-x C-n, will switch from `company-yasnippet' to
|
||||||
;; `company-dabbrev-code'.
|
;; `company-dabbrev-code'.
|
||||||
(defun +company*abort-previous (&rest _) (company-abort))
|
(def-advice! +company--abort-previous-a (&rest _)
|
||||||
(advice-add #'company-begin-backend :before #'+company*abort-previous))
|
:before #'company-begin-backend
|
||||||
|
(company-abort)))
|
||||||
|
|
||||||
(add-hook 'company-mode-hook #'+company|init-backends)
|
(add-hook 'company-mode-hook #'+company|init-backends)
|
||||||
(global-company-mode +1))
|
(global-company-mode +1))
|
||||||
|
|
|
@ -60,7 +60,3 @@ bottom, which is easier on the eyes on big displays."
|
||||||
;;
|
;;
|
||||||
(posframe-delete +helm--posframe-buffer))
|
(posframe-delete +helm--posframe-buffer))
|
||||||
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +helm*fix-get-font-height (orig-fn position)
|
|
||||||
(ignore-errors (funcall orig-fn position)))
|
|
||||||
|
|
|
@ -83,9 +83,11 @@ be negative.")
|
||||||
|
|
||||||
:init
|
:init
|
||||||
(when (and EMACS26+ (featurep! +childframe))
|
(when (and EMACS26+ (featurep! +childframe))
|
||||||
(setq helm-display-function #'+helm-posframe-display)
|
(setq helm-display-function #'+helm-posframe-display-fn)
|
||||||
;; Fix "Specified window is not displaying the current buffer" error
|
(def-advice! +helm--fix-get-font-height-a (orig-fn position)
|
||||||
(advice-add #'posframe--get-font-height :around #'+helm*fix-get-font-height))
|
"Fix \"Specified window is not displaying the current buffer\" error."
|
||||||
|
:around #'posframe--get-font-height
|
||||||
|
(ignore-errors (funcall orig-fn position))))
|
||||||
|
|
||||||
(let ((fuzzy (featurep! +fuzzy)))
|
(let ((fuzzy (featurep! +fuzzy)))
|
||||||
(setq helm-M-x-fuzzy-match fuzzy
|
(setq helm-M-x-fuzzy-match fuzzy
|
||||||
|
@ -119,15 +121,9 @@ be negative.")
|
||||||
(advice-add #'helm-display-mode-line :override #'+helm|hide-mode-line)
|
(advice-add #'helm-display-mode-line :override #'+helm|hide-mode-line)
|
||||||
(advice-add #'helm-ag-show-status-default-mode-line :override #'ignore)
|
(advice-add #'helm-ag-show-status-default-mode-line :override #'ignore)
|
||||||
|
|
||||||
;; TODO Find a better way
|
;; Use helpful instead of describe-* to display documentation
|
||||||
(defun +helm*use-helpful (orig-fn arg)
|
(dolist (fn '(helm-describe-variable helm-describe-function))
|
||||||
(cl-letf (((symbol-function #'describe-function)
|
(advice-add fn :around #'doom-use-helpful-a)))
|
||||||
(symbol-function #'helpful-callable))
|
|
||||||
((symbol-function #'describe-variable)
|
|
||||||
(symbol-function #'helpful-variable)))
|
|
||||||
(funcall orig-fn arg)))
|
|
||||||
(advice-add #'helm-describe-variable :around #'+helm*use-helpful)
|
|
||||||
(advice-add #'helm-describe-function :around #'+helm*use-helpful))
|
|
||||||
|
|
||||||
|
|
||||||
(def-package! helm-flx
|
(def-package! helm-flx
|
||||||
|
@ -142,9 +138,9 @@ be negative.")
|
||||||
(define-key helm-ag-edit-map [remap quit-window] #'helm-ag--edit-abort)
|
(define-key helm-ag-edit-map [remap quit-window] #'helm-ag--edit-abort)
|
||||||
(set-popup-rule! "^\\*helm-ag-edit" :size 0.35 :ttl 0 :quit nil)
|
(set-popup-rule! "^\\*helm-ag-edit" :size 0.35 :ttl 0 :quit nil)
|
||||||
;; Recenter after jumping to match
|
;; Recenter after jumping to match
|
||||||
(advice-add #'helm-ag--find-file-action :after-while #'doom*recenter)
|
(advice-add #'helm-ag--find-file-action :after-while #'doom-recenter-a)
|
||||||
;; And record position before jumping
|
;; And record position before jumping
|
||||||
(advice-add #'helm-ag--find-file-action :around #'doom*set-jump-maybe))
|
(advice-add #'helm-ag--find-file-action :around #'doom-set-jump-maybe-a))
|
||||||
|
|
||||||
|
|
||||||
;;;###package helm-bookmark
|
;;;###package helm-bookmark
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
(insert "~/")
|
(insert "~/")
|
||||||
(call-interactively #'self-insert-command))))
|
(call-interactively #'self-insert-command))))
|
||||||
|
|
||||||
(defun +ido*sort-mtime ()
|
(defun +ido--sort-mtime-a ()
|
||||||
"Sort ido filelist by mtime instead of alphabetically."
|
"Sort ido filelist by mtime instead of alphabetically."
|
||||||
(setq ido-temp-list
|
(setq ido-temp-list
|
||||||
(sort ido-temp-list
|
(sort ido-temp-list
|
||||||
|
@ -40,8 +40,8 @@
|
||||||
(cl-loop for x in ido-temp-list
|
(cl-loop for x in ido-temp-list
|
||||||
if (char-equal (string-to-char x) ?.)
|
if (char-equal (string-to-char x) ?.)
|
||||||
collect x)))
|
collect x)))
|
||||||
(advice-add #'ido-sort-mtime :override #'+ido*sort-mtime)
|
(advice-add #'ido-sort-mtime :override #'+ido--sort-mtime-a)
|
||||||
(add-hook! (ido-make-file-list ido-make-dir-list) #'+ido*sort-mtime)
|
(add-hook! (ido-make-file-list ido-make-dir-list) #'ido-sort-mtime)
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(ido-mode 1)
|
(ido-mode 1)
|
||||||
|
|
|
@ -94,12 +94,12 @@ immediately runs it on the current candidate (ending the ivy session)."
|
||||||
(after! yasnippet
|
(after! yasnippet
|
||||||
(add-to-list 'yas-prompt-functions #'+ivy-yas-prompt nil #'eq))
|
(add-to-list 'yas-prompt-functions #'+ivy-yas-prompt nil #'eq))
|
||||||
|
|
||||||
(defun +ivy*inhibit-ivy-in-evil-ex (orig-fn &rest args)
|
(def-advice! +ivy--inhibit-ivy-in-evil-ex-a (orig-fn &rest args)
|
||||||
"`ivy-completion-in-region' struggles with completing certain
|
"`ivy-completion-in-region' struggles with completing certain
|
||||||
evil-ex-specific constructs, so we disable it solely in evil-ex."
|
evil-ex-specific constructs, so we disable it solely in evil-ex."
|
||||||
|
:around #'evil-ex
|
||||||
(let ((completion-in-region-function #'completion--in-region))
|
(let ((completion-in-region-function #'completion--in-region))
|
||||||
(apply orig-fn args)))
|
(apply orig-fn args)))
|
||||||
(advice-add #'evil-ex :around #'+ivy*inhibit-ivy-in-evil-ex)
|
|
||||||
|
|
||||||
(define-key! ivy-mode-map
|
(define-key! ivy-mode-map
|
||||||
[remap switch-to-buffer] #'+ivy/switch-buffer
|
[remap switch-to-buffer] #'+ivy/switch-buffer
|
||||||
|
|
|
@ -12,12 +12,11 @@
|
||||||
(def-package! expand-region
|
(def-package! expand-region
|
||||||
:commands (er/contract-region er/mark-symbol er/mark-word)
|
:commands (er/contract-region er/mark-symbol er/mark-word)
|
||||||
:config
|
:config
|
||||||
(defun doom*quit-expand-region ()
|
(def-advice! doom--quit-expand-region-a ()
|
||||||
"Properly abort an expand-region region."
|
"Properly abort an expand-region region."
|
||||||
|
:before '(evil-escape doom/escape)
|
||||||
(when (memq last-command '(er/expand-region er/contract-region))
|
(when (memq last-command '(er/expand-region er/contract-region))
|
||||||
(er/contract-region 0)))
|
(er/contract-region 0))))
|
||||||
(advice-add #'evil-escape :before #'doom*quit-expand-region)
|
|
||||||
(advice-add #'doom/escape :before #'doom*quit-expand-region))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
If BANG is non-nil, open compilation output in a comint buffer.
|
If BANG is non-nil, open compilation output in a comint buffer.
|
||||||
|
|
||||||
If BANG, then run ARGUMENTS as a full command. This command understands vim file
|
If BANG, then run ARGUMENTS as a full command. This command understands vim file
|
||||||
modifiers (like %:p:h). See `+evil*resolve-vim-path' for details."
|
modifiers (like %:p:h). See `+evil-resolve-vim-path-a' for details."
|
||||||
(interactive "<sh><!>")
|
(interactive "<sh><!>")
|
||||||
(+evil:compile (format "make %s"
|
(+evil:compile (format "make %s"
|
||||||
(evil-ex-replace-special-filenames
|
(evil-ex-replace-special-filenames
|
||||||
|
@ -29,7 +29,7 @@ modifiers (like %:p:h). See `+evil*resolve-vim-path' for details."
|
||||||
If BANG is non-nil, open compilation output in a comint buffer.
|
If BANG is non-nil, open compilation output in a comint buffer.
|
||||||
|
|
||||||
This command understands vim file modifiers (like %:p:h). See
|
This command understands vim file modifiers (like %:p:h). See
|
||||||
`+evil*resolve-vim-path' for details."
|
`+evil-resolve-vim-path-a' for details."
|
||||||
(interactive "<sh><!>")
|
(interactive "<sh><!>")
|
||||||
(compile (evil-ex-replace-special-filenames
|
(compile (evil-ex-replace-special-filenames
|
||||||
(format "%s %s"
|
(format "%s %s"
|
||||||
|
|
|
@ -1,76 +1,13 @@
|
||||||
;;; editor/evil/autoload/advice.el -*- lexical-binding: t; -*-
|
;;; editor/evil/autoload/advice.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(defun +evil--insert-newline (&optional above _noextranewline)
|
;;;###autoload
|
||||||
(let ((pos (save-excursion (beginning-of-line-text) (point)))
|
(defun +evil-escape-a (&rest _)
|
||||||
comment-auto-fill-only-comments)
|
"Call `doom/escape' if `evil-force-normal-state' is called interactively."
|
||||||
(require 'smartparens)
|
(when (called-interactively-p 'any)
|
||||||
(evil-narrow-to-field
|
(call-interactively #'doom/escape)))
|
||||||
(if above
|
|
||||||
(if (save-excursion (nth 4 (sp--syntax-ppss pos)))
|
|
||||||
(evil-save-goal-column
|
|
||||||
(setq evil-auto-indent nil)
|
|
||||||
(goto-char pos)
|
|
||||||
(let ((ws (abs (skip-chars-backward " \t"))))
|
|
||||||
;; FIXME oh god why
|
|
||||||
(save-excursion
|
|
||||||
(if comment-line-break-function
|
|
||||||
(funcall comment-line-break-function)
|
|
||||||
(comment-indent-new-line))
|
|
||||||
(when (and (derived-mode-p 'c-mode 'c++-mode 'objc-mode 'java-mode 'js2-mode)
|
|
||||||
(eq (char-after) ?/))
|
|
||||||
(insert "*"))
|
|
||||||
(insert
|
|
||||||
(make-string (max 0 (+ ws (skip-chars-backward " \t")))
|
|
||||||
32)))
|
|
||||||
(insert (make-string (max 1 ws) 32))))
|
|
||||||
(evil-move-beginning-of-line)
|
|
||||||
(insert (if use-hard-newlines hard-newline "\n"))
|
|
||||||
(forward-line -1)
|
|
||||||
(back-to-indentation))
|
|
||||||
(evil-move-end-of-line)
|
|
||||||
(cond ((sp-point-in-comment pos)
|
|
||||||
(setq evil-auto-indent nil)
|
|
||||||
(if comment-line-break-function
|
|
||||||
(funcall comment-line-break-function)
|
|
||||||
(comment-indent-new-line)))
|
|
||||||
;; TODO Find a better way to do this
|
|
||||||
((and (eq major-mode 'haskell-mode)
|
|
||||||
(fboundp 'haskell-indentation-newline-and-indent))
|
|
||||||
(setq evil-auto-indent nil)
|
|
||||||
(haskell-indentation-newline-and-indent))
|
|
||||||
(t
|
|
||||||
(insert (if use-hard-newlines hard-newline "\n"))
|
|
||||||
(back-to-indentation)))))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +evil*insert-newline-below-and-respect-comments (orig-fn count)
|
(defun +evil-resolve-vim-path-a (file-name)
|
||||||
(if (or (not +evil-want-o/O-to-continue-comments)
|
|
||||||
(not (eq this-command 'evil-open-below))
|
|
||||||
(evil-insert-state-p))
|
|
||||||
(funcall orig-fn count)
|
|
||||||
(cl-letf (((symbol-function 'evil-insert-newline-below)
|
|
||||||
(lambda () (+evil--insert-newline))))
|
|
||||||
(let ((evil-auto-indent evil-auto-indent))
|
|
||||||
(funcall orig-fn count)))))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +evil*insert-newline-above-and-respect-comments (orig-fn count)
|
|
||||||
(if (or (not +evil-want-o/O-to-continue-comments)
|
|
||||||
(not (eq this-command 'evil-open-above))
|
|
||||||
(evil-insert-state-p))
|
|
||||||
(funcall orig-fn count)
|
|
||||||
(cl-letf (((symbol-function 'evil-insert-newline-above)
|
|
||||||
(lambda () (+evil--insert-newline 'above))))
|
|
||||||
(let ((evil-auto-indent evil-auto-indent))
|
|
||||||
(funcall orig-fn count)))))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +evil*static-reindent (orig-fn &rest args)
|
|
||||||
"Don't move cursor on indent."
|
|
||||||
(save-excursion (apply orig-fn args)))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +evil*resolve-vim-path (file-name)
|
|
||||||
"Take a path and resolve any vim-like filename modifiers in it. This adds
|
"Take a path and resolve any vim-like filename modifiers in it. This adds
|
||||||
support for most vim file modifiers, as well as:
|
support for most vim file modifiers, as well as:
|
||||||
|
|
||||||
|
@ -148,8 +85,77 @@ more information on modifiers."
|
||||||
path file-name t t 1))))
|
path file-name t t 1))))
|
||||||
(replace-regexp-in-string regexp "\\1" file-name t)))
|
(replace-regexp-in-string regexp "\\1" file-name t)))
|
||||||
|
|
||||||
;;;###autoload (autoload '+evil*window-split "editor/evil/autoload/advice" nil t)
|
(defun +evil--insert-newline (&optional above _noextranewline)
|
||||||
(evil-define-command +evil*window-split (&optional count file)
|
(let ((pos (save-excursion (beginning-of-line-text) (point)))
|
||||||
|
comment-auto-fill-only-comments)
|
||||||
|
(require 'smartparens)
|
||||||
|
(evil-narrow-to-field
|
||||||
|
(if above
|
||||||
|
(if (save-excursion (nth 4 (sp--syntax-ppss pos)))
|
||||||
|
(evil-save-goal-column
|
||||||
|
(setq evil-auto-indent nil)
|
||||||
|
(goto-char pos)
|
||||||
|
(let ((ws (abs (skip-chars-backward " \t"))))
|
||||||
|
;; FIXME oh god why
|
||||||
|
(save-excursion
|
||||||
|
(if comment-line-break-function
|
||||||
|
(funcall comment-line-break-function)
|
||||||
|
(comment-indent-new-line))
|
||||||
|
(when (and (derived-mode-p 'c-mode 'c++-mode 'objc-mode 'java-mode 'js2-mode)
|
||||||
|
(eq (char-after) ?/))
|
||||||
|
(insert "*"))
|
||||||
|
(insert
|
||||||
|
(make-string (max 0 (+ ws (skip-chars-backward " \t")))
|
||||||
|
32)))
|
||||||
|
(insert (make-string (max 1 ws) 32))))
|
||||||
|
(evil-move-beginning-of-line)
|
||||||
|
(insert (if use-hard-newlines hard-newline "\n"))
|
||||||
|
(forward-line -1)
|
||||||
|
(back-to-indentation))
|
||||||
|
(evil-move-end-of-line)
|
||||||
|
(cond ((sp-point-in-comment pos)
|
||||||
|
(setq evil-auto-indent nil)
|
||||||
|
(if comment-line-break-function
|
||||||
|
(funcall comment-line-break-function)
|
||||||
|
(comment-indent-new-line)))
|
||||||
|
;; TODO Find a better way to do this
|
||||||
|
((and (eq major-mode 'haskell-mode)
|
||||||
|
(fboundp 'haskell-indentation-newline-and-indent))
|
||||||
|
(setq evil-auto-indent nil)
|
||||||
|
(haskell-indentation-newline-and-indent))
|
||||||
|
(t
|
||||||
|
(insert (if use-hard-newlines hard-newline "\n"))
|
||||||
|
(back-to-indentation)))))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +evil--insert-newline-below-and-respect-comments-a (orig-fn count)
|
||||||
|
(if (or (not +evil-want-o/O-to-continue-comments)
|
||||||
|
(not (eq this-command 'evil-open-below))
|
||||||
|
(evil-insert-state-p))
|
||||||
|
(funcall orig-fn count)
|
||||||
|
(cl-letf (((symbol-function 'evil-insert-newline-below)
|
||||||
|
(lambda () (+evil--insert-newline))))
|
||||||
|
(let ((evil-auto-indent evil-auto-indent))
|
||||||
|
(funcall orig-fn count)))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +evil--insert-newline-above-and-respect-comments-a (orig-fn count)
|
||||||
|
(if (or (not +evil-want-o/O-to-continue-comments)
|
||||||
|
(not (eq this-command 'evil-open-above))
|
||||||
|
(evil-insert-state-p))
|
||||||
|
(funcall orig-fn count)
|
||||||
|
(cl-letf (((symbol-function 'evil-insert-newline-above)
|
||||||
|
(lambda () (+evil--insert-newline 'above))))
|
||||||
|
(let ((evil-auto-indent evil-auto-indent))
|
||||||
|
(funcall orig-fn count)))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +evil--static-reindent-a (orig-fn &rest args)
|
||||||
|
"Don't move cursor on indent."
|
||||||
|
(save-excursion (apply orig-fn args)))
|
||||||
|
|
||||||
|
;;;###autoload (autoload '+evil-window-split-a "editor/evil/autoload/advice" nil t)
|
||||||
|
(evil-define-command +evil-window-split-a (&optional count file)
|
||||||
"Same as `evil-window-split', but focuses (and recenters) the new split."
|
"Same as `evil-window-split', but focuses (and recenters) the new split."
|
||||||
:repeat nil
|
:repeat nil
|
||||||
(interactive "P<f>")
|
(interactive "P<f>")
|
||||||
|
@ -164,8 +170,8 @@ more information on modifiers."
|
||||||
(balance-windows (window-parent)))
|
(balance-windows (window-parent)))
|
||||||
(if file (evil-edit file)))
|
(if file (evil-edit file)))
|
||||||
|
|
||||||
;;;###autoload (autoload '+evil*window-vsplit "editor/evil/autoload/advice" nil t)
|
;;;###autoload (autoload '+evil-window-vsplit-a "editor/evil/autoload/advice" nil t)
|
||||||
(evil-define-command +evil*window-vsplit (&optional count file)
|
(evil-define-command +evil-window-vsplit-a (&optional count file)
|
||||||
"Same as `evil-window-vsplit', but focuses (and recenters) the new split."
|
"Same as `evil-window-vsplit', but focuses (and recenters) the new split."
|
||||||
:repeat nil
|
:repeat nil
|
||||||
(interactive "P<f>")
|
(interactive "P<f>")
|
||||||
|
@ -181,13 +187,7 @@ more information on modifiers."
|
||||||
(if file (evil-edit file)))
|
(if file (evil-edit file)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +evil*escape (&rest _)
|
(defun +evil--make-numbered-markers-global-a (orig-fn char)
|
||||||
"Call `doom/escape' if `evil-force-normal-state' is called interactively."
|
|
||||||
(when (called-interactively-p 'any)
|
|
||||||
(call-interactively #'doom/escape)))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +evil*make-numbered-markers-global (orig-fn char)
|
|
||||||
(or (and (>= char ?2) (<= char ?9))
|
(or (and (>= char ?2) (<= char ?9))
|
||||||
(funcall orig-fn char)))
|
(funcall orig-fn char)))
|
||||||
|
|
||||||
|
|
|
@ -107,36 +107,36 @@ directives. By default, this only recognizes C directives.")
|
||||||
(setq save-silently t)
|
(setq save-silently t)
|
||||||
(add-hook 'after-save-hook #'+evil|display-vimlike-save-message))
|
(add-hook 'after-save-hook #'+evil|display-vimlike-save-message))
|
||||||
;; Make ESC (from normal mode) the universal escaper. See `doom-escape-hook'.
|
;; Make ESC (from normal mode) the universal escaper. See `doom-escape-hook'.
|
||||||
(advice-add #'evil-force-normal-state :after #'+evil*escape)
|
(advice-add #'evil-force-normal-state :after #'+evil-escape-a)
|
||||||
;; Don't move cursor when indenting
|
;; Don't move cursor when indenting
|
||||||
(advice-add #'evil-indent :around #'+evil*static-reindent)
|
(advice-add #'evil-indent :around #'+evil--static-reindent-a)
|
||||||
;; monkey patch `evil-ex-replace-special-filenames' to improve support for
|
;; monkey patch `evil-ex-replace-special-filenames' to improve support for
|
||||||
;; file modifiers like %:p:h. This adds support for most of vim's modifiers,
|
;; file modifiers like %:p:h. This adds support for most of vim's modifiers,
|
||||||
;; and one custom one: %:P (expand to the project root).
|
;; and one custom one: %:P (expand to the project root).
|
||||||
(advice-add #'evil-ex-replace-special-filenames :override #'+evil*resolve-vim-path)
|
(advice-add #'evil-ex-replace-special-filenames :override #'+evil-resolve-vim-path-a)
|
||||||
|
|
||||||
;; make `try-expand-dabbrev' (from `hippie-expand') work in minibuffer
|
;; make `try-expand-dabbrev' (from `hippie-expand') work in minibuffer
|
||||||
(add-hook 'minibuffer-inactive-mode-hook #'+evil*fix-dabbrev-in-minibuffer)
|
(add-hook 'minibuffer-inactive-mode-hook #'+evil--fix-dabbrev-in-minibuffer-a)
|
||||||
|
|
||||||
;; Focus and recenter new splits
|
;; Focus and recenter new splits
|
||||||
(advice-add #'evil-window-split :override #'+evil*window-split)
|
(advice-add #'evil-window-split :override #'+evil-window-split-a)
|
||||||
(advice-add #'evil-window-vsplit :override #'+evil*window-vsplit)
|
(advice-add #'evil-window-vsplit :override #'+evil-window-vsplit-a)
|
||||||
|
|
||||||
;; In evil, registers 2-9 are buffer-local. In vim, they're global, so...
|
;; In evil, registers 2-9 are buffer-local. In vim, they're global, so...
|
||||||
(advice-add #'evil-global-marker-p :around #'+evil*make-numbered-markers-global)
|
(advice-add #'evil-global-marker-p :around #'+evil--make-numbered-markers-global-a)
|
||||||
|
|
||||||
;; Make o/O continue comments (see `+evil-want-o/O-to-continue-comments')
|
;; Make o/O continue comments (see `+evil-want-o/O-to-continue-comments')
|
||||||
(advice-add #'evil-open-above :around #'+evil*insert-newline-above-and-respect-comments)
|
(advice-add #'evil-open-above :around #'+evil--insert-newline-above-and-respect-comments-a)
|
||||||
(advice-add #'evil-open-below :around #'+evil*insert-newline-below-and-respect-comments)
|
(advice-add #'evil-open-below :around #'+evil--insert-newline-below-and-respect-comments-a)
|
||||||
|
|
||||||
;; Recenter screen after most searches
|
;; Recenter screen after most searches
|
||||||
(advice-add! '(evil-visualstar/begin-search-forward
|
(dolist (fn '(evil-visualstar/begin-search-forward
|
||||||
evil-visualstar/begin-search-backward
|
evil-visualstar/begin-search-backward
|
||||||
evil-ex-search-word-backward
|
evil-ex-search-word-backward
|
||||||
evil-ex-search-word-backward
|
evil-ex-search-word-backward
|
||||||
evil-ex-search-forward
|
evil-ex-search-forward
|
||||||
evil-ex-search-backward)
|
evil-ex-search-backward))
|
||||||
:after #'doom*recenter)
|
(advice-add fn :after #'doom-recenter-a))
|
||||||
|
|
||||||
;; --- custom interactive codes -----------
|
;; --- custom interactive codes -----------
|
||||||
;; These arg types will highlight matches in the current buffer
|
;; These arg types will highlight matches in the current buffer
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
(after-all
|
(after-all
|
||||||
(unload-feature 'evil t))
|
(unload-feature 'evil t))
|
||||||
(before-each
|
(before-each
|
||||||
(fset 'resv #'+evil*resolve-vim-path)
|
(fset 'resv #'+evil-resolve-vim-path-a)
|
||||||
(spy-on 'doom-project-root :and-call-fake (lambda () project-root)))
|
(spy-on 'doom-project-root :and-call-fake (lambda () project-root)))
|
||||||
|
|
||||||
;; `evil-ex-replace-special-filenames' / `+evil*resolve-vim-path'
|
;; `evil-ex-replace-special-filenames' / `+evil-resolve-vim-path-a'
|
||||||
(describe "file modifiers"
|
(describe "file modifiers"
|
||||||
(it "supports basic vim file modifiers"
|
(it "supports basic vim file modifiers"
|
||||||
(let ((buffer-file-name "~/.emacs.d/test/modules/feature/test-evil.el")
|
(let ((buffer-file-name "~/.emacs.d/test/modules/feature/test-evil.el")
|
||||||
|
|
|
@ -24,14 +24,11 @@
|
||||||
;; Nicer code-folding overlays (with fringe indicators)
|
;; Nicer code-folding overlays (with fringe indicators)
|
||||||
hs-set-up-overlay #'+fold-hideshow-set-up-overlay)
|
hs-set-up-overlay #'+fold-hideshow-set-up-overlay)
|
||||||
|
|
||||||
(defun +fold-hideshow*ensure-mode (&rest _)
|
(def-advice! +fold-hideshow*ensure-mode (&rest _)
|
||||||
"Ensure `hs-minor-mode' is enabled."
|
"Ensure `hs-minor-mode' is enabled."
|
||||||
|
:before '(hs-toggle-hiding hs-hide-block hs-hide-level hs-show-all hs-hide-all)
|
||||||
(unless (bound-and-true-p hs-minor-mode)
|
(unless (bound-and-true-p hs-minor-mode)
|
||||||
(hs-minor-mode +1)))
|
(hs-minor-mode +1)))
|
||||||
(advice-add! '(hs-toggle-hiding
|
|
||||||
hs-hide-block hs-hide-level
|
|
||||||
hs-show-all hs-hide-all)
|
|
||||||
:before #'+fold-hideshow*ensure-mode)
|
|
||||||
|
|
||||||
;; extra folding support for more languages
|
;; extra folding support for more languages
|
||||||
(unless (assq 't hs-special-modes-alist)
|
(unless (assq 't hs-special-modes-alist)
|
||||||
|
|
|
@ -96,15 +96,15 @@
|
||||||
(setq +mc--compat-mark-was-active nil))))
|
(setq +mc--compat-mark-was-active nil))))
|
||||||
(add-hook 'multiple-cursors-mode-disabled-hook #'+multiple-cursors|compat-back-to-previous-state)
|
(add-hook 'multiple-cursors-mode-disabled-hook #'+multiple-cursors|compat-back-to-previous-state)
|
||||||
|
|
||||||
;; When running edit-lines, point will return (position + 1) as a
|
;; When running edit-lines, point will return (position + 1) as a result of
|
||||||
;; result of how evil deals with regions
|
;; how evil deals with regions
|
||||||
(defun +multiple-cursors*adjust-mark-for-evil (&rest _)
|
(def-advice! +multiple-cursors-adjust-mark-for-evil-a (&rest _)
|
||||||
|
:before #'mc/edit-lines
|
||||||
(when (and (bound-and-true-p evil-mode)
|
(when (and (bound-and-true-p evil-mode)
|
||||||
(not (memq evil-state '(insert emacs))))
|
(not (memq evil-state '(insert emacs))))
|
||||||
(if (> (point) (mark))
|
(if (> (point) (mark))
|
||||||
(goto-char (1- (point)))
|
(goto-char (1- (point)))
|
||||||
(push-mark (1- (mark))))))
|
(push-mark (1- (mark))))))
|
||||||
(advice-add #'mc/edit-lines :before #'+multiple-cursors*adjust-mark-for-evil)
|
|
||||||
|
|
||||||
(defun +multiple-cursors|evil-compat-rect-switch-state ()
|
(defun +multiple-cursors|evil-compat-rect-switch-state ()
|
||||||
(if rectangular-region-mode
|
(if rectangular-region-mode
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
(after! git-timemachine
|
(after! git-timemachine
|
||||||
;; HACK Waiting for https://gitlab.com/pidu/git-timemachine/issues/77
|
;; HACK Waiting for https://gitlab.com/pidu/git-timemachine/issues/77
|
||||||
(defun +vc*git-timemachine-show-commit ()
|
(def-advice! +vc--git-timemachine-show-commit-a ()
|
||||||
|
"Fix `git-timemachine-show-commit'."
|
||||||
|
:override #'git-timemachine-show-commit
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((rev (car git-timemachine-revision)))
|
(let ((rev (car git-timemachine-revision)))
|
||||||
(if (fboundp 'magit-revision-mode)
|
(if (fboundp 'magit-revision-mode)
|
||||||
|
@ -17,7 +19,6 @@
|
||||||
(magit-buffer-diff-args nil)
|
(magit-buffer-diff-args nil)
|
||||||
(magit-buffer-diff-files nil))))
|
(magit-buffer-diff-files nil))))
|
||||||
(message "You need to install magit to show commit"))))
|
(message "You need to install magit to show commit"))))
|
||||||
(advice-add #'git-timemachine-show-commit :override #'+vc*git-timemachine-show-commit)
|
|
||||||
|
|
||||||
;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of
|
;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of
|
||||||
;; showing revision details in the minibuffer, show them in
|
;; showing revision details in the minibuffer, show them in
|
||||||
|
|
|
@ -31,9 +31,10 @@
|
||||||
;;
|
;;
|
||||||
;;; Hacks
|
;;; Hacks
|
||||||
|
|
||||||
(defun +chinese*org-html-paragraph (paragraph contents info)
|
(def-advice! +chinese--org-html-paragraph-a (paragraph contents info)
|
||||||
"Join consecutive Chinese lines into a single long line without unwanted space
|
"Join consecutive Chinese lines into a single long line without unwanted space
|
||||||
when exporting org-mode to html."
|
when exporting org-mode to html."
|
||||||
|
:filter-args #'org-html-paragraph
|
||||||
(let* ((fix-regexp "[[:multibyte:]]")
|
(let* ((fix-regexp "[[:multibyte:]]")
|
||||||
(origin-contents contents)
|
(origin-contents contents)
|
||||||
(fixed-contents
|
(fixed-contents
|
||||||
|
@ -42,4 +43,3 @@ when exporting org-mode to html."
|
||||||
"\\1\\2"
|
"\\1\\2"
|
||||||
origin-contents)))
|
origin-contents)))
|
||||||
(list paragraph fixed-contents info)))
|
(list paragraph fixed-contents info)))
|
||||||
(advice-add #'org-html-paragraph :filter-args #'+chinese*org-html-paragraph)
|
|
||||||
|
|
|
@ -41,9 +41,10 @@
|
||||||
;;
|
;;
|
||||||
;;; Hacks
|
;;; Hacks
|
||||||
|
|
||||||
(defun +japanese*org-html-paragraph (paragraph contents info)
|
(def-advice! +japanese--org-html-paragraph-a (paragraph contents info)
|
||||||
"Join consecutive Japanese lines into a single long line without unwanted space
|
"Join consecutive Japanese lines into a single long line without unwanted space
|
||||||
when exporting org-mode to html."
|
when exporting org-mode to html."
|
||||||
|
:filter-args #'org-html-paragraph
|
||||||
(let* ((fix-regexp "[[:multibyte:]]")
|
(let* ((fix-regexp "[[:multibyte:]]")
|
||||||
(origin-contents contents)
|
(origin-contents contents)
|
||||||
(fixed-contents
|
(fixed-contents
|
||||||
|
@ -52,4 +53,3 @@ when exporting org-mode to html."
|
||||||
"\\1\\2"
|
"\\1\\2"
|
||||||
origin-contents)))
|
origin-contents)))
|
||||||
(list paragraph fixed-contents info)))
|
(list paragraph fixed-contents info)))
|
||||||
(advice-add #'org-html-paragraph :filter-args #'+japanese*org-html-paragraph)
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
||||||
`((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face)))))
|
`((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face)))))
|
||||||
|
|
||||||
;; Recenter window after following definition
|
;; Recenter window after following definition
|
||||||
(advice-add #'elisp-def :after #'doom*recenter)
|
(advice-add #'elisp-def :after #'doom-recenter-a)
|
||||||
|
|
||||||
(map! :localleader
|
(map! :localleader
|
||||||
:map emacs-lisp-mode-map
|
:map emacs-lisp-mode-map
|
||||||
|
|
|
@ -12,24 +12,24 @@ nimsuggest isn't installed."
|
||||||
|
|
||||||
(when IS-WINDOWS
|
(when IS-WINDOWS
|
||||||
;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
|
;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
|
||||||
(defun doom*nimsuggest--get-dirty-dir ()
|
(def-advice! +nim--suggest-get-dirty-dir-a ()
|
||||||
"The original `nimsuggest--get-dirty-dir' incorrectly extracts the frame
|
"The original `nimsuggest--get-dirty-dir' incorrectly extracts the frame
|
||||||
number from the string representation of `selected-frame', which can contain
|
number from the string representation of `selected-frame', which can contain
|
||||||
characters that are illegal on Windows, causing invalid argument errors when
|
characters that are illegal on Windows, causing invalid argument errors when
|
||||||
`nimsuggest--make-tempdir' tries to use it."
|
`nimsuggest--make-tempdir' tries to use it."
|
||||||
|
:override #'nimsuggest--get-dirty-dir
|
||||||
(let* ((frame-str (format "%s" (selected-frame)))
|
(let* ((frame-str (format "%s" (selected-frame)))
|
||||||
(frame-num-str (if (string-match " \\(0x[0-9a-z]+\\)>$" frame-str)
|
(frame-num-str (if (string-match " \\(0x[0-9a-z]+\\)>$" frame-str)
|
||||||
(match-string 1 frame-str))))
|
(match-string 1 frame-str))))
|
||||||
(file-name-as-directory (concat nimsuggest-dirty-directory frame-num-str))))
|
(file-name-as-directory (concat nimsuggest-dirty-directory frame-num-str))))
|
||||||
(advice-add #'nimsuggest--get-dirty-dir :override #'doom*nimsuggest--get-dirty-dir)
|
|
||||||
|
|
||||||
;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
|
;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
|
||||||
(defun doom*nimsuggest--get-temp-file-name (path)
|
(def-advice! +nim--suggest-get-temp-file-name-a (path)
|
||||||
"Removes invalid characters from the temp file path, including the unicode
|
"Removes invalid characters from the temp file path, including the unicode
|
||||||
character that colon is replaced with, which is known to cause issues on
|
character that colon is replaced with, which is known to cause issues on
|
||||||
windows."
|
windows."
|
||||||
(replace-regexp-in-string "[꞉* |<>\"?*]" "" path))
|
:filter-return #'nimsuggest--get-temp-file-name
|
||||||
(advice-add #'nimsuggest--get-temp-file-name :filter-return #'doom*nimsuggest--get-temp-file-name))
|
(replace-regexp-in-string "[꞉* |<>\"?*]" "" path)))
|
||||||
|
|
||||||
(map! :localleader
|
(map! :localleader
|
||||||
:map nim-mode-map
|
:map nim-mode-map
|
||||||
|
|
|
@ -842,7 +842,7 @@ compelling reason, so..."
|
||||||
(if (featurep! +present) (load! "contrib/present"))
|
(if (featurep! +present) (load! "contrib/present"))
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(add-hook 'org-open-at-point-functions #'doom|set-jump)
|
(add-hook 'org-open-at-point-functions #'doom-set-jump-h)
|
||||||
|
|
||||||
;;; Packages
|
;;; Packages
|
||||||
(after! toc-org
|
(after! toc-org
|
||||||
|
|
|
@ -54,11 +54,11 @@
|
||||||
|
|
||||||
;; `rustic-setup-rls' uses `package-installed-p' unnecessarily, which breaks
|
;; `rustic-setup-rls' uses `package-installed-p' unnecessarily, which breaks
|
||||||
;; because Doom lazy loads package.el.
|
;; because Doom lazy loads package.el.
|
||||||
(defun +rust*disable-package-installed-p-call (orig-fn &rest args)
|
(def-advice! +rust--disable-package-call-a (orig-fn &rest args)
|
||||||
|
:around #'rustic-setup-rls
|
||||||
(cl-letf (((symbol-function 'package-installed-p)
|
(cl-letf (((symbol-function 'package-installed-p)
|
||||||
(symbol-function 'ignore)))
|
(symbol-function 'ignore)))
|
||||||
(apply orig-fn args)))
|
(apply orig-fn args))))
|
||||||
(advice-add #'rustic-setup-rls :around #'+rust*disable-package-installed-p-call))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
(nil "^\\s-*\\([[:alpha:]_-][[:alnum:]_-]*\\)\\s-*()" 1)))
|
(nil "^\\s-*\\([[:alpha:]_-][[:alnum:]_-]*\\)\\s-*()" 1)))
|
||||||
|
|
||||||
;; `sh-set-shell' is chatty about setting up indentation rules
|
;; `sh-set-shell' is chatty about setting up indentation rules
|
||||||
(advice-add #'sh-set-shell :around #'doom*shut-up)
|
(advice-add #'sh-set-shell :around #'doom-shut-up-a)
|
||||||
|
|
||||||
;; 1. Fontifies variables in double quotes
|
;; 1. Fontifies variables in double quotes
|
||||||
;; 2. Fontify command substitution in double quotes
|
;; 2. Fontify command substitution in double quotes
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"TODO"
|
"TODO"
|
||||||
(interactive "<fsh><!>")
|
(interactive "<fsh><!>")
|
||||||
(let ((buffer (+eshell-last-buffer))
|
(let ((buffer (+eshell-last-buffer))
|
||||||
(command (+evil*resolve-vim-path command)))
|
(command (+evil-resolve-vim-path-a command)))
|
||||||
(cond (buffer
|
(cond (buffer
|
||||||
(select-window (get-buffer-window buffer))
|
(select-window (get-buffer-window buffer))
|
||||||
(+eshell-run-command command buffer))
|
(+eshell-run-command command buffer))
|
||||||
|
|
|
@ -27,12 +27,18 @@ buffer/window/frame switch, which is less expensive."
|
||||||
(0 font-lock-keyword-face)))))
|
(0 font-lock-keyword-face)))))
|
||||||
(add-hook 'direnv-envrc-mode-hook #'+direnv|envrc-fontify-keywords)
|
(add-hook 'direnv-envrc-mode-hook #'+direnv|envrc-fontify-keywords)
|
||||||
|
|
||||||
(defun +direnv*update (&rest _)
|
(def-advice! +direnv--update-a (&rest _)
|
||||||
"Update direnv. Useful to advise functions that may run
|
"Update direnv. Useful to advise functions that may run
|
||||||
environment-sensitive logic like `flycheck-default-executable-find'. This fixes
|
environment-sensitive logic like `flycheck-default-executable-find'. This fixes
|
||||||
flycheck issues with direnv and on nix."
|
flycheck issues with direnv and on nix."
|
||||||
(direnv-update-environment default-directory))
|
:before #'flycheck-default-executable-find
|
||||||
(advice-add #'flycheck-default-executable-find :before #'+direnv*update)
|
(direnv--maybe-update-environment))
|
||||||
|
|
||||||
(when (executable-find "direnv")
|
(def-advice! +direnv--fail-gracefully-a (orig-fn)
|
||||||
(direnv-mode +1)))
|
"Don't try to update direnv if the executable isn't present."
|
||||||
|
:around #'direnv--maybe-update-environment
|
||||||
|
(if (executable-find "direnv")
|
||||||
|
(funcall orig-fn)
|
||||||
|
(doom-log "Couldn't find direnv executable")))
|
||||||
|
|
||||||
|
(direnv-mode +1))
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
(perl-mode . "pl")
|
(perl-mode . "pl")
|
||||||
(php-mode . "php"))
|
(php-mode . "php"))
|
||||||
"An alist mapping major modes to extensions. Used by
|
"An alist mapping major modes to extensions. Used by
|
||||||
`doom*editorconfig-smart-detection' to give editorconfig filetype hints.")
|
`doom--editorconfig-smart-detection-a' to give editorconfig filetype hints.")
|
||||||
|
|
||||||
|
|
||||||
;; Handles whitespace (tabs/spaces) settings externally. This way projects can
|
;; Handles whitespace (tabs/spaces) settings externally. This way projects can
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
(def-package! editorconfig
|
(def-package! editorconfig
|
||||||
:after-call (doom-switch-buffer-hook after-find-file)
|
:after-call (doom-switch-buffer-hook after-find-file)
|
||||||
:config
|
:config
|
||||||
(defun doom*editorconfig-smart-detection (orig-fn)
|
(defun doom--editorconfig-smart-detection-a (orig-fn)
|
||||||
"Retrieve the properties for the current file. If it doesn't have an
|
"Retrieve the properties for the current file. If it doesn't have an
|
||||||
extension, try to guess one."
|
extension, try to guess one."
|
||||||
(let ((buffer-file-name
|
(let ((buffer-file-name
|
||||||
|
@ -32,7 +32,7 @@ extension, try to guess one."
|
||||||
(concat "." ext)
|
(concat "." ext)
|
||||||
"")))))
|
"")))))
|
||||||
(funcall orig-fn)))
|
(funcall orig-fn)))
|
||||||
(advice-add #'editorconfig-call-editorconfig-exec :around #'doom*editorconfig-smart-detection)
|
(advice-add #'editorconfig-call-editorconfig-exec :around #'doom--editorconfig-smart-detection-a)
|
||||||
|
|
||||||
(defun +editorconfig|disable-ws-butler-maybe (props)
|
(defun +editorconfig|disable-ws-butler-maybe (props)
|
||||||
"Disable `ws-butler-mode' if trim_trailing_whitespace is true."
|
"Disable `ws-butler-mode' if trim_trailing_whitespace is true."
|
||||||
|
|
|
@ -114,7 +114,7 @@ this list.")
|
||||||
(advice-add #'projectile-find-tag :around #'+lookup*projectile-find-tag)
|
(advice-add #'projectile-find-tag :around #'+lookup*projectile-find-tag)
|
||||||
|
|
||||||
;; Use `better-jumper' instead of xref's marker stack
|
;; Use `better-jumper' instead of xref's marker stack
|
||||||
(advice-add #'xref-push-marker-stack :around #'doom*set-jump)
|
(advice-add #'xref-push-marker-stack :around #'doom-set-jump-a)
|
||||||
|
|
||||||
(def-package! ivy-xref
|
(def-package! ivy-xref
|
||||||
:when (featurep! :completion ivy)
|
:when (featurep! :completion ivy)
|
||||||
|
|
|
@ -123,18 +123,3 @@ control in buffers."
|
||||||
(url-or-repo))
|
(url-or-repo))
|
||||||
dir
|
dir
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
|
|
||||||
;;
|
|
||||||
;; Advice
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +magit*hub-settings--format-magithub.enabled ()
|
|
||||||
"Change the setting to display 'false' as its default."
|
|
||||||
(magit--format-popup-variable:choices "magithub.enabled" '("true" "false") "false"))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun +magit*hub-enabled-p ()
|
|
||||||
"Disables magithub by default."
|
|
||||||
(magithub-settings--value-or "magithub.enabled" nil
|
|
||||||
#'magit-get-boolean))
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ It is passed a user and repository name.")
|
||||||
:config
|
:config
|
||||||
(setq magit-todos-keyword-suffix "\\(?:([^)]+)\\)?:?")
|
(setq magit-todos-keyword-suffix "\\(?:([^)]+)\\)?:?")
|
||||||
(define-key magit-todos-section-map "j" nil)
|
(define-key magit-todos-section-map "j" nil)
|
||||||
(advice-add #'magit-todos-mode :around #'doom*shut-up)
|
(advice-add #'magit-todos-mode :around #'doom-shut-up-a)
|
||||||
(magit-todos-mode +1))
|
(magit-todos-mode +1))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -86,10 +86,10 @@
|
||||||
(set-window-fringes (minibuffer-window) 0 0 nil))
|
(set-window-fringes (minibuffer-window) 0 0 nil))
|
||||||
(add-hook 'solaire-mode-hook #'+doom|disable-fringes-in-minibuffer)
|
(add-hook 'solaire-mode-hook #'+doom|disable-fringes-in-minibuffer)
|
||||||
|
|
||||||
(defun doom*no-fringes-in-which-key-buffer (&rest _)
|
(def-advice! +doom--no-fringes-in-which-key-buffer-a (&rest _)
|
||||||
(+doom|disable-fringes-in-minibuffer)
|
:after 'which-key--show-buffer-side-window
|
||||||
|
(+doom--disable-fringes-in-minibuffer-h)
|
||||||
(set-window-fringes (get-buffer-window which-key--buffer) 0 0 nil))
|
(set-window-fringes (get-buffer-window which-key--buffer) 0 0 nil))
|
||||||
(advice-add 'which-key--show-buffer-side-window :after #'doom*no-fringes-in-which-key-buffer)
|
|
||||||
|
|
||||||
(add-hook! '(minibuffer-setup-hook window-configuration-change-hook)
|
(add-hook! '(minibuffer-setup-hook window-configuration-change-hook)
|
||||||
#'+doom|disable-fringes-in-minibuffer)
|
#'+doom|disable-fringes-in-minibuffer)
|
||||||
|
|
|
@ -58,10 +58,10 @@
|
||||||
'(misc-info mu4e github debug fancy-battery " " major-mode process))
|
'(misc-info mu4e github debug fancy-battery " " major-mode process))
|
||||||
|
|
||||||
;; Some functions modify the buffer, causing the modeline to show a false
|
;; Some functions modify the buffer, causing the modeline to show a false
|
||||||
;; modified state, so we try to force them to behave.
|
;; modified state, so force them to behave.
|
||||||
(defun +modeline*inhibit-modification-hooks (orig-fn &rest args)
|
(def-advice! +modeline--inhibit-modification-hooks-a (orig-fn &rest args)
|
||||||
(with-silent-modifications (apply orig-fn args)))
|
:around #'ws-butler-after-save
|
||||||
(advice-add #'ws-butler-after-save :around #'+modeline*inhibit-modification-hooks))
|
(with-silent-modifications (apply orig-fn args))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -36,7 +36,7 @@ for `org-follow-link-hook')."
|
||||||
(defalias '+nav-flash|blink-cursor-maybe #'+nav-flash-blink-cursor-maybe)
|
(defalias '+nav-flash|blink-cursor-maybe #'+nav-flash-blink-cursor-maybe)
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defalias '+nav-flash*blink-cursor #'+nav-flash-blink-cursor-maybe)
|
(defalias '+nav-flash-blink-cursor-a #'+nav-flash-blink-cursor-maybe)
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +nav-flash/blink-cursor (&rest _)
|
(defun +nav-flash/blink-cursor (&rest _)
|
||||||
|
|
|
@ -21,10 +21,9 @@
|
||||||
(add-hook 'org-follow-link-hook #'+nav-flash|delayed-blink-cursor)
|
(add-hook 'org-follow-link-hook #'+nav-flash|delayed-blink-cursor)
|
||||||
|
|
||||||
;; `saveplace'
|
;; `saveplace'
|
||||||
(advice-add #'save-place-find-file-hook :after #'+nav-flash*blink-cursor)
|
(advice-add #'save-place-find-file-hook :after #'+nav-flash-blink-cursor-a)
|
||||||
|
|
||||||
;; `evil'
|
;; `evil'
|
||||||
(advice-add #'evil-window-top :after #'+nav-flash*blink-cursor)
|
(advice-add #'evil-window-top :after #'+nav-flash-blink-cursor-a)
|
||||||
(advice-add #'evil-window-middle :after #'+nav-flash*blink-cursor)
|
(advice-add #'evil-window-middle :after #'+nav-flash-blink-cursor-a)
|
||||||
(advice-add #'evil-window-bottom :after #'+nav-flash*blink-cursor))
|
(advice-add #'evil-window-bottom :after #'+nav-flash-blink-cursor-a))
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,7 @@
|
||||||
(+neotree*indent-cursor)))
|
(+neotree*indent-cursor)))
|
||||||
(add-hook 'neo-enter-hook #'+neotree*fix-cursor)
|
(add-hook 'neo-enter-hook #'+neotree*fix-cursor)
|
||||||
|
|
||||||
(defun +neotree*indent-cursor (&rest _)
|
(def-advice! +neotree--indent-cursor-a (&rest _)
|
||||||
|
:after '(neotree-next-line neotree-previous-line)
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(skip-chars-forward " \t\r"))
|
(skip-chars-forward " \t\r")))
|
||||||
(advice-add #'neotree-next-line :after #'+neotree*indent-cursor)
|
|
||||||
(advice-add #'neotree-previous-line :after #'+neotree*indent-cursor))
|
|
||||||
|
|
|
@ -38,11 +38,10 @@
|
||||||
|
|
||||||
|
|
||||||
;;;###package company
|
;;;###package company
|
||||||
(progn
|
(def-advice! +popup--dont-select-me-a (orig-fn &rest args)
|
||||||
(defun +popup*dont-select-me (orig-fn &rest args)
|
:around #'company-show-doc-buffer
|
||||||
(let ((+popup--inhibit-select t))
|
(let ((+popup--inhibit-select t))
|
||||||
(apply orig-fn args)))
|
(apply orig-fn args)))
|
||||||
(advice-add #'company-show-doc-buffer :around #'+popup*dont-select-me))
|
|
||||||
|
|
||||||
|
|
||||||
;;;###package eshell
|
;;;###package eshell
|
||||||
|
@ -51,21 +50,22 @@
|
||||||
|
|
||||||
;; When eshell runs a visual command (see `eshell-visual-commands'), it spawns
|
;; When eshell runs a visual command (see `eshell-visual-commands'), it spawns
|
||||||
;; a term buffer to run it in, but where it spawns it is the problem...
|
;; a term buffer to run it in, but where it spawns it is the problem...
|
||||||
(defun +popup*eshell-undedicate-popup (orig-fn &rest args)
|
(def-advice! +popup--eshell-undedicate-popup (&rest _)
|
||||||
"Force spawned term buffer to share with the eshell popup (if necessary)."
|
"Force spawned term buffer to share with the eshell popup (if necessary)."
|
||||||
|
:before #'eshell-exec-visual
|
||||||
(when (+popup-window-p)
|
(when (+popup-window-p)
|
||||||
(set-window-dedicated-p nil nil)
|
(set-window-dedicated-p nil nil)
|
||||||
(add-transient-hook! #'eshell-query-kill-processes :after
|
(add-transient-hook! #'eshell-query-kill-processes :after
|
||||||
(set-window-dedicated-p nil t)))
|
(set-window-dedicated-p nil t)))))
|
||||||
(apply orig-fn args))
|
|
||||||
(advice-add #'eshell-exec-visual :around #'+popup*eshell-undedicate-popup))
|
|
||||||
|
|
||||||
|
|
||||||
;;;###package evil
|
;;;###package evil
|
||||||
(progn
|
(progn
|
||||||
(defun +popup*evil-command-window (hist cmd-key execute-fn)
|
;; Make evil-mode cooperate with popups
|
||||||
|
(def-advice! +popup--evil-command-window-a (hist cmd-key execute-fn)
|
||||||
"Monkey patch the evil command window to use `pop-to-buffer' instead of
|
"Monkey patch the evil command window to use `pop-to-buffer' instead of
|
||||||
`switch-to-buffer', allowing the popup manager to handle it."
|
`switch-to-buffer', allowing the popup manager to handle it."
|
||||||
|
:override #'evil-command-window
|
||||||
(when (eq major-mode 'evil-command-window-mode)
|
(when (eq major-mode 'evil-command-window-mode)
|
||||||
(user-error "Cannot recursively open command line window"))
|
(user-error "Cannot recursively open command line window"))
|
||||||
(dolist (win (window-list))
|
(dolist (win (window-list))
|
||||||
|
@ -81,9 +81,10 @@
|
||||||
(evil-command-window-mode)
|
(evil-command-window-mode)
|
||||||
(evil-command-window-insert-commands hist)))
|
(evil-command-window-insert-commands hist)))
|
||||||
|
|
||||||
(defun +popup*evil-command-window-execute ()
|
(def-advice! +popup--evil-command-window-execute-a ()
|
||||||
"Execute the command under the cursor in the appropriate buffer, rather than
|
"Execute the command under the cursor in the appropriate buffer, rather than
|
||||||
the command buffer."
|
the command buffer."
|
||||||
|
:override #'evil-command-window-execute
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((result (buffer-substring (line-beginning-position)
|
(let ((result (buffer-substring (line-beginning-position)
|
||||||
(line-end-position)))
|
(line-end-position)))
|
||||||
|
@ -98,10 +99,6 @@ the command buffer."
|
||||||
(funcall execute-fn result)
|
(funcall execute-fn result)
|
||||||
(setq evil-command-window-current-buffer nil)))
|
(setq evil-command-window-current-buffer nil)))
|
||||||
|
|
||||||
;; Make evil-mode cooperate with popups
|
|
||||||
(advice-add #'evil-command-window :override #'+popup*evil-command-window)
|
|
||||||
(advice-add #'evil-command-window-execute :override #'+popup*evil-command-window-execute)
|
|
||||||
|
|
||||||
;; Don't mess with popups
|
;; Don't mess with popups
|
||||||
(advice-add #'+evil--window-swap :around #'+popup*save)
|
(advice-add #'+evil--window-swap :around #'+popup*save)
|
||||||
(advice-add #'evil-window-move-very-bottom :around #'+popup*save)
|
(advice-add #'evil-window-move-very-bottom :around #'+popup*save)
|
||||||
|
@ -153,9 +150,9 @@ the command buffer."
|
||||||
|
|
||||||
|
|
||||||
;;;###package helpful
|
;;;###package helpful
|
||||||
(progn
|
(def-advice! +popup--helpful-open-in-origin-window-a (button)
|
||||||
(defun +popup*helpful-open-in-origin-window (button)
|
|
||||||
"Open links in non-popup, originating window rather than helpful's window."
|
"Open links in non-popup, originating window rather than helpful's window."
|
||||||
|
:override #'helpful--navigate
|
||||||
(let ((path (substring-no-properties (button-get button 'path)))
|
(let ((path (substring-no-properties (button-get button 'path)))
|
||||||
enable-local-variables
|
enable-local-variables
|
||||||
origin)
|
origin)
|
||||||
|
@ -167,7 +164,6 @@ the command buffer."
|
||||||
(setq origin (selected-window))
|
(setq origin (selected-window))
|
||||||
(recenter))
|
(recenter))
|
||||||
(select-window origin)))
|
(select-window origin)))
|
||||||
(advice-add #'helpful--navigate :override #'+popup*helpful-open-in-origin-window))
|
|
||||||
|
|
||||||
|
|
||||||
;;;###package helm
|
;;;###package helm
|
||||||
|
@ -176,7 +172,8 @@ the command buffer."
|
||||||
(setq helm-default-display-buffer-functions '(+popup-display-buffer-stacked-side-window))
|
(setq helm-default-display-buffer-functions '(+popup-display-buffer-stacked-side-window))
|
||||||
|
|
||||||
;; Fix #897: "cannot open side window" error when TAB-completing file links
|
;; Fix #897: "cannot open side window" error when TAB-completing file links
|
||||||
(defun +popup*hide-org-links-popup (orig-fn &rest args)
|
(def-advice! +popup--helm-hide-org-links-popup-a (orig-fn &rest args)
|
||||||
|
:around #'org-insert-link
|
||||||
(cl-letf* ((old-org-completing-read (symbol-function 'org-completing-read))
|
(cl-letf* ((old-org-completing-read (symbol-function 'org-completing-read))
|
||||||
((symbol-function 'org-completing-read)
|
((symbol-function 'org-completing-read)
|
||||||
(lambda (&rest args)
|
(lambda (&rest args)
|
||||||
|
@ -192,23 +189,22 @@ the command buffer."
|
||||||
(get-buffer-create "*Org Links*"))
|
(get-buffer-create "*Org Links*"))
|
||||||
(apply old-org-completing-read args))))
|
(apply old-org-completing-read args))))
|
||||||
(apply orig-fn args)))
|
(apply orig-fn args)))
|
||||||
(advice-add #'org-insert-link :around #'+popup*hide-org-links-popup)
|
|
||||||
|
|
||||||
;; Fix left-over popup window when closing persistent help for `helm-M-x'
|
;; Fix left-over popup window when closing persistent help for `helm-M-x'
|
||||||
(defun +popup*helm-elisp--persistent-help (candidate _fun &optional _name)
|
(def-advice! +popup--helm-elisp--persistent-help-a (candidate _fun &optional _name)
|
||||||
|
:before #'helm-elisp--persistent-help
|
||||||
(let (win)
|
(let (win)
|
||||||
(when (and (helm-attr 'help-running-p)
|
(when (and (helm-attr 'help-running-p)
|
||||||
(string= candidate (helm-attr 'help-current-symbol))
|
(string= candidate (helm-attr 'help-current-symbol))
|
||||||
(setq win (get-buffer-window (get-buffer (help-buffer)))))
|
(setq win (get-buffer-window (get-buffer (help-buffer)))))
|
||||||
(delete-window win))))
|
(delete-window win))))
|
||||||
(advice-add #'helm-elisp--persistent-help :before #'+popup*helm-elisp--persistent-help)
|
|
||||||
|
|
||||||
;; `helm-ag'
|
;; `helm-ag'
|
||||||
(defun +helm*pop-to-buffer (orig-fn &rest args)
|
(def-advice! +popup--helm-pop-to-buffer-a (orig-fn &rest args)
|
||||||
|
:around #'helm-ag--edit
|
||||||
(pop-to-buffer
|
(pop-to-buffer
|
||||||
(save-window-excursion (apply orig-fn args)
|
(save-window-excursion (apply orig-fn args)
|
||||||
(current-buffer))))
|
(current-buffer)))))
|
||||||
(advice-add #'helm-ag--edit :around #'+helm*pop-to-buffer))
|
|
||||||
|
|
||||||
|
|
||||||
;;;###package ibuffer
|
;;;###package ibuffer
|
||||||
|
@ -216,11 +212,11 @@ the command buffer."
|
||||||
|
|
||||||
|
|
||||||
;;;###package Info
|
;;;###package Info
|
||||||
(defun +popup*switch-to-info-window (&rest _)
|
(def-advice! +popup--switch-to-info-window-a (&rest _)
|
||||||
|
:after #'info-lookup-symbol
|
||||||
(when-let (win (get-buffer-window "*info*"))
|
(when-let (win (get-buffer-window "*info*"))
|
||||||
(when (+popup-window-p win)
|
(when (+popup-window-p win)
|
||||||
(select-window win))))
|
(select-window win))))
|
||||||
(advice-add #'info-lookup-symbol :after #'+popup*switch-to-info-window)
|
|
||||||
|
|
||||||
|
|
||||||
;;;###package multi-term
|
;;;###package multi-term
|
||||||
|
@ -235,26 +231,26 @@ the command buffer."
|
||||||
|
|
||||||
;;;###package org
|
;;;###package org
|
||||||
(after! org
|
(after! org
|
||||||
(defvar +popup--disable-internal nil)
|
|
||||||
;; Org has a scorched-earth window management policy I'm not fond of. i.e. it
|
;; Org has a scorched-earth window management policy I'm not fond of. i.e. it
|
||||||
;; kills all other windows just so it can monopolize the frame. No thanks. We
|
;; kills all other windows just so it can monopolize the frame. No thanks. We
|
||||||
;; can do better ourselves.
|
;; can do better ourselves.
|
||||||
(defun +popup*suppress-delete-other-windows (orig-fn &rest args)
|
(def-advice! +popup-suppress-delete-other-windows-a (orig-fn &rest args)
|
||||||
|
:around '(org-add-log-note
|
||||||
|
org-capture-place-template
|
||||||
|
org-export--dispatch-ui
|
||||||
|
org-agenda-get-restriction-and-command
|
||||||
|
org-fast-tag-selection)
|
||||||
(if +popup-mode
|
(if +popup-mode
|
||||||
(cl-letf (((symbol-function 'delete-other-windows)
|
(cl-letf (((symbol-function 'delete-other-windows)
|
||||||
(symbol-function 'ignore)))
|
(symbol-function 'ignore)))
|
||||||
(apply orig-fn args))
|
(apply orig-fn args))
|
||||||
(apply orig-fn args)))
|
(apply orig-fn args)))
|
||||||
(advice-add #'org-add-log-note :around #'+popup*suppress-delete-other-windows)
|
|
||||||
(advice-add #'org-capture-place-template :around #'+popup*suppress-delete-other-windows)
|
|
||||||
(advice-add #'org-export--dispatch-ui :around #'+popup*suppress-delete-other-windows)
|
|
||||||
(advice-add #'org-agenda-get-restriction-and-command :around #'+popup*suppress-delete-other-windows)
|
|
||||||
(advice-add #'org-fast-tag-selection :around #'+popup*suppress-delete-other-windows)
|
|
||||||
|
|
||||||
(defun +popup*fix-tags-window (orig-fn &rest args)
|
(def-advice! +popup--org-fix-tags-window-a (orig-fn &rest args)
|
||||||
"Hides the mode-line in *Org tags* buffer so you can actually see its
|
"Hides the mode-line in *Org tags* buffer so you can actually see its
|
||||||
content and displays it in a side window without deleting all other windows.
|
content and displays it in a side window without deleting all other windows.
|
||||||
Ugh, such an ugly hack."
|
Ugh, such an ugly hack."
|
||||||
|
:around #'org-fast-tag-selection
|
||||||
(if +popup-mode
|
(if +popup-mode
|
||||||
(cl-letf* ((old-fit-buffer-fn (symbol-function 'org-fit-window-to-buffer))
|
(cl-letf* ((old-fit-buffer-fn (symbol-function 'org-fit-window-to-buffer))
|
||||||
((symbol-function 'org-fit-window-to-buffer)
|
((symbol-function 'org-fit-window-to-buffer)
|
||||||
|
@ -268,31 +264,31 @@ Ugh, such an ugly hack."
|
||||||
(funcall old-fit-buffer-fn window max-height min-height shrink-only))))
|
(funcall old-fit-buffer-fn window max-height min-height shrink-only))))
|
||||||
(apply orig-fn args))
|
(apply orig-fn args))
|
||||||
(apply orig-fn args)))
|
(apply orig-fn args)))
|
||||||
(advice-add #'org-fast-tag-selection :around #'+popup*fix-tags-window)
|
|
||||||
|
|
||||||
(defun +popup*org-src-pop-to-buffer (orig-fn buffer context)
|
(def-advice! +popup-org-src-pop-to-buffer-a (orig-fn buffer context)
|
||||||
"Hand off the src-block window to the popup system by using `display-buffer'
|
"Hand off the src-block window to the popup system by using `display-buffer'
|
||||||
instead of switch-to-buffer-*."
|
instead of switch-to-buffer-*."
|
||||||
|
:around #'org-src-switch-to-buffer
|
||||||
(if (and (eq org-src-window-setup 'popup-window)
|
(if (and (eq org-src-window-setup 'popup-window)
|
||||||
+popup-mode)
|
+popup-mode)
|
||||||
(pop-to-buffer buffer)
|
(pop-to-buffer buffer)
|
||||||
(funcall orig-fn buffer context)))
|
(funcall orig-fn buffer context)))
|
||||||
(advice-add #'org-src-switch-to-buffer :around #'+popup*org-src-pop-to-buffer)
|
|
||||||
(setq org-src-window-setup 'popup-window)
|
(setq org-src-window-setup 'popup-window)
|
||||||
|
|
||||||
;; Ensure todo, agenda, and other minor popups are delegated to the popup system.
|
;; Ensure todo, agenda, and other minor popups are delegated to the popup system.
|
||||||
(defun +popup*org-pop-to-buffer (orig-fn buf &optional norecord)
|
(def-advice! +popup-org-pop-to-buffer-a (orig-fn buf &optional norecord)
|
||||||
"Use `pop-to-buffer' instead of `switch-to-buffer' to open buffer.'"
|
"Use `pop-to-buffer' instead of `switch-to-buffer' to open buffer.'"
|
||||||
|
:around #'org-switch-to-buffer-other-window
|
||||||
(if +popup-mode
|
(if +popup-mode
|
||||||
(pop-to-buffer buf nil norecord)
|
(pop-to-buffer buf nil norecord)
|
||||||
(funcall orig-fn buf norecord)))
|
(funcall orig-fn buf norecord)))
|
||||||
(advice-add #'org-switch-to-buffer-other-window :around #'+popup*org-pop-to-buffer)
|
|
||||||
|
|
||||||
;; `org-agenda'
|
;; `org-agenda'
|
||||||
(setq org-agenda-window-setup 'popup-window
|
(setq org-agenda-window-setup 'popup-window
|
||||||
org-agenda-restore-windows-after-quit nil)
|
org-agenda-restore-windows-after-quit nil)
|
||||||
;; Don't monopolize the frame!
|
;; Don't monopolize the frame!
|
||||||
(defun +popup*org-agenda-suppress-delete-other-windows (orig-fn &rest args)
|
(def-advice! +popup-org-agenda-suppress-delete-other-windows-a (orig-fn &rest args)
|
||||||
|
:around #'org-agenda-prepare-window
|
||||||
(cond ((not +popup-mode)
|
(cond ((not +popup-mode)
|
||||||
(apply orig-fn args))
|
(apply orig-fn args))
|
||||||
((eq org-agenda-window-setup 'popup-window)
|
((eq org-agenda-window-setup 'popup-window)
|
||||||
|
@ -307,18 +303,16 @@ instead of switch-to-buffer-*."
|
||||||
(symbol-function 'ignore)))
|
(symbol-function 'ignore)))
|
||||||
(apply orig-fn args))))
|
(apply orig-fn args))))
|
||||||
((with-popup-rules! nil
|
((with-popup-rules! nil
|
||||||
(apply orig-fn args)))))
|
(apply orig-fn args))))))
|
||||||
(advice-add #'org-agenda-prepare-window :around #'+popup*org-agenda-suppress-delete-other-windows))
|
|
||||||
|
|
||||||
|
|
||||||
;;;###package persp-mode
|
;;;###package persp-mode
|
||||||
(progn
|
(def-advice! +popup--persp-mode-restore-popups-a (&rest _)
|
||||||
(defun +popup*persp-mode-restore-popups (&rest _)
|
|
||||||
"Restore popup windows when loading a perspective from file."
|
"Restore popup windows when loading a perspective from file."
|
||||||
|
:after #'persp-load-state-from-file
|
||||||
(dolist (window (window-list))
|
(dolist (window (window-list))
|
||||||
(when (+popup-parameter 'popup window)
|
(when (+popup-parameter 'popup window)
|
||||||
(+popup--init window nil))))
|
(+popup--init window nil))))
|
||||||
(advice-add #'persp-load-state-from-file :after #'+popup*persp-mode-restore-popups))
|
|
||||||
|
|
||||||
|
|
||||||
;;;###package pdf-tools
|
;;;###package pdf-tools
|
||||||
|
@ -340,11 +334,11 @@ instead of switch-to-buffer-*."
|
||||||
|
|
||||||
|
|
||||||
;;;###package profiler
|
;;;###package profiler
|
||||||
(defun doom*profiler-report-find-entry-in-other-window (orig-fn function)
|
(def-advice! +popup--profiler-report-find-entry-in-other-window-a (orig-fn function)
|
||||||
|
:around #'profiler-report-find-entry
|
||||||
(cl-letf (((symbol-function 'find-function)
|
(cl-letf (((symbol-function 'find-function)
|
||||||
(symbol-function 'find-function-other-window)))
|
(symbol-function 'find-function-other-window)))
|
||||||
(funcall orig-fn function)))
|
(funcall orig-fn function)))
|
||||||
(advice-add #'profiler-report-find-entry :around #'doom*profiler-report-find-entry-in-other-window)
|
|
||||||
|
|
||||||
|
|
||||||
;;;###package wgrep
|
;;;###package wgrep
|
||||||
|
@ -370,17 +364,13 @@ instead of switch-to-buffer-*."
|
||||||
|
|
||||||
|
|
||||||
;;;###package windmove
|
;;;###package windmove
|
||||||
(progn
|
|
||||||
;; Users should be able to hop into popups easily, but Elisp shouldn't.
|
;; Users should be able to hop into popups easily, but Elisp shouldn't.
|
||||||
(defun doom*ignore-window-parameters (orig-fn &rest args)
|
(def-advice! doom--ignore-window-parameters-a (orig-fn &rest args)
|
||||||
"Allow *interactive* window moving commands to traverse popups."
|
"Allow *interactive* window moving commands to traverse popups."
|
||||||
|
:around '(windmove-up windmove-down windmove-left windmove-right)
|
||||||
(cl-letf (((symbol-function #'windmove-find-other-window)
|
(cl-letf (((symbol-function #'windmove-find-other-window)
|
||||||
(lambda (dir &optional arg window)
|
(lambda (dir &optional arg window)
|
||||||
(window-in-direction
|
(window-in-direction
|
||||||
(pcase dir (`up 'above) (`down 'below) (_ dir))
|
(pcase dir (`up 'above) (`down 'below) (_ dir))
|
||||||
window (bound-and-true-p +popup-mode) arg windmove-wrap-around t))))
|
window (bound-and-true-p +popup-mode) arg windmove-wrap-around t))))
|
||||||
(apply orig-fn args)))
|
(apply orig-fn args)))
|
||||||
(advice-add #'windmove-up :around #'doom*ignore-window-parameters)
|
|
||||||
(advice-add #'windmove-down :around #'doom*ignore-window-parameters)
|
|
||||||
(advice-add #'windmove-left :around #'doom*ignore-window-parameters)
|
|
||||||
(advice-add #'windmove-right :around #'doom*ignore-window-parameters))
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue