[Top][All Lists]

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

Re: Modal Keyboard Layout for EMACS

From: sergiusruiz
Subject: Re: Modal Keyboard Layout for EMACS
Date: Fri, 23 Nov 2012 08:53:50 -0800 (PST)
User-agent: G2/1.0

Hi, Junia.

I think I fixed the bugs in Stefan's version of mvi-command-mode. Now, it is 
working flawlessly. Since Stefan wants to provide mvi-command-mode only, there 
is no need to make both commands global. By the way, I guess I know what Stefan 
wanted with mvi-normal-mode: He wanted the normal emacs mode back, what makes a 
lot of sense. I wrote a minor mvi-emacs-mode that exit from mvi-insert-mode, 
mvi-command-mode, and mvi-emacs-mode itself. You should save the file in 
mvi-command-mode.el and add the following line to your .emacs file:

(require 'mvi-command-mode)

To enter command mode, you should use

  M-x mvi-command-mode

from anywhere in emacs (since the command mode is global).

;; Small modifications in a script by Stenfan Monnier
(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) 

(defun mvi-doubled-self-insert-key () 
  (call-interactively 'self-insert-command) 
  (mvi-insert-mode 1)) 

(defvar mvi-insert-mode-map 
  (let ((map (make-sparse-keymap))) 
    (define-key map "\e" 'mvi-command-mode) 
    (define-key map "["  'mvi-command-mode) 

(define-minor-mode mvi-command-mode 
  "Minimalistic VI-like mode." 
  :lighter " <N>" 
  :global t 
  (if mvi-command-mode (mvi-insert-mode -1))) 

(define-minor-mode mvi-insert-mode 
  "Normal Emacs editing mode with escape to VI mode." 
  :lighter " <I>" 
  (if mvi-insert-mode (mvi-command-mode -1))) 

(define-minor-mode mvi-emacs-mode 
  "Normal Emacs editing mode with escape to VI mode." 
  :lighter "" 
  :global t
  (when mvi-emacs-mode 
    (mvi-emacs-mode -1)
    (mvi-insert-mode -1)
    (mvi-command-mode -1)))

(provide 'mvi-command-mode)

reply via email to

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