Updating Doom Emacs.

This commit is contained in:
Derek Taylor
2020-06-19 22:43:40 -05:00
parent 0f664d532a
commit a5c86c514a
453 changed files with 13527 additions and 12455 deletions

View File

@@ -6,33 +6,35 @@
(defvar company-pcomplete-available 'unknown)
(defun company-pcomplete--prefix ()
(let* ((pcomplete-stub)
pcomplete-seen
pcomplete-norm-func
pcomplete-args
pcomplete-last pcomplete-index
(pcomplete-autolist pcomplete-autolist)
(pcomplete-suffix-list pcomplete-suffix-list))
(pcomplete-completions)
(buffer-substring (pcomplete-begin) (point))))
(with-no-warnings
(let* ((pcomplete-stub)
pcomplete-seen
pcomplete-norm-func
pcomplete-args
pcomplete-last pcomplete-index
(pcomplete-autolist pcomplete-autolist)
(pcomplete-suffix-list pcomplete-suffix-list))
(pcomplete-completions)
(buffer-substring (pcomplete-begin) (point)))))
(defun company-pcomplete--candidates ()
(let* ((pcomplete-stub)
(pcomplete-show-list t)
pcomplete-seen pcomplete-norm-func
pcomplete-args pcomplete-last pcomplete-index
(pcomplete-autolist pcomplete-autolist)
(pcomplete-suffix-list pcomplete-suffix-list)
(candidates (pcomplete-completions))
(prefix (buffer-substring (pcomplete-begin) (point)))
;; Collect all possible completions for the current stub
(cnds (all-completions pcomplete-stub candidates))
(bnds (completion-boundaries pcomplete-stub candidates nil ""))
(skip (- (length pcomplete-stub) (car bnds))))
;; Replace the stub at the beginning of each candidate by the prefix
(mapcar (lambda (cand)
(concat prefix (substring cand skip)))
cnds)))
(with-no-warnings
(let* ((pcomplete-stub)
(pcomplete-show-list t)
pcomplete-seen pcomplete-norm-func
pcomplete-args pcomplete-last pcomplete-index
(pcomplete-autolist pcomplete-autolist)
(pcomplete-suffix-list pcomplete-suffix-list)
(candidates (pcomplete-completions))
(prefix (buffer-substring (pcomplete-begin) (point)))
;; Collect all possible completions for the current stub
(cnds (all-completions pcomplete-stub candidates))
(bnds (completion-boundaries pcomplete-stub candidates nil ""))
(skip (- (length pcomplete-stub) (car bnds))))
;; Replace the stub at the beginning of each candidate by the prefix
(mapcar (lambda (cand)
(concat prefix (substring cand skip)))
cnds))))
;;;###autoload
(defun company-pcomplete-available ()

View File

@@ -21,13 +21,15 @@
t))
(defun +eshell--bury-buffer (&optional dedicated-p)
(unless (switch-to-prev-buffer nil 'bury)
(switch-to-buffer (doom-fallback-buffer)))
(when (eq major-mode 'eshell-mode)
(switch-to-buffer (doom-fallback-buffer)))
(when +eshell-enable-new-shell-on-split
(when-let (win (get-buffer-window (+eshell/here)))
(set-window-dedicated-p win dedicated-p))))
(let ((directory default-directory))
(unless (switch-to-prev-buffer nil 'bury)
(switch-to-buffer (doom-fallback-buffer)))
(when (eq major-mode 'eshell-mode)
(switch-to-buffer (doom-fallback-buffer)))
(when +eshell-enable-new-shell-on-split
(let ((default-directory directory))
(when-let (win (get-buffer-window (+eshell/here t)))
(set-window-dedicated-p win dedicated-p))))))
(defun +eshell--setup-window (window &optional flag)
(when (window-live-p window)

View File

@@ -6,7 +6,7 @@
"TODO"
(interactive "<fsh><!>")
(let ((buffer (+eshell-last-buffer))
(command (+evil-resolve-vim-path-a command)))
(command (+evil-replace-filename-modifiers-a command)))
(cond (buffer
(select-window (get-buffer-window buffer))
(+eshell-run-command command buffer))

View File

@@ -12,11 +12,16 @@
(defun +eshell--current-git-branch ()
;; TODO Refactor me
(cl-destructuring-bind (status . output)
(doom-call-process "git" "name-rev" "--name-only" "HEAD")
(doom-call-process "git" "symbolic-ref" "-q" "--short" "HEAD")
(if (equal status 0)
(format " [%s]" output)
"")))
(cl-destructuring-bind (status . output)
(doom-call-process "git" "describe" "--all" "--always" "HEAD")
(if (equal status 0)
(format " [%s]" output)
"")))))
;;;###autoload
(defun +eshell-default-prompt-fn ()

View File

@@ -12,6 +12,10 @@
"Where to store eshell configuration files, as opposed to
`eshell-directory-name', which is where Doom will store temporary/data files.")
(defvar eshell-directory-name (concat doom-etc-dir "eshell")
"Where to store temporary/data files, as opposed to `eshell-config-dir',
which is where Doom will store eshell configuration files.")
(defvar +eshell-enable-new-shell-on-split t
"If non-nil, spawn a new eshell session after splitting from an eshell
buffer.")
@@ -22,11 +26,13 @@ buffer.")
(defvar +eshell-aliases
'(("q" "exit") ; built-in
("f" "find-file $1")
("ff" "find-file $1")
("d" "dired $1")
("bd" "eshell-up $1")
("rg" "rg --color=always $*")
("l" "ls -lh")
("ll" "ls -lah")
("l" "ls -lh $*")
("ll" "ls -lah $*")
("gg" "magit-status")
("clear" "clear-scrollback")) ; more sensible than default
"An alist of default eshell aliases, meant to emulate useful shell utilities,
like fasd and bd. Note that you may overwrite these in your
@@ -35,20 +41,16 @@ to define your aliases.
You should use `set-eshell-alias!' to change this.")
;;
(defvar eshell-directory-name (concat doom-etc-dir "eshell"))
;; These files are exceptions, because they may contain configuration
(defvar eshell-aliases-file (concat +eshell-config-dir "aliases"))
(defvar eshell-rc-script (concat +eshell-config-dir "profile"))
(defvar eshell-login-script (concat +eshell-config-dir "login"))
(defvar +eshell--default-aliases nil)
;;
;; Packages
;;; Packages
(after! eshell ; built-in
(setq eshell-banner-message
@@ -116,10 +118,6 @@ You should use `set-eshell-alias!' to change this.")
(append eshell-command-aliases-list
+eshell-aliases))))
(when (featurep! :editor evil +everywhere)
(advice-add #'evil-collection-eshell-next-prompt-on-insert
:override #'+eshell-goto-prompt-on-insert-a))
(add-hook! 'eshell-first-time-mode-hook
(defun +eshell-init-keymap-h ()
;; Keys must be bound in a hook because eshell resets its keymap every
@@ -132,9 +130,13 @@ You should use `set-eshell-alias!' to change this.")
:n "C" #'+eshell/evil-change-line
:n "d" #'+eshell/evil-delete
:n "D" #'+eshell/evil-delete-line
:ni "C-j" #'eshell-next-matching-input-from-input
:ni "C-k" #'eshell-previous-matching-input-from-input
:ig "C-d" #'+eshell/quit-or-delete-char
"TAB" #'+eshell/pcomplete
[tab] #'+eshell/pcomplete
:i "C-c h" #'evil-window-left
:i "C-c j" #'evil-window-down
:i "C-c k" #'evil-window-up
:i "C-c l" #'evil-window-right
"C-s" #'+eshell/search-history
;; Emacs bindings
"C-e" #'end-of-line
@@ -142,24 +144,17 @@ You should use `set-eshell-alias!' to change this.")
"C-c s" #'+eshell/split-below
"C-c v" #'+eshell/split-right
"C-c x" #'+eshell/kill-and-close
"C-c h" #'windmove-left
"C-c j" #'windmove-down
"C-c k" #'windmove-up
"C-c l" #'windmove-right
[remap split-window-below] #'+eshell/split-below
[remap split-window-right] #'+eshell/split-right
[remap doom/backward-to-bol-or-indent] #'eshell-bol
[remap doom/backward-kill-to-bol-and-indent] #'eshell-kill-input
[remap evil-delete-back-to-indentation] #'eshell-kill-input
[remap evil-window-split] #'+eshell/split-below
[remap evil-window-vsplit] #'+eshell/split-right)))
(add-hook! 'eshell-mode-hook
(defun +eshell-init-company-h ()
(when (featurep! :completion company)
(company-mode +1)
(setq-local company-backends '(company-pcomplete))
(setq-local company-frontends (cons 'company-tng-frontend company-frontends))
(when (bound-and-true-p evil-local-mode)
(evil-normalize-keymaps))))))
[remap evil-window-vsplit] #'+eshell/split-right
(:localleader
"b" #'eshell-insert-buffer-name
"e" #'eshell-insert-envvar
"s" #'+eshell/search-history)))))
(use-package! eshell-up
@@ -178,3 +173,28 @@ You should use `set-eshell-alias!' to change this.")
(use-package! esh-help
:after eshell
:config (setup-esh-help-eldoc))
(use-package! eshell-did-you-mean
:after esh-mode ; Specifically esh-mode, not eshell
:config
(eshell-did-you-mean-setup)
;; HACK There is a known issue with `eshell-did-you-mean' where it does not
;; work on first invocation, so we invoke it once manually by setting the
;; last command and then calling the output filter.
(setq eshell-last-command-name "catt")
(eshell-did-you-mean-output-filter "catt: command not found"))
(use-package! fish-completion
:unless IS-WINDOWS
:hook (eshell-mode . fish-completion-mode)
:init (setq fish-completion-fallback-on-bash-p t)
:config
;; HACK Even with `fish-completion-fallback-on-bash-p' non-nil,
;; `fish-completion--list-completions-with-desc' will throw an error if
;; fish isn't installed (and so, will fail to fall back to bash), so we
;; advise it to fail silently.
(defadvice! +eshell--fallback-to-bash-a (&rest _)
:before-until #'fish-completion--list-completions-with-desc
(unless (executable-find "fish") "")))

View File

@@ -1,7 +1,13 @@
;; -*- no-byte-compile: t; -*-
;;; term/eshell/packages.el
(package! eshell-up)
(package! eshell-z)
(package! shrink-path)
(package! esh-help)
(package! eshell-up :pin "9c100bae5c3020e8d9307e4332d3b64e7dc28519")
(package! eshell-z :pin "337cb241e17bd472bd3677ff166a0800f684213c")
(package! shrink-path :pin "c14882c8599aec79a6e8ef2d06454254bb3e1e41")
(package! esh-help :pin "417673ed18a983930a66a6692dbfb288a995cb80")
(package! eshell-did-you-mean :pin "7cb6ef8e2274d0a50a9e114d412307a6543533d5")
(unless IS-WINDOWS
(when (featurep! :completion company)
(package! fish-completion :pin "10384881817b5ae38cf6197a077a663420090d2c")
(package! bash-completion :pin "96ce14af9674f3e605bacca87abc0c23b8f13cd5")))