]> gitweb.michael.orlitzky.com - emacs.d.git/commitdiff
mode-hooks: hack around double-emacs-nw in multi-term mode.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 25 Jun 2020 01:48:35 +0000 (21:48 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 25 Jun 2020 01:48:35 +0000 (21:48 -0400)
mode-hooks/multi-term-hooks.el

index 9b4f9637e30189923fe9b7284b3eda26f0de53b1..116471c776218a5dd47764d3d574c38aa11b960e 100644 (file)
@@ -1,11 +1,16 @@
 (defun mtm-hook()
-  ;; Pass through C-c, C-x, and M-x for emaception.
-  (delete "C-x" term-unbind-key-list)
-  (delete "C-c"   term-unbind-key-list)
-  (delete "<ESC>" term-unbind-key-list)
+  ;; In a multi-term, we strip out any "-nw" or "--no-window-system"
+  ;; flags that are present in the EDITOR and VISUAL environment
+  ;; variables, to avoid getting trapped inside a double-emacs-nw.
+  (setq editor (getenv "EDITOR"))
+  (setq editor (replace-regexp-in-string " -nw" "" editor))
+  (setq editor (replace-regexp-in-string " --no-window-system" "" editor))
+  (setenv "EDITOR" editor)
 
-  ;; We don't need the special C-c C-c any afterwards.
-  (delete '("C-c C-c" . term-interrupt-subjob) term-bind-key-alist)
+  (setq visual (getenv "VISUAL"))
+  (setq visual (replace-regexp-in-string " -nw" "" visual))
+  (setq visual (replace-regexp-in-string " --no-window-system" "" visual))
+  (setenv "VISUAL" visual)
 )
 
 (add-hook 'term-mode-hook (function mtm-hook))