Function: quail-get-translations

quail-get-translations is a byte-compiled function defined in quail.el.gz.

Signature

(quail-get-translations)

Documentation

Return a string containing the current possible translations.

Source Code

;; Defined in /usr/src/emacs/lisp/international/quail.el.gz
(defun quail-get-translations ()
  "Return a string containing the current possible translations."
  (or (multibyte-string-p quail-current-key)
      (setq quail-current-key (string-to-multibyte quail-current-key)))
  (let ((map (quail-lookup-key quail-current-key nil t))
	(str (copy-sequence quail-current-key)))
    (if quail-current-translations
	(quail-update-current-translations))

    ;; Show the current key.
    (let ((guidance (quail-guidance)))
      (if (listp guidance)
	  ;; We must replace the typed key with the specified PROMPT-KEY.
          (setq str (apply #'string
                           (mapcar
                            (lambda (c)
                              (let ((prompt-key (assq c guidance)))
                                (if prompt-key
                                    (aref (cdr prompt-key) 0)
                                  c)))
                            str)))))

      ;; Show followable keys.
      (if (and (> (length quail-current-key) 0) (cdr map))
	  (setq str
		(format "%s[%s]"
			str
                        (concat (sort (mapcar #'car (cdr map)) #'<)))))
      ;; Show list of translations.
      (if (and quail-current-translations
	       (not (quail-deterministic)))
	  (let* ((indices (car quail-current-translations))
		 (cur (car indices))
		 (start (nth 1 indices))
		 (end (nth 2 indices))
		 (idx start))
	    (if (< (string-width str)
		   (- quail-guidance-translations-starting-column 7))
		(setq str
		      (concat str
			      (make-string
			       (- quail-guidance-translations-starting-column
				  7 (string-width str))
			       32))))
	    (setq str (format "%s(%02d/%s)"
			      str (nth 3 indices)
			      (if (nth 4 indices)
				  (format "%02d" (nth 4 indices))
				"??")))
	    (while (< idx end)
	      (let ((len (length str))
		    (trans (aref (cdr quail-current-translations) idx)))
		(or (stringp trans)
		    (setq trans (string trans)))
		(setq str (format "%s %d.%s"
				  str
				  (if (= (- idx start) 9) 0
				    (1+ (- idx start)))
				  trans))
		(if (= idx cur)
		    (put-text-property (+ len 3) (length str)
				      'face 'highlight str))
		(setq idx (1+ idx))))))

      str))