From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Junia Newsgroups: gmane.emacs.help Subject: Modal Keyboard Layout for EMACS Date: Thu, 22 Nov 2012 12:04:11 -0800 (PST) Message-ID: <5f81bc03-eafb-4330-96b1-383d17886c0c@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1353614717 26810 80.91.229.3 (22 Nov 2012 20:05:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Nov 2012 20:05:17 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 22 21:05:29 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tbd1b-0000ge-Oh for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Nov 2012 21:05:27 +0100 Original-Received: from localhost ([::1]:34680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tbd1N-0000hT-LA for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Nov 2012 15:05:13 -0500 Original-Received: by 10.224.183.16 with SMTP id ce16mr1451348qab.8.1353614651312; Thu, 22 Nov 2012 12:04:11 -0800 (PST) Original-Received: by 10.49.75.195 with SMTP id e3mr20457qew.24.1353614651286; Thu, 22 Nov 2012 12:04:11 -0800 (PST) Original-Path: usenet.stanford.edu!i9no9098277qap.0!news-out.google.com!gf5ni7335600qab.0!nntp.google.com!i9no9058462qap.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=200.131.199.27; posting-account=MljCOQoAAACk1WgCrNhKvnt6QY-OIvBm Original-NNTP-Posting-Host: 200.131.199.27 User-Agent: G2/1.0 Injection-Date: Thu, 22 Nov 2012 20:04:11 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:195523 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87847 Archived-At: I would like to write a small VI emulator for Emacs. By small, I mean reall= y small. The source code should not go beyond 100 lines. I also need a bett= er 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 substitu= tion is nice since people often uses ^[ to represent ESC. If the typist nee= ds 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 on the mode-line. The program below works fine with the [ square br= acket. The problem is that Dvo=C5=99=C3=A1k layout places the [ square bracket at = the upper right hand side corner of the keyboard. In fewer words, the posit= ion of the [ square bracket in Dvo=C5=99=C3=A1k layout is not easy to reach= . As a matter of fact, it is almost as bad as the Esc position in VIM. Ther= efore, I decided to use / slash instead of [ square bracket.=20 However, if I replace / slash for the square bracket, the program below doe= s 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 fa= ils to enter normal command mode. Can anybody tell me why? ;; Variables for possible keyboards (defvar default-keyboard=20 (copy-keymap (current-global-map))) (defvar emap=20 (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 "")) (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 "")) (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 " "=20 :keymap '(emap)=20 :group 'normal (if normal (ademacs) (puremacs) )) (define-globalized-minor-mode gnormal normal (lambda() (normal t))) =20 (provide 'normal)