diff --git a/oni-compilation.el b/oni-compilation.el index d11f395..c5c7444 100644 --- a/oni-compilation.el +++ b/oni-compilation.el @@ -4,8 +4,8 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2019.0908.172111 -;; Package-Requires: (oni-alert) +;; Version: 2019.0919.171849 +;; Package-Requires: (oni-alert xterm-color) ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ (require 'compile) (require 'subr-x) +(require 'xterm-color) (setq compilation-scroll-output t) @@ -45,10 +46,6 @@ ALIST and PLIST contain extra information about the buffer." (unless (string= (string-trim status) "finished") (display-buffer buffer))) -(defun oni-compilation--ansi-color-for-compilation-filter () - "Apply ANSI terminal escape codes to compilation output." - (ansi-color-apply-on-region compilation-filter-start (point))) - (defun oni-compilation--compilation-finish-notify-function (buffer status) "Show an alert of the status of the compliation. @@ -59,21 +56,26 @@ status of the process." (alert "Compilation finished succesfully") (alert "Compilation finished with an error")))) +(defun oni-compilation--filter-xterm-colors (func proc string) + "Call FUNC with PROC and STRING filtered through ‘xterm-color-filter’." + (funcall func proc (xterm-color-filter string))) + +(setq compilation-environment '("TERM=xterm-256color")) + (add-to-list 'display-buffer-alist '("\\`\\*compilation\\*\\'" display-buffer-in-side-window (side . bottom) (slot . 0) (window-height . 0.33))) -(add-hook 'compilation-filter-hook - #'oni-compilation--ansi-color-for-compilation-filter) - (add-hook 'compilation-finish-functions #'oni-compilation--maybe-display-compilation-window) (add-hook 'compilation-finish-functions #'oni-compilation--compilation-finish-notify-function) +(advice-add 'compilation-filter :around #'oni-compilation--filter-xterm-colors) + ;;;###autoload(with-eval-after-load 'compile (require 'oni-compilation)) (provide 'oni-compilation) diff --git a/oni-eshell.el b/oni-eshell.el index 8530ca9..3126a1d 100644 --- a/oni-eshell.el +++ b/oni-eshell.el @@ -4,8 +4,8 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2019.0908.165243 -;; Package-Requires: (eshell-fringe-status esh-autosuggest) +;; Version: 2019.0919.172336 +;; Package-Requires: (eshell-fringe-status esh-autosuggest xterm-color) ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -27,8 +27,10 @@ ;;; Code: (require 'eshell) + (require 'em-prompt) (require 'esh-autosuggest) +(require 'xterm-color) (defun oni-eshell--C-d () "Call `delete-char' or close the buffer if it fails." @@ -48,14 +50,26 @@ "Set `C-d' to quit eshell if used at end of prompt." (define-key eshell-mode-map (kbd "C-d") #'oni-eshell--C-d)) +(defun oni-eshell--set-xterm-variables () + "Set ‘xterm-color-preserve-properties’ to t." + (setq xterm-color-preserve-properties t)) + (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-mode-hook 'esh-autosuggest-mode) (add-hook 'eshell-mode-hook 'goto-address-mode) +(add-hook 'eshell-before-prompt-hook #'oni-eshell--set-xterm-variables) (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 '("\\`\\*eshell" display-buffer-in-side-window (side . bottom)