How can I unbind C-tab from jedi:complete? - emacs

With jedi-mode enabled, the C-tab is bound to jedi:complete.
How can I unbind it so that I can then bind it back to other-window?
I've tried:
(global-set-key (kbd "C-`") 'jedi:complete)
(global-set-key [C-tab] 'other-window)
(global-unset-key (kbd "<C-tab>"))
(defcustom jedi:key-complete (kbd "C-`")
"Keybind for command `jedi:complete'."
:group 'jedi)
None of them is getting me the desired results.

You can use:
(define-key jedi-mode-map (kbd "<C-tab>") nil)
None of the commands with global in them will work, since minor mode key bindings
have priority over global key bindings.

Related

How to disable local key binding in octave-mode?

Here is my key binding.
I want to set C-h to delete-backward-char in all modes, but in octave mode, when I pressed C-h, it shows C-h (Type ? for further options)-. So I add the last 3 lines in my .emacs file, but it doesn't work. C-h still works as the help function.
(global-set-key (kbd "C-?") 'help-command)
(global-set-key (kbd "C-h") 'delete-backward-char)
(define-key octave-mode-map (kbd "C-h") nil)
(define-key octave-mode-map (kbd "C-h a") nil)
(define-key octave-mode-map (kbd "C-h d") nil)
octave.el appears to set those bindings in three different keymaps:
octave-mode-map
inferior-octave-mode-map
octave-help-mode-map
You might also refer to Globally override key binding in Emacs

How to unbind "M-1" and "M-2" in Emacs ansi-term

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.

Use TAB for expand and C-i for indent-relative in emacs

how can i use TAB for dexpand and still have C-i for indent-relative?
Im trying:
(global-set-key (kbd "TAB") 'dabbrev-expand)
(global-set-key "\C-i" 'indent-relative)
but it wont work, because both TAB and C-i are used for dabbrex-expand.
If you never use emacs in terminal then you can do the following
First separate C-i and tab by doing
(define-key key-translation-map [tab] [?\t])
(define-key key-translation-map [?\C-\i] [(control i-key)])
(define-key function-key-map [tab] nil)
(define-key function-key-map [?\t] nil)
Then you can bind commands to the keys as usual
(global-set-key (kbd "TAB") 'dabbrev-expand)
(global-set-key (kbd "<C-i-key>") 'indent-relative)
Credits: I picked this up from this comment by Fuco.

How to keep traditional binding on M-x in emacs evil mode

I am trying to bind execute-extended-command to M-x in evil normal mode.
I currently have
;; evil mode
(require 'evil)
(evil-mode 1)
(define-key evil-normal-state-map "M-x" 'execute-extended-command)
in my .emacs file but the keybinding doesn't work. I tried replacing
"M-x"
with
"\M-x"
and
(kbd "M-x")
but neither works. I also tried adding it to evil.el and evil-maps.el.
I don't know what's wrong with your binding. You could use Emacs' own global-set-key for global stuff and if you plan something special for say, insert mode, you could override that later on, like this:
;; this works, just tested. My evil is 1.0-dev from github.
(global-set-key (kbd "M-x") 'smex)
(define-key evil-insert-state-map (kbd "M-x") 'execute-extended-command)
Use (kdb "") macro when you have modifier keys in your binding. But you can use the macro always, regardless of the content. These are for example usage. When in doubt, wrap the key in (kdb ).
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;;(global-set-key (kbd "M-x") 'execute-extended-command)
(define-key evil-normal-state-map ",d" 'volatile-kill-buffer)
(define-key evil-normal-state-map ",b" 'ido-switch-buffer)
(define-key evil-normal-state-map ",s" 'ispell-word)
(define-key evil-normal-state-map (kbd "C-x g") 'magit-status)
(define-key evil-insert-state-map (kbd "C-f") 'my-expand-file-name-at-point)
(define-key evil-insert-state-map (kbd "C-x C-l") 'my-expand-lines)
(define-key minibuffer-local-map (kbd "C-w") 'backward-kill-word)
(define-key evil-normal-state-map (kbd ",ff") 'ido-find-file)
After long research and with help from #emacs and #evil-mode channels on irc, it turned out that my emacs was broken. It was a snapshot from http://emacs.naquadah.org/ I tried all this on another emacs version (from debian jessies repos) and it worked ok.

Useful keyboard shortcuts and tips for ESS/R

I would like to ask regular ESS/R users what key bindings do they use frequently and tips on using ESS/R.
I have set several shortcuts in my .emacs file. The most useful are:
C-tab to switch between the R command line and the file (similar to josh answer, but much faster):
(global-set-key [C-tab] 'other-window)
Control and up/down arrow keys to search history with matching what you've already typed:
(define-key comint-mode-map [C-up] 'comint-previous-matching-input-from-input)
(define-key comint-mode-map [C-down] 'comint-next-matching-input-from-input)
Comment-uncomment a selected region with C-d or C-maj-d
(defun uncomment-region (beg end)
"Like `comment-region' invoked with a C-u prefix arg."
(interactive "r")
(comment-region beg end -1))
(define-key ess-mode-map (kbd "C-d") 'comment-region)
(define-key ess-mode-map (kbd "C-S-d") 'uncomment-region)
Also I've also enabled CUA mode (from options menu) and reconfigured quite a lot of shortcuts to require only two keystrokes (instead of four in standard mode):
;; Delete selection when pressing [delete] key
(delete-selection-mode t)
;; ESS Mode (.R file)
(define-key ess-mode-map "\C-l" 'ess-eval-line-and-step)
(define-key ess-mode-map "\C-p" 'ess-eval-function-or-paragraph-and-step)
(define-key ess-mode-map "\C-r" 'ess-eval-region)
;; iESS Mode (R console)
(define-key inferior-ess-mode-map "\C-u" 'comint-kill-input)
(define-key inferior-ess-mode-map "\C-w" 'backward-kill-word)
(define-key inferior-ess-mode-map "\C-a" 'comint-bol)
(define-key inferior-ess-mode-map [home] 'comint-bol)
;; Comint Mode (R console as well)
(define-key comint-mode-map "\C-e" 'comint-show-maximum-output)
(define-key comint-mode-map "\C-r" 'comint-show-output)
(define-key comint-mode-map "\C-o" 'comint-kill-output)
;; Search with C-f / C-F (control-maj-F for backware search)
(global-set-key "\C-f" 'isearch-forward)
(global-set-key (kbd "C-S-f") 'isearch-backward)
(define-key isearch-mode-map "\C-f" 'isearch-repeat-forward)
(define-key isearch-mode-map (kbd "C-S-f") 'isearch-repeat-backward)
;; Save with C-s / C-S
(global-set-key (kbd "C-s") 'save-buffer)
(global-set-key (kbd "C-S-s") 'write-file)
;; need to redefine them for isearch mode (don't know why)
(define-key isearch-mode-map (kbd "C-s") 'save-buffer)
(define-key isearch-mode-map (kbd "C-S-s") 'write-file)
;; Pause = dedicate window.
(defun toggle-current-window-dedication ()
(interactive)
(let* ((window (selected-window))
(dedicated (window-dedicated-p window)))
(set-window-dedicated-p window (not dedicated))
(message "Window %sdedicated to %s"
(if dedicated "no longer " "")
(buffer-name))))
(global-set-key [pause] 'toggle-current-window-dedication)
;; delete = delete
(global-set-key [delete] 'delete-char)
;; C-b = list buffers
(global-set-key (kbd "C-b") 'bs-show)
You will find many more useful shortcuts in ESS documentation.
C-c C-z ess-switch-to-end-of-ESS
is nice to jump from your source file that you are editing foo.R to the R console
I found this link to be extremely helpful. It provides elisp code to make Shift+Enter do many common tasks in a context dependent fashion.
http://kieranhealy.org/blog/archives/2009/10/12/make-shift-enter-do-a-lot-in-ess/
Great stuff, have been using it for ages. Unfortunately as of 15-11-2013 the uncomment key binding may not work due to EMACS changes (I think, at least it was working before I loaded the latest version). This is because the default uncomment function has 3 arguments but the one defined above has 2. The best way to fix this is to simply delete the uncomment function from the code and retain the keybinding, so it uses the default uncomment function. Or in other words just use this:
(define-key ess-mode-map (kbd "C-d") 'comment-region)
(define-key ess-mode-map (kbd "C-S-d") 'uncomment-region)
M-n and M-p in the ESS R console for next/previous command.