/[emacs]/emacs/lisp/emulation/viper-cmd.el
ViewVC logotype

Diff of /emacs/lisp/emulation/viper-cmd.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.34 by kifer, Mon Dec 24 05:50:31 2001 UTC revision 1.35 by kifer, Tue Jan 8 04:36:00 2002 UTC
# Line 1  Line 1 
1  ;;; viper-cmd.el --- Vi command support for Viper  ;;; viper-cmd.el --- Vi command support for Viper
2    
3  ;; Copyright (C) 1997 Free Software Foundation, Inc.  ;; Copyright (C) 1997, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
4    
5  ;; Author: Michael Kifer <kifer@cs.sunysb.edu>  ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
6    
7  ;; This file is part of GNU Emacs.  ;; This file is part of GNU Emacs.
8    
# Line 41  Line 41 
41  (defvar quail-current-str)  (defvar quail-current-str)
42  (defvar zmacs-region-stays)  (defvar zmacs-region-stays)
43  (defvar mark-even-if-inactive)  (defvar mark-even-if-inactive)
44    (defvar init-message)
45    (defvar initial)
46    
47  ;; loading happens only in non-interactive compilation  ;; loading happens only in non-interactive compilation
48  ;; in order to spare non-viperized emacs from being viperized  ;; in order to spare non-viperized emacs from being viperized
# Line 145  Line 147 
147  ;; Where viper saves mark. This mark is resurrected by m^  ;; Where viper saves mark. This mark is resurrected by m^
148  (defvar viper-saved-mark nil)  (defvar viper-saved-mark nil)
149    
150    ;; Contains user settings for vars affected by viper-set-expert-level function.
151    ;; Not a user option.
152    (defvar viper-saved-user-settings nil)
153    
154    
155    
156  ;;; CODE  ;;; CODE
# Line 298  Line 304 
304    ;; desirable that viper-pre-command-sentinel is the last hook and    ;; desirable that viper-pre-command-sentinel is the last hook and
305    ;; viper-post-command-sentinel is the first hook.    ;; viper-post-command-sentinel is the first hook.
306    
307    (if viper-xemacs-p    (viper-cond-compile-for-xemacs-or-emacs
308        (progn     ;; xemacs
309          (make-local-hook 'viper-after-change-functions)     (progn
310          (make-local-hook 'viper-before-change-functions)       (make-local-hook 'viper-after-change-functions)
311          (make-local-hook 'viper-post-command-hooks)       (make-local-hook 'viper-before-change-functions)
312          (make-local-hook 'viper-pre-command-hooks)))       (make-local-hook 'viper-post-command-hooks)
313         (make-local-hook 'viper-pre-command-hooks))
314       nil ; emacs
315       )
316    
317    (remove-hook 'post-command-hook 'viper-post-command-sentinel)    (remove-hook 'post-command-hook 'viper-post-command-sentinel)
318    (add-hook 'post-command-hook 'viper-post-command-sentinel)    (add-hook 'post-command-hook 'viper-post-command-sentinel)
# Line 744  Vi's prefix argument will be used.  Othe Line 753  Vi's prefix argument will be used.  Othe
753    
754            ;; this-command, last-command-char, last-command-event            ;; this-command, last-command-char, last-command-event
755            (setq this-command com)            (setq this-command com)
756            (if viper-xemacs-p ; XEmacs represents key sequences as vectors            (viper-cond-compile-for-xemacs-or-emacs
757                (setq last-command-event             ;; XEmacs represents key sequences as vectors
758                      (viper-copy-event (viper-seq-last-elt key))             (setq last-command-event
759                      last-command-char (event-to-character last-command-event))                   (viper-copy-event (viper-seq-last-elt key))
760              ;; Emacs represents them as sequences (str or vec)                   last-command-char (event-to-character last-command-event))
761              (setq last-command-event             ;; Emacs represents them as sequences (str or vec)
762                    (viper-copy-event (viper-seq-last-elt key))             (setq last-command-event
763                    last-command-char last-command-event))                   (viper-copy-event (viper-seq-last-elt key))
764                     last-command-char last-command-event)
765               )
766    
767            (if (commandp com)            (if (commandp com)
768                (progn                (progn
# Line 850  Vi's prefix argument will be used.  Othe Line 861  Vi's prefix argument will be used.  Othe
861                (viper-copy-event (if viper-xemacs-p                (viper-copy-event (if viper-xemacs-p
862                                      (character-to-event ch) ch)))                                      (character-to-event ch) ch)))
863          ) ; let          ) ; let
864      (error)      (error nil)
865      ) ; condition-case      ) ; condition-case
866                
867    (viper-set-input-method nil)    (viper-set-input-method nil)
# Line 1766  invokes the command before that, etc." Line 1777  invokes the command before that, etc."
1777      (message " `.' runs  %s%s"      (message " `.' runs  %s%s"
1778               (concat "`" (viper-array-to-string keys) "'")               (concat "`" (viper-array-to-string keys) "'")
1779               (viper-abbreviate-string               (viper-abbreviate-string
1780                (if viper-xemacs-p                (viper-cond-compile-for-xemacs-or-emacs
1781                    (replace-in-string                 (replace-in-string ; xemacs
1782                     (cond ((characterp text) (char-to-string text))                  (cond ((characterp text) (char-to-string text))
1783                           ((stringp text) text)                        ((stringp text) text)
1784                           (t ""))                        (t ""))
1785                     "\n" "^J")                  "\n" "^J")
1786                  text)                 text ; emacs
1787                   )
1788                max-text-len                max-text-len
1789                "  inserting  `" "'" "    ......."))                "  inserting  `" "'" "    ......."))
1790      ))      ))
# Line 2059  To turn this feature off, set this varia Line 2071  To turn this feature off, set this varia
2071                    (setq cmd                    (setq cmd
2072                          (key-binding (setq key (read-key-sequence nil))))                          (key-binding (setq key (read-key-sequence nil))))
2073                    (cond ((eq cmd 'self-insert-command)                    (cond ((eq cmd 'self-insert-command)
2074                           (if viper-xemacs-p                           (viper-cond-compile-for-xemacs-or-emacs
2075                               (insert (events-to-keys key))                            (insert (events-to-keys key)) ; xemacs
2076                             (insert key)))                            (insert key) ; emacs
2077                              ))
2078                          ((memq cmd '(exit-minibuffer viper-exit-minibuffer))                          ((memq cmd '(exit-minibuffer viper-exit-minibuffer))
2079                           nil)                           nil)
2080                          (t (command-execute cmd)))                          (t (command-execute cmd)))
# Line 2642  On reaching beginning of line, stop and Line 2655  On reaching beginning of line, stop and
2655    (let ((pt (point)))    (let ((pt (point)))
2656      (condition-case nil      (condition-case nil
2657          (forward-char arg)          (forward-char arg)
2658        (error))        (error nil))
2659      (if (< (point) pt) ; arg was negative      (if (< (point) pt) ; arg was negative
2660          (- (viper-chars-in-region pt (point)))          (- (viper-chars-in-region pt (point)))
2661        (viper-chars-in-region pt (point)))))        (viper-chars-in-region pt (point)))))
# Line 2656  On reaching beginning of line, stop and Line 2669  On reaching beginning of line, stop and
2669    (let ((pt (point)))    (let ((pt (point)))
2670      (condition-case nil      (condition-case nil
2671          (backward-char arg)          (backward-char arg)
2672        (error))        (error nil))
2673      (if (> (point) pt) ; arg was negative      (if (> (point) pt) ; arg was negative
2674          (viper-chars-in-region pt (point))          (viper-chars-in-region pt (point))
2675        (- (viper-chars-in-region pt (point))))))        (- (viper-chars-in-region pt (point))))))
# Line 3323  controlled by the sign of prefix numeric Line 3336  controlled by the sign of prefix numeric
3336  ;; (which is called from viper-search-forward/backward/next).  If the value of  ;; (which is called from viper-search-forward/backward/next).  If the value of
3337  ;; viper-search-scroll-threshold is negative - don't scroll.  ;; viper-search-scroll-threshold is negative - don't scroll.
3338  (defun viper-adjust-window ()  (defun viper-adjust-window ()
3339    (let ((win-height (if viper-emacs-p    (let ((win-height (viper-cond-compile-for-xemacs-or-emacs
3340                          (1- (window-height)) ; adjust for modeline                       (window-displayed-height) ; xemacs
3341                        (window-displayed-height)))                       ;; emacs
3342                         (1- (window-height)) ; adjust for modeline
3343                         ))
3344          (pt (point))          (pt (point))
3345          at-top-p at-bottom-p          at-top-p at-bottom-p
3346          min-scroll direction)          min-scroll direction)
# Line 4575  One can use `` and '' to temporarily jum Line 4590  One can use `` and '' to temporarily jum
4590            (t (error viper-InvalidTextmarker reg)))))            (t (error viper-InvalidTextmarker reg)))))
4591    
4592    
   
 ;; commands in insertion mode  
