diff options
Diffstat (limited to 'lisp/emulation/viper-util.el')
-rw-r--r-- | lisp/emulation/viper-util.el | 86 |
1 files changed, 19 insertions, 67 deletions
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el index 51f7406ad26..71043b189db 100644 --- a/lisp/emulation/viper-util.el +++ b/lisp/emulation/viper-util.el @@ -25,12 +25,10 @@ ;;; Code: (require 'seq) +(require 'cl-lib) ;; Compiler pacifier (defvar viper-minibuffer-current-face) -(defvar viper-minibuffer-insert-face) -(defvar viper-minibuffer-vi-face) -(defvar viper-minibuffer-emacs-face) (defvar viper-replace-overlay-face) (defvar viper-fast-keyseq-timeout) (defvar ex-unix-type-shell) @@ -63,22 +61,8 @@ (define-obsolete-function-alias 'viper-iconify #'iconify-or-deiconify-frame "27.1") - -;; CHAR is supposed to be a char or an integer (positive or negative) -;; LIST is a list of chars, nil, and negative numbers -;; Check if CHAR is a member by trying to convert in characters, if necessary. -;; Introduced for compatibility with XEmacs, where integers are not the same as -;; chars. -(defun viper-memq-char (char list) - (cond ((and (integerp char) (>= char 0)) - (memq char list)) - ((memq char list)))) - -;; Check if char-or-int and char are the same as characters -(defun viper-char-equal (char-or-int char) - (cond ((and (integerp char-or-int) (>= char-or-int 0)) - (= char-or-int char)) - ((eq char-or-int char)))) +(define-obsolete-function-alias 'viper-memq-char #'memq "29.1") +(define-obsolete-function-alias 'viper-char-equal #'eq "29.1") ;; Like =, but accommodates null and also is t for eq-objects (defun viper= (char char1) @@ -87,8 +71,7 @@ (= char char1)) (t nil))) -(defsubst viper-color-display-p () - (x-display-color-p)) +(define-obsolete-function-alias 'viper-color-display-p #'x-display-color-p "29.1") (defun viper-get-cursor-color (&optional _frame) (cdr (assoc 'cursor-color (frame-parameters)))) @@ -109,7 +92,7 @@ Otherwise return the normal value." ;; cursor colors (defun viper-change-cursor-color (new-color &optional frame) - (if (and (viper-window-display-p) (viper-color-display-p) + (if (and (viper-window-display-p) (x-display-color-p) (stringp new-color) (x-color-defined-p new-color) (not (string= new-color (viper-get-cursor-color)))) (modify-frame-parameters @@ -141,7 +124,7 @@ Otherwise return the normal value." ;; By default, saves current frame cursor color before changing viper state (defun viper-save-cursor-color (before-which-mode) - (if (and (viper-window-display-p) (viper-color-display-p)) + (if (and (viper-window-display-p) (x-display-color-p)) (let ((color (viper-get-cursor-color))) (if (and (stringp color) (x-color-defined-p color) ;; there is something fishy in that the color is not saved if @@ -927,7 +910,7 @@ Otherwise return the normal value." (t key))) ((listp key) - (setq modifiers (viper-subseq key 0 (1- (length key))) + (setq modifiers (cl-subseq key 0 (1- (length key))) base-key (viper-seq-last-elt key) base-key-name (symbol-name base-key) char-p (= (length base-key-name) 1)) @@ -1091,14 +1074,11 @@ In addition, the symbol `_' may be considered alphanumeric if `viper-syntax-preference' is `strict-vi' or `reformed-vi'.") (defconst viper-strict-ALPHA-chars "a-zA-Z0-9_" - "Regexp matching the set of alphanumeric characters acceptable to strict -Vi.") + "Regexp matching the set of alphanumeric characters acceptable to strict Vi.") (defconst viper-strict-SEP-chars " \t\n" - "Regexp matching the set of alphanumeric characters acceptable to strict -Vi.") + "Regexp matching the set of alphanumeric characters acceptable to strict Vi.") (defconst viper-strict-SEP-chars-sans-newline " \t" - "Regexp matching the set of alphanumeric characters acceptable to strict -Vi.") + "Regexp matching the set of alphanumeric characters acceptable to strict Vi.") (defconst viper-SEP-char-class " -" "String of syntax classes for Vi separators. @@ -1185,25 +1165,23 @@ This option is appropriate if you like Emacs-style words." (looking-at (concat "[" viper-strict-ALPHA-chars addl-chars "]")) (or ;; or one of the additional chars being asked to include - (viper-memq-char char (viper-string-to-list addl-chars)) + (memq char (viper-string-to-list addl-chars)) (and ;; not one of the excluded word chars (note: ;; viper-non-word-characters is a list) - (not (viper-memq-char char viper-non-word-characters)) + (not (memq char viper-non-word-characters)) ;; char of the Viper-word syntax class - (viper-memq-char (char-syntax char) - (viper-string-to-list viper-ALPHA-char-class)))))) - )) + (memq (char-syntax char) + (viper-string-to-list viper-ALPHA-char-class)))))))) (defun viper-looking-at-separator () (let ((char (char-after (point)))) (if char (if (eq viper-syntax-preference 'strict-vi) - (viper-memq-char char (viper-string-to-list viper-strict-SEP-chars)) + (memq char (viper-string-to-list viper-strict-SEP-chars)) (or (eq char ?\n) ; RET is always a separator in Vi - (viper-memq-char (char-syntax char) - (viper-string-to-list viper-SEP-char-class))))) - )) + (memq (char-syntax char) + (viper-string-to-list viper-SEP-char-class))))))) (defsubst viper-looking-at-alphasep (&optional addl-chars) (or (viper-looking-at-separator) (viper-looking-at-alpha addl-chars))) @@ -1329,8 +1307,7 @@ This option is appropriate if you like Emacs-style words." ;; of the excluded characters (if (and (eq syntax-of-char-looked-at ?w) (not negated-syntax)) - (not (viper-memq-char - char-looked-at viper-non-word-characters)) + (not (memq char-looked-at viper-non-word-characters)) t)) (funcall skip-syntax-func 1) 0) @@ -1345,32 +1322,7 @@ This option is appropriate if you like Emacs-style words." (not (eq (get-char-property (point) 'field) (get-char-property (1- (point)) 'field))))) - -;; this is copied from cl-extra.el -;; Return the subsequence of SEQ from START to END. -;; If END is omitted, it defaults to the length of the sequence. -;; If START or END is negative, it counts from the end. -(defun viper-subseq (seq start &optional end) - (if (stringp seq) (substring seq start end) - (let (len) - (and end (< end 0) (setq end (+ end (setq len (length seq))))) - (if (< start 0) (setq start (+ start (or len (setq len (length seq)))))) - (cond ((listp seq) - (if (> start 0) (setq seq (nthcdr start seq))) - (if end - (let ((res nil)) - (while (>= (setq end (1- end)) start) - (push (pop seq) res)) - (nreverse res)) - (copy-sequence seq))) - (t - (or end (setq end (or len (length seq)))) - (let ((res (make-vector (max (- end start) 0) nil)) - (i 0)) - (while (< start end) - (aset res i (aref seq start)) - (setq i (1+ i) start (1+ start))) - res)))))) +(define-obsolete-function-alias 'viper-subseq #'cl-subseq "28.1") (provide 'viper-util) ;;; viper-util.el ends here |