I am getting errors when I try to add this to my ~/.emacs file:
(define-key evil-normal-state-map "ss" 'split-window-vertically)
I get this error:
error: Key sequence s s starts with non-prefix key s
The problem is that there is already a command bound to s (specifically, evil-substitute), which means you could not get to you ss binding because the first s would invoke evil-substitute. You can undefine the s by setting it to nil and then bind ss as you already have it:
(define-key evil-normal-state-map "s" nil)
(define-key evil-normal-state-map "ss" 'split-window-vertically)
(If you want to know what commands are bound to which keys, you can use M-x describe-key SOMEKEY or C-h k SOMEKEY.)
Related
I would like to customize the key bindings so that "n" and "p" run 'ess-rdired-next-line and 'ess-rdired-previous-line automatically by editing my .emacs
It doesn't recognize the variable ess-rdired-mode-map until I call ess-rdired from a buffer with an ESS process. I tried putting (ess-rdired) earlier in my .emacs and get the error
No ESS process is associated with this buffer now
When I call ess-rdired from an ESS buffer before using define-key as below, they key bindings work as expected.
(define-key ess-rdired-mode-map "P" 'ess-rdired-plot)
(define-key ess-rdired-mode-map "n" 'ess-rdired-next-line)
(define-key ess-rdired-mode-map "p" 'ess-rdired-previous-line)
Debugger entered--Lisp error: (void-variable ess-rdired-mode-map)
The variable isn't defined until the package is loaded, so you can just wrap your key definitions to be loaded after ess-rdired,
(with-eval-after-load 'ess-rdired
;; (define-key ...)
)
I finally got this to work, but wanted to know if there was an easier way.
I want to bind a key "U" to put spacemacs into insert-mode, but at the start of the text of the line.
(define-key evil-normal-state-map "u" 'evil-insert)
(define-key evil-normal-state-map "U" (lambda ()
(interactive)
(beginning-of-line-text)
(execute-kbd-macro "u")))
Is there an 'evil command to insert mode at start of line? Or a more elegant way to fire 'evil-insert or run multiple commands?
In evil-mode i executes evil-insert and I executes evil-insert-line.
So the simplest rebinding would be:
(define-key evil-normal-state-map "u" 'evil-insert)
(define-key evil-normal-state-map "U" 'evil-insert-line)
Whenever you want to know which keys run which functions just press C-h k and then the keybinding of choice.
I have my emacs editor setup to run a shell when I press Ctrl-z. When inside of a shell buffer, I use Ctrl-z to clear the buffer by running the erase-buffer function. The code is being evaluated (when I Ctrl-h v and describe the shell-mode-map I can see that C-z is bound to clear-shell-buffer in shell mode. When I run the clear-shell-buffer with M-x the message says:
You can run the command clear-shell-buffer with <C-z>
However, when I type Ctrl-z in the shell it does not run the function or give any messages at all. Any idea why?
(defun clear-shell-buffer ()
"Clear the contents of the current buffer"
(interactive)
(erase-buffer)
;; (insert "/usr/games/fortune -a")
(comint-send-input)
)
(put 'erase-buffer 'disabled nil)
(eval-after-load 'shell
'(define-key shell-mode-map [(\C-z)] 'clear-shell-buffer))
This is happening because of the key binding being incorrect. You can verify this by doing C-h k C-z when in shell mode.
Instead of [(\C-z)], use one of these options:
[(?\C-z)]
[(control ?z)]
(kbd "C-z")
which will correctly set the key binding, and let you call the correct function with C-z
You can see a little bit of what's happening if you evaluate just the those statements. Here's the output I get for each
(define-key shell-mode-map [(\C-z)] 'clear-shell-buffer)
;;Output: (define-key shell-mode-map [(C-z)] (quote clear-shell-buffer))
(define-key shell-mode-map [(?\C-z)] 'clear-shell-buffer)
;;Output: (define-key shell-mode-map [(26)] (quote clear-shell-buffer))
You can see that the types differ for the key binding. Right now, you're passing a symbol, when you want to be passing a character code.
I use tabbar in emacs, and bind following key.
(global-set-key (kbd "M-2") 'tabbar-forward-tab)
(global-set-key (kbd "M-1") 'tabbar-backward-tab)
But, those key-binds don't work in ansi-term mode. When I type 'M-1', it do not run tabbar-backward-tab, the key is captured by bash.
[xx#local ~]$
(arg: 1)
How to unbind "M-1" and "M-2" in Emacs ansi-term?
In term-char-mode M-<n> sequences are bound to term-send-raw (as are most sequences which a terminal would normally handle).
To unbind them, you can use:
(eval-after-load "term"
'(progn
(define-key term-raw-map (kbd "M-1") nil)
(define-key term-raw-map (kbd "M-2") nil)))
That will stop them from shadowing the global bindings.
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