all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Modal Keyboard Layout for EMACS
@ 2012-11-22 20:04 Junia
  2012-11-22 20:52 ` Junia
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Junia @ 2012-11-22 20:04 UTC (permalink / raw)
  To: help-gnu-emacs

I would like to write a small VI emulator for Emacs. By small, I mean really small. The source code should not go beyond 100 lines. I also need a better keyboard map than one can find in VIM. The ESC key should be replaced by a key that a typist can easily reach with the right hand.

My first idea was to substitute the [ square bracket for ESC. This substitution is nice since people often uses ^[ to represent ESC. If the typist needs a [ square bracket, she can press the [ square bracket key twice. If she presses the [ key once, Emacs enters the normal command mode, that appears as <N> on the mode-line. The program below works fine with the [ square bracket.

The problem is that Dvořák layout places the [ square bracket at the upper right hand side corner of the keyboard. In fewer words, the position of the [ square bracket in Dvořák layout is not easy to reach. As a matter of fact, it is almost as bad as the Esc position in VIM. Therefore, I decided to use / slash instead of [ square bracket. 

However, if I replace / slash for the square bracket, the program below does not work correctly. I mean, it ignores my remap of the / slash key. If I press slash after replacing / slash for the occurrences of [ the program fails to enter normal command mode.

Can anybody tell me why?



;; Variables for possible keyboards
(defvar default-keyboard 
   (copy-keymap (current-global-map)))

(defvar emap 
    (copy-keymap (current-global-map)))
(defun tovim()  (interactive)
    (setq minor-mode-alist
      (assq-delete-all 'normal minor-mode-alist))
    (add-to-list 'minor-mode-alist '(normal "<N>"))
    (force-mode-line-update)
    (use-global-map vmap))
(define-key emap "[" 'tovim)

(defvar vmap
    (copy-keymap (current-global-map)))
(define-key vmap (kbd "h") 'backward-char)
(define-key vmap (kbd "j") 'next-line)
(define-key vmap (kbd "k") 'previous-line)
(define-key vmap (kbd "l") 'forward-char)
(defun ademacs()
   (setq minor-mode-alist
    (assq-delete-all 'normal minor-mode-alist))
  (add-to-list 'minor-mode-alist '(normal "<I>"))
   (force-mode-line-update)
  (use-global-map emap) )
(defun toemacs()  (interactive)
  (ademacs))
(define-key vmap (kbd "i") 'toemacs)
(defun slash()(interactive)
   (ademacs) ; type twice for [
   (insert "["))
(define-key vmap (kbd "[") 'slash)

(defun puremacs()
   (use-global-map default-keyboard))

(define-minor-mode normal
       :init-value nil
       :lighter " <N> " 
       :keymap '(emap) 
      :group 'normal
   (if   normal   (ademacs) (puremacs) ))

(define-globalized-minor-mode gnormal normal
    (lambda()  (normal t)))   

(provide 'normal)


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

end of thread, other threads:[~2012-11-24  3:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-22 20:04 Modal Keyboard Layout for EMACS Junia
2012-11-22 20:52 ` Junia
2012-11-22 23:21 ` Stefan Monnier
     [not found] ` <mailman.13585.1353626494.855.help-gnu-emacs@gnu.org>
2012-11-23 12:55   ` sergiusruiz
2012-11-23 16:53 ` sergiusruiz
2012-11-23 18:55   ` Stefan Monnier
     [not found]   ` <mailman.13650.1353696942.855.help-gnu-emacs@gnu.org>
2012-11-24  0:00     ` rosangelamesil
2012-11-24  1:56 ` rosangelamesil
2012-11-24  3:16 ` rosangelamesil

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.