bind <tab> to vimpulse-abbrev-expand-before in insert mode
Dear list, I'd like to be able to expand words and symbols by pressing the tab key in insert mode. I tried this method: (vimpulse-imap [(tab)] 'vimpulse-abbrev-expand-before) But when I press tab in insert mode after evaluating this nothing happens. I'm was running emacs -nw. The strange thing is that it does work when I run emacs with the graphical user interface (GNU Emacs 23.1.1 from Ubuntu lucid). Any ideas about what is going on here and how I can fix it? The other problem I'm having is that C-v does not activate block selection but inserts text. I'd be happy about any suggestion! Here's my init.el, not much going on there: (require 'slime) (setq inferior-lisp-program "/usr/bin/sbcl") (slime-setup) (load "~/.emacs.d/vimpulse.el") (setq-default fill-column 80) (mouse-wheel-mode t) (setq auto-fill-mode 1) (add-hook 'text-mode-hook 'turn-on-auto-fill) (xterm-mouse-mode t) ;; tab expands (vimpulse-imap [(tab)] 'vimpulse-abbrev-expand-before) ;; cycle buffer as in chrome (global-set-key (kbd "C-<next>") 'next-buffer) (global-set-key (kbd "C-<prior>") 'previous-buffer) Sorry, for these basic questions. I just switched to emacs after having used vim for 10 years. I'm a bit lost. Titus
Titus von der Malsburg <[email protected]> writes:
Dear list,
I'd like to be able to expand words and symbols by pressing the tab key in insert mode. I tried this method:
(vimpulse-imap [(tab)] 'vimpulse-abbrev-expand-before)
But when I press tab in insert mode after evaluating this nothing happens. I'm was running emacs -nw. The strange thing is that it does work when I run emacs with the graphical user interface (GNU Emacs 23.1.1 from Ubuntu lucid). Any ideas about what is going on here and how I can fix it?
You can see what is going on using `C-h c TAB', which will show you how Emacs understands what your Tab key sends. In all terminals I know, the Tab key sends ^I (i.e. ASCII 0x09), so you have to use something like "\C-i" for the event you want to bind (instead of [(tab)]).
The other problem I'm having is that C-v does not activate block selection but inserts text. I'd be happy about any suggestion!
No idea. `C-v' does the right thing for me both in the terminal and the GUI.
Here's my init.el, not much going on there:
Indeed, nothing there suggests `C-v' shouldn't work. Could the problem be that something other than Emacs catches the C-v event? Štěpán
Štěpán, many thanks for your response! On Fri, Dec 17, 2010 at 5:24 PM, Štěpán Němec <[email protected]> wrote:
You can see what is going on using `C-h c TAB', which will show you how Emacs understands what your Tab key sends.
C-h c TAB says: "TAB runs the command indent-for-tab-command" in emacs -nw I can say (global-set-key (kbd "TAB") 'vimpulse-abbrev-expand-before) and that works. But (vimpulse-imap (kbd "TAB") 'vimpulse-abbrev-expand-before) throws an error: Debugger entered--Lisp error: (args-out-of-range [] -1) aref([] -1) (eq (aref temp-sequence (1- ...)) t) (if (eq (aref temp-sequence ...) t) nil (setq temp-sequence (vconcat temp-seq$ (unless (eq (aref temp-sequence ...) t) (setq temp-sequence (vconcat temp-seq$ (cond ((featurep ...) (vimpulse-xemacs-def-binding keymap temp-sequence def c$ (let ((temp-sequence ...)) (unless define-func (setq define-func ...)) (cond $ vimpulse-default-binding((keymap (tab . vimpulse-abbrev-expand-before) (27 . $ (if (keymapp (lookup-key keymap key-vector)) (vimpulse-default-binding keymap$ (cond ((not def) (funcall define-func keymap key-vector def) (while ... ... .$ (let (key-vector temp-sequence current-binding previous-binding) (setq define$ vimpulse-make-careful-binding((keymap (tab . vimpulse-abbrev-expand-before) ($ (let ((viper-current-state new-viper-state)) (viper-normalize-minor-mode-map-$ (progn (viper-set-mode-vars-for new-viper-state) (let (...) (viper-normalize-$ (unwind-protect (progn (viper-set-mode-vars-for new-viper-state) (let ... ...$ (let ((new-viper-state state) (old-viper-state viper-current-state)) (unwind-$ (vimpulse-with-state state (vimpulse-make-careful-binding basic-map key def)) (if modes (dolist (mode modes) (if ... ... ...)) (vimpulse-with-state state ($ (let* ((map ...) (basic-map ...)) (if modes (dolist ... ...) (vimpulse-with-s$ vimpulse-map-state(insert-state " " vimpulse-abbrev-expand-before nil) vimpulse-imap(" " vimpulse-abbrev-expand-before) eval((vimpulse-imap (kbd "TAB") (quote vimpulse-abbrev-expand-before))) eval-last-sexp-1(nil) eval-last-sexp(nil) call-interactively(eval-last-sexp nil nil)
The other problem I'm having is that C-v does not activate block selection but inserts text. I'd be happy about any suggestion!
No idea. `C-v' does the right thing for me both in the terminal and the GUI.
C-h c C-v says "C-v runs the command cua-paste" although vimpulse.el (which executed without errors) contains: (define-key viper-vi-basic-map "\C-v" 'vimpulse-visual-toggle-block) Executing this line doesn't throw an error but also doesn't fix the problem. Titus
Titus von der Malsburg <[email protected]> writes:
I can say (global-set-key (kbd "TAB") 'vimpulse-abbrev-expand-before) and that works. But (vimpulse-imap (kbd "TAB") 'vimpulse-abbrev-expand-before) throws an error:
Debugger entered--Lisp error: (args-out-of-range [] -1)
[...] Hm. Looks like `vimpulse-imap' is doing something strange. I've been (almost) living in blissful ignorance of all things Vimpulse/Viper for some time, so instead of trying to figure out what it might be, here's another suggestion: I never use the `vimpulse-FOO' binding commands. What I would do to get what you want[1] is this: (define-key viper-insert-global-user-map "\C-i" 'vimpulse-abbrev-expand-before)
C-h c C-v says "C-v runs the command cua-paste" although vimpulse.el (which executed without errors) contains:
(define-key viper-vi-basic-map "\C-v" 'vimpulse-visual-toggle-block)
Executing this line doesn't throw an error but also doesn't fix the problem.
I see. So you're using CUA mode, right? I have no experience with it, but surely enough when I enable it, C-v breaks. Looks like the CUA mode bindings get even higher priority than the Viper ones. I have no idea why anybody would want to use the CUA bindings and Vim emulation at the same time. Are you sure you really want that? Some key map surgery would be necessary in that case, or perhaps CUA mode provides some way of customizing the binding setup? [1] Let me just note that I would never want anything like that myself ;-) -- Tab is too precious to hardcode it to something like `vimpulse-abbrev-expand-before'. Štěpán
On 2010-12-17 18:23, Titus von der Malsburg wrote:
(vimpulse-imap [(tab)] 'vimpulse-abbrev-expand-before)
But when I press tab in insert mode after evaluating this nothing happens. I'm was running emacs -nw. The strange thing is that it does work when I run emacs with the graphical user interface (GNU Emacs 23.1.1 from Ubuntu lucid).
Hi Titus, welcome to the list! In the terminal, C-i and <tab> are the same key, and any binding for the former has precedence over the latter -- regardless of keymap order. Since indent.el binds `indent-for-tab-command' to C-i, any binding you make for <tab> is overridden. This should work: (vimpulse-imap "\C-i" 'vimpulse-abbrev-expand-before)
The other problem I'm having is that C-v does not activate block selection but inserts text. I'd be happy about any suggestion!
C-h c C-v says "C-v runs the command cua-paste"
It seems that Cua-mode and Vimpulse fight over priority in ` `emulation-mode-map-alists'. This should be fixed in commit d21311d.
Here's my init.el, not much going on there:
(load "~/.emacs.d/vimpulse.el")
To get the latest bugfixes, you should upgrade to the Git version. In the ~/.emacs.d/ directory, do git clone git://gitorious.org/vimpulse/vimpulse.git (If Git isn't installed, do "sudo aptitude install git-all" first. Later on, you can grab updates by cd-ing into ~/.emacs.d/vimpulse/ and entering "git pull".) Also, add ~/.emacs.d/vimpulse/ to `load-path' by placing this line in your .emacs: (add-to-list 'load-path "~/.emacs.d/vimpulse") Then, for good measure, nail the old vimpulse.el to a frisbee and fling it over a rainbow. -- Vegard
On Sat, Dec 18, 2010 at 5:31 PM, Vegard Øye <[email protected]> wrote:
This should work:
(vimpulse-imap "\C-i" 'vimpulse-abbrev-expand-before)
Works indeed!
C-h c C-v says "C-v runs the command cua-paste"
It seems that Cua-mode and Vimpulse fight over priority in ` `emulation-mode-map-alists'. This should be fixed in commit d21311d.
I was using the version from EmacsWiki. Somewhere it was said that his is the latest but that's apparently not true. Many thanks for you support! I hope I will be able to do this favor to other people one this list once I'm more familiar with Emacs and Vimpulse. Titus
participants (3)
-
Titus von der Malsburg -
Vegard Øye -
Štěpán Němec