Commits

Anonymous committed e5b5e4f

2001-09-09 Michael Kifer <kifer@cs.sunysb.edu>

* viper-cmd.el (viper-special-read-and-insert-char): new function
that reads a character and uses the current input method or
iso-accents when appropriate.

* viper.el and all others: corrections to the comment blocks at
the top.

  • Participants
  • Parent commits 7dc9f47

Comments (0)

Files changed (9)

+2001-09-09  Michael Kifer  <kifer@cs.sunysb.edu>
+	
+	* viper-cmd.el (viper-special-read-and-insert-char): new function
+	that reads a character and uses the current input method or
+	iso-accents when appropriate.
+	
+	* viper.el and all others: corrections to the comment blocks at
+	the top.
+	
 2001-07-21  Michael Kifer  <kifer@cs.sunysb.edu>
 	
 	* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy

File viper-cmd.el

 ;;; viper-cmd.el --- Vi command support for Viper
+
 ;; Copyright (C) 1997 Free Software Foundation, Inc.
 
+;; Author: Michael Kifer <kifer@cs.sunysb.edu>
+
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
   ;; set state in the new buffer
   (viper-set-mode-vars-for viper-current-state))
 
+;; This is used in order to allow reading characters according to the input
+;; method. The character is read in emacs and inserted into the buffer.
+;; If an input method is in effect, this might
+;; cause several characters to be combined into one.
+;; Also takes care of the iso-accents mode
+(defun viper-special-read-and-insert-char ()
+  (viper-set-mode-vars-for 'emacs-state)
+  (viper-normalize-minor-mode-map-alist)
+  (if viper-special-input-method
+      (viper-set-input-method t))
+  (if viper-automatic-iso-accents
+      (viper-set-iso-accents-mode t))
+  (condition-case nil
+      (let (viper-vi-kbd-minor-mode
+	    viper-insert-kbd-minor-mode
+	    viper-emacs-kbd-minor-mode
+	    ch)
+	(cond ((and viper-special-input-method
+		    viper-emacs-p
+		    (fboundp 'quail-input-method))
+	       ;; (let ...) is used to restore unread-command-events to the
+	       ;; original state. We don't want anything left in there after
+	       ;; key translation. (Such left-overs are possible if the user
+	       ;; types a regular key.)
+	       (let (unread-command-events)
+		 ;; The next 2 cmds are intended to prevent the input method
+		 ;; from swallowing ^M, ^Q and other special characters
+		 (setq ch (read-char))
+		 (viper-set-unread-command-events ch)
+		 (quail-input-method nil)
+
+		 (if (and ch (string= quail-current-str ""))
+		     (insert ch)
+		   (insert quail-current-str))
+		 (setq ch (or ch
+			      (aref quail-current-str
+				    (1- (length quail-current-str)))))
+		 ))
+	      ((and viper-special-input-method
+		    viper-xemacs-p
+		    (fboundp 'quail-start-translation))
+	       ;; same as above but for XEmacs, which doesn't have
+	       ;; quail-input-method
+	       (let (unread-command-events)
+		 (setq ch (read-char))
+		 (viper-set-unread-command-events ch)
+		 (quail-start-translation nil)
+
+		 (if (and ch (string= quail-current-str ""))
+		     (insert ch)
+		   (insert quail-current-str))
+		 (setq ch (or ch
+			      (aref quail-current-str
+				    (1- (length quail-current-str)))))
+		 ))
+	      ((and (boundp 'iso-accents-mode) iso-accents-mode)
+	       (setq ch (aref (read-key-sequence nil) 0))
+	       (insert ch))
+	      (t
+	       (setq ch (read-char))
+	       (insert ch))
+	      )
+	(setq last-command-event
+	      (viper-copy-event (if viper-xemacs-p
+				    (character-to-event ch) ch)))
+	) ; let
+    (error)
+    ) ; condition-case
+      
+  (viper-set-input-method nil)
+  (viper-set-iso-accents-mode nil)
+  (viper-set-mode-vars-for viper-current-state)
+  )
+
+
 (defun viper-exec-form-in-vi  (form)
   "Execute FORM in Vi state, regardless of the Ccurrent Vi state."
   (let ((buff (current-buffer))
   (interactive "P")
   (viper-set-complex-command-for-undo)
   (let ((val (viper-p-val arg))
-	(com (viper-getcom arg)))
+	;;(com (viper-getcom arg))
+	)
     (viper-set-destructive-command (list 'viper-insert val ?r nil nil nil))
     (if (eq viper-intermediate-command 'viper-repeat)
 	(viper-loop val (viper-yank-last-insertion))
   (interactive "P")
   (viper-set-complex-command-for-undo)
   (let ((val (viper-p-val arg))
-	(com (viper-getcom arg)))
+	;;(com (viper-getcom arg))
+	)
     (viper-set-destructive-command (list 'viper-append val ?r nil nil nil))
     (if (not (eolp)) (forward-char))
     (if (eq viper-intermediate-command 'viper-repeat)
   (interactive "P")
   (viper-set-complex-command-for-undo)
   (let ((val (viper-p-val arg))
-	(com (viper-getcom arg)))
+	;;(com (viper-getcom arg))
+	)
     (viper-set-destructive-command (list 'viper-Append val ?r nil nil nil))
     (end-of-line)
     (if (eq viper-intermediate-command 'viper-repeat)
   (interactive "P")
   (viper-set-complex-command-for-undo)
   (let ((val (viper-p-val arg))
-	(com (viper-getcom arg)))
+	;;(com (viper-getcom arg))
+	)
     (viper-set-destructive-command (list 'viper-Insert val ?r nil nil nil))
     (back-to-indentation)
     (if (eq viper-intermediate-command 'viper-repeat)
   (interactive "P")
   (viper-set-complex-command-for-undo)
   (let ((val (viper-p-val arg))
-	(com (viper-getcom arg)))
+	;;(com (viper-getcom arg))
+	)
     (viper-set-destructive-command (list 'viper-open-line val ?r nil nil nil))
     (let ((col (current-indentation)))
       (if (eq viper-intermediate-command 'viper-repeat)
   (interactive "P")
   (viper-set-complex-command-for-undo)
   (let ((val (viper-p-val arg))
-	(com (viper-getcom arg)))
+	;;(com (viper-getcom arg))
+	)
     (viper-set-destructive-command (list 'viper-Open-line val ?r nil nil nil))
     (let ((col (current-indentation)))
       (if (eq viper-intermediate-command 'viper-repeat)
   (interactive "P")
   (viper-set-complex-command-for-undo)
   (let ((val (viper-p-val arg))
-	(com (viper-getcom arg)))
+	;;(com (viper-getcom arg))
+	)
     (viper-set-destructive-command
      (list 'viper-open-line-at-point val ?r nil nil nil))
     (if (eq viper-intermediate-command 'viper-repeat)
   "Substitute characters."
   (interactive "P")
   (let ((val (viper-p-val arg))
-	(com (viper-getcom arg)))
+	;;(com (viper-getcom arg))
+	)
     (push-mark nil t)
     (forward-char val)
     (if (eq viper-intermediate-command 'viper-repeat)
   "Begin overwrite mode."
   (interactive "P")
   (let ((val (viper-p-val arg))
-	(com (viper-getcom arg)) (len))
+	;;(com (viper-getcom arg))
+	(len))
     (viper-set-destructive-command (list 'viper-overwrite val ?r nil nil nil))
     (if (eq viper-intermediate-command 'viper-repeat)
 	(progn
   ))
 
 (defun viper-replace-char-subr (com arg)
-  (let (char)
-    (setq char (if (eq viper-intermediate-command 'viper-repeat)
-		   viper-d-char
-		 (read-char)))
-    (let (inhibit-quit) ; preserve consistency of undo-list and iso-accents
-      (if (and  viper-automatic-iso-accents
-		(viper-memq-char char '(?' ?\" ?^ ?~)))
-	  ;; get European characters
-	  (progn
-	    (viper-set-iso-accents-mode t)
-	    (viper-set-unread-command-events char)
-	    (setq char (aref (read-key-sequence nil) 0))
-	    (viper-set-iso-accents-mode nil)))
-      (viper-set-complex-command-for-undo)
-      (if (eq char ?\C-m) (setq char ?\n))
-      (if (and viper-special-input-method (fboundp 'quail-start-translation))
-	  ;; get Intl. characters
-	  (progn
-	    (viper-set-input-method t)
-	    (setq last-command-event
-		  (viper-copy-event
-		   (if viper-xemacs-p (character-to-event char) char)))
-	    (delete-char 1 t)
-	    (condition-case nil
-		(if com
-		    (insert char)
-		  (if viper-emacs-p
-		      (quail-start-translation 1)
-		    (quail-start-translation)))
-	      (error))
-	    ;; quail translation failed
-	    (if (and (not (stringp quail-current-str))
-		     (not (viper-characterp quail-current-str)))
-		(progn
-		  (viper-adjust-undo)
-		  (undo-start)
-		  (undo-more 1)
-		  (viper-set-input-method nil)
-		  (error "Composing character failed, changes undone")))
-	    ;; quail translation seems ok
-	    (or com
-		;;(setq char quail-current-str))
-		(setq char (viper-char-at-pos 'backward)))
-	    (setq viper-d-char char)
-	    (viper-loop (1- (if (> arg 0) arg (- arg)))
-			(delete-char 1 t)
-			(insert char))
-	    (viper-set-input-method nil))
-	(delete-char arg t)
-	(setq viper-d-char char)
-	(viper-loop (if (> arg 0) arg (- arg))
-		    (insert char)))
+  (let (char inhibit-quit)
+    (viper-set-complex-command-for-undo)
+    (or (eq viper-intermediate-command 'viper-repeat)
+	(viper-special-read-and-insert-char))
+
+      (delete-char 1 t)
+
+      (setq char (if com viper-d-char (viper-char-at-pos 'backward)))
+      (if com (insert char))
+
+      (setq viper-d-char char)
+
+      (viper-loop (1- (if (> arg 0) arg (- arg)))
+		  (delete-char 1 t)
+		  (insert char))
+
       (viper-adjust-undo)
-      (backward-char arg))))
+      (backward-char arg)
+      ))
 
 
 ;; basic cursor movement.  j, k, l, h commands.
 
 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
 
+;; Author: Michael Kifer <kifer@cs.sunysb.edu>
+
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify

File viper-init.el

 
 ;; Copyright (C) 1997 Free Software Foundation, Inc.
 
+;; Author: Michael Kifer <kifer@cs.sunysb.edu>
+
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify

File viper-keym.el

 
 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
 
+;; Author: Michael Kifer <kifer@cs.sunysb.edu>
+
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify

File viper-macs.el

 
 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
 
+;; Author: Michael Kifer <kifer@cs.sunysb.edu>
+
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify

File viper-mous.el

 
 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
 
+;; Author: Michael Kifer <kifer@cs.sunysb.edu>
+
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify

File viper-util.el

 
 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
 
+;; Author: Michael Kifer <kifer@cs.sunysb.edu>
+
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
        ;; CVS files are considered not checked in
        (not (memq (vc-backend file) '(nil CVS)))
        (if (fboundp 'vc-state)
-	   (progn
+	   (and
 	     (not (memq (vc-state file) '(edited needs-merge)))
 	     (not (stringp (vc-state file))))
 	 ;; XEmacs has no vc-state
 ;;		 a VI Plan for Emacs Rescue,
 ;;		 and a venomous VI PERil.
 ;;		 Viper Is also a Package for Emacs Rebels.
-;;
-;; Keywords: emulations
-;; Author: Michael Kifer <kifer@cs.sunysb.edu>
 
 ;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 Free Software Foundation, Inc.
 
-(defconst viper-version "3.11 of July 18, 2001"
+;; Author: Michael Kifer <kifer@cs.sunysb.edu>
+;; Keywords: emulations
+
+(defconst viper-version "3.11.1 of September 9, 2001"
   "The current version of Viper")
 
 ;; This file is part of GNU Emacs.