From: kate Date: Fri, 20 Feb 1998 12:16:43 +0000 (+0000) Subject: bug fix (confuse conversion environment) and re-enter fence mode on C-k X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fegg-980219;p=elisp%2Fegg.git bug fix (confuse conversion environment) and re-enter fence mode on C-k --- diff --git a/ChangeLog b/ChangeLog index e27efae..9989248 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +1998-02-20 KATAYAMA Yoshio + + * its.el (its-restart): New function. + (its-insert-fence-open, its-insert-fence-close): New function. + (its-start): Rewritten. Use its-insert-fence-open and + its-insert-fence-close. + (its-exit-mode-internal): Leave its-syl property. + (its-exit-mode-internal): Delete the property in this case. + (its-keydef): Require it. + + * its-keydef.el: Provide the feature. + + * egg-cnv.el (egg-convert-region): Add egg-source property to save + the source string. + (egg-conversion-map, \C-c): New keybind. + (egg-get-previous-bunsetsu): Bug fix. + (egg-decide-before-point): New implementation. + (egg-exit-conversion): Use gg-decide-before-point. + (egg-abort-conversion): New command. + +1998-02-20 NIIBE Yutaka + + * Makefile (SRCS), Egg.prj: Remove euc-china.el. + * egg-com.el: Include egg-china.el. + * egg-china.el: Removed. + 1998-02-18 NIIBE Yutaka * Egg.prj: Use PRCS. diff --git a/egg-cnv.el b/egg-cnv.el index 76a748b..b743c77 100644 --- a/egg-cnv.el +++ b/egg-cnv.el @@ -117,7 +117,11 @@ (narrow-to-region start end) (goto-char start) (insert egg-conversion-open) - (put-text-property start (point) 'egg-start t) + (add-text-properties start (point) + (list + 'egg-start t + 'egg-source (buffer-substring (point) + (point-max)))) (if egg-conversion-face (put-text-property start (point) 'invisible t)) (setq start (point)) @@ -229,6 +233,7 @@ (define-key map [?\C-\ ] 'egg-decide-first-char) (define-key map "\C-a" 'egg-beginning-of-conversion-buffer) (define-key map "\C-b" 'egg-backward-bunsetsu) + (define-key map "\C-c" 'egg-abort-conversion) (define-key map "\C-e" 'egg-end-of-conversion-buffer) (define-key map "\C-f" 'egg-forward-bunsetsu) (define-key map "\C-h" 'egg-help-command) @@ -299,9 +304,9 @@ (signal 'end-of-buffer nil)))) (defun egg-get-previous-bunsetsu (p) - (if (get-text-property (1- p) 'egg-start) - nil - (egg-get-bunsetsu-info (- p 2)))) + (and (null (get-text-property (1- p) 'egg-start)) + (null (get-text-property (1- p) 'egg-bunsetsu-last)) + (egg-get-bunsetsu-info (- p 2)))) (defun egg-separate-characters (str) (let* ((v (string-to-vector str)) @@ -391,65 +396,61 @@ (interactive "p") (egg-next-candidate (- n))) -(defun egg-decide-bunsetsu (&optional end-marker) - (let ((in-loop t) - p bunsetsu-info-list bl) - (setq p (point)) - (while in-loop - (let ((bl1 (cons (egg-get-bunsetsu-info p) nil))) - (if bl - (setq bl (setcdr bl bl1)) - (setq bunsetsu-info-list (setq bl bl1)))) - (forward-char) - (remove-text-properties p (point) '(face nil - intangible nil - local-map nil - egg-bunsetsu-last nil)) - (setq p (point)) - (if (or (and end-marker (= p end-marker)) - (get-text-property p 'egg-end)) - (setq in-loop nil) - (setq p (1- p)) - (delete-region p (1+ p)))) ; Delete bunsetsu separator - bunsetsu-info-list)) - (defun egg-decide-before-point () (interactive) - (let ((m (make-marker)) - all start bunsetsu-list) - (if (get-text-property (1- (point)) 'egg-start) - (signal 'beginning-of-buffer nil) - (setq start (1- (previous-single-property-change (point) 'egg-start)))) - (set-marker m (point)) - (goto-char start) - ;; Delete open marker - (delete-region start (1+ start)) - (setq bunsetsu-list (egg-decide-bunsetsu m)) - ;; delete separator - (delete-region (1- (point)) (point)) - ;; insert open marker - (insert egg-conversion-open) - (put-text-property m (point) 'egg-start t) - (if egg-conversion-face - (put-text-property p (point) 'invisible t)) - (egg-end-conversion bunsetsu-list) - (set-marker m nil))) + (let (bunsetsu-list bl (p (point)) source (dlen 0) l s) + (save-restriction + (if (null (get-text-property (1- (point)) 'egg-start)) + (goto-char (previous-single-property-change (point) 'egg-start))) + (narrow-to-region (1- (point)) p) + (setq source (get-text-property (1- (point)) 'egg-source)) + (setq bunsetsu-list (setq bl (list nil))) + (while (< (point) (point-max)) + ;; delete sparator/open marker + (delete-region (1- (point)) (point)) + (setq bl (setcdr bl (list (egg-get-bunsetsu-info (point))))) + (setq dlen (+ dlen (length (egg-get-bunsetsu-source (car bl))))) + (if (get-text-property (point) 'egg-bunsetsu-last) + (progn + (egg-end-conversion (cdr bunsetsu-list)) + (setq bunsetsu-list (setq bl (list nil))))) + (setq p (point)) + (forward-char) + (remove-text-properties p (point) '(face nil + intangible nil + local-map nil + egg-bunsetsu-last nil)))) + (if (get-text-property (point) 'egg-end) + (progn + ;; delete close marker + (delete-region (point) (1+ (point))) + (egg-do-auto-fill) + (run-hooks 'input-method-after-insert-chunk-hook)) + ;; delete last from speparater to close marker + (delete-region (1- (point)) + (1+ (next-single-property-change (point) 'egg-end))) + ;; rebuild fence mode string + (setq p 0) + (while (< p dlen) + (setq s (car (get-text-property p 'its-syl source)) + l (length s) + p (+ p l)) + (if (> p dlen) + (put-text-property dlen p + 'its-syl (list (substring s (- dlen p))) + source))) + (its-restart (substring source dlen))))) (defun egg-exit-conversion () (interactive) - (let (start bunsetsu-list) - (if (get-text-property (1- (point)) 'egg-start) - (setq start (1- (point))) - (setq start (1- (previous-single-property-change (point) 'egg-start)))) - (goto-char start) - ;; Delete open marker - (delete-region start (1+ start)) - (setq bunsetsu-list (egg-decide-bunsetsu)) - ;; Delete close marker - (delete-region (point) (1+ (point))) - (egg-do-auto-fill) - (egg-end-conversion bunsetsu-list) - (run-hooks 'input-method-after-insert-chunk-hook))) + (goto-char (next-single-property-change (point) 'egg-end)) + (egg-decide-before-point)) + +(defun egg-abort-conversion () + (interactive) + (if (null (get-text-property (1- (point)) 'egg-start)) + (goto-char (previous-single-property-change (point) 'egg-start))) + (egg-decide-before-point)) (defun egg-select-candidate () (interactive) diff --git a/its-keydef.el b/its-keydef.el index 90b77f1..d295424 100644 --- a/its-keydef.el +++ b/its-keydef.el @@ -58,3 +58,5 @@ ("H" hangul hangul hangul Korean) ("J" jeonkak-upcase jeonkak jeonkak-up Korean) ("j" jeonkak-downcase jeonkak jeonkak-down Korean))) + +(provide 'its-keydef) diff --git a/its.el b/its.el index 26aeb04..56bab98 100644 --- a/its.el +++ b/its.el @@ -222,28 +222,38 @@ ;; intangible intangible ;; 1 2 ;; -(defun its-start (key) - (let (p cursor) - (setq p (point)) +(defun its-insert-fence-open () + (let ((p (point))) (insert its-fence-open) - (add-text-properties p (point) - (let ((props '(its-start t intangible its-part-1))) - (if its-fence-face - (append '(invisible t) props) - props))) - (setq p (point)) - (setq cursor (its-input nil key)) - (its-put-cursor cursor) - (forward-char 1) - (setq p (point)) + (add-text-properties p (point) + (if its-fence-face + '(invisible t its-start t intangible its-part-1) + '(its-start t intangible its-part-1))))) + +(defun its-insert-fence-close () + (let ((p (point))) (insert its-fence-close) (add-text-properties p (point) - (let ((props '(its-end t intangible its-part-2))) - (if its-fence-face - (append '(invisible t) props) - props))) - (forward-char -2) - (force-mode-line-update))) + (if its-fence-face + '(invisible t its-end t intangible its-part-2) + '(its-end t intangible its-part-2))) + (goto-char p))) + +(defun its-start (key) + (its-insert-fence-open) + (its-insert-fence-close) + (its-put-cursor (its-input nil key)) + (force-mode-line-update)) + +(defun its-restart (str) + (let (p) + (its-insert-fence-open) + (its-insert-fence-close) + (setq p (point)) + (insert str) + (put-text-property p (point) 'intangible 'its-part-2) + (goto-char p) + (its-put-cursor t))) (defun its-self-insert-char () (interactive) @@ -688,13 +698,12 @@ Return last state." (setq end (next-single-property-change (point) 'its-end))) (delete-region end (1+ end)) ;; Remove all properties added by ITS - (remove-text-properties start end '(its-syl nil - its-map nil + (remove-text-properties start end '(its-map nil face nil intangible nil)) (if proceed-to-conversion (egg-convert-region start end) - (remove-text-properties start end '(its-lang nil)) + (remove-text-properties start end '(its-lang nil its-syl nil)) (egg-do-auto-fill) (run-hooks 'input-method-after-insert-chunk-hook)))) @@ -739,7 +748,7 @@ Return last state." (delete-region start end) (apply 'insert (reverse its-translation-result)))) -(load "its-keydef.el") +(require 'its-keydef) (provide 'its) ;;; its.el ends here.