emacs -nw issues with cscope and terminals - emacs

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,

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)

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".

Related

Evil in emacs: cannot remap "s": buffer is read-only

I'm trying to remap some evil keys to navigate using htns. htn works fine, but s always gives me the "buffer is read-only" error. I'm assuming I need to remap save buffer, but I'm getting lost in the key rebinding api. My .emacs looks like
(define-key evil-motion-state-map (kbd "n") 'evil-next-line)
(define-key evil-motion-state-map (kbd "s") 'evil-previous-line)
(define-key evil-motion-state-map (kbd "h") 'evil-forward-char)
(define-key evil-motion-state-map (kbd "t") 'evil-backward-char)
It's ok if IĀ use the normal state map instead:
(define-key evil-normal-state-map (kbd "s") 'evil-previous-line)
Does that suit your needs ?
I guess you had this error because the binding was not working.

Emacs evil: general window movement remap

This is the question I should have asked instead of this:
Emacs evil: space as a prefix key in motion state
I want to define a bunch of commands for moving, moving between, opening and closing windows and buffers that works in all states except insert mode, and are all of the form "SPC ". It would be nice to be able to set this once and be fine everywhere (except when there are conflicts, though overriding would be fine), but if that isn't easy, I would also like to know how to override keybindings in new states that I run across where my keybindings don't work. Hopefully knowing that would also help me edit keybindings in arbitrary states.
What I currently have is this:
(define-key evil-normal-state-map (kbd "SPC") nil)
(define-key evil-motion-state-map (kbd "SPC") nil)
(define-key evil-motion-state-map (kbd "SPC h") 'evil-window-left)
(define-key evil-motion-state-map (kbd "SPC j") 'evil-window-down)
(define-key evil-motion-state-map (kbd "SPC k") 'evil-window-up)
(define-key evil-motion-state-map (kbd "SPC l") 'evil-window-right)
(define-key evil-normal-state-map (kbd "SPC h") 'evil-window-left)
(define-key evil-normal-state-map (kbd "SPC j") 'evil-window-down)
(define-key evil-normal-state-map (kbd "SPC k") 'evil-window-up)
(define-key evil-normal-state-map (kbd "SPC l") 'evil-window-right)
and "SPC H" and so on for moving windows. It doesn't work in list-buffers or Dired. Evil leader only seems to work for normal mode.
We meet again.
Perhaps it'd be simpler to define a prefix keymap and bind to it. For example:
(define-prefix-command 'my-window-map)
(let ((map my-window-map))
(define-key map "h" 'evil-window-left)
(define-key map "j" 'evil-window-down)
(define-key map "k" 'evil-window-up)
(define-key map "l" 'evil-window-right)
(define-key map "H" 'evil-window-move-far-left)
(define-key map "J" 'evil-window-move-very-bottom)
(define-key map "K" 'evil-window-move-very-top)
(define-key map "L" 'evil-window-move-far-right)
;; And presumably, for opening/closing
(define-key map "v" 'evil-window-vsplit)
(define-key map "s" 'evil-window-split)
(define-key map "c" 'evil-window-delete))
Then you can map the prefix keymap to SPC in various modes:
;; Do this for each state you want these bindings available
(define-key evil-motion-state-map " " 'my-window-map)
(define-key evil-visual-state-map " " 'my-window-map)
;; You don't need to unbind/rebind evil-normal-state-map --
;; there is no default mapping for " ". Also: unbound keys in normal
;; mode will fall through to motion bindings.
;; For particular modes (like dired and list-buffer window)
(define-key dired-mode-map " " 'my-window-map)
(define-key Buffer-menu-mode-map " " 'my-window-map)
Alternatively, you can have dired and list-buffer start in normal mode. This will likely interfere with their default mappings.
(evil-set-initial-state 'dired-mode 'normal)
(evil-set-initial-state 'Buffer-menu-mode 'normal)
If you find your mapping overridden by another mode (which shouldn't be common for that key), you can try adding my-window-map to evil-overriding-maps: (add-to-list 'evil-overriding-maps '(my-window-map)). This supposedly gives those maps precedence.
Disclaimer: I haven't tested this. I find it simpler to undefine keys in conflicting plugins.
On a side note, all these commands are already available in evil-window-map. It may be simpler for you to map SPC to that:
(define-key evil-motion-state-map " " 'evil-window-map)
(define-key evil-visual-state-map " " 'evil-window-map)
...

Can I bind action to a keypress in Emacs?

I have (kbd "C-c S-<down>") and (kbd "C-c S-<up>") bound to shrink-window and enlarge-window, respectively.
It works, but I also want Emacs to change window size during a keypress, while I am holding S-<down> or S-<up>.
Is it possible in Emacs?
(define-key global-map [S-up] 'enlarge-window)
(define-key global-map [S-down] 'shrink-window)

Emacs keys to move in pop ups of auto-complete

I am setting my Emacs for cpp development.
I have set up auto-complete and yasnippets and it is great.
But every time one of pop up comes, i have to reach the mouse to click the lowest or middle one..
It must be possible with keys too but i struggled to find one.
I found this article keys-for-pop-up but i think he is speaking about auto-completing without asking the user or showing no pops.
For anyone reading this, to move up or down in the auto-complete popup:
Move down: M-n
Move up: M-p
Here's the complete mode map from auto-complete.el
(define-key map "\t" 'ac-expand)
(define-key map [tab] 'ac-expand)
(define-key map "\r" 'ac-complete)
(define-key map [return] 'ac-complete)
(define-key map (kbd "M-TAB") 'auto-complete)
(define-key map "\M-n" 'ac-next)
(define-key map "\M-p" 'ac-previous)
(define-key map [down] 'ac-next)
(define-key map [up] 'ac-previous)
(define-key map [f1] 'ac-help)
(define-key map [M-f1] 'ac-persist-help)
(define-key map (kbd "C-?") 'ac-help)
(define-key map (kbd "C-M-?") 'ac-persist-help)
(define-key map [C-down] 'ac-quick-help-scroll-down)
(define-key map [C-up] 'ac-quick-help-scroll-up)
(define-key map "\C-\M-n" 'ac-quick-help-scroll-down)
(define-key map "\C-\M-p" 'ac-quick-help-scroll-up)

Key Bindings Not Working? How to Configure

I'm using Emacs 24. and Octave 3.6.3 on Linux Mint Maya
I have set-up my init file, and all works fine. M-x run-octave gives me inferior octave, and .m files open automatically in octave mode.
But I can't seem to get key bindings to work? When I'm in octave mode, I press
'Ctrl' and 'c' together, then I press 'i', and emacs tells me that C-c i is undefined?
Could someone please help? I just want to send lines easily
It is better to look in the source file. Here is how shortcuts are defined for the octave mode:
(defvar octave-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "`" 'octave-abbrev-start)
(define-key map "\e\n" 'octave-indent-new-comment-line)
(define-key map "\M-\C-q" 'octave-indent-defun)
(define-key map "\C-c\C-b" 'octave-submit-bug-report)
(define-key map "\C-c\C-p" 'octave-previous-code-line)
(define-key map "\C-c\C-n" 'octave-next-code-line)
(define-key map "\C-c\C-a" 'octave-beginning-of-line)
(define-key map "\C-c\C-e" 'octave-end-of-line)
(define-key map [remap down-list] 'smie-down-list)
(define-key map "\C-c\M-\C-h" 'octave-mark-block)
(define-key map "\C-c]" 'smie-close-block)
(define-key map "\C-c/" 'smie-close-block)
(define-key map "\C-c\C-f" 'octave-insert-defun)
;; FIXME: free C-h so it can do the describe-prefix-bindings.
(define-key map "\C-c\C-h" 'info-lookup-symbol)
(define-key map "\C-c\C-il" 'octave-send-line)
(define-key map "\C-c\C-ib" 'octave-send-block)
(define-key map "\C-c\C-if" 'octave-send-defun)
(define-key map "\C-c\C-ir" 'octave-send-region)
(define-key map "\C-c\C-is" 'octave-show-process-buffer)
(define-key map "\C-c\C-ih" 'octave-hide-process-buffer)
(define-key map "\C-c\C-ik" 'octave-kill-process)
(define-key map "\C-c\C-i\C-l" 'octave-send-line)
(define-key map "\C-c\C-i\C-b" 'octave-send-block)
(define-key map "\C-c\C-i\C-f" 'octave-send-defun)
(define-key map "\C-c\C-i\C-r" 'octave-send-region)
(define-key map "\C-c\C-i\C-s" 'octave-show-process-buffer)
;; FIXME: free C-h so it can do the describe-prefix-bindings.
(define-key map "\C-c\C-i\C-h" 'octave-hide-process-buffer)
(define-key map "\C-c\C-i\C-k" 'octave-kill-process)
map)
"Keymap used in Octave mode.")
As you can see, you have to use C-c C-i l to send a line
I think the documentation you read for octave-mode is outdated. You probably need to use C-c C-i as a prefix instead of C-c i. To have a full command you need to type another character, for example r or C-r to send the region.
This change was most likely done to conform with emacs specifications. Emacs reserves the keys in C-c <char> where <char> is any one character for the user. Therefore octave-mode should not have use such a key in the first place.
disable some minor mode,maybe has some code defined likes(define-key xx-map "\C-c i" nill) and effected by mode-hook