4593    
4594  (defun viper-delete-backward-word (arg)  (defun viper-delete-backward-word (arg)
4595    "Delete previous word."    "Delete previous word."
# Line 4587  One can use `` and '' to temporarily jum Line 4600  One can use `` and '' to temporarily jum
4600      (delete-region (point) (mark t))      (delete-region (point) (mark t))
4601      (pop-mark)))      (pop-mark)))
4602    
4603    
4604    
4605    ;; Get viper standard value of SYMBOL.  If symbol is customized, get its
4606    ;; standard value.  Otherwise, get the value saved in the alist STORAGE.  If
4607    ;; STORAGE is nil, use viper-saved-user-settings.
4608    (defun viper-standard-value (symbol &optional storage)
4609      (or (eval (car (get symbol 'customized-value)))
4610          (eval (car (get symbol 'saved-value)))
4611          (nth 1 (assoc symbol (or storage viper-saved-user-settings)))))
4612    
4613    
4614    
4615  (defun viper-set-expert-level (&optional dont-change-unless)  (defun viper-set-expert-level (&optional dont-change-unless)
4616    "Sets the expert level for a Viper user.    "Sets the expert level for a Viper user.
# Line 4913  Mail anyway (y or n)? ") Line 4937  Mail anyway (y or n)? ")
4937            (require 'reporter)            (require 'reporter)
4938            (set-window-configuration window-config)            (set-window-configuration window-config)
4939    
4940            (reporter-submit-bug-report "kifer@cs.sunysb.edu"            (reporter-submit-bug-report "kifer@cs.stonybrook.edu"
4941                                        (viper-version)                                        (viper-version)
4942                                        varlist                                        varlist
4943                                        nil 'delete-other-windows                                        nil 'delete-other-windows
# Line 4921  Mail anyway (y or n)? ") Line 4945  Mail anyway (y or n)? ")
4945            ))            ))
4946    
4947    
   
 ;; Smoothes out the difference between Emacs' unread-command-events  
 ;; and XEmacs unread-command-event.  Arg is a character, an event, a list of  
 ;; events or a sequence of keys.  
 ;;  
 ;; Due to the way unread-command-events in Emacs (not XEmacs), a non-event  
 ;; symbol in unread-command-events list may cause Emacs to turn this symbol  
 ;; into an event.  Below, we delete nil from event lists, since nil is the most  
 ;; common symbol that might appear in this wrong context.  
 (defun viper-set-unread-command-events (arg)  
   (if viper-emacs-p  
       (setq  
        unread-command-events  
        (let ((new-events  
               (cond ((eventp arg) (list arg))  
                     ((listp arg) arg)  
                     ((sequencep arg)  
                      (listify-key-sequence arg))  
                     (t (error  
                         "viper-set-unread-command-events: Invalid argument, %S"  
                         arg)))))  
          (if (not (eventp nil))  
              (setq new-events (delq nil new-events)))  
          (append new-events unread-command-events)))  
     ;; XEmacs  
     (setq  
      unread-command-events  
      (append  
       (cond ((viper-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))  
             (t (error  
                 "viper-set-unread-command-events: Invalid argument, %S" arg)))  
       unread-command-events))))  
   
 ;; list is assumed to be a list of events of characters  
 (defun viper-eventify-list-xemacs (lis)  
   (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))  
     
4948        
4949    
4950  ;;; viper-cmd.el ends here  ;;; viper-cmd.el ends here

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26