diff options
-rw-r--r-- | modules/workstation/emacs/init.el | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/modules/workstation/emacs/init.el b/modules/workstation/emacs/init.el index e09d92863e24..a61ebccd50fb 100644 --- a/modules/workstation/emacs/init.el +++ b/modules/workstation/emacs/init.el @@ -23,6 +23,19 @@ (setq bidi-paragraph-direction 'left-to-right) (setq bidi-inhibit-bpa t) +;;; Utility functions ;;; + +;; Set an environment variable value for a single buffer. +(defun setenv-local (variable &optional value substitute-env-vars) + ;; If process-environment is the global one, make a copy of it. + (when (eq process-environment (default-value 'process-environment)) + (make-local-variable 'process-environment) + (setq process-environment (mapcar 'concat process-environment))) + (setenv variable value substitute-env-vars)) + +(defun enable-ansi-color () + (setenv-local "TERM" "dumb-emacs-ansi")) + ;;; Major modes ;;; (add-to-list 'auto-mode-alist '("\\.adoc\\'" . adoc-mode)) (add-to-list 'auto-mode-alist '("\\.quirks\\'" . conf-unix-mode)) @@ -33,6 +46,12 @@ ;; Default to kernel style. (add-to-list 'c-default-style '(other . "linux"))) +;;; Comint ;;; +(defun enable-comint-ansi-color () + (when ansi-color-for-comint-mode + (enable-ansi-color))) +(add-hook 'comint-mode-hook #'enable-comint-ansi-color) + ;;; Dired ;;; (with-eval-after-load 'dired (setq dired-listing-switches @@ -60,9 +79,7 @@ (setenv "PAGER" "") ;;; Eshell ;;; -;; Tell programs we support ANSI color. -(add-hook 'eshell-mode-hook - (lambda () (setenv "TERM" "dumb-emacs-ansi"))) +(add-hook 'eshell-mode-hook #'enable-ansi-color) ;;; Ibuffer ;;; ;; Open ibuffer in other window, to match behaviour of the default |