(defun mtm-hook() ;; 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) (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))