emacs -nw issues with cscope and terminals

2019-06-11 16:40发布

问题:

Few issues with emacs in term windows. Any help is appreciated.

a. I start emacs over ssh with emacs -nw with cscope enabled. After I search for a symbol or a definition, on the cscope buffer when i press 'enter', emacs says - Buffer is read-only. Whereas the same functionality on emacs with xwindows (gtk or anything else) takes me to the file and line on edit buffer. How can I have the same functionality with 'emacs -nw'.

b. Also the arrow mark on edit/source buffer when i do next reference for symbol from cscope buffer stays on the edit buffer. How can I make it go?

c. My keys are mapped to cscope functions just like in xcscope.el. All the control keys expect Ctrl-F3 and Ctrl-F4 work. How can I enable this too.

Thanks much,

回答1:

a. Add the following to your .emacs file:

(define-key global-map (kbd "\r") [return])

I got the answer from http://weenix.cs.brown.edu/mediawiki/index.php/Cscope

b. If you hit the space bar in the cscope buffer, you will get the arrow. It's just a display thing; the file has not changed. If you want to get rid of it, add the following to your .emacs file:

(setq cscope-allow-arrow-overlays nil)


回答2:

terminal send different key sequences than emacs may be expecting. you need to provide translations for the terminal type in order to get emacs to work correctly. for example, i have this config to setup the terminal i use (the weird char is a literal "escape" char, which you can type in using "C-q <esc>":

(let ((map (if (boundp 'input-decode-map)
               input-decode-map function-key-map)))
  (define-key map (kbd "RET") [return])

  (define-key map "[OA" (kbd "<C-up>"))
  (define-key map "[OB" (kbd "<C-down>"))
  (define-key map "[OC" (kbd "<C-right>"))
  (define-key map "[OD" (kbd "<C-left>"))

  (define-key map "[A" (kbd "<C-up>"))
  (define-key map "[B" (kbd "<C-down>"))
  (define-key map "[C" (kbd "<C-right>"))
  (define-key map "[D" (kbd "<C-left>"))

  (define-key map "OA" (kbd "<M-up>"))
  (define-key map "OB" (kbd "<M-down>"))
  (define-key map "OC" (kbd "<M-right>"))
  (define-key map "OD" (kbd "<M-left>"))

  (define-key map "[OA" (kbd "<M-C-up>"))
  (define-key map "[OB" (kbd "<M-C-down>"))
  (define-key map "[OC" (kbd "<M-C-right>"))
  (define-key map "[OD" (kbd "<M-C-left>"))

  (define-key map "[[17~" (kbd "<C-f6>"))
  (define-key map "[[18~" (kbd "<C-f7>"))
  (define-key map "[[19~" (kbd "<C-f8>"))
  (define-key map "[[20~" (kbd "<C-f9>"))
  (define-key map "[[21~" (kbd "<C-f10>"))
  (define-key map "[[23~" (kbd "<C-f11>"))
  (define-key map "[[24~" (kbd "<C-f12>"))

  (define-key map "\e[1~" [home])
  (define-key map "\e[4~" [end])
  (define-key map "\e\e[1~" [M-home])
  (define-key map "\e\e[4~" [M-end])
)

in some terminals, you can get the key code by typing "C-v" and then the desired keys. this should output the actual keycodes that the terminal sends for the keys you pressed after the "C-v".