summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-03-19 10:52:28 -0600
committerTom Tromey <tom@tromey.com>2017-04-05 15:53:38 -0600
commit14659f69b0330187c7390418a0c7366083de9fd7 (patch)
tree1a2851c3a27d700dfb846ba6594b4c8d9caaf789 /lisp/subr.el
parent95aba610f1c1a40b0218b64b4d20ade7a6299208 (diff)
downloademacs-14659f69b0330187c7390418a0c7366083de9fd7.tar.gz
change viper to use derived-mode-p
* lisp/subr.el (provided-mode-derived-p): New function. (derived-mode-p): Use it. * lisp/emulation/viper.el (viper-mode): Use derived-mode-p. (this-major-mode-requires-vi-state): Use provided-mode-derived-p. (set-viper-state-in-major-mode): Use derived-mode-p.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el13
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 6b0403890cf..13567d8753e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1872,13 +1872,18 @@ Only affects hooks run in the current buffer."
;; PUBLIC: find if the current mode derives from another.
+(defun provided-mode-derived-p (mode &rest modes)
+ "Non-nil if MODE is derived from one of MODES.
+Uses the `derived-mode-parent' property of the symbol to trace backwards.
+If you just want to check `major-mode', use `derived-mode-p'."
+ (while (and (not (memq mode modes))
+ (setq mode (get mode 'derived-mode-parent))))
+ mode)
+
(defun derived-mode-p (&rest modes)
"Non-nil if the current major mode is derived from one of MODES.
Uses the `derived-mode-parent' property of the symbol to trace backwards."
- (let ((parent major-mode))
- (while (and (not (memq parent modes))
- (setq parent (get parent 'derived-mode-parent))))
- parent))
+ (apply #'provided-mode-derived-p major-mode modes))
;;;; Minor modes.