~ubuntu-branches/ubuntu/maverick/uim/maverick

« back to all changes in this revision

Viewing changes to emacs/uim-candidate.el

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2006-11-23 15:10:53 UTC
  • mfrom: (3.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061123151053-q42sk1lvks41xpfx
Tags: 1:1.2.1-9
uim-gtk2.0.postinst: Don't call update-gtk-immodules on purge.
(closes: Bug#398530)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;; 
 
2
;;  Copyright (c) 2005-2006 uim Project http://uim.freedesktop.org/
 
3
;;
 
4
;;  All rights reserved.
 
5
;;
 
6
;;  Redistribution and use in source and binary forms, with or
 
7
;;  without modification, are permitted provided that the
 
8
;;  following conditions are met:
 
9
;;
 
10
;;  1. Redistributions of source code must retain the above
 
11
;;     copyright notice, this list of conditions and the
 
12
;;     following disclaimer.
 
13
;;  2. Redistributions in binary form must reproduce the above
 
14
;;     copyright notice, this list of conditions and the
 
15
;;     following disclaimer in the documentation and/or other
 
16
;;     materials provided with the distribution.
 
17
;;  3. Neither the name of authors nor the names of its
 
18
;;     contributors may be used to endorse or promote products
 
19
;;     derived from this software without specific prior written
 
20
;;     permission.
 
21
;;
 
22
;;  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 
23
;;  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 
24
;;  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 
25
;;  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
26
;;  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 
27
;;  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
28
;;  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 
29
;;  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
30
;;  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
31
;;  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
32
;;  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 
33
;;  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
34
;;  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
35
;;
 
36
 
 
37
;;
 
38
;; Checks that the candidate list can be displayed inlinely on current window.
 
39
;;
 
40
(defun uim-check-candidate-space ()
 
41
  ;; don't show the candidate in mini-buffer
 
42
  ;; also thin window is not supported
 
43
  (and (= (minibuffer-depth) 0)
 
44
       (>= (window-width) uim-candidate-minimum-width)))
 
45
 
 
46
 
 
47
;; 
 
48
;; Merge formatted text into current buffer
 
49
;;
 
50
(defun uim-merge-candidate ()
 
51
 
 
52
  (let ((maxwidth (string-width (nth 1 (car uim-candidate-line-list))))
 
53
        offset mark-base mark-cursor)
 
54
 
 
55
    ;; format page label
 
56
    (setq uim-candidate-page-label
 
57
          (concat (make-string (- maxwidth 
 
58
                                  (- (string-width uim-candidate-page-label) 1))
 
59
                               (if uim-candidate-display-frame ?- 32))
 
60
                  uim-candidate-page-label))
 
61
 
 
62
    ;; make mark for chasing
 
63
    (setq mark-cursor (point-marker))
 
64
 
 
65
    (goto-char uim-candidate-start)
 
66
 
 
67
    ;; mark current-point
 
68
    (setq mark-base (point-marker))
 
69
    ;;(uim-debug (format "before: %s" (marker-position mark-base)))
 
70
 
 
71
    ;; save original string
 
72
    (setq uim-candidate-original-str
 
73
          (buffer-substring uim-candidate-original-start
 
74
                            uim-candidate-original-end))
 
75
 
 
76
    ;; remove tabs/spaces
 
77
    (uim-tab-pad-space uim-candidate-original-start
 
78
                       uim-candidate-original-end)
 
79
 
 
80
 
 
81
    ;; update uim-candidate-start
 
82
    (let (base-ofs)
 
83
      (setq base-ofs (- (marker-position mark-base) uim-candidate-start))
 
84
      (setq uim-candidate-start (+ uim-candidate-start base-ofs)))
 
85
 
 
86
    ;;(uim-debug (format "after: %s" (marker-position mark-base)))
 
87
 
 
88
    (set-marker mark-base nil)
 
89
 
 
90
    (goto-char uim-candidate-start)
 
91
 
 
92
    (save-excursion
 
93
      (uim-vertical-motion 0)
 
94
      (setq offset 
 
95
            (uim-string-width (buffer-substring (point) uim-candidate-start))))
 
96
 
 
97
    ;;(uim-debug (format "offset: %s" offset))
 
98
 
 
99
    ;; if offset + maxwidth >= window-width then reduce offset
 
100
    (if (>= (+ offset maxwidth 2) (window-width))
 
101
        (setq offset (- (- (window-width) 1) 
 
102
                        (+ maxwidth 2))))
 
103
 
 
104
 
 
105
    (save-excursion
 
106
      (if uim-show-candidate-upward
 
107
          (uim-vertical-motion (- (+ (length uim-candidate-line-list) 1)))
 
108
        (uim-vertical-motion uim-candidate-vofs))
 
109
 
 
110
      (let ((rest t)
 
111
            mergecount vhead linetmp padding overflow)
 
112
        
 
113
        (save-excursion
 
114
          (setq mergecount (uim-vertical-motion 
 
115
                               (+ (length uim-candidate-line-list) 1))))
 
116
 
 
117
 
 
118
        (while rest
 
119
          (let (candidx candstr candsel)
 
120
            (if uim-candidate-line-list
 
121
                (progn
 
122
                  ;; normal candidate line
 
123
                  (setq candidx (nth 0 (car uim-candidate-line-list)))
 
124
                  (setq candstr 
 
125
                        (uim-format-string (nth 1 (car uim-candidate-line-list))
 
126
                                           maxwidth))
 
127
                  (setq candsel (nth 2 (car uim-candidate-line-list)))
 
128
 
 
129
                  (setq candstr
 
130
                        (if uim-candidate-display-frame
 
131
                            (if candsel
 
132
                                (concat ">" candstr "<")
 
133
                              (concat "|" candstr "|"))
 
134
                          (if candsel
 
135
                              (concat "[" candstr "]")
 
136
                            (concat " " candstr " "))))
 
137
                  )
 
138
              ;; page label
 
139
              (setq candidx 0)
 
140
 
 
141
              (setq candstr
 
142
                    (if uim-candidate-display-frame
 
143
                        (concat "+" uim-candidate-page-label )
 
144
                      (concat " " uim-candidate-page-label )))
 
145
              (setq candsel nil)
 
146
              )
 
147
 
 
148
            (if (> mergecount 0)
 
149
                (progn
 
150
                  ;; go virtual head of the next line
 
151
                  (if (not uim-show-candidate-upward)
 
152
                      (uim-vertical-motion 1))
 
153
 
 
154
                  (setq vhead (point))
 
155
 
 
156
                  ;; make new line
 
157
                  (save-excursion
 
158
 
 
159
                    (end-of-line)
 
160
                    
 
161
                    ;; |ABCDEFGH\ + |___aaa__|
 
162
                    ;; |IJKLMN  |
 
163
                    ;;
 
164
                    ;; get region from vhead to physical end
 
165
                    ;;
 
166
                    ;; linetmp = ABCDEFGH
 
167
                    ;; 
 
168
                    (setq linetmp 
 
169
                          (truncate-string-to-width (buffer-substring vhead (point))
 
170
                                                    (window-width)))
 
171
 
 
172
                    ;; make padding by truncating linetmp to offset size
 
173
                    ;;  (add space as padding if shortage)
 
174
                    ;;   witdth of padding is equal to offset
 
175
                    ;; 
 
176
                    ;; padding = ABC
 
177
                    ;;
 
178
                    (setq padding
 
179
                          (truncate-string-to-width linetmp offset nil 32))
 
180
                      
 
181
                    ;;  overflow = GH
 
182
                    ;;
 
183
                    (let ((candwidth (+ maxwidth 2)))
 
184
 
 
185
                      (if (>= (uim-string-width linetmp) (+ offset candwidth))
 
186
                          (setq overflow 
 
187
                                (truncate-string-to-width linetmp 
 
188
                                                          (uim-string-width linetmp)
 
189
                                                          (+ offset candwidth) 32))
 
190
                        (setq overflow "")))
 
191
 
 
192
                    ;; index string selected appendix
 
193
                    (save-excursion
 
194
                      (goto-char vhead)
 
195
                      (delete-region vhead (+ vhead (length linetmp)))
 
196
                        
 
197
                      (when uim-xemacs
 
198
                        (insert " ")
 
199
                        (remove-text-properties (- (point) 1) (point)
 
200
                                                '(face nil))
 
201
                        (goto-char (- (point) 1)))
 
202
 
 
203
                      (insert (concat padding 
 
204
                                      candstr
 
205
                                      overflow))
 
206
 
 
207
                      (when uim-xemacs
 
208
                        (delete-char 1))
 
209
                      
 
210
                      )
 
211
                
 
212
                    (uim-set-candidate-face candidx candsel 
 
213
                                            (+ vhead (length padding))
 
214
                                            (length candstr))
 
215
 
 
216
 
 
217
                    ;; update merge-end
 
218
                    (save-excursion
 
219
                      (end-of-line)
 
220
                      (setq uim-candidate-end (point)))
 
221
              
 
222
                    (setq mergecount (- mergecount 1))
 
223
                    )
 
224
 
 
225
                  (if uim-show-candidate-upward
 
226
                  (uim-vertical-motion 1))
 
227
                    
 
228
                  )
 
229
              ;; append 
 
230
              (let (vhead)
 
231
 
 
232
                (goto-char (point-max))
 
233
 
 
234
                (setq vhead (+ (point) 1))
 
235
 
 
236
                (insert (concat "\n"
 
237
                                (make-string offset 32)
 
238
                                candstr))
 
239
 
 
240
                (uim-set-candidate-face candidx candsel 
 
241
                                        (+ vhead offset)
 
242
                                        (length candstr))
 
243
 
 
244
                (save-excursion
 
245
                  (end-of-line)
 
246
                  (setq uim-candidate-end (point))))))
 
247
            
 
248
          (if uim-candidate-line-list
 
249
              (setq uim-candidate-line-list
 
250
                    (cdr uim-candidate-line-list))
 
251
            (setq rest nil))
 
252
 
 
253
          )
 
254
        
 
255
        ;; move to end of preedit
 
256
        (if uim-show-candidate-upward
 
257
            (save-excursion
 
258
              (end-of-line)
 
259
              (setq uim-candidate-end (point))))
 
260
 
 
261
        (force-mode-line-update)
 
262
 
 
263
        ;; update cursor position
 
264
        (when mark-cursor
 
265
          
 
266
          (goto-char (marker-position mark-cursor))
 
267
          (setq uim-candidate-cursor (point))
 
268
 
 
269
          (set-marker mark-cursor nil)
 
270
          )
 
271
        ))
 
272
    ))
 
273
 
 
274
 
 
275
 
 
276
(defun uim-echo-candidate (cand)
 
277
 
 
278
  ;; display candidate in minibuffer 
 
279
 
 
280
  (let ((cands "")
 
281
        (selstart 0)
 
282
        (selend 0)
 
283
        (page-current (format "%d" (caar cand)))
 
284
        (page-total (format "%d" (cdar cand)))
 
285
        )
 
286
 
 
287
    (setq cand (cdr cand))
 
288
 
 
289
 
 
290
    (mapcar 
 
291
     '(lambda (x)
 
292
        (let ((selected (nth 0 x))
 
293
              (candlabel (nth 1 x))
 
294
              (candstr (nth 2 x)))
 
295
 
 
296
          (if selected
 
297
              (setq selstart (length cands)))
 
298
 
 
299
          (setq cands
 
300
                (if selected
 
301
                    (concat cands "[" candlabel "." candstr "]")
 
302
                  (concat cands " "  candlabel "." candstr " ")))
 
303
 
 
304
          (if selected
 
305
              (setq selend (length cands)))
 
306
 
 
307
          )
 
308
        ) cand)
 
309
 
 
310
    
 
311
    (if (and uim-emacs
 
312
             (>= emacs-major-version 21))
 
313
        ;; Emcas-21 or Emacs-22
 
314
        (let ((page-space (- (string-width page-total) 
 
315
                             (string-width page-current)))
 
316
              message-log-max)
 
317
          (setq cands 
 
318
                (concat (if (> page-space 0) (make-string page-space 32))
 
319
                        page-current  "/" page-total " " cands))
 
320
          (message cands)
 
321
          )
 
322
      ;; Emacs-20 or XEmacs
 
323
      (let* ((page-space (- (string-width page-total) 
 
324
                            (string-width page-current)))
 
325
             (page-label (concat (if (> page-space 0) 
 
326
                                     (make-string page-space 32))
 
327
                                  page-current  "/" page-total " "))
 
328
             (page-width (string-width page-label))
 
329
             (cands-width (string-width cands))
 
330
             (echoreg-width (- (- (window-width) 1) page-width)))
 
331
 
 
332
        (cond ((>= echoreg-width cands-width)
 
333
               (setq cands
 
334
                     (concat page-label cands)))
 
335
 
 
336
              ((= selstart 0)
 
337
               ;; | 10/134 [1.xxxxx] 2.yyyyy 3.zzzzz ...|
 
338
               (setq cands 
 
339
                     (truncate-string-to-width cands
 
340
                                               (if (> echoreg-width 3)
 
341
                                                   (- echoreg-width 3)
 
342
                                                 0)))
 
343
               (setq cands
 
344
                     (concat page-label
 
345
                             cands
 
346
                             (make-string (- echoreg-width
 
347
                                             (string-width cands))
 
348
                                          ?.)))
 
349
 
 
350
               )
 
351
              ((> (string-width (substring cands 0 selstart))
 
352
                  (+ (- cands-width echoreg-width) 3))
 
353
               ;; | 10/134 ...yyy [3.zzzzz] 
 
354
               (setq cands
 
355
                     (truncate-string-to-width cands
 
356
                                               cands-width 
 
357
                                               (+ (- cands-width echoreg-width) 3)))
 
358
               (setq cands
 
359
                     (concat page-label
 
360
                             (make-string (- echoreg-width 
 
361
                                             (string-width cands))
 
362
                                          ?.)
 
363
                             cands)))
 
364
              (t
 
365
               ;; | 10/134 ...[3.zzzzz] ---- ...|
 
366
               (setq cands 
 
367
                     (concat "..."
 
368
                             (truncate-string-to-width (substring cands selstart)
 
369
                                                       (if (> echoreg-width 6)
 
370
                                                           (- echoreg-width 6)
 
371
                                                         0))
 
372
                             ))
 
373
               (setq cands
 
374
                     (concat page-label
 
375
                             cands
 
376
                             (make-string (- echoreg-width 
 
377
                                             (string-width cands))
 
378
                                          ?.))))))
 
379
 
 
380
      (let (message-log-max)
 
381
        (message cands))
 
382
      )
 
383
    
 
384
    )
 
385
  )
 
386
 
 
387
 
 
388
;;
 
389
;; Make candidate list to be displayed
 
390
(defun uim-make-candlist (cand) 
 
391
  ;; cand: (( <nil|t> "candlabel"  "candstr" ) ... )
 
392
 
 
393
  (let* ((i 1)
 
394
         (truncwidth (min (- (window-width) 3)
 
395
                          (max (+ uim-max-candlabel uim-max-candstr 1)
 
396
                               (- (string-width uim-candidate-page-label) 1))))
 
397
         (candlist '()))
 
398
 
 
399
    (mapcar 
 
400
     '(lambda (x)
 
401
        (let ((selected (nth 0 x))
 
402
              (candlabel (nth 1 x))
 
403
              (candstr (nth 2 x)))
 
404
 
 
405
          (setq candlabel 
 
406
                (concat (make-string (- uim-max-candlabel 
 
407
                                        (string-width candlabel)) 32)
 
408
                        candlabel))
 
409
 
 
410
          (setq candstr (concat candlabel "." candstr))
 
411
        
 
412
          (catch 'truncate-loop
 
413
            (let (candlabelpad)
 
414
              (while t
 
415
                (let* ((trunc (truncate-string-to-width candstr
 
416
                                                        truncwidth nil))
 
417
                       (width-truncated (string-width trunc))
 
418
                       )
 
419
                
 
420
                  (setq candlist 
 
421
                        (append candlist 
 
422
                                (list 
 
423
                                 (list i (concat trunc 
 
424
                                                 (make-string (- truncwidth
 
425
                                                                 width-truncated)
 
426
                                                              32))
 
427
                                       selected))))
 
428
 
 
429
                  (if (= width-truncated (string-width candstr))
 
430
                      (throw 'truncate-loop t))
 
431
 
 
432
                  (if (not candlabelpad)
 
433
                      (setq candlabelpad
 
434
                            (make-string (+ (string-width candlabel) 1) 32)))
 
435
 
 
436
                  (setq candstr
 
437
                        (concat candlabelpad
 
438
                                (truncate-string-to-width candstr
 
439
                                                          (string-width candstr)
 
440
                                                          width-truncated)))
 
441
                  ))))
 
442
          )
 
443
        (setq i (+ i 1))
 
444
        ) cand)
 
445
 
 
446
    (setq uim-candidate-line-list candlist)
 
447
    )
 
448
  )
 
449
  
 
450
 
 
451
 
 
452
;;
 
453
;; Put overlay
 
454
;;
 
455
(defun uim-set-candidate-face (index selected begin length)
 
456
  (let (face)
 
457
    (cond 
 
458
     (selected
 
459
      (setq face 'uim-candidate-selected-face))
 
460
     ((= index 0)
 
461
      (setq face 'uim-candidate-nth-face))
 
462
     ((= (% index 2) 1)
 
463
      (setq face 'uim-candidate-odd-face))
 
464
     ((= (% index 2) 0)
 
465
      (setq face 'uim-candidate-even-face)))
 
466
 
 
467
    (put-text-property begin (+ begin length) 'face face)
 
468
 
 
469
    ))
 
470
 
 
471
 
 
472
 
 
473
 
 
474
(defun uim-check-overlay (head tail)
 
475
  (if (> head (point-min))
 
476
      (setq head (- head 1)))
 
477
 
 
478
  (if (< tail (point-max))
 
479
      (setq tail (+ tail 1)))
 
480
  
 
481
  (overlays-in  head tail))
 
482
 
 
483
 
 
484
;;
 
485
;; Insert candidate string
 
486
;;
 
487
(defun uim-show-candidate (candidate)
 
488
 
 
489
 
 
490
  ;; separate appendix (for prime...)
 
491
  (setq candidate
 
492
        (cons (car candidate)
 
493
              (mapcar
 
494
               '(lambda (x)
 
495
                  (let ((selected (nth 0 x))
 
496
                        (candlabel (nth 1 x))
 
497
                        (candstr (nth 2 x)))
 
498
 
 
499
                    ;; separate appendix (for prime...)
 
500
                    (if (string-match "\t" candstr) 
 
501
                        (setq candstr (substring candstr 0 (match-beginning 0))))
 
502
                    (list selected candlabel candstr)
 
503
                    )
 
504
                  ) (cdr candidate))))
 
505
        
 
506
  (setq uim-max-candlabel 
 
507
        (eval (cons 'max 
 
508
                    (mapcar '(lambda (x) (string-width (nth 1 x)))
 
509
                            (cdr candidate)))))
 
510
 
 
511
  ;; get max width 
 
512
  (setq uim-max-candstr 
 
513
        (eval (cons 'max 
 
514
                    (mapcar '(lambda (x) (string-width (nth 2 x)))
 
515
                            (cdr candidate)))))
 
516
 
 
517
  (setq uim-candidate-page-label 
 
518
        (format "%d/%d" (caar candidate) (cdar candidate)))
 
519
 
 
520
  (setq uim-candidate-original-start nil)
 
521
  (setq uim-candidate-original-end nil)
 
522
 
 
523
  (let ((display-inline uim-candidate-display-inline))
 
524
 
 
525
    (if (>= (max (+ uim-max-candlabel 6) 
 
526
                 (+ (string-width uim-candidate-page-label) 2))
 
527
            (window-width))
 
528
        (progn
 
529
          (setq display-inline nil)
 
530
          (uim-debug "disable inline: window is too thin")
 
531
          ))
 
532
 
 
533
 
 
534
    (if display-inline
 
535
        (uim-make-candlist (cdr candidate)))
 
536
  
 
537
 
 
538
    (if display-inline
 
539
        (save-excursion
 
540
          (goto-char uim-candidate-start)
 
541
 
 
542
          (let ((winofs (uim-get-window-offset))
 
543
                (candlines (+ 1 (length uim-candidate-line-list)))
 
544
                ol-down dhead dtail uhead utail)
 
545
            
 
546
            (if (and (not (setq ol-down (uim-check-overlay
 
547
                                         (save-excursion
 
548
                                           (beginning-of-line)
 
549
                                           (setq dhead (point)))
 
550
                                         (save-excursion
 
551
                                           (uim-vertical-motion 
 
552
                                            (+ uim-candidate-vofs 
 
553
                                               candlines))
 
554
                                           (end-of-line)
 
555
                                           (setq dtail(point))))))
 
556
                     (>= (- (- (window-height) 1) (+ winofs 1)) 
 
557
                         candlines))
 
558
 
 
559
                (progn
 
560
                  (setq uim-show-candidate-upward nil)
 
561
                  (setq uim-candidate-original-start dhead)
 
562
                  (setq uim-candidate-original-end dtail)
 
563
                  )
 
564
 
 
565
              (if (and (>= winofs candlines)
 
566
                       (not (uim-check-overlay
 
567
                             (save-excursion
 
568
                               (uim-vertical-motion (- candlines))
 
569
                               (beginning-of-line)
 
570
                               (setq uhead (point)))
 
571
                             (save-excursion
 
572
                               (end-of-line)
 
573
                               (setq utail (point)))))
 
574
                       )
 
575
                  (progn
 
576
                    (setq uim-show-candidate-upward t)
 
577
                    (setq uim-candidate-original-start uhead)
 
578
                    (setq uim-candidate-original-end utail)
 
579
                    )
 
580
                
 
581
                ;; scroll anyway
 
582
                (if (not ol-down)
 
583
                    (let* ((fspace (- (- (- (window-height) 1) winofs) 1))
 
584
                           (vshift (- candlines fspace)))
 
585
                      (setq uim-show-candidate-upward nil)
 
586
                      (setq uim-window-force-scrolled t)
 
587
 
 
588
                      (setq uim-candidate-original-start dhead)
 
589
                      (setq uim-candidate-original-end dtail)
 
590
 
 
591
                      (if (> vshift winofs)
 
592
                          (recenter 0)
 
593
                        (save-excursion 
 
594
                          ;;(uim-debug (format "vshift %s" vshift))
 
595
                          (uim-vertical-motion (- (- (window-height)
 
596
                                                     candlines 2)))
 
597
                          (recenter 0))))
 
598
                  ;; disable inline display
 
599
                  (setq display-inline nil)
 
600
                  
 
601
                  ;;(uim-debug (format "ol-down %s" ol-down))
 
602
                  
 
603
                  ))))))
 
604
 
 
605
    (if (not display-inline)
 
606
        (uim-debug "disable inline"))
 
607
 
 
608
 
 
609
    (if display-inline
 
610
        ;; inline candidate display mode
 
611
        (let ((inhibit-read-only t))
 
612
          (uim-merge-candidate))
 
613
      ;; display in echo region
 
614
      (uim-echo-candidate candidate)
 
615
      )
 
616
    )
 
617
  )
 
618
 
 
619
;;
 
620
;; Remove candidate
 
621
;;
 
622
(defun uim-remove-candidate ()
 
623
  (if (and uim-candidate-display-inline
 
624
           uim-candidate-original-start)
 
625
      (let ((inhibit-read-only t))
 
626
 
 
627
        ;; delete region which includes candidate
 
628
        (delete-region uim-candidate-original-start 
 
629
                       uim-candidate-end)
 
630
 
 
631
        ;; restore original region
 
632
        (save-excursion
 
633
          (goto-char uim-candidate-original-start)
 
634
          (insert uim-candidate-original-str))
 
635
 
 
636
        )
 
637
 
 
638
    ;; clear minibuffer
 
639
    (let (message-log-max)
 
640
      (message nil))
 
641
   
 
642
    )
 
643
  
 
644
  )
 
645
 
 
646
 
 
647
(provide 'uim-candidate)