What private changes to Viper and/or Vimpulse do you have in your .emacs file?

Štěpán Němec stepnem at gmail.com
Tue Jul 20 10:45:50 CEST 2010


Jason Spiro <jasonspiro4+gmane at gmail.com> writes:

> Hi all,
>
> I am curious: what private changes to Viper and/or Vimpulse do you have in
> your
> .emacs file?  You can tell us:
>
> 1.  an English-language summary of what your code does, or
> 2.  the code itself, or
> 3.  both.

Hi Jason,
nice idea; I'd definitely prefer the 2. though, i.e. let the Elisp speak
for itself. Furthermore, contents of the Viper init file, which is
different from .emacs/init.el is relevant, too. Also, why didn't *you*
paste your customisations here to begin with?

I have no .emacs; I use init.el which loads some other init files. Here
are the Viper/Vimpulse-related parts with some explanations:

init.el:
--------
(setq viper-custom-file-name "~/.emacs.d/init/viper")
(load "~/.emacs.d/init/init-vimpulse.el")

;; Don't mess with my minibuffer, bad, bad Viper!
(remove-hook 'minibuffer-setup-hook 'viper-minibuffer-setup-sentinel)

;; Don't mess with my Esc key in Vi state, bad, bad Viper!
(define-key viper-vi-intercept-map viper-ESC-key nil) ; viper-intercept-ESC-key

;; Don't mess with my input methods, bad, bad Viper!
(defalias 'viper-set-input-method 'ignore)
(ad-deactivate 'activate-input-method)
(ad-deactivate 'inactivate-input-method)
(ad-deactivate 'toggle-input-method)

init-vimpulse.el:
-----------------
(setq vimpulse-want-vi-keys-in-apropos nil)
(setq vimpulse-want-vi-keys-in-buffmenu nil)
(setq vimpulse-want-vi-keys-in-dired nil)
(setq vimpulse-want-vi-keys-in-help nil)
(setq vimpulse-want-vi-keys-in-Info nil)
(setq vimpulse-want-change-undo nil)

(add-to-list 'load-path "~/Hacking/emacs/vimpulse/vimpulse")
(require 'vimpulse)

;; redefine (equiv. of the famous `map Y y$')
(defun viper-yank-line (arg)
  "Delete to the end of line."
  (interactive "P")
  (viper-goto-eol (cons arg ?y)))

(vimpulse-define-text-object vimpulse-sexp (arg)
  "Select a S-expression."
  :keys '("ae" "ie")
  (vimpulse-inner-object-range
   arg
   'backward-sexp
   'forward-sexp))

;; http://www.emacswiki.org/emacs/GotoChg
(define-key viper-vi-basic-map "g;" 'goto-last-change)
(define-key viper-vi-basic-map "g," 'goto-last-change-reverse)

(define-key viper-vi-basic-map "ga" 'what-cursor-position)
(define-key viper-vi-basic-map "go" 'goto-char)

viper:
------
(setq-default viper-auto-indent t)

(setq viper-change-notification-threshold 0
      viper-expert-level 5
      viper-inhibit-startup-message t
      viper-vi-style-in-minibuffer nil
      viper-want-ctl-h-help t)

(setq-default viper-ex-style-editing nil)
(setq-default viper-ex-style-motion nil)
(setq-default viper-delete-backwards-in-replace t)

;; `.mad-to-list' is defined in yet another file like this:
;; (defun .mad-to-list (lvar els &optional append cmpfun)
;;   "Add elements contained in the list ELS to LVAR.
;; In short, multi- `add-to-list', which also see for explanation of
;; the optional arguments.
;; Returns the new value of LVAR."
;;   (dolist (el els (symbol-value lvar)) (add-to-list lvar el append cmpfun)))
(.mad-to-list 'viper-emacs-state-mode-list '(desktop-menu-mode etags-select-mode))
 
(define-key viper-vi-basic-map "\C-c/" nil)    ; viper-toggle-search-style
(define-key viper-vi-basic-map "\C-\\" nil)    ; viper-alternate-Meta-key
(define-key viper-insert-basic-map "\C-\\" nil)
(define-key viper-vi-basic-map "\C-^" nil)     ; (viper-ex "e#")
(define-key viper-insert-basic-map "\C-d" nil) ; viper-backward-indent
(define-key viper-insert-basic-map "\C-t" nil) ; viper-forward-indent
(define-key viper-insert-basic-map "\C-w" nil) ; viper-delete-backward-word
(define-key viper-insert-basic-map (kbd "<delete>") nil)

;; see `viper-adjust-keys-for'; mind boggles...
(defadvice viper-adjust-keys-for (after fuck-viper activate)
  (define-key viper-insert-basic-map "\C-m" nil) ; viper-autoindent
  (define-key viper-insert-basic-map "\C-j" nil)
  (define-key viper-insert-basic-map (kbd "<backspace>") nil) ; viper-del-backward-char-in-insert
  (define-key viper-insert-basic-map "" nil))

(define-key viper-vi-global-user-map " " 'viper-scroll-screen)
(define-key viper-vi-global-user-map (kbd "<backspace>") 'viper-scroll-screen-back)
(define-key viper-vi-global-user-map (kbd "DEL") 'viper-scroll-screen-back)

;; `copy-from-above-command' is defined in misc.el and comes with Emacs;
;; `copy-from-below-command' is just an adjustment of the above, left as an
;; exercise for the reader
(define-key viper-insert-global-user-map (kbd "C-y") (lambda (&optional arg) (interactive "p") (copy-from-above-command arg)))
(define-key viper-insert-global-user-map (kbd "C-e") (lambda (&optional arg) (interactive "p") (copy-from-below-command arg)))

HOWGH. Looking forward to seeing yours!

Štěpán



More information about the implementations-list mailing list