viper-insert-point
(>= (point) viper-insert-point))
(setq viper-last-posn-while-in-insert-state (point-marker)))
- (or (viper-overlay-p viper-replace-overlay)
+ (or (overlayp viper-replace-overlay)
(progn
(viper-set-replace-overlay (point-min) (point-min))
(viper-hide-replace-overlay)))
(if (and viper-first-time (not (viper-is-in-minibuffer)))
(viper-mode)
(if overwrite-mode (overwrite-mode -1))
- (or (viper-overlay-p viper-replace-overlay)
+ (or (overlayp viper-replace-overlay)
(viper-set-replace-overlay (point-min) (point-min)))
(viper-hide-replace-overlay)
;; Expand abbrevs iff the previous character has word syntax.
(interactive)
(viper-change-state 'insert-state)
- (or (viper-overlay-p viper-replace-overlay)
+ (or (overlayp viper-replace-overlay)
(viper-set-replace-overlay (point-min) (point-min)))
(viper-hide-replace-overlay)
(defun viper-change-state-to-emacs (&rest _)
"Change Viper state to Emacs."
(interactive)
- (or (viper-overlay-p viper-replace-overlay)
+ (or (overlayp viper-replace-overlay)
(viper-set-replace-overlay (point-min) (point-min)))
(viper-hide-replace-overlay)
;; this-command, last-command-char, last-command-event
(setq this-command com)
;; Emacs represents key sequences as sequences (str or vec)
- (setq last-command-event
- (viper-copy-event (viper-seq-last-elt key)))
+ (setq last-command-event (viper-seq-last-elt key))
(if (commandp com)
;; pretend that current state is the state we escaped to
(if (memq ch '(?\C-v ?\C-q))
(setq ch (aref (read-key-sequence nil) 0)))
(insert ch)))
- (setq last-command-event (viper-copy-event ch))
+ (setq last-command-event ch)
) ; let
(error nil)
) ; condition-case
(interactive)
(if (and (< viper-expert-level 2) (equal viper-toggle-key "\C-z"))
(if (viper-window-display-p)
- (viper-iconify)
+ (iconify-or-deiconify-frame)
(suspend-emacs))
(viper-change-state-to-emacs)))
(let ((viper-intermediate-command 'viper-digit-argument)
value func)
;; read while number
- (while (and (viper-characterp event-char)
+ (while (and (characterp event-char)
(>= event-char ?0) (<= event-char ?9))
(setq value (+ (* (if (integerp value) value 0) 10) (- event-char ?0)))
- (setq event-char (viper-read-event-convert-to-char)))
+ (setq event-char (read-event)))
(setq prefix-arg value)
(if com (setq prefix-arg (cons prefix-arg com)))
(while (eq event-char ?U)
(viper-describe-arg prefix-arg)
- (setq event-char (viper-read-event-convert-to-char)))
+ (setq event-char (read-event)))
(if (or com (and (not (eq viper-current-state 'vi-state))
;; make sure it is a Vi command
- (viper-characterp event-char)
+ (characterp event-char)
(viper-vi-command-p event-char)
))
;; If appears to be one of the vi commands,
(if cmd-to-exec-at-end
(progn
- (setq last-command-event (viper-copy-event char))
+ (setq last-command-event char)
(condition-case err
(funcall cmd-to-exec-at-end cmd-info)
(error
(defun viper-digit-argument (arg)
"Begin numeric argument for the next command."
(interactive "P")
- (viper-leave-region-active)
(viper-prefix-arg-value
(viper-last-command-char) (if (consp arg) (cdr arg) nil)))
(t (error viper-InvalidCommandArgument))))
(quit (setq viper-use-register nil)
(signal 'quit nil)))
- (viper-deactivate-mark)))
+ (deactivate-mark)))
\f
;; repeat last destructive command
(if (> lines-saved viper-change-notification-threshold)
(unless (viper-is-in-minibuffer)
(message "Saved %d lines" lines-saved)))))
- (viper-deactivate-mark)
+ (deactivate-mark)
(goto-char viper-com-point))
(defun viper-exec-bang (_m-com com)
;; executed by `.' is already on the ring.
(if (eq last-command 'viper-display-current-destructive-command)
(viper-push-onto-ring viper-d-com 'viper-command-ring))
- (viper-deactivate-mark)
+ (deactivate-mark)
))
(defun viper-repeat-from-history ()
"Move point right ARG characters (left if ARG negative).
On reaching end of line, stop and signal error."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
"Move point left ARG characters (right if ARG negative).
On reaching beginning of line, stop and signal error."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
(defun viper-forward-word (arg)
"Forward word."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
(defun viper-forward-Word (arg)
"Forward word delimited by white characters."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
(defun viper-end-of-word (arg &optional _careful)
"Move point to end of current word."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
(defun viper-end-of-Word (arg)
"Forward to end of word delimited by white character."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
(defun viper-backward-word (arg)
"Backward word."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
(if com
(defun viper-backward-Word (arg)
"Backward word delimited by white character."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
(if com
(defun viper-beginning-of-line (arg)
"Go to beginning of line."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
(defun viper-bol-and-skip-white (arg)
"Beginning of line at first non-white character."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
(defun viper-goto-eol (arg)
"Go to end of line."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
(defun viper-goto-col (arg)
"Go to ARG's column."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getcom arg))
line-len)
(defun viper-next-line (arg)
"Go to next line."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getCom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
(if (and (fboundp 'button-at) (fboundp 'push-button) (button-at (point)))
(push-button)
;; not a widget or a button
- (viper-leave-region-active)
(save-excursion
(end-of-line)
(if (eobp) (error "Last line in buffer")))
(defun viper-previous-line (arg)
"Go to previous line."
(interactive "P")
- (viper-leave-region-active)
(let ((val (viper-p-val arg))
(com (viper-getCom arg)))
(if com (viper-move-marker-locally 'viper-com-point (point)))
(defun viper-previous-line-at-bol (arg)
"Previous line at beginning of line."
(interactive "P")
- (viper-leave-region-active)
(save-excursion
(beginning-of-line)
(if (bobp) (error "First line in buffer")))
(let ((val (viper-P-val arg))
(com (viper-getCom arg)))
(viper-move-marker-locally 'viper-com-point (point))
- (viper-deactivate-mark)
+ (deactivate-mark)
(push-mark nil t)
(if (null val)
(goto-char (point-max))
(interactive "P")
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
- (viper-deactivate-mark)
+ (deactivate-mark)
(if com (viper-move-marker-locally 'viper-com-point (point)))
(viper-find-char val viper-f-char viper-f-forward viper-f-offset)
(if com
(interactive "P")
(let ((val (viper-p-val arg))
(com (viper-getcom arg)))
- (viper-deactivate-mark)
+ (deactivate-mark)
(if com (viper-move-marker-locally 'viper-com-point (point)))
(viper-find-char val viper-f-char (not viper-f-forward) viper-f-offset)
(if com
(interactive "P")
(let ((val (viper-p-val arg))
(com (viper-getCom arg)))
- (viper-leave-region-active)
(if com (viper-move-marker-locally 'viper-com-point (point)))
(push-mark nil t)
(move-to-window-line (1- val))
(interactive "P")
(let ((val (viper-p-val arg))
(com (viper-getCom arg)))
- (viper-leave-region-active)
(if com (viper-move-marker-locally 'viper-com-point (point)))
(push-mark nil t)
(move-to-window-line (+ (/ (1- (window-height)) 2) (1- val)))
(interactive "P")
(let ((val (viper-p-val arg))
(com (viper-getCom arg)))
- (viper-leave-region-active)
(if com (viper-move-marker-locally 'viper-com-point (point)))
(push-mark nil t)
(move-to-window-line (- val))
(defun viper-paren-match (arg)
"Go to the matching parenthesis."
(interactive "P")
- (viper-leave-region-active)
(let ((com (viper-getcom arg))
(parse-sexp-ignore-comments viper-parse-sexp-ignore-comments)
anchor-point)
(offset (not no-offset))
(case-fold-search viper-case-fold-search)
(start-point (or init-point (point))))
- (viper-deactivate-mark)
+ (deactivate-mark)
(if forward
(condition-case nil
(progn
;; ?g acts as a default value for viper-buffer-search-char
(setq viper-buffer-search-char ?g)))
(define-key viper-vi-basic-map
- (cond ((viper-characterp viper-buffer-search-char)
+ (cond ((characterp viper-buffer-search-char)
(char-to-string viper-buffer-search-char))
(t (error "viper-buffer-search-char: wrong value type, %S"
viper-buffer-search-char)))
(forward-line 1))
(beginning-of-line))
(if (not (eolp)) (viper-forward-char-carefully)))
- (set-marker (viper-mark-marker) (point) (current-buffer))
+ (set-marker (mark-marker) (point) (current-buffer))
(viper-set-destructive-command
(list 'viper-put-back val nil viper-use-register nil nil))
(setq sv-point (point))
(exchange-point-and-mark)
(if (bolp)
(back-to-indentation)))
- (viper-deactivate-mark))
+ (deactivate-mark))
(defun viper-Put-back (arg)
"Put back at point/above line."
(if (viper-end-with-a-newline-p text) (beginning-of-line))
(viper-set-destructive-command
(list 'viper-Put-back val nil viper-use-register nil nil))
- (set-marker (viper-mark-marker) (point) (current-buffer))
+ (set-marker (mark-marker) (point) (current-buffer))
(setq sv-point (point))
(viper-loop val (viper-yank text))
(setq chars-inserted (abs (- (point) sv-point))
(exchange-point-and-mark)
(if (bolp)
(back-to-indentation)))
- (viper-deactivate-mark))
+ (deactivate-mark))
;; Copy region to kill-ring.
(interactive)
(let ((char (read-char)))
(cond ((and (<= ?a char) (<= char ?z))
- (point-to-register (viper-int-to-char (1+ (- char ?a)))))
+ (point-to-register (1+ (- char ?a))))
((viper= char ?<) (viper-mark-beginning-of-buffer))
((viper= char ?>) (viper-mark-end-of-buffer))
((viper= char ?.) (viper-set-mark-if-necessary))
(if (eq last-command 'viper-cycle-through-mark-ring)
()
;; save current mark if the first iteration
- (setq mark-ring (delete (viper-mark-marker) mark-ring))
+ (setq mark-ring (delete (mark-marker) mark-ring))
(if (mark t)
(push-mark (mark t) t)) )
(pop-mark)
(set-mark-command 1)
;; don't duplicate mark on the ring
- (setq mark-ring (delete (viper-mark-marker) mark-ring))
+ (setq mark-ring (delete (mark-marker) mark-ring))
(push-mark sv-pt t)
- (viper-deactivate-mark)
+ (deactivate-mark)
(setq this-command 'viper-cycle-through-mark-ring)
))
(backward-char 1)))
(cond ((viper-valid-register char '(letter))
(let* ((buff (current-buffer))
- (reg (viper-int-to-char (1+ (- char ?a))))
+ (reg (1+ (- char ?a)))
(text-marker (get-register reg)))
;; If marker points to file that had markers set (and those markers
;; were saved (as e.g., in session.el), then restore those markers
((viper= ?\] reg)
(viper-heading-end arg))
((viper-valid-register reg '(letter))
- (let* ((val (get-register (viper-int-to-char (1+ (- reg ?a)))))
+ (let* ((val (get-register (1+ (- reg ?a))))
(buf (if (not (markerp val))
(error viper-EmptyTextmarker reg)
(marker-buffer val)))
(if (and enforce-buffer
(not (equal (current-buffer) (marker-buffer val))))
(error (concat viper-EmptyTextmarker " in this buffer")
- (viper-int-to-char (1- (+ char ?a)))))
+ (1- (+ char ?a))))
(pop-to-buffer (marker-buffer val))
(goto-char val))
((and (consp val) (eq (car val) 'file))
(find-file (cdr val)))
(t
- (error viper-EmptyTextmarker (viper-int-to-char (1- (+ char ?a))))))))
+ (error viper-EmptyTextmarker (1- (+ char ?a)))))))
(defun viper-save-kill-buffer ()
(viper-frame-parameters (if (fboundp 'frame-parameters)
(frame-parameters (selected-frame))))
(viper-minibuffer-emacs-face (if (viper-has-face-support-p)
- (viper-get-face
+ (facep
viper-minibuffer-emacs-face)
'non-x))
(viper-minibuffer-vi-face (if (viper-has-face-support-p)
- (viper-get-face viper-minibuffer-vi-face)
+ (facep viper-minibuffer-vi-face)
'non-x))
(viper-minibuffer-insert-face (if (viper-has-face-support-p)
- (viper-get-face
+ (facep
viper-minibuffer-insert-face)
'non-x))
varlist salutation window-config)
(exchange-point-and-mark)
(goto-char
(viper-register-to-point
- (viper-int-to-char (1+ (- ex-token ?a))) 'enforce-buffer)))
+ (1+ (- ex-token ?a)))
+ 'enforce-buffer))
(setq address (point-marker)))))
address))
(defun viper-handle-! ()
(interactive)
(if (and (string=
- (buffer-string) (viper-abbreviate-file-name default-directory))
+ (buffer-string) (abbreviate-file-name default-directory))
(member ex-token '("read" "write")))
(erase-buffer))
(insert "!"))
(if (not file)
(viper-get-ex-file))
(cond ((and (string= ex-file "") buffer-file-name)
- (setq ex-file (viper-abbreviate-file-name (buffer-file-name))))
+ (setq ex-file (abbreviate-file-name (buffer-file-name))))
((string= ex-file "")
(error viper-NoFileSpecified)))
(error "`%s' requires a following letter" ex-token))))
(save-excursion
(goto-char (car ex-addresses))
- (point-to-register (viper-int-to-char (1+ (- char ?a)))))))
+ (point-to-register (1+ (- char ?a))))))
(if (not (viper-buffer-live-p buf))
(error "Didn't find buffer %S or file %S"
file-or-buffer-name
- (viper-abbreviate-file-name
+ (abbreviate-file-name
(expand-file-name file-or-buffer-name))))
(if (equal buf (current-buffer))
;; setup buffer
(if (setq wind (viper-get-visible-buffer-window buf))
()
- (setq wind (get-lru-window (if (featurep 'xemacs) nil 'visible)))
+ (setq wind (get-lru-window 'visible))
(set-window-buffer wind buf))
(if (viper-window-display-p)
(condition-case nil
(progn
(pop-to-buffer (get-buffer-create "*info*"))
- (info (if (featurep 'xemacs) "viper.info" "viper"))
+ (info "viper")
(message "Type `i' to search for a specific topic"))
(error (beep 1)
(with-output-to-temp-buffer " *viper-info*"
(princ (format "
The Info file for Viper does not seem to be installed.
-This file is part of the standard distribution of %sEmacs.
-Please contact your system administrator. "
- (if (featurep 'xemacs) "X" "")
- ))))))
+This file is part of the standard distribution of Emacs.
+Please contact your system administrator. "))))))
;; Ex source command.
;; Loads the file specified as argument or viper-custom-file-name.
;; create temp buffer for the region
(setq temp-buf (get-buffer-create " *ex-write*"))
(set-buffer temp-buf)
- (if (featurep 'xemacs)
- (set-visited-file-name ex-file)
- (set-visited-file-name ex-file 'noquery))
+ (set-visited-file-name ex-file 'noquery)
(erase-buffer)
(if (and file-exists ex-append)
(insert-file-contents ex-file))
(defun ex-write-info (exists file-name beg end)
(message "`%s'%s %d lines, %d characters"
- (viper-abbreviate-file-name file-name)
+ (abbreviate-file-name file-name)
(if exists "" " [New file]")
(count-lines beg (min (1+ end) (point-max)))
(- end beg)))
lines file info)
(setq lines (count-lines (point-min) (viper-line-pos 'end))
file (cond ((buffer-file-name)
- (concat (viper-abbreviate-file-name (buffer-file-name)) ":"))
+ (concat (abbreviate-file-name (buffer-file-name)) ":"))
((buffer-file-name (buffer-base-buffer))
- (concat (viper-abbreviate-file-name (buffer-file-name (buffer-base-buffer))) " (indirect buffer):"))
+ (concat (abbreviate-file-name (buffer-file-name (buffer-base-buffer))) " (indirect buffer):"))
(t (concat (buffer-name) " [Not visiting any file]:")))
info (format "line=%d/%d pos=%d/%d col=%d %s"
(if (= pos1 pos2)
(defun viper-add-keymap (mapsrc mapdst)
"Add contents of mapsrc to mapdst. It is assumed that mapsrc is sparse."
- (if (featurep 'xemacs)
- ;; Emacs 22 has map-keymap.
- (map-keymap (lambda (key binding) (define-key mapdst key binding))
- mapsrc)
- (mapc (lambda (p) (define-key mapdst (vector (car p)) (cdr p)))
- (cdr mapsrc))))
+ (mapc (lambda (p) (define-key mapdst (vector (car p)) (cdr p)))
+ (cdr mapsrc)))
(defun viper-modify-keymap (map alist)
"Modifies MAP with bindings specified in the ALIST. The alist has the
t)))
(if (y-or-n-p
(format "Save this macro in %s? "
- (viper-abbreviate-file-name viper-custom-file-name)))
+ (abbreviate-file-name viper-custom-file-name)))
(viper-save-string-in-file
(format "\n(viper-record-kbd-macro %S '%S %s '%S)"
(viper-display-macro macro-name)
;; the next pending event is not a mouse event, we execute the
;; current mouse event
(progn
- (setq interrupting-event (viper-read-event))
+ (setq interrupting-event (read-event))
(viper-mouse-event-p last-input-event)))
(progn ; interrupted wait
(setq viper-global-prefix-argument arg)
;; pending event is not a mouse event, we execute the current mouse
;; event
(progn
- (viper-read-event)
+ (read-event)
(viper-mouse-event-p last-input-event)))
(progn ; interrupted wait
(setq viper-global-prefix-argument (or viper-global-prefix-argument
viper-global-prefix-argument nil))
(setq arg (or arg 1))
- (viper-deactivate-mark)
+ (deactivate-mark)
(if (or (not (string= click-word viper-s-string))
(not (markerp viper-search-start-marker))
(not (equal (marker-buffer viper-search-start-marker)
\f
-(defalias 'viper-overlay-p
- (if (featurep 'xemacs) 'extentp 'overlayp))
-(defalias 'viper-make-overlay
- (if (featurep 'xemacs) 'make-extent 'make-overlay))
-(defalias 'viper-overlay-live-p
- (if (featurep 'xemacs) 'extent-live-p 'overlayp))
-(defalias 'viper-move-overlay
- (if (featurep 'xemacs) 'set-extent-endpoints 'move-overlay))
-(defalias 'viper-overlay-start
- (if (featurep 'xemacs) 'extent-start-position 'overlay-start))
-(defalias 'viper-overlay-end
- (if (featurep 'xemacs) 'extent-end-position 'overlay-end))
-(defalias 'viper-overlay-get
- (if (featurep 'xemacs) 'extent-property 'overlay-get))
-(defalias 'viper-overlay-put
- (if (featurep 'xemacs) 'set-extent-property 'overlay-put))
-(defalias 'viper-read-event
- (if (featurep 'xemacs) 'next-command-event 'read-event))
-(defalias 'viper-characterp
- (if (featurep 'xemacs) 'characterp 'integerp))
-(defalias 'viper-int-to-char
- (if (featurep 'xemacs) 'int-to-char 'identity))
-(defalias 'viper-get-face
- (if (featurep 'xemacs) 'get-face 'facep))
-(defalias 'viper-color-defined-p
- (if (featurep 'xemacs) 'valid-color-name-p 'x-color-defined-p))
-(defalias 'viper-iconify
- (if (featurep 'xemacs) 'iconify-frame 'iconify-or-deiconify-frame))
+(define-obsolete-function-alias 'viper-overlay-p 'overlayp "27.1")
+(define-obsolete-function-alias 'viper-make-overlay 'make-overlay "27.1")
+(define-obsolete-function-alias 'viper-overlay-live-p 'overlayp "27.1")
+(define-obsolete-function-alias 'viper-move-overlay 'move-overlay "27.1")
+(define-obsolete-function-alias 'viper-overlay-start 'overlay-start "27.1")
+(define-obsolete-function-alias 'viper-overlay-end 'overlay-end "27.1")
+(define-obsolete-function-alias 'viper-overlay-get 'overlay-get "27.1")
+(define-obsolete-function-alias 'viper-overlay-put 'overlay-put "27.1")
+(define-obsolete-function-alias 'viper-read-event 'read-event "27.1")
+(define-obsolete-function-alias 'viper-characterp 'integerp "27.1")
+(define-obsolete-function-alias 'viper-int-to-char 'identity "27.1")
+(define-obsolete-function-alias 'viper-get-face 'facep "27.1")
+(define-obsolete-function-alias 'viper-color-defined-p
+ 'x-color-defined-p "27.1")
+(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)
;; chars.
(defun viper-memq-char (char list)
(cond ((and (integerp char) (>= char 0))
- (memq (viper-int-to-char char) list))
+ (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))
- (= (viper-int-to-char char-or-int) char))
+ (= char-or-int char))
((eq char-or-int char))))
;; Like =, but accommodates null and also is t for eq-objects
(defun viper= (char char1)
(cond ((eq char char1) t)
- ((and (viper-characterp char) (viper-characterp char1))
+ ((and (characterp char) (characterp char1))
(= char char1))
(t nil)))
(defsubst viper-color-display-p ()
- (if (featurep 'xemacs) (eq (device-class (selected-device)) 'color)
- (x-display-color-p)))
+ (x-display-color-p))
-(defun viper-get-cursor-color (&optional frame)
- (if (featurep 'xemacs)
- (color-instance-name
- (frame-property (or frame (selected-frame)) 'cursor-color))
- (cdr (assoc 'cursor-color (frame-parameters)))))
+(defun viper-get-cursor-color (&optional _frame)
+ (cdr (assoc 'cursor-color (frame-parameters))))
(defmacro viper-frame-value (variable)
"Return the value of VARIABLE local to the current frame, if there is one.
Otherwise return the normal value."
- `(if (featurep 'xemacs)
+ ;; Frame-local variables are obsolete from Emacs 22.2 onwards,
+ ;; so we do it by hand instead.
+ ;; Buffer-local values take precedence over frame-local ones.
+ `(if (local-variable-p ',variable)
,variable
- ;; Frame-local variables are obsolete from Emacs 22.2 onwards,
- ;; so we do it by hand instead.
- ;; Buffer-local values take precedence over frame-local ones.
- (if (local-variable-p ',variable)
- ,variable
- ;; Distinguish between no frame parameter and a frame parameter
- ;; with a value of nil.
- (let ((fp (assoc ',variable (frame-parameters))))
- (if fp (cdr fp)
- ,variable)))))
+ ;; Distinguish between no frame parameter and a frame parameter
+ ;; with a value of nil.
+ (let ((fp (assoc ',variable (frame-parameters))))
+ (if fp (cdr fp)
+ ,variable))))
;; cursor colors
(defun viper-change-cursor-color (new-color &optional frame)
- (if (and (viper-window-display-p) (viper-color-display-p)
- (stringp new-color) (viper-color-defined-p new-color)
+ (if (and (viper-window-display-p) (viper-color-display-p)
+ (stringp new-color) (x-color-defined-p new-color)
(not (string= new-color (viper-get-cursor-color))))
- (if (featurep 'xemacs)
- (set-frame-property
- (or frame (selected-frame))
- 'cursor-color (make-color-instance new-color))
- (modify-frame-parameters
- (or frame (selected-frame))
- (list (cons 'cursor-color new-color))))))
+ (modify-frame-parameters
+ (or frame (selected-frame))
+ (list (cons 'cursor-color new-color)))))
;; Note that the colors this function uses might not be those
;; associated with FRAME, if there are frame-local values.
(defun viper-save-cursor-color (before-which-mode)
(if (and (viper-window-display-p) (viper-color-display-p))
(let ((color (viper-get-cursor-color)))
- (if (and (stringp color) (viper-color-defined-p color)
+ (if (and (stringp color) (x-color-defined-p color)
;; there is something fishy in that the color is not saved if
;; it is the same as frames default cursor color. need to be
;; checked.
;; restore cursor color from replace overlay
(defun viper-restore-cursor-color(after-which-mode)
- (if (viper-overlay-p viper-replace-overlay)
+ (if (overlayp viper-replace-overlay)
(viper-change-cursor-color
(cond ((eq after-which-mode 'after-replace-mode)
(viper-get-saved-cursor-color-in-replace-mode))
(defun viper-get-visible-buffer-window (wind)
- (if (featurep 'xemacs)
- (get-buffer-window wind t)
- (get-buffer-window wind 'visible)))
-
+ (get-buffer-window wind 'visible))
;; Return line position.
;; If pos is 'start then returns position of line start.
(if (fboundp 'vc-state)
(and
(not (memq (vc-state file) '(edited needs-merge)))
- (not (stringp (vc-state file))))
- ;; XEmacs has no vc-state
- (if (featurep 'xemacs) (not (vc-locking-user file))))))
+ (not (stringp (vc-state file)))))))
;; checkout if visited file is checked in
(defun viper-maybe-checkout (buf)
\f
;;; Overlays
(defun viper-put-on-search-overlay (beg end)
- (if (viper-overlay-p viper-search-overlay)
- (viper-move-overlay viper-search-overlay beg end)
- (setq viper-search-overlay (viper-make-overlay beg end (current-buffer)))
- (viper-overlay-put
+ (if (overlayp viper-search-overlay)
+ (move-overlay viper-search-overlay beg end)
+ (setq viper-search-overlay (make-overlay beg end (current-buffer)))
+ (overlay-put
viper-search-overlay 'priority viper-search-overlay-priority))
- (viper-overlay-put viper-search-overlay 'face viper-search-face))
+ (overlay-put viper-search-overlay 'face viper-search-face))
;; Search
nil
(viper-put-on-search-overlay (match-beginning 0) (match-end 0))
(sit-for 2)
- (viper-overlay-put viper-search-overlay 'face nil)))
+ (overlay-put viper-search-overlay 'face nil)))
(defun viper-hide-search-overlay ()
- (if (not (viper-overlay-p viper-search-overlay))
+ (if (not (overlayp viper-search-overlay))
(progn
(setq viper-search-overlay
- (viper-make-overlay (point-min) (point-min) (current-buffer)))
- (viper-overlay-put
+ (make-overlay (point-min) (point-min) (current-buffer)))
+ (overlay-put
viper-search-overlay 'priority viper-search-overlay-priority)))
- (viper-overlay-put viper-search-overlay 'face nil))
+ (overlay-put viper-search-overlay 'face nil))
;; Replace state
(defsubst viper-move-replace-overlay (beg end)
- (viper-move-overlay viper-replace-overlay beg end))
+ (move-overlay viper-replace-overlay beg end))
(defun viper-set-replace-overlay (beg end)
- (if (viper-overlay-live-p viper-replace-overlay)
+ (if (overlayp viper-replace-overlay)
(viper-move-replace-overlay beg end)
- (setq viper-replace-overlay (viper-make-overlay beg end (current-buffer)))
+ (setq viper-replace-overlay (make-overlay beg end (current-buffer)))
;; never detach
- (viper-overlay-put
+ (overlay-put
viper-replace-overlay (if (featurep 'emacs) 'evaporate 'detachable) nil)
- (viper-overlay-put
+ (overlay-put
viper-replace-overlay 'priority viper-replace-overlay-priority)
;; If Emacs will start supporting overlay maps, as it currently supports
;; text-property maps, we could do away with viper-replace-minor-mode and
;; just have keymap attached to replace overlay.
- ;;(viper-overlay-put
+ ;;(overlay-put
;; viper-replace-overlay
;; (if (featurep 'xemacs) 'keymap 'local-map)
;; viper-replace-map)
)
(if (viper-has-face-support-p)
- (viper-overlay-put
+ (overlay-put
viper-replace-overlay 'face viper-replace-overlay-face))
(viper-save-cursor-color 'before-replace-mode)
(viper-change-cursor-color
(defun viper-set-replace-overlay-glyphs (before-glyph after-glyph)
- (or (viper-overlay-live-p viper-replace-overlay)
+ (or (overlayp viper-replace-overlay)
(viper-set-replace-overlay (point-min) (point-min)))
(if (or (not (viper-has-face-support-p))
viper-use-replace-region-delimiters)
- (let ((before-name (if (featurep 'xemacs) 'begin-glyph 'before-string))
- (after-name (if (featurep 'xemacs) 'end-glyph 'after-string)))
- (viper-overlay-put viper-replace-overlay before-name before-glyph)
- (viper-overlay-put viper-replace-overlay after-name after-glyph))))
+ (overlay-put viper-replace-overlay 'before-string before-glyph)
+ (overlay-put viper-replace-overlay 'after-string after-glyph)))
(defun viper-hide-replace-overlay ()
(viper-set-replace-overlay-glyphs nil nil)
(viper-restore-cursor-color 'after-replace-mode)
(viper-restore-cursor-color 'after-insert-mode)
(if (viper-has-face-support-p)
- (viper-overlay-put viper-replace-overlay 'face nil)))
+ (overlay-put viper-replace-overlay 'face nil)))
(defsubst viper-replace-start ()
- (viper-overlay-start viper-replace-overlay))
+ (overlay-start viper-replace-overlay))
(defsubst viper-replace-end ()
- (viper-overlay-end viper-replace-overlay))
+ (overlay-end viper-replace-overlay))
;; Minibuffer
(defun viper-set-minibuffer-overlay ()
(viper-check-minibuffer-overlay)
(when (viper-has-face-support-p)
- (viper-overlay-put
+ (overlay-put
viper-minibuffer-overlay 'face viper-minibuffer-current-face)
- (viper-overlay-put
+ (overlay-put
viper-minibuffer-overlay 'priority viper-minibuffer-overlay-priority)
;; never detach
- (viper-overlay-put
- viper-minibuffer-overlay
- (if (featurep 'emacs) 'evaporate 'detachable)
- nil)
- ;; make viper-minibuffer-overlay open-ended
- ;; In emacs, it is made open ended at creation time
- (when (featurep 'xemacs)
- (viper-overlay-put viper-minibuffer-overlay 'start-open nil)
- (viper-overlay-put viper-minibuffer-overlay 'end-open nil))))
+ (overlay-put viper-minibuffer-overlay 'evaporate nil)))
(defun viper-check-minibuffer-overlay ()
- (if (viper-overlay-live-p viper-minibuffer-overlay)
- (viper-move-overlay
+ (if (overlayp viper-minibuffer-overlay)
+ (move-overlay
viper-minibuffer-overlay
(if (fboundp 'minibuffer-prompt-end) (minibuffer-prompt-end) 1)
(1+ (buffer-size)))
(setq viper-minibuffer-overlay
- (if (featurep 'xemacs)
- (viper-make-overlay 1 (1+ (buffer-size)) (current-buffer))
- ;; make overlay open-ended
- (viper-make-overlay
- (if (fboundp 'minibuffer-prompt-end) (minibuffer-prompt-end) 1)
- (1+ (buffer-size))
- (current-buffer) nil 'rear-advance)))))
+ ;; make overlay open-ended
+ (make-overlay
+ (if (fboundp 'minibuffer-prompt-end) (minibuffer-prompt-end) 1)
+ (1+ (buffer-size))
+ (current-buffer) nil 'rear-advance))))
(defsubst viper-is-in-minibuffer ()
;;; XEmacs compatibility
(defun viper-abbreviate-file-name (file)
- (if (featurep 'xemacs)
- (abbreviate-file-name file t) ; XEmacs requires addl argument
- (abbreviate-file-name file)))
+ (abbreviate-file-name file))
;; Sit for VAL milliseconds. XEmacs doesn't support the millisecond arg
;; in sit-for, so this function smooths out the differences.
(with-current-buffer buf
(and (<= pos (point-max)) (<= (point-min) pos))))))
-(defsubst viper-mark-marker ()
- (if (featurep 'xemacs) (mark-marker t)
- (mark-marker)))
+(define-obsolete-function-alias 'viper-mark-marker 'mark-marker "27.1")
(defvar viper-saved-mark nil
"Where viper saves mark. This mark is resurrected by m^.")
;; like (set-mark-command nil) but doesn't push twice, if (car mark-ring)
;; is the same as (mark t).
(defsubst viper-set-mark-if-necessary ()
- (setq mark-ring (delete (viper-mark-marker) mark-ring))
+ (setq mark-ring (delete (mark-marker) mark-ring))
(set-mark-command nil)
(setq viper-saved-mark (point)))
-;; In transient mark mode (zmacs mode), it is annoying when regions become
-;; highlighted due to Viper's pushing marks. So, we deactivate marks, unless
-;; the user explicitly wants highlighting, e.g., by hitting '' or ``
-(defun viper-deactivate-mark ()
- (if (featurep 'xemacs)
- (zmacs-deactivate-region)
- (deactivate-mark)))
+;; In transient mark mode, it is annoying when regions become
+;; highlighted due to Viper's pushing marks. So, we deactivate marks,
+;; unless the user explicitly wants highlighting, e.g., by hitting ''
+;; or ``
+(define-obsolete-function-alias 'viper-deactivate-mark 'deactivate-mark "27.1")
-(defsubst viper-leave-region-active ()
- (if (featurep 'xemacs) (setq zmacs-region-stays t)))
+(define-obsolete-function-alias 'viper-leave-region-active 'ignore "27.1")
;; Check if arg is a valid character for register
;; TYPE is a list that can contain `letter', `Letter', and `digit'.
-;; it is suggested that an event must be copied before it is assigned to
-;; last-command-event in XEmacs
-(defun viper-copy-event (event)
- (if (featurep 'xemacs) (copy-event event)
- event))
+(define-obsolete-function-alias 'viper-copy-event 'identity "27.1")
;; Uses different timeouts for ESC-sequences and others
(defun viper-fast-keysequence-p ()
viper-fast-keyseq-timeout)
t)))
-;; like read-event, but in XEmacs also try to convert to char, if possible
-(defun viper-read-event-convert-to-char ()
- (let (event)
- (if (featurep 'xemacs)
- (progn
- (setq event (next-command-event))
- (or (event-to-character event)
- event))
- (read-event))))
+(define-obsolete-function-alias 'viper-read-event-convert-to-char
+ 'read-event "27.1")
;; Emacs has a bug in eventp, which causes (eventp nil) to return (nil)
(defun viper-event-key (event)
(or (and event (eventp event))
(error "viper-event-key: Wrong type argument, eventp, %S" event))
- (when (if (featurep 'xemacs)
- (or (key-press-event-p event) (mouse-event-p event)) ; xemacs
- t ; emacs
- )
- (let ((mod (event-modifiers event))
- basis)
- (setq basis
- (if (featurep 'xemacs)
- ;; XEmacs
- (cond ((key-press-event-p event)
- (event-key event))
- ((button-event-p event)
- (concat "mouse-" (prin1-to-string (event-button event))))
- (t
- (error "viper-event-key: Unknown event, %S" event)))
- ;; Emacs doesn't handle capital letters correctly, since
- ;; \S-a isn't considered the same as A (it behaves as
- ;; plain `a' instead). So we take care of this here
- (cond ((and (viper-characterp event) (<= ?A event) (<= event ?Z))
- (setq mod nil
- event event))
- ;; Emacs has the oddity whereby characters 128+char
- ;; represent M-char *if* this appears inside a string.
- ;; So, we convert them manually to (meta char).
- ((and (viper-characterp event)
- (< ?\C-? event) (<= event 255))
- (setq mod '(meta)
- event (- event ?\C-? 1)))
- ((and (null mod) (eq event 'return))
- (setq event ?\C-m))
- ((and (null mod) (eq event 'space))
- (setq event ?\ ))
- ((and (null mod) (eq event 'delete))
- (setq event ?\C-?))
- ((and (null mod) (eq event 'backspace))
- (setq event ?\C-h))
- (t (event-basic-type event)))
- ) ; (featurep 'xemacs)
- )
- (if (viper-characterp basis)
- (setq basis
- (if (viper= basis ?\C-?)
- (list 'control '\?) ; taking care of an emacs bug
- (intern (char-to-string basis)))))
- (if mod
- (append mod (list basis))
- basis))))
+ (let ((mod (event-modifiers event))
+ basis)
+ (setq basis
+ ;; Emacs doesn't handle capital letters correctly, since
+ ;; \S-a isn't considered the same as A (it behaves as
+ ;; plain `a' instead). So we take care of this here
+ (cond ((and (characterp event) (<= ?A event) (<= event ?Z))
+ (setq mod nil
+ event event))
+ ;; Emacs has the oddity whereby characters 128+char
+ ;; represent M-char *if* this appears inside a string.
+ ;; So, we convert them manually to (meta char).
+ ((and (characterp event)
+ (< ?\C-? event) (<= event 255))
+ (setq mod '(meta)
+ event (- event ?\C-? 1)))
+ ((and (null mod) (eq event 'return))
+ (setq event ?\C-m))
+ ((and (null mod) (eq event 'space))
+ (setq event ?\ ))
+ ((and (null mod) (eq event 'delete))
+ (setq event ?\C-?))
+ ((and (null mod) (eq event 'backspace))
+ (setq event ?\C-h))
+ (t (event-basic-type event))))
+
+ (if (characterp basis)
+ (setq basis
+ (if (viper= basis ?\C-?)
+ (list 'control '\?) ; taking care of an emacs bug
+ (intern (char-to-string basis)))))
+ (if mod
+ (append mod (list basis))
+ basis)))
(defun viper-last-command-char ()
- (if (featurep 'xemacs)
- (event-to-character last-command-event)
- last-command-event))
+ last-command-event)
(defun viper-key-to-emacs-key (key)
(let (key-name char-p modifiers mod-char-list base-key base-key-name)
- (cond ((featurep 'xemacs) key)
-
- ((symbolp key)
+ (cond ((symbolp key)
(setq key-name (symbol-name key))
(cond ((= (length key-name) 1) ; character event
(string-to-char key-name))
;; LIS is assumed to be a list of events of characters
-(defun viper-eventify-list-xemacs (lis)
- (if (featurep 'xemacs)
- (mapcar
- (lambda (elt)
- (cond ((viper-characterp elt) (character-to-event elt))
- ((eventp elt) elt)
- (t (error
- "viper-eventify-list-xemacs: can't convert to event, %S"
- elt))))
- lis)))
+(define-obsolete-function-alias 'viper-eventify-list-xemacs 'ignore "27.1")
;; Smooths out the difference between Emacs's unread-command-events
(setq
unread-command-events
(append
- (cond ((viper-characterp arg) (list (character-to-event arg)))
+ (cond ((characterp arg) (list (character-to-event arg)))
((eventp arg) (list arg))
((stringp arg) (mapcar 'character-to-event arg))
((vectorp arg) (append arg nil)) ; turn into list
- ((listp arg) (viper-eventify-list-xemacs arg))
+ ((listp arg) nil)
(t (error
"viper-set-unread-command-events: Invalid argument, %S" arg)))
unread-command-events))))
(defun viper-char-array-p (array)
- (eval (cons 'and (mapcar 'viper-characterp array))))
+ (eval (cons 'and (mapcar 'characterp array))))
;; Args can be a sequence of events, a string, or a Viper macro. Will try to
(t (prin1-to-string event-seq)))))
(defun viper-key-press-events-to-chars (events)
- (mapconcat (if (featurep 'xemacs)
- (lambda (elt) (char-to-string (event-to-character elt))) ; xemacs
- 'char-to-string ; emacs
- )
- events
- ""))
+ (mapconcat #'char-to-string events ""))
(defun viper-read-char-exclusive ()
(setq char (read-char))
(error
;; skip event if not char
- (viper-read-event))))
+ (read-event))))
char))
;; key is supposed to be in viper's representation, e.g., (control l), a
(and (fboundp 'add-to-ordered-list) (boundp 'emulation-mode-map-alists))
(viper-delocalize-var 'minor-mode-map-alist))
(viper-delocalize-var 'require-final-newline)
- (if (featurep 'xemacs) (viper-delocalize-var 'bar-cursor))
-
;; deactivate all advices done by Viper.
(viper--deactivate-advice-list)
;; In emacs, we have to advice handle-switch-frame
;; This advice is undone earlier, when all advices matching "viper-" are
;; deactivated.
- (if (featurep 'xemacs)
- (remove-hook 'mouse-leave-frame-hook #'viper-remember-current-frame))
) ; end viper-go-away
(lambda (orig-fun &rest args)
;; FIXME: Use remapping?
(if (and (eq viper-current-state 'vi-state)
- ;; Do not use called-interactively-p here. XEmacs does not have it
- ;; and interactive-p is just fine.
- (if (featurep 'xemacs)
- (interactive-p)
- ;; Respect the spirit of the above comment, though it
- ;; seems pointless, since XE doesn't have advice-add or
- ;; lexical binding or any other of the newer features
- ;; this file uses.
- (called-interactively-p 'interactive)))
+ (called-interactively-p 'interactive))
(beep 1)
(apply orig-fun args))))
;; catch frame switching event
(if (viper-window-display-p)
- (if (featurep 'xemacs)
- (add-hook 'mouse-leave-frame-hook
- #'viper-remember-current-frame)
- (viper--advice-add 'handle-switch-frame :before
- (lambda (&rest _)
- "Remember the selected frame before the switch-frame event."
- (viper-remember-current-frame (selected-frame))))))
+ (viper--advice-add
+ 'handle-switch-frame :before
+ (lambda (&rest _)
+ "Remember the selected frame before the switch-frame event."
+ (viper-remember-current-frame (selected-frame)))))
) ; end viper-non-hook-settings