[uim-commit] r2488 - trunk/emacs
ekato at freedesktop.org
ekato at freedesktop.org
Fri Dec 9 05:17:48 PST 2005
Author: ekato
Date: 2005-12-09 05:17:43 -0800 (Fri, 09 Dec 2005)
New Revision: 2488
Modified:
trunk/emacs/uim-candidate.el
trunk/emacs/uim-key.el
trunk/emacs/uim-keymap.el
trunk/emacs/uim-preedit.el
trunk/emacs/uim-var.el
trunk/emacs/uim.el
Log:
2005-12-09 Konosuke Watanabe
* emacs/uim-candidate.el
* emacs/uim-key.el
* emacs/uim-keymap.el
* emacs/uim-preedit.el
* emacs/uim-var.el
* emacs/uim.el
- Support candidates without preedit string.
Modified: trunk/emacs/uim-candidate.el
===================================================================
--- trunk/emacs/uim-candidate.el 2005-12-09 13:04:54 UTC (rev 2487)
+++ trunk/emacs/uim-candidate.el 2005-12-09 13:17:43 UTC (rev 2488)
@@ -64,7 +64,7 @@
;; mark current-point
(setq mark-base (point-marker))
- (uim-debug (format "before: %s" (marker-position mark-base)))
+ ;;(uim-debug (format "before: %s" (marker-position mark-base)))
;; save original string
(setq uim-candidate-original-str
@@ -90,7 +90,7 @@
(setq base-ofs (- (marker-position mark-base) uim-candidate-start))
(setq uim-candidate-start (+ uim-candidate-start base-ofs)))
- (uim-debug (format "after: %s" (marker-position mark-base)))
+ ;;(uim-debug (format "after: %s" (marker-position mark-base)))
(set-marker mark-base nil)
@@ -101,7 +101,7 @@
(setq offset
(uim-string-width (buffer-substring (point) uim-candidate-start))))
- (uim-debug (format "offset: %s" offset))
+ ;;(uim-debug (format "offset: %s" offset))
;; if offset + maxwidth >= window-width then reduce offset
(if (>= (+ offset maxwidth 2) (window-width))
@@ -583,11 +583,6 @@
(save-excursion
(goto-char uim-candidate-original-start)
(insert uim-candidate-original-str))
-
- ;; delete overlay
- ;;(mapcar 'delete-overlay uim-candidate-overlays)
- ;;(setq uim-candidate-overlays nil)
-
)
;; clear minibuffer
Modified: trunk/emacs/uim-key.el
===================================================================
--- trunk/emacs/uim-key.el 2005-12-09 13:04:54 UTC (rev 2487)
+++ trunk/emacs/uim-key.el 2005-12-09 13:17:43 UTC (rev 2488)
@@ -543,7 +543,7 @@
;;(uim-debug (format "stacked-key-vector: %s" uim-stacked-key-vector))
- (cond ((and uim-preedit-displayed
+ (cond ((and uim-preedit-keymap-enabled
(uim-is-escape uim-stacked-key-vector)) ;; preedit ESC-ESC
(uim-debug "Escape")
;; stop waiting and return ESC key
@@ -553,10 +553,10 @@
(setq keyvec (vector (uim-xemacs-make-event [escape]))))
(setq uim-stacked-key-vector nil)
)
- ((or (and uim-preedit-displayed ;; with preedit
+ ((or (and uim-preedit-keymap-enabled
(and replace-continue ;; wait ESC- key vector
(uim-is-start-with-escape uim-stacked-key-vector)))
- (and (not uim-preedit-displayed) ;; without preedit
+ (and (not uim-preedit-keymap-enabled)
(or replace-continue ;; wait all
(keymapp (uim-getbind uim-stacked-key-vector)))))
;; wait next
Modified: trunk/emacs/uim-keymap.el
===================================================================
--- trunk/emacs/uim-keymap.el 2005-12-09 13:04:54 UTC (rev 2487)
+++ trunk/emacs/uim-keymap.el 2005-12-09 13:17:43 UTC (rev 2488)
@@ -206,44 +206,65 @@
nil))
(defun uim-enable-preedit-keymap ()
- (setcdr (assq 'uim-mode minor-mode-map-alist)
- uim-preedit-map)
+ (when (not uim-preedit-keymap-enabled)
- (when (not uim-minor-mode-map-alist)
- (setq uim-minor-mode-map-alist minor-mode-map-alist)
- (setq minor-mode-map-alist (list (assq 'uim-mode minor-mode-map-alist)))
+ (setq uim-preedit-keymap-enabled t)
+ (uim-debug "enable preedit keymap")
- (when (and uim-emacs (= emacs-major-version 22))
- (setq uim-emulation-mode-map-alists emulation-mode-map-alists)
- (setq emulation-mode-map-alists nil)))
+ (setcdr (assq 'uim-mode minor-mode-map-alist)
+ uim-preedit-map)
- (when uim-xemacs
- (make-variable-buffer-local 'toolbar-map)
- (setq toolbar-map uim-toolbar-map)
- (uim-xemacs-save-menubar)
+ ;; disable other keymaps
+ (when (not uim-minor-mode-map-alist)
+ (setq uim-minor-mode-map-alist minor-mode-map-alist)
+ (setq minor-mode-map-alist (list (assq 'uim-mode minor-mode-map-alist)))
+
+ (when (and uim-emacs (= emacs-major-version 22))
+ (setq uim-emulation-mode-map-alists emulation-mode-map-alists)
+ (setq emulation-mode-map-alists nil)))
+
+ (when uim-xemacs
+ ;; disable toolbar and menubar
+ (make-variable-buffer-local 'toolbar-map)
+ (setq toolbar-map uim-toolbar-map)
+ (uim-xemacs-save-menubar))
)
-
)
(defun uim-disable-preedit-keymap ()
+ (when uim-preedit-keymap-enabled
+ (setq uim-preedit-keymap-enabled nil)
+ (uim-debug "disable preedit keymap")
- (when uim-minor-mode-map-alist
- (setq minor-mode-map-alist uim-minor-mode-map-alist)
- (setq uim-minor-mode-map-alist nil)
+ ;; enable other keymaps
+ (when uim-minor-mode-map-alist
+ (setq minor-mode-map-alist uim-minor-mode-map-alist)
+ (setq uim-minor-mode-map-alist nil)
- (when (and uim-emacs (= emacs-major-version 22))
- (setq emulation-mode-map-alists uim-emulation-mode-map-alists)
- (setq uim-emulation-mode-map-alists nil)))
+ (when (and uim-emacs (= emacs-major-version 22))
+ (setq emulation-mode-map-alists uim-emulation-mode-map-alists)
+ (setq uim-emulation-mode-map-alists nil)))
- (uim-enable-mode-keymap)
+ (uim-enable-mode-keymap)
- (when uim-xemacs
- (kill-local-variable 'toolbar-map)
- (uim-xemacs-restore-menubar)
+ (when uim-xemacs
+ ;;enable toolbar and menubar
+ (kill-local-variable 'toolbar-map)
+ (uim-xemacs-restore-menubar))
+
)
)
+;; (defun uim-mode-keymap-enabled ()
+;; (eq (cdr (assq 'uim-mode minor-mode-map-alist))
+;; uim-mode-map))
+
+;; (defun uim-preedit-keymap-enabled ()
+;; (eq (cdr (assq 'uim-mode minor-mode-map-alist))
+;; uim-preedit-map))
+
+
;;
;; Copy toggle key to uim-mode-map
;;
Modified: trunk/emacs/uim-preedit.el
===================================================================
--- trunk/emacs/uim-preedit.el 2005-12-09 13:04:54 UTC (rev 2487)
+++ trunk/emacs/uim-preedit.el 2005-12-09 13:17:43 UTC (rev 2488)
@@ -57,18 +57,16 @@
(mapcar
'(lambda (x)
- (let (cand-start-cand
- (preedit-flag (format "%s" (car x)))
+ (let ((preedit-flag (format "%s" (car x)))
(preedit-str (car (cdr x))))
;; save point for candidate displaying before insertion
;; i.e. head of the block
(if (string-match "c" preedit-flag)
- (progn
- (if (> (length preedit-str) 0)
- (setq uim-candidate-start (point))
- ;; workaround for uim-prime
- (setq uim-candidate-start block-start-point))))
+ (if (> (length preedit-str) 0)
+ (setq uim-candidate-start (point))
+ ;; workaround for uim-prime
+ (setq uim-candidate-start block-start-point)))
(setq block-start-point (point))
Modified: trunk/emacs/uim-var.el
===================================================================
--- trunk/emacs/uim-var.el 2005-12-09 13:04:54 UTC (rev 2487)
+++ trunk/emacs/uim-var.el 2005-12-09 13:17:43 UTC (rev 2488)
@@ -34,7 +34,7 @@
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
-(defconst uim-el-version "0.0.6-beta2")
+(defconst uim-el-version "0.0.6-beta3")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -335,6 +335,7 @@
(uim-deflocalvar uim-undo-stacking nil)
+(uim-deflocalvar uim-preedit-keymap-enabled nil)
;; save font-lock mode
(uim-deflocalvar uim-font-lock-mode nil)
Modified: trunk/emacs/uim.el
===================================================================
--- trunk/emacs/uim.el 2005-12-09 13:04:54 UTC (rev 2487)
+++ trunk/emacs/uim.el 2005-12-09 13:17:43 UTC (rev 2488)
@@ -361,7 +361,7 @@
;; hide candidate/preedit when buffer-save has been called
(add-hook 'local-write-file-hooks
'(lambda ()
- (if uim-preedit-displayed
+ (if (or uim-preedit-displayed uim-candidate-displayed)
(uim-process-agent-output '(("e"))))))
;; change IM engine to uim-default-im-engine
@@ -528,6 +528,7 @@
;;
(defun uim-restore-undo ()
(when uim-buffer-undo-list-saved
+ (uim-debug "restore undo list")
(buffer-enable-undo)
(setq buffer-undo-list uim-buffer-undo-list)
(setq uim-buffer-undo-list-saved nil))
@@ -539,6 +540,7 @@
;;
(defun uim-save-undo ()
(when (not uim-buffer-undo-list-saved)
+ (uim-debug "save undo list")
(setq uim-buffer-undo-list buffer-undo-list)
(buffer-disable-undo)
(setq uim-buffer-undo-list-saved 't))
@@ -920,8 +922,9 @@
(setq bypass t)
(setq count (prefix-numeric-value arg)))
- ((and (not uim-preedit-displayed)
- (uim-buffer-not-editable) )
+ ((and (not (or uim-preedit-displayed
+ uim-candidate-displayed))
+ (uim-buffer-not-editable))
;; through uim-el-agent when buffer is uneditable
(setq bypass t)
))
@@ -949,7 +952,8 @@
(setq bypass t)
(setq mouse t)
)
- ((and (not uim-preedit-displayed)
+ ((and (not (or uim-preedit-displayed
+ uim-candidate-displayed))
(uim-buffer-not-editable))
(setq bypass t))
(t
@@ -1001,22 +1005,24 @@
;; process return expression from uim-el-agent
(defun uim-process-agent-output (str)
- (let (preedit-exists
- candidate-exists
- key commit (preedit nil) candidate default label imlist)
+ (let (preedit-existed
+ candidate-existed
+ key commit preedit candidate default label imlist)
(let ((modified (buffer-modified-p)))
;; remove candidate anyway
(when uim-candidate-displayed
- (setq candidate-exists t)
+ (setq candidate-existed t)
(uim-remove-candidate)
- (setq uim-candidate-displayed nil))
+ (setq uim-candidate-displayed nil)
+ (goto-char uim-candidate-start))
;; remove preedit anyway
(when uim-preedit-displayed
- (setq preedit-exists t)
+ (setq preedit-existed t)
(uim-remove-preedit)
- (setq uim-preedit-displayed nil))
+ (setq uim-preedit-displayed nil)
+ (goto-char uim-preedit-start))
;; restore modified flag
(set-buffer-modified-p modified))
@@ -1070,77 +1076,97 @@
(when imlist
(uim-update-imlist imlist))
- (if (or commit
- (and preedit-exists (not preedit)))
- (uim-restore-undo))
(if commit
- (mapcar '(lambda (x)
- (insert x) (undo-boundary))
- commit))
+ (let ((buffer-undo-list-saved uim-buffer-undo-list-saved))
+ ;; restore undo history before committing
+ (when buffer-undo-list-saved
+ (uim-debug "call restore undo")
+ (uim-restore-undo))
- (if key
- ;; process raw key
- (progn
- (if preedit-exists
- (uim-disable-preedit-keymap))
- (uim-process-keyvec key))
+ ;; insert committed strings
+ (mapcar
+ '(lambda (x)
+ (insert x)
+ (uim-debug (format "insert %s" x))
+ (undo-boundary))
+ commit)
- ;; process preedit
- (if preedit
- (let ((modified (buffer-modified-p)))
+ ;; save undo hisotry again
+ (when buffer-undo-list-saved
+ (uim-debug "call save undo")
+ (uim-save-undo)))
+ )
- (uim-flush-concat-undo)
- ;; switch keymap to preedit mode
- (if (not preedit-exists)
- (uim-enable-preedit-keymap))
+ (if (or preedit candidate)
+ ;; process preedit/candidate
+ (let ((modified (buffer-modified-p)))
- (uim-save-undo)
+ ;; save undo list if not saved
+ (when (not uim-buffer-undo-list-saved)
+ (uim-flush-concat-undo)
+ (uim-debug "call save undo")
+ (uim-save-undo))
- (setq uim-preedit-displayed t)
+ ;; change keymap and freeze faces at first time
+ (when (not uim-preedit-keymap-enabled)
+ (uim-debug "call enable keymap")
+ (uim-enable-preedit-keymap)
+ (if (= (minibuffer-depth) 0)
+ (uim-freeze-buffer)))
- ;; freeze buffer if the first preedit display
- (if (and (not preedit-exists)
- (= (minibuffer-depth) 0))
- (uim-freeze-buffer))
+ ;; show preedit
+ (if preedit
+ (progn
+ (setq uim-preedit-displayed t)
+ (uim-insert-preedit preedit))
+ (setq uim-candidate-start (point))
+ (setq uim-candidate-vofs 0)
+ (setq uim-preedit-cursor (point)))
- (uim-insert-preedit preedit)
+ ;; show candidate
+ (if candidate
+ (progn
+ (setq uim-candidate-displayed t)
+ (if (uim-check-candidate-space)
+ (uim-show-candidate candidate))))
+
+ (set-buffer-modified-p modified)
- ;; show candidate
- (if candidate
- (progn
- (setq uim-candidate-displayed t)
- (if (uim-check-candidate-space)
- (uim-show-candidate candidate))))
+ )
- (set-buffer-modified-p modified)
- )
+ ;; no preedit/candidate
- (when (and preedit-exists
- uim-buffer-frozen)
- (uim-disable-preedit-keymap)
- (uim-unfreeze-buffer)
+ ;; restore undo-list before raw key processing
+ (when uim-buffer-undo-list-saved
+ (uim-debug "call restore undo")
+ (uim-restore-undo))
- )
- )
+ ;; no raw-key and no preedit/candidate
+ (when uim-preedit-keymap-enabled
+ (uim-debug "call disable preedit keymap")
+ (uim-disable-preedit-keymap)
+ (uim-unfreeze-buffer))
- (when (and candidate-exists
- (not uim-candidate-displayed)
- uim-window-force-scrolled)
- (uim-debug "recenter: window-force-scrolled is true")
- (setq uim-window-force-scrolled nil)
- (recenter)
- )
-
+ (if key
+ ;; process raw key
+ (uim-process-keyvec key))
+ )
- ;; move cursor
+ ;; scroll buffer after candidate removed
+ ;; recenter if buffer is force scrolled at candidate displaying
+ (when (and candidate-existed
+ (not uim-candidate-displayed)
+ uim-window-force-scrolled)
+ (uim-debug "recenter: window-force-scrolled is true")
+ (setq uim-window-force-scrolled nil)
+ (recenter))
- (when uim-preedit-displayed
- (goto-char uim-preedit-cursor))
- )
+ ;; move cursor
+ (when (or uim-preedit-displayed uim-candidate-displayed)
+ (goto-char uim-preedit-cursor))
-
))
More information about the uim-commit
mailing list