summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJakob L. Kreuze2020-07-02 21:13:48 -0400
committerJakob L. Kreuze2020-07-02 21:13:48 -0400
commitc8c83655f71d3061cabffc02724c7d2b8657bcab (patch)
treebb90d6ce2f07c6007287127ef0262f9939b060b1 /lisp
parent11337451b89797abb5b2edb28837695f0dbabf7a (diff)
Only set `comint-terminfo-terminal' in shell-mode.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/shell.el28
1 files changed, 19 insertions, 9 deletions
diff --git a/lisp/shell.el b/lisp/shell.el
index 7045880..81fc82a 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -12,6 +12,14 @@
;;; [1]: https://ambrevar.xyz/emacs-eshell-versus-shell/index.html
;;;
+(defmacro with-temporary-bindings (bindings &rest form)
+ "Weak and partially underspecified macro to temporarily set
+`bindings', undoing them when `form' has finished evaluating."
+ `(unwind-protect
+ (progn ,@(mapcar #'(lambda (form) (cons 'setq form)) bindings)
+ ,@form)
+ (progn ,@(mapcar #'(lambda (form) `(setq ,(car form) ,(eval (car form)))) bindings))))
+
;; I dislike the default behavior of creating a new window upon invoking
;; `shell', but there isn't a better way of dealing with that.
(defun shell-same-window (&optional buffer)
@@ -24,6 +32,10 @@
(setq n (1+ n)))
(setq buffer (switch-to-buffer buffer-name)))
+ ;; Don't play 'dumb', but don't ruin it for other modes that use comint.
+ ;; (make-local-variable 'comint-terminfo-terminal)
+ ;; (setq comint-terminfo-terminal "xterm-256color")
+
(with-connection-local-variables
;; On remote hosts, the local `shell-file-name' might be useless.
(when (file-remote-p default-directory)
@@ -47,20 +59,18 @@
(unless (file-exists-p startfile)
(setq startfile (concat user-emacs-directory "init_" name ".sh")))
(setq-local shell--start-prog (file-name-nondirectory prog))
- (apply #'make-comint-in-buffer "shell" buffer prog
- (if (file-exists-p startfile) startfile)
- (if (and xargs-name (boundp xargs-name))
- (symbol-value xargs-name)
- '("-i")))
+ (setq comint-terminfo-terminal "xterm-256color")
+ (with-temporary-bindings ((comint-terminfo-terminal "xterm-256color"))
+ (apply #'make-comint-in-buffer "shell" buffer prog
+ (if (file-exists-p startfile) startfile)
+ (if (and xargs-name (boundp xargs-name))
+ (symbol-value xargs-name)
+ '("-i"))))
(shell-mode))))
buffer)
;; Use ANSI colors in `shell' (and elsewhere!?).
(use-package xterm-color
- ;; Don't play 'dumb'.
- :init
- (setq comint-terminfo-terminal "xterm-256color")
-
;; Use the same colors as Alacritty.
:init
(setq xterm-color-names

© 2015 - 2026 Jakob L. Kreuze