Function: viper-set-expert-level

viper-set-expert-level is an interactive and byte-compiled function defined in viper-cmd.el.gz.

Signature

(viper-set-expert-level &optional DONT-CHANGE-UNLESS)

Documentation

Set the expert level for a Viper user.

Can be called interactively to change (temporarily or permanently) the current expert level.

The optional argument DONT-CHANGE-UNLESS, if not nil, says that the level should not be changed, unless its current value is meaningless (i.e., not one of 1,2,3,4,5).

User level determines the setting of Viper variables that are most sensitive for VI-style look-and-feel.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emulation/viper-cmd.el.gz
(defun viper-set-expert-level (&optional dont-change-unless)
  "Set the expert level for a Viper user.
Can be called interactively to change (temporarily or permanently) the
current expert level.

The optional argument DONT-CHANGE-UNLESS, if not nil, says that
the level should not be changed, unless its current value is
meaningless (i.e., not one of 1,2,3,4,5).

User level determines the setting of Viper variables that are most
sensitive for VI-style look-and-feel."

  (interactive)

  (if (not (natnump viper-expert-level)) (setq viper-expert-level 0))

  (save-window-excursion
    (delete-other-windows)
    ;; if 0 < viper-expert-level < viper-max-expert-level
    ;;    & dont-change-unless = t -- use it; else ask
    (viper-ask-level dont-change-unless))

  (setq viper-always                            t
	viper-ex-style-motion                   t
	viper-ex-style-editing			t
	viper-want-ctl-h-help nil)

  (cond ((eq viper-expert-level 1) ; novice or beginner
	 (global-set-key   ; in emacs-state
	  viper-toggle-key
	  (if (viper-window-display-p) 'viper-iconify 'suspend-emacs))
	 (setq viper-no-multiple-ESC	       t
	       viper-re-search	               t
	       viper-vi-style-in-minibuffer    t
	       viper-search-wrap-around        t
	       viper-electric-mode	       nil
	       viper-want-emacs-keys-in-vi     nil
	       viper-want-emacs-keys-in-insert nil))

	((and (> viper-expert-level 1) (< viper-expert-level 5))
	 ;; intermediate to guru
	 (setq viper-no-multiple-ESC           (if (viper-window-display-p)
						   t 'twice)
	       viper-electric-mode	       t
	       viper-want-emacs-keys-in-vi     t
	       viper-want-emacs-keys-in-insert (> viper-expert-level 2))

	 (if (eq viper-expert-level 4)  ; respect user's ex-style motion
					; and viper-no-multiple-ESC
	     (progn
	       (setq-default
		viper-ex-style-editing
		(viper-standard-value 'viper-ex-style-editing)
		viper-ex-style-motion
		(viper-standard-value 'viper-ex-style-motion))
	       (setq viper-ex-style-motion
		     (viper-standard-value 'viper-ex-style-motion)
		     viper-ex-style-editing
		     (viper-standard-value 'viper-ex-style-editing)
		     viper-re-search
		     (viper-standard-value 'viper-re-search)
		     viper-no-multiple-ESC
		     (viper-standard-value 'viper-no-multiple-ESC)))))

	;; A wizard!!
	;; Ideally, if 5 is selected, a buffer should pop up to let the
	;; user toggle the values of variables.
	(t (setq-default viper-ex-style-editing
			 (viper-standard-value 'viper-ex-style-editing)
			 viper-ex-style-motion
			 (viper-standard-value 'viper-ex-style-motion))
	   (setq  viper-want-ctl-h-help
		  (viper-standard-value 'viper-want-ctl-h-help)
		  viper-always
		  (viper-standard-value 'viper-always)
		  viper-no-multiple-ESC
		  (viper-standard-value 'viper-no-multiple-ESC)
		  viper-ex-style-motion
		  (viper-standard-value 'viper-ex-style-motion)
		  viper-ex-style-editing
		  (viper-standard-value 'viper-ex-style-editing)
		  viper-re-search
		  (viper-standard-value 'viper-re-search)
		  viper-electric-mode
		  (viper-standard-value 'viper-electric-mode)
		  viper-want-emacs-keys-in-vi
		  (viper-standard-value 'viper-want-emacs-keys-in-vi)
		  viper-want-emacs-keys-in-insert
		  (viper-standard-value 'viper-want-emacs-keys-in-insert))))

  (viper-set-mode-vars-for viper-current-state)
  (if (or viper-always
	  (and (> viper-expert-level 0) (> 5 viper-expert-level)))
      (viper-set-hooks)))