I have regularly tried, over the years, to run emacs through putty to get rid of the need to install a local X server. I remember the putty+emacs combination being abysmal in the past; and right now it seems slightly better but still outright unusable.

For example, even after applying all configurations from https://www.emacswiki.org/emacs/PuTTY (setting to SCO emulation, etc.), many keys still do not get sent to emacs work (e.g., Shift-Arrow, Ctrl-Arrow, Ctrl-PageUp/Down etc.). That page is from 2014, though.

Has someone had good results in a current(ish) PuTTY (0.65, which is from 2015, but the changelog displays only minor bugfixes and security changes since then) with GNU emacs (24.5.1 in my case, but the problems seem to occur long before they actually reach emacs...). Or is it still hopeless?

EDIT: I am aware of Emacs being available as a native windows executable; I have used that; also Tramp, or running an X server on the Windows machine. This question is geared toward the specific situation of being forced to start it in this specific terminal program (which seems to be quite standard in the Windows world) on a remote machine (Unix, of course), for whatever reasons out of my control.

EDIT^2: I don't see how I can get much more specific. I named a few commonplace key combinations that do not work; I would suspect/hope that anybody who regularly uses Emacs over Putty would be able to give a quick "situational update" like "it kind of works, but better learn to only use Ctrl/Alt+[a-z] keys instead of any 'modern' key" or "if you set option XYZ in Putty and option ABC in Emacs, 99% of all combinations work". I'll interpret "no answer" as "let go of all hope".

  • 1
    Please consider editing the question to make it more discrete and identify the specific problems you're having on the Emacs side. You're more likely to get helpful answers that way. – Dan Sep 28 '16 at 13:13
  • 2
    Have you considered to use an MS-Windows local Emacs, and to access your remote files via Tramp? – Michael Albinus Sep 28 '16 at 13:19
  • 1
    From your edits, it sounds like your question is actually about access to keybindings. If so, it may help to take a look at Problems with keybindings when using terminal. – Dan Sep 28 '16 at 20:53
  • I'm using putty to access my running Emacs on my Linux system at work on a nearly daily basis. I had just to adjust the encoding to utf8 in putty. Nearly all key bindings working for me except the Alt Arrow keys in org-mode. But as @Dan mentioned this seems to be an issue of the terminal version of Emacs and not putty. Could it be that you configured putty to death? – Dieter.Wilhelm Oct 7 '16 at 4:29
  • @Dieter.Wilhelm, no, I have tried starting from fresh default settings in Putty. But I have solved my problem now and will provide an answer myself in a second, maybe it helps someone else. – AnoE Oct 7 '16 at 9:21

I solved my problem with a workaround: I use Autohotkey Pro (AHK) on the windows machine to change the non-working key combinations to something else; on the Emacs side I alias them back to the original meaning.

Without further ado, this is the AHK script:

# emacs_fix.ahk

SendMode Input    

#IfWinActive, emacs

end:: Send, ^xpe
^right:: Send, ^xpcr
^left:: Send, ^xpcl
^up:: Send, ^xpcu
^down:: Send, ^xpcd
^end:: Send, ^xpce
^home:: Send, ^xpch

And in init.el:

(defmacro defkbalias (old new)
  `(define-key (current-global-map) ,new
     (lookup-key (current-global-map) ,old)))

(defkbalias (kbd "<end>") (kbd "C-x p e"))
(defkbalias (kbd "C-<right>") (kbd "C-x p c r"))
(defkbalias (kbd "C-<left>") (kbd "C-x p c l"))
(defkbalias (kbd "C-<up>") (kbd "C-x p c u"))
(defkbalias (kbd "C-<down>") (kbd "C-x p c d"))
(defkbalias (kbd "C-<end>") (kbd "C-x p c e"))
(defkbalias (kbd "C-<home>") (kbd "C-x p c h"))

I picked C-x p as prefix because it was unused in emacs; it should work with anything that goes through.

Now I am very happy - I am positive that I can fix any further broken key combination this way. The display side seems fine - Putty and emacs seem to talk the same language in that regard, at least.

  • i wish there was a less hacky-solution, but this actually works, and that's more important ;-) out of laziness (and because i need portability across machines), i didn't want to set up mappings in init.el, so i'm mapping the keys to sequences that putty will pass through correctly, for example, ^home:: Send {Esc}<. The final sentence here (can fix any further broken key combination this way) is a key observation. – jdigital Feb 10 '18 at 19:51
  • Aye, @jdigital. Thank bob I don't need that hack anymore at the moment as I am not forced to run Emacs through Putty atm, but can use it locally. But as long as I needed it, it worked splendidly. Setting up the proper combinations (like a "discrete" Esc instead of M-...) is great of course. – AnoE Feb 10 '18 at 20:32
  • BTW, to understand the scope of the putty problem, see this article which has a table of keystrokes and how they work (or don't) with modifier keys: emacswiki.org/emacs/PuTTY – jdigital Feb 10 '18 at 23:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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