From 11f53711a41e4e1f09b054c28c5792135475e18a Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 20 Sep 2019 09:34:43 -0700 Subject: [PATCH] Fix error in setting up xterm-color in eshell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently when the ‘oni-eshell’ library gets loaded neither ‘eshell-preoutput-filter-functions’ nor ‘eshell-output-filter-functions’ are ready to be used, even though they are defined in the ‘esh-mode’ libary, which is loaded at this point in time. --- oni-eshell.el | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/oni-eshell.el b/oni-eshell.el index 3126a1d..1dd5e65 100644 --- a/oni-eshell.el +++ b/oni-eshell.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2019.0919.172336 +;; Version: 2019.0920.093304 ;; Package-Requires: (eshell-fringe-status esh-autosuggest xterm-color) ;; This program is free software; you can redistribute it and/or modify @@ -46,6 +46,15 @@ "Add `eshell-truncate-buffer' to `eshell-output-filter-functions'." (add-to-list 'eshell-output-filter-functions 'eshell-truncate-buffer)) +(defun oni-eshell--enable-xterm-filter () + "Add ‘xterm-color-filter’ to ‘eshell-preoutput-filter-functions’." + (add-to-list 'eshell-preoutput-filter-functions 'xterm-color-filter)) + +(defun oni-eshell--disable-ansi-color-handling () + "Remove ‘eshell-handle-ansi-color’ from ‘eshell-output-filter-functions’." + (setq eshell-output-filter-functions + (remove 'eshell-handle-ansi-color eshell-output-filter-functions))) + (defun oni-eshell--set-eshell-C-d () "Set `C-d' to quit eshell if used at end of prompt." (define-key eshell-mode-map (kbd "C-d") #'oni-eshell--C-d)) @@ -56,6 +65,8 @@ (add-hook 'eshell-first-time-mode-hook #'oni-eshell--set-eshell-C-d) (add-hook 'eshell-load-hook #'oni-eshell--enable-truncating-buffers) +(add-hook 'eshell-load-hook #'oni-eshell--enable-xterm-filter) +(add-hook 'eshell-load-hook #'oni-eshell--disable-ansi-color-handling) (add-hook 'eshell-mode-hook 'esh-autosuggest-mode) (add-hook 'eshell-mode-hook 'goto-address-mode) (add-hook 'eshell-before-prompt-hook #'oni-eshell--set-xterm-variables) @@ -63,11 +74,6 @@ (when (display-graphic-p) (add-hook 'eshell-mode-hook 'eshell-fringe-status-mode)) -(add-to-list 'eshell-preoutput-filter-functions 'xterm-color-filter) - -(setq eshell-output-filter-functions - (remove 'eshell-handle-ansi-color eshell-output-filter-functions)) - (setenv "TERM" "xterm-256color") (add-to-list 'display-buffer-alist