Remove some compat code from viper*.el

* lisp/emulation/viper.el (viper-go-away, viper-set-hooks)
(viper-non-hook-settings, viper-mode):
* lisp/emulation/viper-cmd.el (viper-normalize-minor-mode-map-alist)
(viper-harness-minor-mode): Remove a bunch of checks to do (or
not do) things based on whether add-to-ordered-list is fbound and
emulation-mode-map-alists is bound, because in Emacs now, these
are always true.
This commit is contained in:
Lars Ingebrigtsen 2020-08-12 18:52:53 +02:00
parent 1dfb170476
commit 9a929de29b
2 changed files with 12 additions and 53 deletions

View file

@ -466,24 +466,7 @@
(assoc major-mode viper-emacs-state-modifier-alist)))
(cdr
(assoc major-mode viper-emacs-state-modifier-alist))
viper-empty-keymap))
))
;; This var is not local in Emacs, so we make it local. It must be local
;; because although the stack of minor modes can be the same for all buffers,
;; the associated *keymaps* can be different. In Viper,
;; viper-vi-local-user-map, viper-insert-local-user-map, and others can have
;; different keymaps for different buffers. Also, the keymaps associated
;; with viper-vi/insert-state-modifier-minor-mode can be different.
;; ***This is needed only in case emulation-mode-map-alists is not defined.
;; In emacs with emulation-mode-map-alists, nothing needs to be done
(unless
(and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
(set (make-local-variable 'minor-mode-map-alist)
(viper-append-filter-alist
(append viper--intercept-key-maps viper--key-maps)
minor-mode-map-alist)))
)
viper-empty-keymap)))))
@ -893,16 +876,7 @@ LOAD-FILE is the name of the file where the specific minor mode is defined.
Suffixes such as .el or .elc should be stripped."
(interactive "sEnter name of the load file: ")
(eval-after-load load-file '(viper-normalize-minor-mode-map-alist))
;; Change the default for minor-mode-map-alist each time a harnessed minor
;; mode adds its own keymap to the a-list.
(unless
(and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
(eval-after-load
load-file '(setq-default minor-mode-map-alist minor-mode-map-alist)))
)
(eval-after-load load-file '(viper-normalize-minor-mode-map-alist)))
(defun viper-ESC (arg)

View file

@ -695,9 +695,6 @@ It also can't undo some Viper settings."
'mark-even-if-inactive viper-saved-non-viper-variables))
;; Ideally, we would like to be able to de-localize local variables
(unless
(and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
(viper-delocalize-var 'minor-mode-map-alist))
(viper-delocalize-var 'require-final-newline)
;; deactivate all advices done by Viper.
@ -705,11 +702,9 @@ It also can't undo some Viper settings."
(setq viper-mode nil)
(when (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
(setq emulation-mode-map-alists
(delq 'viper--intercept-key-maps
(delq 'viper--key-maps emulation-mode-map-alists))
))
(setq emulation-mode-map-alists
(delq 'viper--intercept-key-maps
(delq 'viper--key-maps emulation-mode-map-alists)))
(viper-delocalize-var 'viper-vi-minibuffer-minor-mode)
(viper-delocalize-var 'viper-insert-minibuffer-minor-mode)
@ -943,13 +938,11 @@ Two differences:
(setq viper-vi-state-cursor-color color-name)))
(when (and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
;; needs to be as early as possible
(add-to-ordered-list
'emulation-mode-map-alists 'viper--intercept-key-maps 100)
;; needs to be after cua-mode
(add-to-ordered-list 'emulation-mode-map-alists 'viper--key-maps 500)
)
;; needs to be as early as possible
(add-to-ordered-list
'emulation-mode-map-alists 'viper--intercept-key-maps 100)
;; needs to be after cua-mode
(add-to-ordered-list 'emulation-mode-map-alists 'viper--key-maps 500)
;; Emacs shell, ange-ftp, and comint-based modes
(add-hook 'comint-mode-hook #'viper-comint-mode-hook) ; comint
@ -1062,10 +1055,7 @@ This may be needed if the previous `:map' command terminated abnormally."
(viper--advice-add 'add-minor-mode :after
(lambda (&rest _)
"Run viper-normalize-minor-mode-map-alist after adding a minor mode."
(viper-normalize-minor-mode-map-alist)
(unless
(and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
(setq-default minor-mode-map-alist minor-mode-map-alist))))
(viper-normalize-minor-mode-map-alist)))
;; catch frame switching event
(if (viper-window-display-p)
@ -1253,12 +1243,7 @@ These two lines must come in the order given."))
;; Without setting the default, new buffers that come up in emacs mode have
;; minor-mode-map-alist = nil, unless we call viper-change-state-*
(when (eq viper-current-state 'emacs-state)
(viper-change-state-to-emacs)
(unless
(and (fboundp 'add-to-ordered-list)
(boundp 'emulation-mode-map-alists))
(setq-default minor-mode-map-alist minor-mode-map-alist))
)
(viper-change-state-to-emacs))
(if (this-major-mode-requires-vi-state major-mode)
(viper-mode))