1

I'm struggling to find a way to define keys only for eshell. Looking at the emacs wiki I saw examples using the eshell-mode-map yet I get errors when trying to define it.

progn: Symbol’s value as variable is void: eshell-mode-map

I'm trying to get the f-keys to work as nornal f-keys after using them to quick launch functions in global mode.

Here is what I tried

(define-key eshell-mode-map (kbd "<f9>") (kbd "<f9>")  )
  • I'm confused by the use of (kbd "<f9>") (kbd "<f9>") (which will cause an infinite loop). Ignoring the specific code, what is the desired result? What is <f9> currently doing (and in which specific scenario)?, and what do you need it to do? – phils May 7 '17 at 8:23
  • According to the comments on @xuchunyang's answer, I think the idea is to send <f9> to a program running in term, which probably requires using escape codes somehow. – npostavs May 7 '17 at 15:34
2
(add-hook 'eshell-mode-hook
          (lambda ()
            (define-key eshell-mode-map (kbd "<f9>") #'emacs-version)))
  • thx @xuchunyang. i tried that but that results in <f9> is undefined when trying to issue 'f9' in a terminal app. thx Z – zeltak Feb 2 '17 at 15:45
  • @zeltak What do you mean by 'terminal app'? eshell and term are two different things in Emacs. – Tyler Feb 2 '17 at 18:16
  • 1
    @zeltak htop will not run (I mean it doesn't produce correct output) under eshell because it requires a terminal device, unless you put htop into eshell-visual-commands in your own Emacs init file. When htop runs in term, you can try term-raw-map (which is used in "char mode") or term-mode-map (which is used in "line mode"). – xuchunyang Feb 3 '17 at 4:20
  • 1
    @zeltak Ah I see! This is a tricky one - eshell visual commands are not actually run in an eshell buffer, because eshell can't handle the visual formatting directly. Instead, eshell starts a term mode buffer and runs the command there. So your htop process is running in term mode, even though you call it from eshell. So you need to modify the term-mode key map. – Tyler Feb 3 '17 at 14:22
  • 1
    @zeltak For term-mode-map, you need to switch to "line mode" to get f9 work. term uses "char mode" at the beginning, in this mode, term-raw-map should work. – xuchunyang Feb 6 '17 at 6:49

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.