Function: quail-update-current-translations
quail-update-current-translations is a byte-compiled function defined
in quail.el.gz.
Signature
(quail-update-current-translations &optional RELATIVE-INDEX)
Documentation
Update quail-current-translations.
Make RELATIVE-INDEX the current translation.
Source Code
;; Defined in /usr/src/emacs/lisp/international/quail.el.gz
(defun quail-update-current-translations (&optional relative-index)
"Update `quail-current-translations'.
Make RELATIVE-INDEX the current translation."
(let* ((indices (car quail-current-translations))
(cur (car indices))
(start (nth 1 indices))
(end (nth 2 indices)))
;; Validate the index number of current translation.
(if (< cur 0)
(setcar indices (setq cur 0))
(if (>= cur (length (cdr quail-current-translations)))
(setcar indices
(setq cur (1- (length (cdr quail-current-translations)))))))
(if (or (null end) ; We have not yet calculated END.
(< cur start) ; We moved to the previous block.
(>= cur end)) ; We moved to the next block.
(let ((len (length (cdr quail-current-translations)))
(maxcol (- (window-width)
quail-guidance-translations-starting-column))
(block (nth 3 indices))
col idx width trans num-items)
(if (< cur start)
;; We must calculate from the head.
(setq start 0 block 0)
(if end ; i.e. (>= cur end)
(setq start end)))
(setq idx start col 0 end start num-items 0)
;; Loop until we hit the tail, or reach the block of CUR.
(while (and (< idx len) (>= cur end))
(if (= num-items 0)
(setq start idx col 0 block (1+ block)))
(setq trans (aref (cdr quail-current-translations) idx))
(setq width (if (integerp trans) (char-width trans)
(string-width trans)))
(setq col (+ col width 3) num-items (1+ num-items))
(if (and (> num-items 0)
(or (>= col maxcol) (> num-items 10)))
(setq end idx num-items 0)
(setq idx (1+ idx))))
(setcar (nthcdr 3 indices) block)
(if (>= idx len)
(progn
;; We hit the tail before reaching MAXCOL.
(setq end idx)
(setcar (nthcdr 4 indices) block)))
(setcar (cdr indices) start)
(setcar (nthcdr 2 indices) end)))
(if relative-index
(if (>= (+ start relative-index) end)
(setcar indices (1- end))
(setcar indices (+ start relative-index))))
(setq quail-current-str
(aref (cdr quail-current-translations) (car indices)))
(or (stringp quail-current-str)
(setq quail-current-str (char-to-string quail-current-str)))))