Commits

Anonymous committed 096a547

SJ3 fixes

Comments (0)

Files changed (5)

+1999-03-05  Katsumi Yamaoka <yamaoka@jpl.org>
+
+	* egg-sj3.el (henkan-region-internal): Use
+	`buffer-substring-no-properties' instead of `buffer-substring'.
+
+	* egg.el (its:simulate-input): Use `sref' instead of `aref'.
+	(its-defrule**): Ditto.
+
+1999-03-04
+	* egg-sj3.el (henkan-region-internal):  Bug fix: henkan-region
+	didn't work.
+
+1999-02-28  Masahiro MURATA <muse@ba2.so-net.ne.jp>
+
+	* egg.el (suspend-undo): New function to save the buffer-undo-list
+	and bind it to t.
+	(enter-fence-mode): Use it.
+	(resume-undo-list): New function to restore the saved buffer-undo-list.
+	(fence-exit-internal): Use it.
+	(egg-buffer-undo-list): New variable for the saved buffer-undo-list.
+
+	* egg-wnn.el (henkan-kakutei-first-char): Use `resume-undo-list'.
+	(henkan-kakutei): Ditto.
+	(sai-henkan): Use `suspend-undo', `resume-undo-list'.
+	(henkan-region-internal): Ditto.
+
+	* egg-sj3.el (henkan-kakutei): Use `resume-undo-list'.
+	(henkan-region-internal): Use `suspend-undo'.
+
+1998-10-22  Takeshi YAMADA <yamada@cslab.kecl.ntt.co.jp>
+
+	* egg-sj3.el (henkan-region-internal): Bug fix - wrong logic at
+	unwind-protect.
+
+	(TopLevel): Make `egg:henkan-mode-in-use' buffer-local.
+
+1998-10-10  Takeshi YAMADA <yamada@cslab.kecl.ntt.co.jp>
+
+	(TopLevel): Make `egg:henkan-mode-in-use' buffer-local.
+
+1998-10-03  Katsumi Yamaoka <yamaoka@ga.sony.co.jp>
+	
+	(fence-post-command-hook): Abolished.
+	(egg:quit-egg-mode): Don't use `fence-post-command-hook'.
+	(enter-fence-mode): Don't use `fence-post-command-hook'.
+	* egg-sj3.el (henkan-mode-map): Use `minor-mode-map-alist' instead
+	of a local-map.
+	(henkan-quit, henkan-kakutei-before-point): Don't use
+	`fence-mode-map' as a local-map.
+	(henkan-region-internal): Don't use `henkan-mode-map' as a
+	local-map; don't use `egg:*local-map-backup*'.
+
+1998-07-06  SAKAI Kiyotaka <ksakai@netwk.ntt-at.co.jp>
+
+	* egg-wnn.el (henkan-mode-map): Use `minor-mode-map-alist' instead
+	of a local-map.
+	(henkan-quit): Don't use `fence-mode-map' as a local-map.
+	(sai-henkan): Don't use `henkan-mode-map' as a local-map; don't
+	use `egg:*local-map-backup*'.
+	(henkan-kakutei-before-point): Don't use `fence-mode-map' as a
+	local-map.
+	(henkan-region-internal): Don't use `henkan-mode-map' as a
+	local-map; don't use `egg:*local-map-backup*'.
+	(read-current-its-string): Don't bind `minibuffer-exit-hook'.
+	
+1998-07-06  Kazu Yamamoto <kazu@iijlab.net>
+	
+	* egg.el (fence-mode-map): Use `minor-mode-map-alist' instead of a
+	local-map.
+	(read-hiragana-string): Don't bind `minibuffer-exit-hook'.
+	(egg:quit-egg-mode): Don't use `egg:*local-map-backup*'.
+	(enter-fence-mode): Don't use `egg:*local-map-backup*' or
+	`fence-mode-map'.
+	(egg:*local-map-backup*): Abolished.
+	(egg:*global-map-backup*): Abolished.
+
 1999-01-04  YOKOTA Hiroshi <y5t0964@students.chiba-u.ac.jp>
 
 	* egg.el: defvar (not defconst) some user parameters
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.15
+VERSION = 1.16
 AUTHOR_VERSION =
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = egg-its
 
 (defconst egg:*henkan-open*  "|" "*$BJQ49$N;OE@$r<($9J8;zNs(B")
 (defconst egg:*henkan-close* "|" "*$BJQ49$N=*E@$r<($9J8;zNs(B")
-(defvar egg:henkan-mode-in-use nil)
+
+(make-variable-buffer-local
+ (defvar egg:henkan-mode-in-use nil "buffer $B$,JQ49Cf$N;~(B t"))
 
 (defun egg:henkan-face-on ()
   (when egg:*henkan-face*
 	(unwind-protect
 	    (progn
 	      (setq egg:henkan-mode-in-use t
-		    egg:*kanji-kanabuff* (buffer-substring start end))
+		    egg:*kanji-kanabuff* (buffer-substring-no-properties
+					  start end))
 	      (setq *bunsetu-number* 0)
 	      (let ((result (KKCP:henkan-begin egg:*kanji-kanabuff*)))
 		(when result
 		  (if (null (marker-position egg:*region-start*))
 		      (progn
                       ;;;(setq egg:*global-map-backup* (current-global-map))
-			(setq egg:*local-map-backup* (current-local-map))
+			;;(setq egg:*local-map-backup* (current-local-map))
 			;; XEmacs change:
-			(buffer-disable-undo (current-buffer))
+			;;(buffer-disable-undo (current-buffer))
 			(goto-char start)
 			(delete-region start end)
+			(suspend-undo)
 			(insert egg:*henkan-open*)
 			(set-marker egg:*region-start* (point))
 			(insert egg:*henkan-close*)
 		      (set-marker egg:*region-end* point))
 		    (goto-char start)
 		    (delete-region start end)
+		    )
 		    (henkan-insert-kouho 0)
 		    (egg:henkan-face-on)
 		    (egg:bunsetu-face-on *bunsetu-number*)
 		    (henkan-goto-bunsetu 0)
 		    ;;(use-global-map henkan-mode-map)
 		    ;;(use-local-map nil)
-		    (use-local-map henkan-mode-map)))
+		    ;;(use-local-map henkan-mode-map)
+		    ))
 		(setq finished t))
 	      (or finished
-		  (setq egg:henkan-mode-in-use nil)))))))
-
+		  (setq egg:henkan-mode-in-use nil))))))
 
 (defun henkan-paragraph ()
   "Kana-kanji henkan  paragraph at or after point."
   (delete-region egg:*region-start* egg:*region-end*)
   (delete-region egg:*region-end* (+ egg:*region-end* (length egg:*henkan-close*)))
   (goto-char egg:*region-start*)
+  (resume-undo-list)
   (let ((i 0) (max (bunsetu-su)))
     (while (< i max)
       ;;;(KKCP:henkan-kakutei i (bunsetu-kouho-number i))
   ;;;(use-global-map fence-mode-map)
   ;;;(use-local-map  nil)
   (setq egg:henkan-mode-in-use nil)
-  (use-local-map fence-mode-map)
+  ;;(use-local-map fence-mode-map)
   (egg:mode-line-display))
 
 (defun egg:set-bunsetu-face (no face switch)
   ;;;(use-global-map fence-mode-map)
   ;;;(use-local-map  nil)
   (setq egg:henkan-mode-in-use nil)
-  (use-local-map fence-mode-map)
+  ;;(use-local-map fence-mode-map)
   (egg:mode-line-display)
   )
 
 (define-key henkan-mode-map "\C-z" 'undefined)
 (define-key henkan-mode-map "\177" 'henkan-quit)
 
+(unless (assq 'egg:henkan-mode-in-use minor-mode-map-alist)
+  (setq minor-mode-map-alist
+	(cons (cons 'egg:henkan-mode-in-use henkan-mode-map)
+	      minor-mode-map-alist)))
+
 (defun henkan-help-command ()
   "Display documentation fo henkan-mode."
   (interactive)
 (defvar egg:*henkan-open*  "|" "*$BJQ49$N;OE@$r<($9J8;zNs(B")
 (defvar egg:*henkan-close* "|" "*$BJQ49$N=*E@$r<($9J8;zNs(B")
 
-(defvar egg:henkan-mode-in-use nil)
+(make-variable-buffer-local
+ (defvar egg:henkan-mode-in-use nil "buffer $B$,JQ49Cf$N;~(B t"))
 
 ;;; ----------------------------------------------------------------
 ;;;	$B0J2<$N(B its mode $B4X78$N4X?t$O!"(Begg.el $B$GDj5A$5$l$F$$$k$,!"(B
 (defun read-current-its-string (prompt &optional initial-input henkan)
   (let ((egg:fence-buffer (window-buffer (minibuffer-window)))
         (old-its-map its:*current-map*)
-        (minibuffer-exit-hook
-         (append minibuffer-exit-hook
-                 '((lambda () (use-local-map minibuffer-local-map))))))
+        ;;(minibuffer-exit-hook
+        ;; (append minibuffer-exit-hook
+        ;;         '((lambda () (use-local-map minibuffer-local-map)))))
+	)
   (save-excursion
     (set-buffer egg:fence-buffer)
     (setq egg:*input-mode* t
 		      (if (null (marker-position egg:*region-start*))
 			  (progn
 			    ;;;(setq egg:*global-map-backup* (current-global-map))
-			    (setq egg:*local-map-backup* (current-local-map))
+			    ;;(setq egg:*local-map-backup* (current-local-map))
 			    (and (boundp 'disable-undo) (setq disable-undo t))
 			    (delete-region start end)
+			    (suspend-undo)
 			    (goto-char start)
 			    (insert egg:*henkan-open*)
 			    (set-marker egg:*region-start* (point))
 		      (henkan-goto-bunsetu 0)
 		      ;;;(use-global-map henkan-mode-map)
 		      ;;;(use-local-map nil)
-		      (use-local-map henkan-mode-map)
+		      ;;(use-local-map henkan-mode-map)
 		      (run-hooks 'egg:henkan-start-hook)))))
 	    (setq finished t))
-	(or finished (setq disable-undo nil) (setq egg:henkan-mode-in-use nil)))))
+	(or finished (setq disable-undo nil) (setq egg:henkan-mode-in-use nil)
+	    (resume-undo-list)))))
   )
 
 (defun henkan-paragraph ()
   (delete-region egg:*region-end* (+ egg:*region-end* (length egg:*henkan-close*)))
   (goto-char egg:*region-start*)
   (setq egg:*sai-henkan-start* (point))
+  (resume-undo-list)
   (let ((i 0) (max (wnn-server-bunsetu-suu)))
     (setq egg:*old-bunsetu-suu* max)
     (while (< i max)
 				     ;; 92.8.5  by Y.Kasai
 				     (length egg:*henkan-close*)))
   (goto-char egg:*region-start*)
+  (resume-undo-list)
   (insert (car (wnn-server-bunsetu-kanji 0)))
   (if (not overwrite-mode)
       (undo-boundary))
   ;;;(use-global-map fence-mode-map)
   ;;;(use-local-map  nil)
   (setq egg:henkan-mode-in-use nil)
-  (use-local-map fence-mode-map)
+  ;;(use-local-map fence-mode-map)
   (egg:mode-line-display))
 
 ;; ### Should probably put this on a key.
 	 (setq egg:henkan-mode-in-use t)
 	 (mode-line-egg-mode-update (egg:msg-get 'henkan-mode-indicator))
 	 (goto-char egg:*sai-henkan-start*)
-	 (setq egg:*local-map-backup* (current-local-map))
+	 (suspend-undo)
+	 ;;(setq egg:*local-map-backup* (current-local-map))
 	 (and (boundp 'disable-undo) (setq disable-undo t))
 	 (delete-region egg:*sai-henkan-start* egg:*sai-henkan-end*)
 	 (goto-char egg:*sai-henkan-start*)
 	 (egg:henkan-face-on)
 	 (egg:bunsetu-face-on)
 	 (henkan-goto-bunsetu 0)
-	 (use-local-map henkan-mode-map)
+	 ;;(use-local-map henkan-mode-map)
 	 (setq finished t))
-       (or finished (setq disable-undo nil) (setq egg:henkan-mode-in-use nil)))))
+       (or finished (setq disable-undo nil) (setq egg:henkan-mode-in-use nil)
+	   (resume-undo-list)))))
   )
 
 (defun egg:bunsetu-face-on ()
   ;;;(use-global-map fence-mode-map)
   ;;;(use-local-map  nil)
   (setq egg:henkan-mode-in-use nil)
-  (use-local-map fence-mode-map)
+  ;;(use-local-map fence-mode-map)
   (egg:mode-line-display)
   )
 
 (define-key henkan-mode-map [down] 'henkan-next-kouho)
 (define-key henkan-mode-map [up] 'henkan-previous-kouho)
 
+(unless (assq 'egg:henkan-mode-in-use minor-mode-map-alist)
+  (setq minor-mode-map-alist
+	(cons (cons 'egg:henkan-mode-in-use henkan-mode-map)
+	      minor-mode-map-alist)))
+
 (defun henkan-help-command ()
   "Display documentation for henkan-mode."
   (interactive)
 (put 'its:*current-map* 'permanent-local t)
 (put 'mode-line-egg-mode 'permanent-local t)
 
+;; undo functions.
+(make-variable-buffer-local
+ (defvar egg-buffer-undo-list nil))
+
+(defun suspend-undo ()
+  (setq egg-buffer-undo-list buffer-undo-list)
+  (setq buffer-undo-list t)
+  )
+
+(defun resume-undo-list ()
+  (setq buffer-undo-list egg-buffer-undo-list))
+
 ;;;----------------------------------------------------------------------
 ;;;
 ;;; 16$B?JI=8=$N(BJIS $B4A;z%3!<%I$r(B minibuffer $B$+$iFI$_9~$`(B
 		 map)))
        (t
 	(let((newmap
-	      (or (get-next-map-locally map (sref input i))
+	      (or (get-next-map-locally map (aref input i))
 		  (make-map (funcall its:make-non-terminal-state
 				     map
-				     (substring input 0 (+ i (char-bytes (sref input i)))))))))
-	  (set-next-map map (sref input i) 
-			(its-defrule** (+ i (char-bytes (sref input i))) input action state newmap)))
+				     (substring input 0 (+ i (char-bytes (aref input i)))))))))
+	  (set-next-map map (aref input i) 
+			(its-defrule** (+ i (char-bytes (aref input i))) input action state newmap)))
 	(if (and (null (map-action map))
 		 (map-terminalp map))
 	    nil
       
 (defun its:simulate-input (i j  input map)
   (while (<= i j)
-    (setq map (get-next-map map (sref input i))) ;92.12.26 by S.Tomura
-    (setq i (+ i (char-bytes (sref input i)))))	;92.12.26 by S.Tomura
+    (setq map (get-next-map map (aref input i))) ;92.12.26 by S.Tomura
+    (setq i (+ i (char-bytes (aref input i)))))	;92.12.26 by S.Tomura
   map)
 
 ;;; meta-flag $B$,(B on $B$N;~$K$O!"F~NO%3!<%I$K(B \200 $B$r(B or $B$7$?$b$N$,F~NO$5(B
 (defvar egg:*region-end* nil)
 (make-variable-buffer-local 'egg:*region-end*)
 (set-default 'egg:*region-end* nil)
-(defvar egg:*global-map-backup* nil)
-(defvar egg:*local-map-backup*  nil)
+;;(defvar egg:*global-map-backup* nil)
+;;(defvar egg:*local-map-backup*  nil)
 
 
 ;;; Moved to kanji.el
 
   ;; XEmacs change:
 ;  (buffer-disable-undo (current-buffer))
-  (undo-boundary)
+  (suspend-undo)
   (setq egg:*in-fence-mode* t
 	egg:fence-buffer (current-buffer))
   (egg:mode-line-display)
   ;;;(setq egg:*global-map-backup* (current-global-map))
-  (setq egg:*local-map-backup*  (current-local-map))
+  ;;(setq egg:*local-map-backup*  (current-local-map))
   ;;;(use-global-map fence-mode-map)
   ;;;(use-local-map nil)
-  (use-local-map fence-mode-map)
+  ;;(use-local-map fence-mode-map)
   (egg:check-fence-in-cont)            ; for Wnn6
   (insert egg:*fence-open*)
   (or (markerp egg:*region-start*) (setq egg:*region-start* (make-marker)))
   (set-marker egg:*region-end* egg:*region-start*)
   (egg:fence-face-on)
   (goto-char egg:*region-start*)
-  (add-hook 'post-command-hook 'fence-post-command-hook)
+  ;;(add-hook 'post-command-hook 'fence-post-command-hook)
   )
 
 (defun henkan-fence-region-or-single-space ()
 
 (defun fence-exit-internal ()
   (egg:fence-face-off)
-  (delete-region (- egg:*region-start* (length egg:*fence-open*)) egg:*region-start*)
-  (delete-region egg:*region-end* (+ egg:*region-end* (length egg:*fence-close*)))
+  (let ((kakutei-string (buffer-substring
+			 egg:*region-start* egg:*region-end*)))
+    (delete-region (- egg:*region-start* (length egg:*fence-open*))
+		   egg:*region-start*)
+    (delete-region egg:*region-start* egg:*region-end*)
+    (delete-region egg:*region-end*
+		   (+ egg:*region-end* (length egg:*fence-close*)))
+    (goto-char egg:*region-start*)
+    (resume-undo-list)
+    (insert kakutei-string))
   (if its:*previous-map*
       (setq its:*current-map* its:*previous-map*
 	    its:*previous-map* nil))
 
 (defun egg:quit-egg-mode ()
   ;;;(use-global-map egg:*global-map-backup*)
-  (use-local-map egg:*local-map-backup*)
-  (remove-hook 'post-command-hook 'fence-post-command-hook)
+  ;;(use-local-map egg:*local-map-backup*)
+  ;;(remove-hook 'post-command-hook 'fence-post-command-hook)
   (setq egg:*in-fence-mode* nil)
   (egg:mode-line-display)
   (if overwrite-mode
   (delete-region egg:*region-start* egg:*region-end*)
   (fence-exit-internal))
 
-(defun fence-post-command-hook ()
-  ;; For use as the value of `post-command-hook' when fence is active.
-  ;; If we got out of the region specified by the fence,
-  ;; kill the fence before that command is executed.
-  ;;
-  (cond ((not (eq (current-buffer) egg:fence-buffer))
-	 ;; If the buffer (likely meaning "frame") has changed, bail.
-	 ;; This can also happen if a proc filter has popped up another
-	 ;; buffer, which is arguably a bad thing for it to have done,
-	 ;; but the way in which egg would have hosed you in that
-	 ;; case is unarguably even worse.
-	 (save-excursion
-	   (set-buffer egg:fence-buffer)
-	   (its:reset-input)
-	   (fence-kill-operation)))
-	((or (< (point) egg:*region-start*)
-	     (> (point) egg:*region-end*))
-	 (save-excursion
-	   (its:reset-input)
-	   (fence-kill-operation)))))
+;;(defun fence-post-command-hook ()
+;;  ;; For use as the value of `post-command-hook' when fence is active.
+;;  ;; If we got out of the region specified by the fence,
+;;  ;; kill the fence before that command is executed.
+;;  ;;
+;;  (cond ((not (eq (current-buffer) egg:fence-buffer))
+;;	 ;; If the buffer (likely meaning "frame") has changed, bail.
+;;	 ;; This can also happen if a proc filter has popped up another
+;;	 ;; buffer, which is arguably a bad thing for it to have done,
+;;	 ;; but the way in which egg would have hosed you in that
+;;	 ;; case is unarguably even worse.
+;;	 (save-excursion
+;;	   (set-buffer egg:fence-buffer)
+;;	   (its:reset-input)
+;;	   (fence-kill-operation)))
+;;	((or (< (point) egg:*region-start*)
+;;	     (> (point) egg:*region-end*))
+;;	 (save-excursion
+;;	   (its:reset-input)
+;;	   (fence-kill-operation)))))
 
 (defun egg-lang-switch-callback ()
   "Do whatever processing is necessary when the language-environment changes."
 (define-key fence-mode-map [right] 'fence-forward-char)
 (define-key fence-mode-map [left] 'fence-backward-char)
 
+(unless (assq 'egg:*in-fence-mode* minor-mode-map-alist)
+  (setq minor-mode-map-alist
+	(cons (cons 'egg:*in-fence-mode* fence-mode-map)
+	      minor-mode-map-alist)))
+
 ;;;----------------------------------------------------------------------
 ;;;
 ;;; Read hiragana from minibuffer
 
 (defun read-hiragana-string (prompt &optional initial-input)
   (let ((egg:fence-buffer (window-buffer (minibuffer-window)))
-	(minibuffer-exit-hook
-	 (append minibuffer-exit-hook
-		 '((lambda () (use-local-map minibuffer-local-map))))))
+	;;(minibuffer-exit-hook
+	;; (append minibuffer-exit-hook
+	;;	 '((lambda () (use-local-map minibuffer-local-map)))))
+	)
     (save-excursion
       (set-buffer egg:fence-buffer)
       (setq egg:*input-mode* t