Emacs: Eshell: Move the full config to mode-eshell

master
Pierre Neidhardt 2017-06-16 19:53:25 +01:00
parent d2bedbd7ce
commit a1520a5626
2 changed files with 50 additions and 48 deletions

View File

@ -217,20 +217,7 @@ e-mail."
;;; Eshell
;;; Extend completion.
(nconc package-selected-packages '(pcomplete-extension))
;;; Eshell gets initialized differently. When eshell.el first gets loaded, only
;;; the core is defined and `eshell-load-hook' is called. For every Eshell
;;; session, `eshell-mode' is run: it resets `eshell-mode-map', it loads
;;; modules, runs their hooks and concludes with `eshell-first-time-mode-hook'
;;; (for the first session only) and `eshell-mode-hook'.
;;;
;;; TODO: Move most features inside (with-eval-after-load 'eshell ...)
;;; `eshell-directory-name' is part of the core.
(with-eval-after-load 'eshell
(setq eshell-directory-name (concat emacs-cache-folder "eshell")))
;;; The banner is a module.
(with-eval-after-load 'em-banner
(setq-default eshell-modules-list (delq 'eshell-banner eshell-modules-list)))
(add-hook 'eshell-first-time-mode-hook (lambda () (require 'mode-eshell)))
(with-eval-after-load 'eshell (require 'mode-eshell))
;;; Evil
(nconc package-selected-packages '(evil evil-leader evil-ediff evil-magit evil-mc evil-mc-extras linum-relative))

View File

@ -1,5 +1,17 @@
;;; Eshell
;;; Eshell gets initialized differently. When eshell.el first gets loaded, only
;;; the core is defined and `eshell-load-hook' is called. For every Eshell
;;; session, `eshell-mode' is run: it resets `eshell-mode-map', it loads
;;; modules, runs their hooks and concludes with `eshell-first-time-mode-hook'
;;; (for the first session only) and `eshell-mode-hook'.
(setq eshell-directory-name (concat emacs-cache-folder "eshell"))
;;; Remove the banner module.
(with-eval-after-load 'em-banner
(setq-default eshell-modules-list (delq 'eshell-banner eshell-modules-list)))
;;; TODO: Bind "ls"? No need if we have Ctrl-e?
;; (local-set-key "\C-l" 'eshell/ls)
@ -26,11 +38,12 @@
;;; Warning: This is a local variable.
(setq eshell-prompt-regexp (setq-default eshell-prompt-regexp "^> "))
(nconc eshell-visual-commands
'("abook" "cmus" "fzf" "htop" "mpv" "mutt" "ncdu" "newsbeuter" "ranger"))
(setq eshell-visual-subcommands
'(("git" "log" "diff" "show")
("sudo" "vi")))
(with-eval-after-load 'em-term
(nconc eshell-visual-commands
'("abook" "cmus" "fzf" "htop" "mpv" "mutt" "ncdu" "newsbeuter" "ranger"))
(setq eshell-visual-subcommands
'(("git" "log" "diff" "show")
("sudo" "vi"))))
;;; Alias management possibilities:
;;; - Version eshell-alias and store it in user-emacs-directory. Simplest and
@ -43,42 +56,44 @@
;;; Let's write manually instead.
;;; TODO: Add pacman functions from fish config.
;;; TODO: Compare system tools and lisp equivalents of ls and grep.
(eshell-read-aliases-list)
(dolist
(alias
'(("l" "ls -1 $*")
("la" "ls -lAh $*")
("ll" "ls -lh $*")
;; ("ls" "ls -F $*")
;; ("grep" "grep --color=auto")
;; ("cal" "*cal -m $*")
;; ("emacs" "find-file $1")
;; ("em" "find-file $*")
("cp" "*cp -i $*")
("mv" "*mv -i $*")
("mkdir" "*mkdir -p $*")
("mkcd" "*mkdir -p $* && cd $1")))
(add-to-list 'eshell-command-aliases-list alias))
(eshell-write-aliases-list)
(with-eval-after-load 'em-alias
(eshell-read-aliases-list)
(dolist
(alias
'(("l" "ls -1 $*")
("la" "ls -lAh $*")
("ll" "ls -lh $*")
;; ("ls" "ls -F $*")
;; ("grep" "grep --color=auto")
;; ("cal" "*cal -m $*")
;; ("emacs" "find-file $1")
;; ("em" "find-file $*")
("cp" "*cp -i $*")
("mv" "*mv -i $*")
("mkdir" "*mkdir -p $*")
("mkcd" "*mkdir -p $* && cd $1")))
(add-to-list 'eshell-command-aliases-list alias))
(eshell-write-aliases-list))
;;; Emacs' standard functions fail when output has empty lines.
;;; This implementation is more reliable.
;;; TODO: Test when eshell-highlight-prompt is nil.
;;; TODO: Report upstream.
(defun eshell-next-prompt (n)
"Move to end of Nth next prompt in the buffer.
(with-eval-after-load 'em-prompt
(defun eshell-next-prompt (n)
"Move to end of Nth next prompt in the buffer.
See `eshell-prompt-regexp'."
(interactive "p")
(re-search-forward eshell-prompt-regexp nil t n)
(while (not (get-text-property (line-beginning-position) 'read-only) )
(re-search-forward eshell-prompt-regexp nil t n))
(eshell-skip-prompt))
(interactive "p")
(re-search-forward eshell-prompt-regexp nil t n)
(while (not (get-text-property (line-beginning-position) 'read-only) )
(re-search-forward eshell-prompt-regexp nil t n))
(eshell-skip-prompt))
(defun eshell-previous-prompt (n)
"Move to end of Nth previous prompt in the buffer.
(defun eshell-previous-prompt (n)
"Move to end of Nth previous prompt in the buffer.
See `eshell-prompt-regexp'."
(interactive "p")
(backward-char)
(eshell-next-prompt (- n)))
(interactive "p")
(backward-char)
(eshell-next-prompt (- n))))
(provide 'mode-eshell)