Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
e36a387d
Commit
e36a387d
authored
Jun 18, 1997
by
Michael Kifer
Browse files
new version
parent
dd824ce4
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
430 additions
and
325 deletions
+430
-325
lisp/emulation/viper-cmd.el
lisp/emulation/viper-cmd.el
+20
-84
lisp/emulation/viper-ex.el
lisp/emulation/viper-ex.el
+62
-25
lisp/emulation/viper-init.el
lisp/emulation/viper-init.el
+1
-4
lisp/emulation/viper-keym.el
lisp/emulation/viper-keym.el
+2
-2
lisp/emulation/viper.el
lisp/emulation/viper.el
+345
-210
No files found.
lisp/emulation/viper-cmd.el
View file @
e36a387d
...
...
@@ -12,6 +12,7 @@
(
defvar
vip-minibuffer-insert-face
)
(
defvar
vip-minibuffer-vi-face
)
(
defvar
vip-minibuffer-emacs-face
)
(
defvar
viper-always
)
(
defvar
vip-mode-string
)
(
defvar
iso-accents-mode
)
(
defvar
zmacs-region-stays
)
...
...
@@ -412,80 +413,7 @@
;; Sets Viper mode string in global-mode-string
(
force-mode-line-update
))
;;;###autoload
(
defun
viper-mode
()
"Turn on Viper emulation of Vi."
(
interactive
)
(
if
(
not
noninteractive
)
(
progn
(
if
vip-first-time
; This check is important. Without it, startup and
(
progn
; expert-level msgs mix up when viper-mode recurses
(
setq
vip-first-time
nil
)
(
if
(
not
vip-inhibit-startup-message
)
(
save-window-excursion
(
setq
vip-inhibit-startup-message
t
)
(
delete-other-windows
)
(
switch-to-buffer
"Viper Startup Message"
)
(
erase-buffer
)
(
insert
(
substitute-command-keys
"Viper Is a Package for Emacs Rebels.
It is also a VI Plan for Emacs Rescue and a venomous VI PERil.
Technically speaking, Viper is a Vi emulation package for GNU Emacs 19 and
XEmacs 19. It supports virtually all of Vi and Ex functionality, extending
and improving upon much of it.
1. Viper supports Vi at several levels. Level 1 is the closest to Vi,
level 5 provides the most flexibility to depart from many Vi conventions.
You will be asked to specify your user level in a following screen.
If you select user level 1 then the keys ^X, ^C, ^Z, and ^G will behave
as in VI, to smooth transition to Viper for the beginners. However, to
use Emacs productively, you are advised to reach user level 3 or higher.
If your user level is 2 or higher, ^X and ^C will invoke Emacs
functions,as usual in Emacs; ^Z will toggle vi/emacs modes, and
^G will be the usual Emacs's keyboard-quit (something like ^C in VI).
2. Vi exit functions (e.g., :wq, ZZ) work on INDIVIDUAL files -- they
do not cause Emacs to quit, except at user level 1 (a novice).
3. ^X^C EXITS EMACS.
4. Viper supports multiple undo: `u' will undo. Typing `.' will repeat
undo. Another `u' changes direction.
6. Emacs Meta functions are invoked by typing `C-\\' or `\\ ESC'.
On a window system, the best way is to use the Meta-key.
7. Try \\[keyboard-quit] and \\[abort-recursive-edit] repeatedly,if
something funny happens. This would abort the current editing command.
You can get more information on Viper by:
a. Typing `:help' in Vi state
b. Printing Viper manual, found in ./etc/viper.dvi
c. Printing ViperCard, the Quick Reference, found in ./etc/viperCard.dvi
This startup message appears whenever you load Viper, unless you type `y' now."
))
(
goto-char
(
point-min
))
(
if
(
y-or-n-p
"Inhibit Viper startup message? "
)
(
vip-save-setting
'vip-inhibit-startup-message
"Viper startup message inhibited"
vip-custom-file-name
t
))
;;(kill-buffer (current-buffer))
(
message
"The last message is in buffer `Viper Startup Message'"
)
(
sit-for
4
)
))
(
vip-set-expert-level
'dont-change-unless
)))
(
vip-change-state-to-vi
))))
;;;###autoload
(
defalias
'vip-mode
'viper-mode
)
;; Switch from Insert state to Vi state.
(
defun
vip-exit-insert-state
()
...
...
@@ -4109,7 +4037,8 @@ One can use `` and '' to temporarily jump 1 step back."
(
if
vip-auto-indent
(
progn
(
setq
vip-cted
t
)
(
if
vip-electric-mode
(
if
(
and
vip-electric-mode
(
not
(
eq
major-mode
'fundamental-mode
)))
(
indent-according-to-mode
)
(
indent-to
vip-current-indent
))
))
...
...
@@ -4207,7 +4136,7 @@ One can use `` and '' to temporarily jump 1 step back."
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 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).
...
...
@@ -4224,7 +4153,7 @@ sensitive for VI-style look-and-feel."
;; & dont-change-unless = t -- use it; else ask
(
vip-ask-level
dont-change-unless
))
(
setq
vip-always
t
(
setq
vip
er
-always
t
vip-ex-style-motion
t
vip-ex-style-editing-in-insert
t
vip-want-ctl-h-help
nil
)
...
...
@@ -4237,16 +4166,19 @@ sensitive for VI-style look-and-feel."
vip-re-search
t
vip-vi-style-in-minibuffer
t
vip-search-wrap-around-t
t
vip-electric-mode
nil
vip-want-emacs-keys-in-vi
nil
vip-want-emacs-keys-in-insert
nil
))
((
and
(
>
vip-expert-level
1
)
(
<
vip-expert-level
5
))
;; intermediate to guru
(
setq
vip-no-multiple-ESC
(
if
(
vip-window-display-p
)
t
'twice
)
(
setq
vip-no-multiple-ESC
(
if
(
vip-window-display-p
)
t
'twice
)
vip-electric-mode
t
vip-want-emacs-keys-in-vi
t
vip-want-emacs-keys-in-insert
(
>
vip-expert-level
2
))
(
if
(
eq
vip-expert-level
4
)
; respect user's ex-style motion
s
(
if
(
eq
vip-expert-level
4
)
; respect user's ex-style motion
; and vip-no-multiple-ESC
(
progn
(
setq-default
vip-ex-style-editing-in-insert
...
...
@@ -4277,8 +4209,8 @@ sensitive for VI-style look-and-feel."
vip-saved-user-settings
)))
(
setq
vip-want-ctl-h-help
(
cdr
(
assoc
'vip-want-ctl-h-help
vip-saved-user-settings
))
vip-always
(
cdr
(
assoc
'vip-always
vip-saved-user-settings
))
vip
er
-always
(
cdr
(
assoc
'vip
er
-always
vip-saved-user-settings
))
vip-no-multiple-ESC
(
cdr
(
assoc
'vip-no-multiple-ESC
vip-saved-user-settings
))
vip-ex-style-motion
...
...
@@ -4288,6 +4220,9 @@ sensitive for VI-style look-and-feel."
vip-saved-user-settings
))
vip-re-search
(
cdr
(
assoc
'vip-re-search
vip-saved-user-settings
))
vip-electric-mode
(
cdr
(
assoc
'vip-electric-mode
vip-saved-user-settings
))
vip-want-emacs-keys-in-vi
(
cdr
(
assoc
'vip-want-emacs-keys-in-vi
vip-saved-user-settings
))
...
...
@@ -4295,7 +4230,7 @@ sensitive for VI-style look-and-feel."
(
cdr
(
assoc
'vip-want-emacs-keys-in-insert
vip-saved-user-settings
)))))
(
vip-set-mode-vars-for
vip-current-state
)
(
if
(
or
vip-always
(
if
(
or
vip
er
-always
(
and
(
>
vip-expert-level
0
)
(
>
5
vip-expert-level
)))
(
vip-set-hooks
)))
...
...
@@ -4374,9 +4309,9 @@ You can change it at any time by typing `M-x vip-set-expert-level RET'
4 -- GURU: Like 3, but user settings are respected for vip-no-multiple-ESC,
vip-re-search, vip-ex-style-motion, & vip-ex-style-editing-in-insert
variables. Adjust these settings to your taste.
5 -- WIZARD: Like 4, but user settings are also respected for vip-always,
vip-want-ctl-h-help, vip-want-emacs-keys-in-vi,
and
vip-want-emacs-keys-in-insert. Adjust these to your taste.
5 -- WIZARD: Like 4, but user settings are also respected for vip
er
-always,
vip-electric-mode,
vip-want-ctl-h-help, vip-want-emacs-keys-in-vi,
and
vip-want-emacs-keys-in-insert. Adjust these to your taste.
Please, specify your level now: "
)
...
...
@@ -4495,6 +4430,7 @@ Please, specify your level now: ")
'vip-want-emacs-keys-in-vi
'vip-keep-point-on-undo
'vip-no-multiple-ESC
'vip-electric-mode
'vip-ESC-key
'vip-want-ctl-h-help
'vip-ex-style-editing-in-insert
...
...
lisp/emulation/viper-ex.el
View file @
e36a387d
...
...
@@ -34,6 +34,7 @@
(
defvar
vip-expert-level
)
(
defvar
vip-custom-file-name
)
(
defvar
vip-case-fold-search
)
(
defvar
explicit-shell-file-name
)
;; loading happens only in non-interactive compilation
;; in order to spare non-viperized emacs from being viperized
...
...
@@ -76,15 +77,16 @@
;; A-list of Ex variables that can be set using the :set command.
(
defconst
ex-variable-alist
'
((
"wrapscan"
)
(
"ws"
)
(
"wrapmargin"
)
(
"wm"
)
(
"
global-
tabstop"
)
(
"
g
ts"
)
(
"tabstop"
)
(
"ts"
)
(
"tabstop
-global
"
)
(
"ts
-g
"
)
(
"tabstop"
)
(
"ts"
)
(
"showmatch"
)
(
"sm"
)
(
"shiftwidth"
)
(
"sw"
)
(
"shell"
)
(
"sh"
)
(
"readonly"
)
(
"ro"
)
(
"nowrapscan"
)
(
"nows"
)
(
"noshowmatch"
)
(
"nosm"
)
(
"noreadonly"
)
(
"noro"
)
(
"nomagic"
)
(
"noma"
)
(
"noignorecase"
)
(
"noic"
)
(
"
global-
noautoindent"
)
(
"
g
noai"
)
(
"noautoindent"
)
(
"noai"
)
(
"noautoindent
-global
"
)
(
"noai
-g
"
)
(
"noautoindent"
)
(
"noai"
)
(
"magic"
)
(
"ma"
)
(
"ignorecase"
)
(
"ic"
)
(
"global-autoindent"
)
(
"gai"
)
(
"autoindent"
)
(
"ai"
)
(
"autoindent-global"
)
(
"ai-g"
)
(
"autoindent"
)
(
"ai"
)
(
"all"
)
))
...
...
@@ -1564,7 +1566,7 @@ reversed.")
(
while
(
string-match
"^[ \\t\\n]*$"
(
setq
str
(
completing-read
":set "
ex-variable-alist
)))
(
message
":set <Variable> "
)
(
message
":set <Variable>
[= <Value>]
"
)
;; if there are unread events, don't wait
(
or
(
vip-set-unread-command-events
""
)
(
sit-for
2
))
)
; while
...
...
@@ -1582,12 +1584,15 @@ reversed.")
actual-lisp-cmd
lisp-cmd-del-pattern
val2
orig-var
)
(
setq
orig-var
var
)
(
cond
((
member
var
'
(
"ai"
"autoindent"
))
(
cond
((
string=
var
"all"
)
(
setq
ask-if-save
nil
set-cmd
nil
))
((
member
var
'
(
"ai"
"autoindent"
))
(
setq
var
"vip-auto-indent"
set-cmd
"setq"
ask-if-save
nil
val
"t"
))
((
member
var
'
(
"
g
ai"
"
global-
autoindent"
))
((
member
var
'
(
"ai
-g
"
"autoindent
-global
"
))
(
kill-local-variable
'vip-auto-indent
)
(
setq
var
"vip-auto-indent"
set-cmd
"setq-default"
...
...
@@ -1596,7 +1601,7 @@ reversed.")
(
setq
var
"vip-auto-indent"
ask-if-save
nil
val
"nil"
))
((
member
var
'
(
"
g
noai"
"
global-
noautoindent"
))
((
member
var
'
(
"noai
-g
"
"noautoindent
-global
"
))
(
kill-local-variable
'vip-auto-indent
)
(
setq
var
"vip-auto-indent"
set-cmd
"setq-default"
...
...
@@ -1610,7 +1615,7 @@ reversed.")
((
member
var
'
(
"ma"
"magic"
))
(
setq
var
"vip-re-search"
val
"t"
))
((
member
var
'
(
"noma"
"nomagic"
))
((
member
var
'
(
"noma"
"nomagic"
))
(
setq
var
"vip-re-search"
val
"nil"
))
((
member
var
'
(
"ro"
"readonly"
))
...
...
@@ -1631,7 +1636,7 @@ reversed.")
((
member
var
'
(
"nows"
"nowrapscan"
))
(
setq
var
"vip-search-wrap-around-t"
val
"nil"
)))
(
if
(
eq
val
0
)
; value must be set by the user
(
if
(
and
set-cmd
(
eq
val
0
)
)
; value must be set by the user
(
let
((
cursor-in-echo-area
t
))
(
message
":set %s = <Value>"
var
)
;; if there are unread events, don't wait
...
...
@@ -1643,7 +1648,7 @@ reversed.")
(
if
(
member
var
'
(
"sw"
"shiftwidth"
"ts"
"tabstop"
"
g
ts"
"
global-
tabstop"
"ts
-g
"
"tabstop
-global
"
"wm"
"wrapmargin"
))
(
condition-case
nil
(
or
(
numberp
(
setq
val2
(
car
(
read-from-string
val
))))
...
...
@@ -1659,7 +1664,7 @@ reversed.")
(
setq
var
"tab-width"
set-cmd
"setq"
ask-if-save
nil
))
((
member
var
'
(
"
g
ts"
"
global-
tabstop"
))
((
member
var
'
(
"ts
-g
"
"tabstop
-global
"
))
(
kill-local-variable
'tab-width
)
(
setq
var
"tab-width"
set-cmd
"setq-default"
))
...
...
@@ -1674,11 +1679,12 @@ reversed.")
val
(
format
"\"%s\""
val
)))))
(
ex-fixup-history
"set"
orig-var
))
(
setq
actual-lisp-cmd
(
format
"\n(%s %s %s) %s"
set-cmd
var
val
auto-cmd-label
))
(
setq
lisp-cmd-del-pattern
(
format
"^\n?[ \t]*([ \t]*%s[ \t]+%s[ \t].*)[ \t]*%s"
set-cmd
var
auto-cmd-label
))
(
if
set-cmd
(
setq
actual-lisp-cmd
(
format
"\n(%s %s %s) %s"
set-cmd
var
val
auto-cmd-label
)
lisp-cmd-del-pattern
(
format
"^\n?[ \t]*([ \t]*%s[ \t]+%s[ \t].*)[ \t]*%s"
set-cmd
var
auto-cmd-label
)))
(
if
(
and
ask-if-save
(
y-or-n-p
(
format
"Do you want to save this setting in %s "
...
...
@@ -1705,15 +1711,19 @@ reversed.")
))
))
(
message
"%s %s %s"
set-cmd
var
(
if
(
string-match
"^[ \t]*$"
val
)
(
format
"%S"
val
)
val
))
(
eval
(
car
(
read-from-string
actual-lisp-cmd
)))
(
if
(
string=
var
"fill-column"
)
(
if
(
>
val2
0
)
(
auto-fill-mode
1
)
(
auto-fill-mode
-1
)))
(
if
set-cmd
(
message
"%s %s %s"
set-cmd
var
(
if
(
string-match
"^[ \t]*$"
val
)
(
format
"%S"
val
)
val
)))
(
if
actual-lisp-cmd
(
eval
(
car
(
read-from-string
actual-lisp-cmd
))))
(
if
(
string=
var
"fill-column"
)
(
if
(
>
val2
0
)
(
auto-fill-mode
1
)
(
auto-fill-mode
-1
)))
(
if
(
string=
var
"all"
)
(
ex-show-vars
))
))
;; In inline args, skip regex-forw and (optionally) chars-back.
...
...
@@ -2077,5 +2087,32 @@ Please contact your system administrator. "
(
kill-buffer
" *vip-info*"
)))
))
;; display all variables set through :set
(
defun
ex-show-vars
()
(
with-output-to-temp-buffer
" *vip-info*"
(
princ
(
if
vip-auto-indent
"autoindent (local)\n"
"noautoindent (local)\n"
))
(
princ
(
if
(
default-value
'vip-auto-indent
)
"autoindent (global) \n"
"noautoindent (global) \n"
))
(
princ
(
if
vip-case-fold-search
"ignorecase\n"
"noignorecase\n"
))
(
princ
(
if
vip-re-search
"magic\n"
"nomagic\n"
))
(
princ
(
if
buffer-read-only
"readonly\n"
"noreadonly\n"
))
(
princ
(
if
blink-matching-paren
"showmatch\n"
"noshowmatch\n"
))
(
princ
(
if
vip-search-wrap-around-t
"wrapscan\n"
"nowrapscan\n"
))
(
princ
(
format
"shiftwidth \t\t= %S\n"
vip-shift-width
))
(
princ
(
format
"tabstop (local) \t= %S\n"
tab-width
))
(
princ
(
format
"tabstop (global) \t= %S\n"
(
default-value
'tab-width
)))
(
princ
(
format
"wrapmargin (local) \t= %S\n"
(
-
(
window-width
)
fill-column
)))
(
princ
(
format
"wrapmargin (global) \t= %S\n"
(
-
(
window-width
)
(
default-value
'fill-column
))))
(
princ
(
format
"shell \t\t\t= %S\n"
(
if
(
boundp
'explicit-shell-file-name
)
explicit-shell-file-name
'none
)))
))
;;; viper-ex.el ends here
lisp/emulation/viper-init.el
View file @
e36a387d
...
...
@@ -599,10 +599,7 @@ These buffers can be cycled through via :R and :P commands.")
(
defvar
vip-inhibit-startup-message
nil
"Whether Viper startup message should be inhibited."
)
(
defvar
vip-always
t
"t means, arrange that vi-state will be a default."
)
(
defvar
vip-custom-file-name
(
vip-convert-standard-file-name
"~/.vip"
)
(
defvar
vip-custom-file-name
(
vip-convert-standard-file-name
"~/.viper"
)
"Viper customisation file.
This variable must be set _before_ loading Viper."
)
...
...
lisp/emulation/viper-keym.el
View file @
e36a387d
...
...
@@ -24,7 +24,7 @@
(
provide
'viper-keym
)
;; compiler pacifier
(
defvar
vip-always
)
(
defvar
vip
er
-always
)
(
defvar
vip-current-state
)
(
defvar
vip-mode-string
)
(
defvar
vip-expert-level
)
...
...
@@ -586,7 +586,7 @@ Arguments: (major-mode vip-state keymap)"
(
princ
(
format
"\nvip-expert-level %S\n"
vip-expert-level
))
(
princ
(
format
"vip-no-multiple-ESC %S\n"
vip-no-multiple-ESC
))
(
princ
(
format
"vip-always %S\n"
vip-always
))
(
princ
(
format
"vip
er
-always %S\n"
vip
er
-always
))
(
princ
(
format
"vip-ex-style-motion %S\n"
vip-ex-style-motion
))
(
princ
(
format
"vip-ex-style-editing-in-insert %S\n"
...
...
lisp/emulation/viper.el
View file @
e36a387d
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment