From 133b9f821fcba0f57f847e11de1cb2fefff8223d Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Thu, 9 Jun 2016 18:23:04 +0200 Subject: [PATCH] Emacs: Fix Eshell loading hooks to use cache folder --- .emacs.d/init.el | 2 +- .emacs.d/lisp/mode-eshell.el | 49 ++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 18a92823..48b96a86 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -60,7 +60,7 @@ To view where the bindings are set in your config files, lookup ;; Minor modes (add-hook 'dired-mode-hook (lambda () (require 'mode-dired))) (add-hook 'ediff-mode-hook (lambda () (require 'mode-ediff))) -(add-hook 'eshell-mode-hook (lambda () (require 'mode-eshell))) +(add-hook 'eshell-load-hook (lambda () (require 'mode-eshell))) (add-hook 'gud-mode-hook (lambda () (require 'mode-gud))) (add-hook 'octave-mode-hook (lambda () (require 'mode-octave))) (add-hook 'org-mode-hook (lambda () (require 'mode-org))) diff --git a/.emacs.d/lisp/mode-eshell.el b/.emacs.d/lisp/mode-eshell.el index 4fa3d131..e64f2511 100644 --- a/.emacs.d/lisp/mode-eshell.el +++ b/.emacs.d/lisp/mode-eshell.el @@ -1,4 +1,7 @@ ;; Eshell +;; This mode has a lot of hooks. +;; `emacs-load-hook' is run at the very beginning; not all variables/functions will be set. +;; `emacs-mode-hook' is run once everything is loaded. (setq eshell-directory-name (concat emacs-cache-folder "eshell")) ;; (setq eshell-aliases-file (concat user-emacs-directory "eshell-alias")) @@ -11,26 +14,30 @@ ;; "\n`--" ;; (if (= (user-uid) 0) "# " "> "))))) -(nconc eshell-visual-commands - '("abook" "cmus" "htop" "mutt" "ncdu" "newsbeuter" "ranger" "task")) -(when (file-executable-p "/usr/bin/pacman") - (map-on-pair 'eshell/alias - '(("pc" "sudo pacman -Sc") - ("pi" "sudo pacman -S --needed") - ("pqi" "pacman -Qi") - ("pqo" "pacman -Qo") - ("pqs" "pacman -Qs") - ("pr" "sudo pacman -Rs") - ("psi" "pacman -Si") - ("pss" "pacman -Ss") - ("pu" "sudo pacman -Syu")))) -(map-on-pair 'eshell/alias - '(("mkdir" "mkdir -p") - ("lx" "ls -lXh") - ("lx" "ls -lXh") - ("lk" "ls -lSrh") - ("lc" "ls -lrc") - ("ll" "ls -hl") - ("la" "ls -ahl"))) +(eval-after-load 'em-term + '(nconc eshell-visual-commands + '("abook" "cmus" "htop" "mutt" "ncdu" "newsbeuter" "ranger" "task"))) + +(eval-after-load 'em-alias + '(progn + (when (file-executable-p "/usr/bin/pacman") + (map-on-pair 'eshell/alias + '(("pc" "sudo pacman -Sc") + ("pi" "sudo pacman -S --needed") + ("pqi" "pacman -Qi") + ("pqo" "pacman -Qo") + ("pqs" "pacman -Qs") + ("pr" "sudo pacman -Rs") + ("psi" "pacman -Si") + ("pss" "pacman -Ss") + ("pu" "sudo pacman -Syu")))) + (map-on-pair 'eshell/alias + '(("mkdir" "mkdir -p") + ("lx" "ls -lXh") + ("lx" "ls -lXh") + ("lk" "ls -lSrh") + ("lc" "ls -lrc") + ("ll" "ls -hl") + ("la" "ls -ahl"))))) (provide 'mode-eshell)