5

This might have an obvious answer but I've been trying to fix this issue with no luck. (I'm new to Emacs)

Whenever I start Emacs within a Tmux pane, it ignores some of my .emacs settings. These are the contents of the .emacs file:

(custom-set-variables
;; custom-set-variables was added by Custom.                                                                                                                                             
;; If you edit it by hand, you could mess it up, so be careful.                                                                                                                          
;; Your init file should contain only one such instance.                                                                                                                                 
;; If there is more than one, they won't work right.                                                                                                                                     
'(ansi-color-faces-vector
[default default default italic underline success warning error])
'(cua-mode t nil (cua-base))
'(show-paren-mode t)
'(tool-bar-mode nil))

(custom-set-faces
;; custom-set-faces was added by Custom.                                                                                                                                                 
;; If you edit it by hand, you could mess it up, so be careful.                                                                                                                          
;; Your init file should contain only one such instance.                                                                                                                                 
;; If there is more than one, they won't work right.                                                                                                                                     
)

;;Initial GUI frame size and position                                                                                                                                                     
(when window-system (set-frame-size (selected-frame) 160 50))

;; Resizing window quick shortcuts                                                                                                                                                        
(global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally)
(global-set-key (kbd "S-C-<down>") 'shrink-window)
(global-set-key (kbd "S-C-<up>") 'enlarge-window)

;;Kill buffer without prompt unless there are unsaved changes                                                                                                                             
(global-set-key (kbd "C-x k") 'kill-this-buffer)

;;Interactively-do-mode, improves file and interface navigation                                                                                                                           
(require 'ido)
(ido-mode t)

Settings like IDO mode and kill-this-buffer work fine. But the syntax color scheme and S-C-arrows for resizing the window don't work.

Inside Tmux: enter image description here Outside Tmux (still in gnome-terminal): enter image description here

*Also, is running Emacs inside Tmux a bad idea in general?

  • How do you know it ignores the configuration? – choroba Dec 19 '16 at 15:09
  • The only thing that seems to be working from my configuration mode is Ido mode. Other than that my syntax theme doesn't work, my custom keybindings don't work and changing settings in the init file like menu-bar-mode -1 doesn't work. It does work in a regular terminal though. – Rtsne42 Dec 19 '16 at 15:26
  • Does M-: (getenv "HOME") point to your user's home directory? – wvxvw Dec 19 '16 at 15:31
  • Yes, it does. I killed all the Tmux sessions and some of the new keybinds seem to work now. – Rtsne42 Dec 19 '16 at 15:34
  • But things like my window resize keybinds and syntax theme don't work: (global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally) (global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally) (global-set-key (kbd "S-C-<down>") 'shrink-window) (global-set-key (kbd "S-C-<up>") 'enlarge-window) – Rtsne42 Dec 19 '16 at 15:35
5

The following additions to your .tmux.conf file ought to fix most or your problems:

set-option -g default-terminal "xterm-256color"
set-window-option -g xterm-keys on

The reason that your color themes aren't working as expected is most likely that emacs thinks that it is running in a terminal with only 8 colors. Setting the terminal to be xterm-256color tells emacs that your terminal can support 256 colors.

The reason that your keyboard shortcuts aren't working as expected is that the tmux doesn't know what you expect it to do with modified keys. Turning xterm-keys on tells tmux to send the modified keys as escape sequences the same way xterm does. Since emacs thinks that your terminal is xterm, it will interpret incoming escape sequences as if they were from xterm, and do the right thing.

  • Although this didn't fix the issue directly. For some reason after adding these settings not much changed other than the fact that the screen split lines had no background. Then after removing the changes. Suddenly everything works. Don't know what fixed it. If I find out I'll update the post. For now I might as well accept it as an answer. – Rtsne42 Dec 19 '16 at 17:24
  • This only worked for me after killing all current tmux sessions. – erjoalgo May 19 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.