help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Delegating key actions


From: Pascal J. Bourguignon
Subject: Re: Delegating key actions
Date: Wed, 08 Dec 2010 15:08:34 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Karan Bathla <karan_goku@yahoo.com> writes:
> I would like to be able to use n,p,j,; as down,up,left,right
> respectively upon invocation of a function/minor-mode. Is there
> already some package that does something like this?

If it was hjkl, there would be viper-mode.


(defun* backward-line (&optional (x 1)) 
    (interactive)
    (forward-line (- x)))

(defun my-movement-keys (off)
   (interactive "P")
   (let ((bindings '(("n" forward-line)
                     ("p" backward-line)
                     ("j" backward-char)
                     (";" forward-char))))
     (loop for (key fun) in bindings
           do (local-set-key (read-kbd-macro key) 
                             (if off
                                 (function self-insert-command)
                                 fun)))))



> I want to delegate all keystrokes i.e. "C-n" and "M-n" would do
> "C-<down>" and "M-<down>" whatever function that keystroke corresponds
> to in the buffer. 

Have a look at keyboard-translate

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]