💥 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
|
||||
(section! "Checking your enabled modules...")
|
||||
(let ((indent (+ indent 2)))
|
||||
(advice-add #'require :around #'doom*shut-up)
|
||||
(advice-add #'require :around #'doom-shut-up-a)
|
||||
(maphash
|
||||
(lambda (key plist)
|
||||
(let ((prefix (format! (bold "(%s %s) " (car key) (cdr key)))))
|
||||
(condition-case-unless-debug ex
|
||||
(let ((doctor-file (doom-module-path (car key) (cdr key) "doctor.el"))
|
||||
(packages-file (doom-module-path (car key) (cdr key) "packages.el")))
|
||||
(cl-loop with doom--stage = 'packages
|
||||
for name in (let (doom-packages
|
||||
(cl-loop for name in (let (doom-packages
|
||||
doom-disabled-packages)
|
||||
(load packages-file 'noerror 'nomessage)
|
||||
(mapcar #'car doom-packages))
|
||||
|
@ -350,8 +349,7 @@
|
|||
(package-built-in-p name)
|
||||
(package-installed-p 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)))
|
||||
(error (error! "Syntax error: %s" ex)))))
|
||||
doom-modules)))))
|
||||
|
|
|
@ -255,41 +255,6 @@ regex PATTERN. Returns the number of killed buffers."
|
|||
(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
|
||||
|
||||
|
|
|
@ -348,7 +348,6 @@ This excludes core packages listed in `doom-core-packages'.
|
|||
If ALL-P, gather packages unconditionally across all modules, including disabled
|
||||
ones."
|
||||
(let ((noninteractive t)
|
||||
(doom--stage 'packages)
|
||||
(doom-modules (doom-modules))
|
||||
doom-packages
|
||||
doom-disabled-packages
|
||||
|
|
|
@ -27,12 +27,12 @@ are open."
|
|||
;; Advice
|
||||
|
||||
;;;###autoload
|
||||
(defun doom*recenter (&rest _)
|
||||
(defun doom-recenter-a (&rest _)
|
||||
"Generic advisor for recentering window (typically :after other functions)."
|
||||
(recenter))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom*shut-up (orig-fn &rest args)
|
||||
(defun doom-shut-up-a (orig-fn &rest args)
|
||||
"Generic advisor for silencing noisy functions."
|
||||
(quiet! (apply orig-fn args)))
|
||||
|
||||
|
|
|
@ -54,13 +54,13 @@ detected.")
|
|||
;; Remove hscroll-margin in shells, otherwise it causes jumpiness
|
||||
(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
|
||||
(when find-file-literally
|
||||
(setq buffer-read-only t)
|
||||
(buffer-disable-undo))
|
||||
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")
|
||||
save-place-forget-unreadable-files t
|
||||
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."
|
||||
:after-while #'save-place-find-file-hook
|
||||
(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))
|
||||
|
||||
(def-package! server
|
||||
|
@ -202,14 +201,14 @@ savehist file."
|
|||
(better-jumper-mode +1)
|
||||
(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."
|
||||
(better-jumper-set-jump (if (markerp (car args)) (car args)))
|
||||
(let ((evil--jumps-jumping t)
|
||||
(better-jumper--jumping t))
|
||||
(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."
|
||||
(let ((origin (point-marker))
|
||||
(result
|
||||
|
@ -261,9 +260,10 @@ savehist file."
|
|||
(push '(t tab-width) dtrt-indent-hook-generic-mapping-list)
|
||||
|
||||
(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
|
||||
`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))
|
||||
(cl-letf* ((old-smie-config-guess (symbol-function 'smie-config-guess))
|
||||
((symbol-function 'smie-config-guess)
|
||||
|
@ -273,8 +273,7 @@ savehist file."
|
|||
(message "[WARNING] Indent detection: %s"
|
||||
(error-message-string e))
|
||||
(message "")))))) ; warn silently
|
||||
(funcall orig-fn arg))))
|
||||
(advice-add #'dtrt-indent-mode :around #'doom*fix-broken-smie-modes))
|
||||
(funcall orig-fn arg)))))
|
||||
|
||||
|
||||
(def-package! helpful
|
||||
|
@ -354,17 +353,16 @@ savehist file."
|
|||
`(("." . ,(concat doom-cache-dir "undo-tree-hist/"))))
|
||||
|
||||
(when (executable-find "zstd")
|
||||
(defun doom*undo-tree-make-history-save-file-name (file)
|
||||
(concat file ".zst"))
|
||||
(advice-add #'undo-tree-make-history-save-file-name :filter-return
|
||||
#'doom*undo-tree-make-history-save-file-name))
|
||||
(def-advice! doom--undo-tree-make-history-save-file-name-a (file)
|
||||
:filter-return #'undo-tree-make-history-save-file-name
|
||||
(concat file ".zst")))
|
||||
|
||||
(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)
|
||||
(and (consp item)
|
||||
(stringp (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))
|
||||
|
||||
|
|
|
@ -76,21 +76,6 @@ list is returned as-is."
|
|||
collect (cadr 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
|
||||
|
@ -303,32 +288,26 @@ If N and M = 1, there's no benefit to using this macro over `remove-hook'.
|
|||
(nreverse forms))))
|
||||
collect `(add-hook ',hook #',fn 'append)))))
|
||||
|
||||
(defun advice-add! (symbols where functions)
|
||||
"Variadic version of `advice-add'.
|
||||
(defmacro def-advice! (symbol arglist docstring where places &rest body)
|
||||
"Define an advice called NAME and add it to PLACES.
|
||||
|
||||
SYMBOLS and FUNCTIONS can be lists of functions."
|
||||
(let ((functions (if (functionp functions)
|
||||
(list functions)
|
||||
functions)))
|
||||
(dolist (s (doom-enlist symbols))
|
||||
(dolist (f (doom-enlist functions))
|
||||
(advice-add s where f)))))
|
||||
|
||||
(defun advice-remove! (symbols where-or-fns &optional functions)
|
||||
"Variadic version of `advice-remove'.
|
||||
|
||||
WHERE-OR-FNS is ignored if FUNCTIONS is provided. This lets you substitute
|
||||
advice-add with advice-remove and evaluate them without having to modify every
|
||||
statement."
|
||||
(unless functions
|
||||
(setq functions where-or-fns
|
||||
where-or-fns nil))
|
||||
(let ((functions (if (functionp functions)
|
||||
(list functions)
|
||||
functions)))
|
||||
(dolist (s (doom-enlist symbols))
|
||||
(dolist (f (doom-enlist functions))
|
||||
(advice-remove s f)))))
|
||||
ARGLIST is as in `defun'. WHERE is a keyword as passed to `advice-add', and
|
||||
PLACE is the function to which to add the advice, like in `advice-add'.
|
||||
DOCSTRING and BODY are as in `defun'."
|
||||
(declare (doc-string 3) (indent defun))
|
||||
(unless (stringp docstring)
|
||||
(push places body)
|
||||
(setq places where
|
||||
where docstring
|
||||
docstring (format "%s advice for %s." where places)))
|
||||
`(progn
|
||||
(defun ,symbol ,arglist
|
||||
,docstring
|
||||
,@body)
|
||||
(dolist (target (doom-enlist ,places))
|
||||
(if (eq ,where :remove)
|
||||
(advice-remove target #',symbol)
|
||||
(advice-add target ,where #',symbol)))))
|
||||
|
||||
(cl-defmacro associate! (mode &key modes match files when)
|
||||
"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
|
||||
to have them return non-nil (or exploit that to overwrite Doom's config)."
|
||||
(declare (indent defun))
|
||||
(doom--assert-stage-p 'init #'package!)
|
||||
(unless (memq when '(:pre-init :post-init :pre-config :post-config))
|
||||
(error "'%s' isn't a valid hook for def-package-hook!" when))
|
||||
`(progn
|
||||
|
@ -470,8 +469,7 @@ module."
|
|||
(let ((doom--current-module ',(cons category module))
|
||||
(doom--current-flags ',flags))
|
||||
(load! "init" module-path :noerror)
|
||||
(let ((doom--stage 'config))
|
||||
(load! "config" module-path :noerror)))
|
||||
(load! "config" module-path :noerror))
|
||||
('error
|
||||
(lwarn 'doom-modules :error
|
||||
"%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
|
||||
elsewhere."
|
||||
(declare (indent defun))
|
||||
(doom--assert-stage-p 'packages #'package!)
|
||||
(let ((old-plist (cdr (assq name doom-packages))))
|
||||
(when recipe
|
||||
(when (cl-evenp (length recipe))
|
||||
|
@ -218,21 +217,9 @@ elsewhere."
|
|||
`((add-to-list 'doom-disabled-packages ',name nil 'eq)
|
||||
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)
|
||||
"A convenience macro like `package!', but allows you to disable multiple
|
||||
packages at once.
|
||||
|
||||
Only use this macro in a module's packages.el file."
|
||||
(doom--assert-stage-p 'packages #'disable-packages!)
|
||||
"A convenience macro for disabling packages in bulk.
|
||||
Only use this macro in a module's (or your private) packages.el file."
|
||||
(macroexp-progn
|
||||
(cl-loop for pkg in packages
|
||||
collect (macroexpand `(package! ,pkg :disable t)))))
|
||||
|
|
|
@ -44,31 +44,14 @@ Emacs.")
|
|||
(global-set-key [remap find-tag] #'projectile-find-tag)
|
||||
|
||||
: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)
|
||||
|
||||
;; a more generic project root file
|
||||
(push ".project" projectile-project-root-files-bottom-up)
|
||||
(push (abbreviate-file-name doom-local-dir) projectile-globally-ignored-directories)
|
||||
|
||||
(defun doom*projectile-default-generic-command (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."
|
||||
(ignore-errors (apply orig-fn args)))
|
||||
(advice-add #'projectile-default-generic-command :around #'doom*projectile-default-generic-command)
|
||||
;; Treat current directory in dired as a "file in a project" and track it
|
||||
(add-hook 'dired-before-readin-hook #'projectile-track-known-projects-find-file-hook)
|
||||
|
||||
;; Accidentally indexing big directories like $HOME or / will massively bloat
|
||||
;; 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-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
|
||||
;; 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
|
||||
|
@ -143,7 +116,37 @@ c) are not valid projectile projects."
|
|||
projectile-indexing-method 'alien)
|
||||
;; fix breakage on windows in git projects
|
||||
(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
|
||||
|
|
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)
|
||||
(setq doom--last-frame (selected-frame)))))
|
||||
|
||||
(defun doom*run-switch-buffer-hooks (orig-fn buffer-or-name &rest args)
|
||||
(let ((gc-cons-threshold doom-gc-cons-upper-limit))
|
||||
(defun doom-run-switch-buffer-hooks-a (orig-fn buffer-or-name &rest args)
|
||||
(let ((gc-cons-threshold most-positive-fixnum))
|
||||
(if (or doom-inhibit-switch-buffer-hooks
|
||||
(eq (current-buffer) (get-buffer buffer-or-name))
|
||||
(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))
|
||||
buffer)))))
|
||||
|
||||
(defun doom*run-switch-to-next-prev-buffer-hooks (orig-fn &rest args)
|
||||
(let ((gc-cons-threshold doom-gc-cons-upper-limit))
|
||||
(defun doom-run-switch-to-next-prev-buffer-hooks-a (orig-fn &rest args)
|
||||
(let ((gc-cons-threshold most-positive-fixnum))
|
||||
(if doom-inhibit-switch-buffer-hooks
|
||||
(apply orig-fn args)
|
||||
(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))
|
||||
buffer)))))
|
||||
|
||||
(defun doom*run-load-theme-hooks (theme &optional _no-confirm no-enable)
|
||||
"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 ()
|
||||
(defun doom-protect-fallback-buffer-h ()
|
||||
"Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'."
|
||||
(not (eq (current-buffer) (doom-fallback-buffer))))
|
||||
|
||||
|
@ -239,6 +233,39 @@ read-only or not file-visiting."
|
|||
window-divider-default-right-width 1)
|
||||
(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
|
||||
|
@ -329,16 +356,14 @@ read-only or not file-visiting."
|
|||
: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)
|
||||
: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)
|
||||
(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
|
||||
(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))
|
||||
(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
|
||||
|
@ -499,10 +544,10 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
|
|||
;; + `doom-switch-frame-hook'
|
||||
(add-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks)
|
||||
(add-hook 'focus-in-hook #'doom|run-switch-frame-hooks)
|
||||
(advice-add! '(switch-to-next-buffer switch-to-prev-buffer)
|
||||
:around #'doom*run-switch-to-next-prev-buffer-hooks)
|
||||
(advice-add! '(switch-to-buffer display-buffer)
|
||||
:around #'doom*run-switch-buffer-hooks))
|
||||
(dolist (fn '(switch-to-next-buffer switch-to-prev-buffer))
|
||||
(advice-add fn :around #'doom-run-switch-to-next-prev-buffer-hooks-a))
|
||||
(dolist (fn '(switch-to-buffer display-buffer))
|
||||
(advice-add fn :around #'doom-run-switch-buffer-hooks-a)))
|
||||
|
||||
;; Apply `doom-theme'
|
||||
(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)
|
||||
;; Ensure unicode fonts are set on each frame
|
||||
(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)
|
||||
|
||||
|
@ -527,35 +569,13 @@ By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
|
|||
(unless (fboundp 'define-fringe-bitmap)
|
||||
(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
|
||||
(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
|
||||
it to fix all that visual noise."
|
||||
(unless (frame-parameter nil 'parent-frame)
|
||||
(funcall orig-fn)))
|
||||
(add-function :around whitespace-enable-predicate #'doom*disable-whitespace-mode-in-childframes)
|
||||
|
||||
(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))
|
||||
(add-function :around whitespace-enable-predicate #'doom-disable-whitespace-mode-in-childframes-a))
|
||||
|
||||
;; Don't allow cursor to enter the 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 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)
|
||||
;;; 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-version nil)
|
||||
(defvar doom--refreshed-p nil)
|
||||
(defvar doom--stage 'init)
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -62,13 +62,15 @@
|
|||
(setq a (switch-to-buffer (get-buffer-create "a"))
|
||||
b (get-buffer-create "b"))
|
||||
(spy-on 'hook)
|
||||
(add-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks)
|
||||
(add-hook 'focus-in-hook #'doom|run-switch-frame-hooks)
|
||||
(advice-add! '(switch-to-buffer display-buffer) :around #'doom*run-switch-buffer-hooks))
|
||||
(add-hook 'buffer-list-update-hook #'doom-run-switch-window-hooks-h)
|
||||
(add-hook 'focus-in-hook #'doom-run-switch-frame-hooks-h)
|
||||
(dolist (fn '(switch-to-buffer display-buffer))
|
||||
(advice-add fn :around #'doom-run-switch-buffer-hooks-a)))
|
||||
(after-each
|
||||
(remove-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks)
|
||||
(remove-hook 'focus-in-hook #'doom|run-switch-frame-hooks)
|
||||
(advice-remove! '(switch-to-buffer display-buffer) #'doom*run-switch-buffer-hooks)
|
||||
(remove-hook 'buffer-list-update-hook #'doom-run-switch-window-hooks-h)
|
||||
(remove-hook 'focus-in-hook #'doom-run-switch-frame-hooks-h)
|
||||
(dolist (fn '(switch-to-buffer display-buffer))
|
||||
(advice-remove fn #'doom-run-switch-buffer-hooks-a))
|
||||
(kill-buffer a)
|
||||
(kill-buffer b))
|
||||
|
||||
|
|
|
@ -27,8 +27,9 @@
|
|||
;; 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
|
||||
;; `company-dabbrev-code'.
|
||||
(defun +company*abort-previous (&rest _) (company-abort))
|
||||
(advice-add #'company-begin-backend :before #'+company*abort-previous))
|
||||
(def-advice! +company--abort-previous-a (&rest _)
|
||||
:before #'company-begin-backend
|
||||
(company-abort)))
|
||||
|
||||
(add-hook 'company-mode-hook #'+company|init-backends)
|
||||
(global-company-mode +1))
|
||||
|
|
|
@ -60,7 +60,3 @@ bottom, which is easier on the eyes on big displays."
|
|||
;;
|
||||
(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
|
||||
(when (and EMACS26+ (featurep! +childframe))
|
||||
(setq helm-display-function #'+helm-posframe-display)
|
||||
;; Fix "Specified window is not displaying the current buffer" error
|
||||
(advice-add #'posframe--get-font-height :around #'+helm*fix-get-font-height))
|
||||
(setq helm-display-function #'+helm-posframe-display-fn)
|
||||
(def-advice! +helm--fix-get-font-height-a (orig-fn position)
|
||||
"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)))
|
||||
(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-ag-show-status-default-mode-line :override #'ignore)
|
||||
|
||||
;; TODO Find a better way
|
||||
(defun +helm*use-helpful (orig-fn arg)
|
||||
(cl-letf (((symbol-function #'describe-function)
|
||||
(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))
|
||||
;; Use helpful instead of describe-* to display documentation
|
||||
(dolist (fn '(helm-describe-variable helm-describe-function))
|
||||
(advice-add fn :around #'doom-use-helpful-a)))
|
||||
|
||||
|
||||
(def-package! helm-flx
|
||||
|
@ -142,9 +138,9 @@ be negative.")
|
|||
(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)
|
||||
;; 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
|
||||
(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
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
(insert "~/")
|
||||
(call-interactively #'self-insert-command))))
|
||||
|
||||
(defun +ido*sort-mtime ()
|
||||
(defun +ido--sort-mtime-a ()
|
||||
"Sort ido filelist by mtime instead of alphabetically."
|
||||
(setq ido-temp-list
|
||||
(sort ido-temp-list
|
||||
|
@ -40,8 +40,8 @@
|
|||
(cl-loop for x in ido-temp-list
|
||||
if (char-equal (string-to-char x) ?.)
|
||||
collect x)))
|
||||
(advice-add #'ido-sort-mtime :override #'+ido*sort-mtime)
|
||||
(add-hook! (ido-make-file-list ido-make-dir-list) #'+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)
|
||||
|
||||
;;
|
||||
(ido-mode 1)
|
||||
|
|
|
@ -94,12 +94,12 @@ immediately runs it on the current candidate (ending the ivy session)."
|
|||
(after! yasnippet
|
||||
(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
|
||||
evil-ex-specific constructs, so we disable it solely in evil-ex."
|
||||
:around #'evil-ex
|
||||
(let ((completion-in-region-function #'completion--in-region))
|
||||
(apply orig-fn args)))
|
||||
(advice-add #'evil-ex :around #'+ivy*inhibit-ivy-in-evil-ex)
|
||||
|
||||
(define-key! ivy-mode-map
|
||||
[remap switch-to-buffer] #'+ivy/switch-buffer
|
||||
|
|
|
@ -12,12 +12,11 @@
|
|||
(def-package! expand-region
|
||||
:commands (er/contract-region er/mark-symbol er/mark-word)
|
||||
:config
|
||||
(defun doom*quit-expand-region ()
|
||||
(def-advice! doom--quit-expand-region-a ()
|
||||
"Properly abort an expand-region region."
|
||||
:before '(evil-escape doom/escape)
|
||||
(when (memq last-command '(er/expand-region er/contract-region))
|
||||
(er/contract-region 0)))
|
||||
(advice-add #'evil-escape :before #'doom*quit-expand-region)
|
||||
(advice-add #'doom/escape :before #'doom*quit-expand-region))
|
||||
(er/contract-region 0))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
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
|
||||
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><!>")
|
||||
(+evil:compile (format "make %s"
|
||||
(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.
|
||||
|
||||
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><!>")
|
||||
(compile (evil-ex-replace-special-filenames
|
||||
(format "%s %s"
|
||||
|
|
|
@ -1,76 +1,13 @@
|
|||
;;; editor/evil/autoload/advice.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defun +evil--insert-newline (&optional above _noextranewline)
|
||||
(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-escape-a (&rest _)
|
||||
"Call `doom/escape' if `evil-force-normal-state' is called interactively."
|
||||
(when (called-interactively-p 'any)
|
||||
(call-interactively #'doom/escape)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +evil*insert-newline-below-and-respect-comments (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 (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)
|
||||
(defun +evil-resolve-vim-path-a (file-name)
|
||||
"Take a path and resolve any vim-like filename modifiers in it. This adds
|
||||
support for most vim file modifiers, as well as:
|
||||
|
||||
|
@ -148,8 +85,77 @@ more information on modifiers."
|
|||
path file-name t t 1))))
|
||||
(replace-regexp-in-string regexp "\\1" file-name t)))
|
||||
|
||||
;;;###autoload (autoload '+evil*window-split "editor/evil/autoload/advice" nil t)
|
||||
(evil-define-command +evil*window-split (&optional count file)
|
||||
(defun +evil--insert-newline (&optional above _noextranewline)
|
||||
(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."
|
||||
:repeat nil
|
||||
(interactive "P<f>")
|
||||
|
@ -164,8 +170,8 @@ more information on modifiers."
|
|||
(balance-windows (window-parent)))
|
||||
(if file (evil-edit file)))
|
||||
|
||||
;;;###autoload (autoload '+evil*window-vsplit "editor/evil/autoload/advice" nil t)
|
||||
(evil-define-command +evil*window-vsplit (&optional count file)
|
||||
;;;###autoload (autoload '+evil-window-vsplit-a "editor/evil/autoload/advice" nil t)
|
||||
(evil-define-command +evil-window-vsplit-a (&optional count file)
|
||||
"Same as `evil-window-vsplit', but focuses (and recenters) the new split."
|
||||
:repeat nil
|
||||
(interactive "P<f>")
|
||||
|
@ -181,13 +187,7 @@ more information on modifiers."
|
|||
(if file (evil-edit file)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +evil*escape (&rest _)
|
||||
"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)
|
||||
(defun +evil--make-numbered-markers-global-a (orig-fn char)
|
||||
(or (and (>= char ?2) (<= char ?9))
|
||||
(funcall orig-fn char)))
|
||||
|
||||
|
|
|
@ -107,36 +107,36 @@ directives. By default, this only recognizes C directives.")
|
|||
(setq save-silently t)
|
||||
(add-hook 'after-save-hook #'+evil|display-vimlike-save-message))
|
||||
;; 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
|
||||
(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
|
||||
;; file modifiers like %:p:h. This adds support for most of vim's modifiers,
|
||||
;; 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
|
||||
(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
|
||||
(advice-add #'evil-window-split :override #'+evil*window-split)
|
||||
(advice-add #'evil-window-vsplit :override #'+evil*window-vsplit)
|
||||
(advice-add #'evil-window-split :override #'+evil-window-split-a)
|
||||
(advice-add #'evil-window-vsplit :override #'+evil-window-vsplit-a)
|
||||
|
||||
;; 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')
|
||||
(advice-add #'evil-open-above :around #'+evil*insert-newline-above-and-respect-comments)
|
||||
(advice-add #'evil-open-below :around #'+evil*insert-newline-below-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-a)
|
||||
|
||||
;; 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-ex-search-word-backward
|
||||
evil-ex-search-word-backward
|
||||
evil-ex-search-forward
|
||||
evil-ex-search-backward)
|
||||
:after #'doom*recenter)
|
||||
evil-ex-search-backward))
|
||||
(advice-add fn :after #'doom-recenter-a))
|
||||
|
||||
;; --- custom interactive codes -----------
|
||||
;; These arg types will highlight matches in the current buffer
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
(after-all
|
||||
(unload-feature 'evil t))
|
||||
(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)))
|
||||
|
||||
;; `evil-ex-replace-special-filenames' / `+evil*resolve-vim-path'
|
||||
;; `evil-ex-replace-special-filenames' / `+evil-resolve-vim-path-a'
|
||||
(describe "file modifiers"
|
||||
(it "supports basic vim file modifiers"
|
||||
(let ((buffer-file-name "~/.emacs.d/test/modules/feature/test-evil.el")
|
||||
|
|
|
@ -24,14 +24,11 @@
|
|||
;; Nicer code-folding overlays (with fringe indicators)
|
||||
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."
|
||||
:before '(hs-toggle-hiding hs-hide-block hs-hide-level hs-show-all hs-hide-all)
|
||||
(unless (bound-and-true-p hs-minor-mode)
|
||||
(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
|
||||
(unless (assq 't hs-special-modes-alist)
|
||||
|
|
|
@ -96,15 +96,15 @@
|
|||
(setq +mc--compat-mark-was-active nil))))
|
||||
(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
|
||||
;; result of how evil deals with regions
|
||||
(defun +multiple-cursors*adjust-mark-for-evil (&rest _)
|
||||
;; When running edit-lines, point will return (position + 1) as a result of
|
||||
;; how evil deals with regions
|
||||
(def-advice! +multiple-cursors-adjust-mark-for-evil-a (&rest _)
|
||||
:before #'mc/edit-lines
|
||||
(when (and (bound-and-true-p evil-mode)
|
||||
(not (memq evil-state '(insert emacs))))
|
||||
(if (> (point) (mark))
|
||||
(goto-char (1- (point)))
|
||||
(push-mark (1- (mark))))))
|
||||
(advice-add #'mc/edit-lines :before #'+multiple-cursors*adjust-mark-for-evil)
|
||||
|
||||
(defun +multiple-cursors|evil-compat-rect-switch-state ()
|
||||
(if rectangular-region-mode
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
|
||||
(after! git-timemachine
|
||||
;; 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)
|
||||
(let ((rev (car git-timemachine-revision)))
|
||||
(if (fboundp 'magit-revision-mode)
|
||||
|
@ -17,7 +19,6 @@
|
|||
(magit-buffer-diff-args nil)
|
||||
(magit-buffer-diff-files nil))))
|
||||
(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
|
||||
;; showing revision details in the minibuffer, show them in
|
||||
|
|
|
@ -31,9 +31,10 @@
|
|||
;;
|
||||
;;; 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
|
||||
when exporting org-mode to html."
|
||||
:filter-args #'org-html-paragraph
|
||||
(let* ((fix-regexp "[[:multibyte:]]")
|
||||
(origin-contents contents)
|
||||
(fixed-contents
|
||||
|
@ -42,4 +43,3 @@ when exporting org-mode to html."
|
|||
"\\1\\2"
|
||||
origin-contents)))
|
||||
(list paragraph fixed-contents info)))
|
||||
(advice-add #'org-html-paragraph :filter-args #'+chinese*org-html-paragraph)
|
||||
|
|
|
@ -41,9 +41,10 @@
|
|||
;;
|
||||
;;; 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
|
||||
when exporting org-mode to html."
|
||||
:filter-args #'org-html-paragraph
|
||||
(let* ((fix-regexp "[[:multibyte:]]")
|
||||
(origin-contents contents)
|
||||
(fixed-contents
|
||||
|
@ -52,4 +53,3 @@ when exporting org-mode to html."
|
|||
"\\1\\2"
|
||||
origin-contents)))
|
||||
(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)))))
|
||||
|
||||
;; Recenter window after following definition
|
||||
(advice-add #'elisp-def :after #'doom*recenter)
|
||||
(advice-add #'elisp-def :after #'doom-recenter-a)
|
||||
|
||||
(map! :localleader
|
||||
:map emacs-lisp-mode-map
|
||||
|
|
|
@ -12,24 +12,24 @@ nimsuggest isn't installed."
|
|||
|
||||
(when IS-WINDOWS
|
||||
;; 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
|
||||
number from the string representation of `selected-frame', which can contain
|
||||
characters that are illegal on Windows, causing invalid argument errors when
|
||||
`nimsuggest--make-tempdir' tries to use it."
|
||||
:override #'nimsuggest--get-dirty-dir
|
||||
(let* ((frame-str (format "%s" (selected-frame)))
|
||||
(frame-num-str (if (string-match " \\(0x[0-9a-z]+\\)>$" frame-str)
|
||||
(match-string 1 frame-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)
|
||||
(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
|
||||
character that colon is replaced with, which is known to cause issues on
|
||||
windows."
|
||||
(replace-regexp-in-string "[꞉* |<>\"?*]" "" path))
|
||||
(advice-add #'nimsuggest--get-temp-file-name :filter-return #'doom*nimsuggest--get-temp-file-name))
|
||||
:filter-return #'nimsuggest--get-temp-file-name
|
||||
(replace-regexp-in-string "[꞉* |<>\"?*]" "" path)))
|
||||
|
||||
(map! :localleader
|
||||
:map nim-mode-map
|
||||
|
|
|
@ -842,7 +842,7 @@ compelling reason, so..."
|
|||
(if (featurep! +present) (load! "contrib/present"))
|
||||
|
||||
:config
|
||||
(add-hook 'org-open-at-point-functions #'doom|set-jump)
|
||||
(add-hook 'org-open-at-point-functions #'doom-set-jump-h)
|
||||
|
||||
;;; Packages
|
||||
(after! toc-org
|
||||
|
|
|
@ -54,11 +54,11 @@
|
|||
|
||||
;; `rustic-setup-rls' uses `package-installed-p' unnecessarily, which breaks
|
||||
;; 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)
|
||||
(symbol-function 'ignore)))
|
||||
(apply orig-fn args)))
|
||||
(advice-add #'rustic-setup-rls :around #'+rust*disable-package-installed-p-call))
|
||||
(apply orig-fn args))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
(nil "^\\s-*\\([[:alpha:]_-][[:alnum:]_-]*\\)\\s-*()" 1)))
|
||||
|
||||
;; `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
|
||||
;; 2. Fontify command substitution in double quotes
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"TODO"
|
||||
(interactive "<fsh><!>")
|
||||
(let ((buffer (+eshell-last-buffer))
|
||||
(command (+evil*resolve-vim-path command)))
|
||||
(command (+evil-resolve-vim-path-a command)))
|
||||
(cond (buffer
|
||||
(select-window (get-buffer-window buffer))
|
||||
(+eshell-run-command command buffer))
|
||||
|
|
|
@ -27,12 +27,18 @@ buffer/window/frame switch, which is less expensive."
|
|||
(0 font-lock-keyword-face)))))
|
||||
(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
|
||||
environment-sensitive logic like `flycheck-default-executable-find'. This fixes
|
||||
flycheck issues with direnv and on nix."
|
||||
(direnv-update-environment default-directory))
|
||||
(advice-add #'flycheck-default-executable-find :before #'+direnv*update)
|
||||
:before #'flycheck-default-executable-find
|
||||
(direnv--maybe-update-environment))
|
||||
|
||||
(when (executable-find "direnv")
|
||||
(direnv-mode +1)))
|
||||
(def-advice! +direnv--fail-gracefully-a (orig-fn)
|
||||
"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")
|
||||
(php-mode . "php"))
|
||||
"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
|
||||
|
@ -20,7 +20,7 @@
|
|||
(def-package! editorconfig
|
||||
:after-call (doom-switch-buffer-hook after-find-file)
|
||||
: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
|
||||
extension, try to guess one."
|
||||
(let ((buffer-file-name
|
||||
|
@ -32,7 +32,7 @@ extension, try to guess one."
|
|||
(concat "." ext)
|
||||
"")))))
|
||||
(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)
|
||||
"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)
|
||||
|
||||
;; 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
|
||||
:when (featurep! :completion ivy)
|
||||
|
|
|
@ -123,18 +123,3 @@ control in buffers."
|
|||
(url-or-repo))
|
||||
dir
|
||||
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
|
||||
(setq magit-todos-keyword-suffix "\\(?:([^)]+)\\)?:?")
|
||||
(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))
|
||||
|
||||
|
||||
|
|
|
@ -86,10 +86,10 @@
|
|||
(set-window-fringes (minibuffer-window) 0 0 nil))
|
||||
(add-hook 'solaire-mode-hook #'+doom|disable-fringes-in-minibuffer)
|
||||
|
||||
(defun doom*no-fringes-in-which-key-buffer (&rest _)
|
||||
(+doom|disable-fringes-in-minibuffer)
|
||||
(def-advice! +doom--no-fringes-in-which-key-buffer-a (&rest _)
|
||||
: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))
|
||||
(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)
|
||||
#'+doom|disable-fringes-in-minibuffer)
|
||||
|
|
|
@ -58,10 +58,10 @@
|
|||
'(misc-info mu4e github debug fancy-battery " " major-mode process))
|
||||
|
||||
;; Some functions modify the buffer, causing the modeline to show a false
|
||||
;; modified state, so we try to force them to behave.
|
||||
(defun +modeline*inhibit-modification-hooks (orig-fn &rest args)
|
||||
(with-silent-modifications (apply orig-fn args)))
|
||||
(advice-add #'ws-butler-after-save :around #'+modeline*inhibit-modification-hooks))
|
||||
;; modified state, so force them to behave.
|
||||
(def-advice! +modeline--inhibit-modification-hooks-a (orig-fn &rest args)
|
||||
:around #'ws-butler-after-save
|
||||
(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)
|
||||
|
||||
;;;###autoload
|
||||
(defalias '+nav-flash*blink-cursor #'+nav-flash-blink-cursor-maybe)
|
||||
(defalias '+nav-flash-blink-cursor-a #'+nav-flash-blink-cursor-maybe)
|
||||
|
||||
;;;###autoload
|
||||
(defun +nav-flash/blink-cursor (&rest _)
|
||||
|
|
|
@ -21,10 +21,9 @@
|
|||
(add-hook 'org-follow-link-hook #'+nav-flash|delayed-blink-cursor)
|
||||
|
||||
;; `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'
|
||||
(advice-add #'evil-window-top :after #'+nav-flash*blink-cursor)
|
||||
(advice-add #'evil-window-middle :after #'+nav-flash*blink-cursor)
|
||||
(advice-add #'evil-window-bottom :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-a)
|
||||
(advice-add #'evil-window-bottom :after #'+nav-flash-blink-cursor-a))
|
||||
|
|
|
@ -50,8 +50,7 @@
|
|||
(+neotree*indent-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)
|
||||
(skip-chars-forward " \t\r"))
|
||||
(advice-add #'neotree-next-line :after #'+neotree*indent-cursor)
|
||||
(advice-add #'neotree-previous-line :after #'+neotree*indent-cursor))
|
||||
(skip-chars-forward " \t\r")))
|
||||
|
|
|
@ -38,11 +38,10 @@
|
|||
|
||||
|
||||
;;;###package company
|
||||
(progn
|
||||
(defun +popup*dont-select-me (orig-fn &rest args)
|
||||
(def-advice! +popup--dont-select-me-a (orig-fn &rest args)
|
||||
:around #'company-show-doc-buffer
|
||||
(let ((+popup--inhibit-select t))
|
||||
(apply orig-fn args)))
|
||||
(advice-add #'company-show-doc-buffer :around #'+popup*dont-select-me))
|
||||
|
||||
|
||||
;;;###package eshell
|
||||
|
@ -51,21 +50,22 @@
|
|||
|
||||
;; 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...
|
||||
(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)."
|
||||
:before #'eshell-exec-visual
|
||||
(when (+popup-window-p)
|
||||
(set-window-dedicated-p nil nil)
|
||||
(add-transient-hook! #'eshell-query-kill-processes :after
|
||||
(set-window-dedicated-p nil t)))
|
||||
(apply orig-fn args))
|
||||
(advice-add #'eshell-exec-visual :around #'+popup*eshell-undedicate-popup))
|
||||
(set-window-dedicated-p nil t)))))
|
||||
|
||||
|
||||
;;;###package evil
|
||||
(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
|
||||
`switch-to-buffer', allowing the popup manager to handle it."
|
||||
:override #'evil-command-window
|
||||
(when (eq major-mode 'evil-command-window-mode)
|
||||
(user-error "Cannot recursively open command line window"))
|
||||
(dolist (win (window-list))
|
||||
|
@ -81,9 +81,10 @@
|
|||
(evil-command-window-mode)
|
||||
(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
|
||||
the command buffer."
|
||||
:override #'evil-command-window-execute
|
||||
(interactive)
|
||||
(let ((result (buffer-substring (line-beginning-position)
|
||||
(line-end-position)))
|
||||
|
@ -98,10 +99,6 @@ the command buffer."
|
|||
(funcall execute-fn result)
|
||||
(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
|
||||
(advice-add #'+evil--window-swap :around #'+popup*save)
|
||||
(advice-add #'evil-window-move-very-bottom :around #'+popup*save)
|
||||
|
@ -153,9 +150,9 @@ the command buffer."
|
|||
|
||||
|
||||
;;;###package helpful
|
||||
(progn
|
||||
(defun +popup*helpful-open-in-origin-window (button)
|
||||
(def-advice! +popup--helpful-open-in-origin-window-a (button)
|
||||
"Open links in non-popup, originating window rather than helpful's window."
|
||||
:override #'helpful--navigate
|
||||
(let ((path (substring-no-properties (button-get button 'path)))
|
||||
enable-local-variables
|
||||
origin)
|
||||
|
@ -167,7 +164,6 @@ the command buffer."
|
|||
(setq origin (selected-window))
|
||||
(recenter))
|
||||
(select-window origin)))
|
||||
(advice-add #'helpful--navigate :override #'+popup*helpful-open-in-origin-window))
|
||||
|
||||
|
||||
;;;###package helm
|
||||
|
@ -176,7 +172,8 @@ the command buffer."
|
|||
(setq helm-default-display-buffer-functions '(+popup-display-buffer-stacked-side-window))
|
||||
|
||||
;; 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))
|
||||
((symbol-function 'org-completing-read)
|
||||
(lambda (&rest args)
|
||||
|
@ -192,23 +189,22 @@ the command buffer."
|
|||
(get-buffer-create "*Org Links*"))
|
||||
(apply old-org-completing-read 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'
|
||||
(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)
|
||||
(when (and (helm-attr 'help-running-p)
|
||||
(string= candidate (helm-attr 'help-current-symbol))
|
||||
(setq win (get-buffer-window (get-buffer (help-buffer)))))
|
||||
(delete-window win))))
|
||||
(advice-add #'helm-elisp--persistent-help :before #'+popup*helm-elisp--persistent-help)
|
||||
|
||||
;; `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
|
||||
(save-window-excursion (apply orig-fn args)
|
||||
(current-buffer))))
|
||||
(advice-add #'helm-ag--edit :around #'+helm*pop-to-buffer))
|
||||
(current-buffer)))))
|
||||
|
||||
|
||||
;;;###package ibuffer
|
||||
|
@ -216,11 +212,11 @@ the command buffer."
|
|||
|
||||
|
||||
;;;###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 (+popup-window-p win)
|
||||
(select-window win))))
|
||||
(advice-add #'info-lookup-symbol :after #'+popup*switch-to-info-window)
|
||||
|
||||
|
||||
;;;###package multi-term
|
||||
|
@ -235,26 +231,26 @@ the command buffer."
|
|||
|
||||
;;;###package org
|
||||
(after! org
|
||||
(defvar +popup--disable-internal nil)
|
||||
;; 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
|
||||
;; 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
|
||||
(cl-letf (((symbol-function 'delete-other-windows)
|
||||
(symbol-function 'ignore)))
|
||||
(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
|
||||
content and displays it in a side window without deleting all other windows.
|
||||
Ugh, such an ugly hack."
|
||||
:around #'org-fast-tag-selection
|
||||
(if +popup-mode
|
||||
(cl-letf* ((old-fit-buffer-fn (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))))
|
||||
(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'
|
||||
instead of switch-to-buffer-*."
|
||||
:around #'org-src-switch-to-buffer
|
||||
(if (and (eq org-src-window-setup 'popup-window)
|
||||
+popup-mode)
|
||||
(pop-to-buffer buffer)
|
||||
(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)
|
||||
|
||||
;; 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.'"
|
||||
:around #'org-switch-to-buffer-other-window
|
||||
(if +popup-mode
|
||||
(pop-to-buffer buf nil norecord)
|
||||
(funcall orig-fn buf norecord)))
|
||||
(advice-add #'org-switch-to-buffer-other-window :around #'+popup*org-pop-to-buffer)
|
||||
|
||||
;; `org-agenda'
|
||||
(setq org-agenda-window-setup 'popup-window
|
||||
org-agenda-restore-windows-after-quit nil)
|
||||
;; 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)
|
||||
(apply orig-fn args))
|
||||
((eq org-agenda-window-setup 'popup-window)
|
||||
|
@ -307,18 +303,16 @@ instead of switch-to-buffer-*."
|
|||
(symbol-function 'ignore)))
|
||||
(apply orig-fn args))))
|
||||
((with-popup-rules! nil
|
||||
(apply orig-fn args)))))
|
||||
(advice-add #'org-agenda-prepare-window :around #'+popup*org-agenda-suppress-delete-other-windows))
|
||||
(apply orig-fn args))))))
|
||||
|
||||
|
||||
;;;###package persp-mode
|
||||
(progn
|
||||
(defun +popup*persp-mode-restore-popups (&rest _)
|
||||
(def-advice! +popup--persp-mode-restore-popups-a (&rest _)
|
||||
"Restore popup windows when loading a perspective from file."
|
||||
:after #'persp-load-state-from-file
|
||||
(dolist (window (window-list))
|
||||
(when (+popup-parameter 'popup window)
|
||||
(+popup--init window nil))))
|
||||
(advice-add #'persp-load-state-from-file :after #'+popup*persp-mode-restore-popups))
|
||||
|
||||
|
||||
;;;###package pdf-tools
|
||||
|
@ -340,11 +334,11 @@ instead of switch-to-buffer-*."
|
|||
|
||||
|
||||
;;;###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)
|
||||
(symbol-function 'find-function-other-window)))
|
||||
(funcall orig-fn function)))
|
||||
(advice-add #'profiler-report-find-entry :around #'doom*profiler-report-find-entry-in-other-window)
|
||||
|
||||
|
||||
;;;###package wgrep
|
||||
|
@ -370,17 +364,13 @@ instead of switch-to-buffer-*."
|
|||
|
||||
|
||||
;;;###package windmove
|
||||
(progn
|
||||
;; 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."
|
||||
:around '(windmove-up windmove-down windmove-left windmove-right)
|
||||
(cl-letf (((symbol-function #'windmove-find-other-window)
|
||||
(lambda (dir &optional arg window)
|
||||
(window-in-direction
|
||||
(pcase dir (`up 'above) (`down 'below) (_ dir))
|
||||
window (bound-and-true-p +popup-mode) arg windmove-wrap-around t))))
|
||||
(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