Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send M-. to terminal (multi-term) in Emacs

I am trying to send the command M-. (i.e. <ALT> .) to a terminal that is running in multi-term in Emacs. For reference, M-. is typically bound to insert the last argument of the previous command in a terminal (i.e. yank-last-arg / insert-last-argument)

I have the following set up:

(require 'multi-term)
(multi-term-keystroke-setup)
(setq multi-term-program "/home/john/sw/zsh/bin/zsh")

(setq term-bind-key-alist
    (list
    ( cons "C-c C-j" 'term-line-mode)
    ( cons "C-c C-k" 'term-char-mode)
    ( cons "C-p"  'term-send-raw)
    ( cons "C-n"  'term-send-raw)
    ( cons "C-a"  'term-send-raw)
    ( cons "C-e"  'term-send-raw)
    ( cons "M-b"  'term-send-backward-word)
    ( cons "M-f"  'term-send-forward-word)
    ( cons "M-d"  'term-send-forward-kill-word)
    ( cons "C-k"  'term-send-raw)
))
)

# Make sure yanking works:
(add-hook 'term-mode-hook (lambda ()
                            (define-key term-raw-map (kbd "C-y") 'term-paste)))

I have tried adding:

( cons "M-."  'term-send-raw)

but it doesn't seem to do anything.

In case it is useful, here's the list of commands that seem to have the term prefix and that are defined in term.el

term-send-M-x
term-send-backspace
term-send-backward-kill-word
term-send-backward-word
term-send-del
term-send-down
term-send-end
term-send-eof
term-send-forward-kill-word
term-send-forward-word
term-send-home
term-send-input
term-send-insert
term-send-invisible
term-send-left
term-send-next
term-send-prior
term-send-quote
term-send-raw
term-send-raw-meta
term-send-reverse-search-history
term-send-right
term-send-up
like image 282
Amelio Vazquez-Reina Avatar asked Oct 05 '22 20:10

Amelio Vazquez-Reina


1 Answers

I don't have multi-term to test it, but you can try using term-send-raw-meta instead of term-send-raw:

(setq term-bind-key-alist
    (list (cons "C-c C-j" 'term-line-mode)
          ; ...
          (cons "M-."  'term-send-raw-meta)))
like image 81
François Févotte Avatar answered Oct 10 '22 03:10

François Févotte