From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Modal Keyboard Layout for EMACS Date: Thu, 22 Nov 2012 18:21:10 -0500 Message-ID: References: <5f81bc03-eafb-4330-96b1-383d17886c0c@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1353626499 23293 80.91.229.3 (22 Nov 2012 23:21:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Nov 2012 23:21:39 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 23 00:21:51 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 1Tbg5c-00019R-3y for geh-help-gnu-emacs@m.gmane.org; Fri, 23 Nov 2012 00:21:48 +0100 Original-Received: from localhost ([::1]:59727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tbg5R-0001Cl-A3 for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Nov 2012 18:21:37 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:47068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tbg5L-0001Cg-Vh for help-gnu-emacs@gnu.org; Thu, 22 Nov 2012 18:21:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tbg5K-0006IS-QU for help-gnu-emacs@gnu.org; Thu, 22 Nov 2012 18:21:31 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:58014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tbg5K-0006IL-KI for help-gnu-emacs@gnu.org; Thu, 22 Nov 2012 18:21:30 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Tbg5Q-0000yF-JG for help-gnu-emacs@gnu.org; Fri, 23 Nov 2012 00:21:36 +0100 Original-Received: from 69-165-164-58.dsl.teksavvy.com ([69.165.164.58]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 23 Nov 2012 00:21:36 +0100 Original-Received: from monnier by 69-165-164-58.dsl.teksavvy.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 23 Nov 2012 00:21:36 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 58 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 69-165-164-58.dsl.teksavvy.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:w2YGIY48MdhF+7cQrmu65JNEr1c= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:87853 Archived-At: > 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. The shortest code (a single line) might look something like: (viper-mode 1) But I guess that's not what you mean. > 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. I don't see any obvious reason why that would be the case. I suggest you look at what C-h k / says to help you figure out what's going on. I also appended my own take on the problem. Stefan (defvar mvi-command-mode-map (let ((map (make-sparse-keymap))) (define-key map "h" 'backward-char) (define-key map "j" 'next-line) (define-key map "k" 'previous-line) (define-key map "l" 'forward-char) (define-key map "i" 'mvi-insert-mode) (define-key map "/" 'mvi-doubled-self-insert-key) map)) (defun mvi-doubled-self-insert-key () (interactive) (call-interactively 'self-insert-command) (mvi-insert-mode 1)) (define-minor-mode mvi-command-mode "Minimalistic VI-like mode." :lighter " " :global t (if mvi-command-mode (mvi-normal-mode -1))) (defvar mvi-command-mode-map (let ((map (make-sparse-keymap))) (define-key map "\e" 'mvi-command-mode) (define-key map "/" 'mvi-command-mode) map)) (define-minor-mode mvi-insert-mode "Normal Emacs editing mode with escape to VI mode." :lighter " " :global t (if mvi-insert-mode (mvi-command-mode -1)))