Replace ‘ansi-color’ with ‘xterm-color’
According to a tweet from Mickey Petersen[1], ‘xterm-color’ is faster and more accurate. [1]: https://twitter.com/mickeynp/status/1132236557308579840?s=09
This commit is contained in:
parent
8724c976fc
commit
d37d8f969b
2 changed files with 27 additions and 11 deletions
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
;; Keywords: local
|
;; Keywords: local
|
||||||
;; Version: 2019.0908.172111
|
;; Version: 2019.0919.171849
|
||||||
;; Package-Requires: (oni-alert)
|
;; Package-Requires: (oni-alert xterm-color)
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; 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
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
(require 'compile)
|
(require 'compile)
|
||||||
(require 'subr-x)
|
(require 'subr-x)
|
||||||
|
(require 'xterm-color)
|
||||||
|
|
||||||
(setq compilation-scroll-output t)
|
(setq compilation-scroll-output t)
|
||||||
|
|
||||||
|
@ -45,10 +46,6 @@ ALIST and PLIST contain extra information about the buffer."
|
||||||
(unless (string= (string-trim status) "finished")
|
(unless (string= (string-trim status) "finished")
|
||||||
(display-buffer buffer)))
|
(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)
|
(defun oni-compilation--compilation-finish-notify-function (buffer status)
|
||||||
"Show an alert of the status of the compliation.
|
"Show an alert of the status of the compliation.
|
||||||
|
|
||||||
|
@ -59,21 +56,26 @@ status of the process."
|
||||||
(alert "Compilation finished succesfully")
|
(alert "Compilation finished succesfully")
|
||||||
(alert "Compilation finished with an error"))))
|
(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
|
(add-to-list 'display-buffer-alist
|
||||||
'("\\`\\*compilation\\*\\'" display-buffer-in-side-window
|
'("\\`\\*compilation\\*\\'" display-buffer-in-side-window
|
||||||
(side . bottom)
|
(side . bottom)
|
||||||
(slot . 0)
|
(slot . 0)
|
||||||
(window-height . 0.33)))
|
(window-height . 0.33)))
|
||||||
|
|
||||||
(add-hook 'compilation-filter-hook
|
|
||||||
#'oni-compilation--ansi-color-for-compilation-filter)
|
|
||||||
|
|
||||||
(add-hook 'compilation-finish-functions
|
(add-hook 'compilation-finish-functions
|
||||||
#'oni-compilation--maybe-display-compilation-window)
|
#'oni-compilation--maybe-display-compilation-window)
|
||||||
|
|
||||||
(add-hook 'compilation-finish-functions
|
(add-hook 'compilation-finish-functions
|
||||||
#'oni-compilation--compilation-finish-notify-function)
|
#'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))
|
;;;###autoload(with-eval-after-load 'compile (require 'oni-compilation))
|
||||||
|
|
||||||
(provide 'oni-compilation)
|
(provide 'oni-compilation)
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
;; Keywords: local
|
;; Keywords: local
|
||||||
;; Version: 2019.0908.165243
|
;; Version: 2019.0919.172336
|
||||||
;; Package-Requires: (eshell-fringe-status esh-autosuggest)
|
;; Package-Requires: (eshell-fringe-status esh-autosuggest xterm-color)
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; 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
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
@ -27,8 +27,10 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(require 'eshell)
|
(require 'eshell)
|
||||||
|
|
||||||
(require 'em-prompt)
|
(require 'em-prompt)
|
||||||
(require 'esh-autosuggest)
|
(require 'esh-autosuggest)
|
||||||
|
(require 'xterm-color)
|
||||||
|
|
||||||
(defun oni-eshell--C-d ()
|
(defun oni-eshell--C-d ()
|
||||||
"Call `delete-char' or close the buffer if it fails."
|
"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."
|
"Set `C-d' to quit eshell if used at end of prompt."
|
||||||
(define-key eshell-mode-map (kbd "C-d") #'oni-eshell--C-d))
|
(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-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-truncating-buffers)
|
||||||
(add-hook 'eshell-mode-hook 'esh-autosuggest-mode)
|
(add-hook 'eshell-mode-hook 'esh-autosuggest-mode)
|
||||||
(add-hook 'eshell-mode-hook 'goto-address-mode)
|
(add-hook 'eshell-mode-hook 'goto-address-mode)
|
||||||
|
(add-hook 'eshell-before-prompt-hook #'oni-eshell--set-xterm-variables)
|
||||||
|
|
||||||
(when (display-graphic-p)
|
(when (display-graphic-p)
|
||||||
(add-hook 'eshell-mode-hook 'eshell-fringe-status-mode))
|
(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
|
(add-to-list 'display-buffer-alist
|
||||||
'("\\`\\*eshell" display-buffer-in-side-window
|
'("\\`\\*eshell" display-buffer-in-side-window
|
||||||
(side . bottom)
|
(side . bottom)
|
||||||
|
|
Loading…
Reference in a new issue