unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Delegating key actions
@ 2010-05-15 21:15 Karan Bathla
  0 siblings, 0 replies; 2+ messages in thread
From: Karan Bathla @ 2010-05-15 21:15 UTC (permalink / raw)
  To: help-gnu-emacs

Hi

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

Thanks
Karan




      



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Delegating key actions
       [not found] <mailman.2.1273975665.25571.help-gnu-emacs@gnu.org>
@ 2010-05-16 21:49 ` Pascal J. Bourguignon
  0 siblings, 0 replies; 2+ messages in thread
From: Pascal J. Bourguignon @ 2010-05-16 21:49 UTC (permalink / raw)
  To: help-gnu-emacs

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/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-16 21:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.2.1273975665.25571.help-gnu-emacs@gnu.org>
2010-05-16 21:49 ` Delegating key actions Pascal J. Bourguignon
2010-05-15 21:15 Karan Bathla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).