Function: quail-update-guidance

quail-update-guidance is a byte-compiled function defined in quail.el.gz.

Signature

(quail-update-guidance)

Documentation

Update the Quail guidance buffer and completion buffer (if displayed now).

Source Code

;; Defined in /usr/src/emacs/lisp/international/quail.el.gz
(defun quail-update-guidance ()
  "Update the Quail guidance buffer and completion buffer (if displayed now)."
  ;; Update the guidance string.
  (when (quail-require-guidance-buf)
    (let ((guidance (quail-guidance)))
      (cond ((or (eq guidance t)
		 (consp guidance))
	     ;; Show the current possible translations.
	     (setq quail-guidance-str
		   (quail-get-translations)))
	    ((null guidance)
	     ;; Show the current input keys.
	     (let ((key quail-current-key))
	       (if (quail-kbd-translate)
		   (setq key (quail-keyseq-translate key)))
	       (setq quail-guidance-str (if (stringp key) key (string key)))))
	    (t
	     (setq quail-guidance-str " ")))))

  ;; Update completion buffer if displayed now.  We highlight the
  ;; selected candidate string in *Completion* buffer if any.
  (let ((win (get-buffer-window quail-completion-buf))
	key str pos)
    (if win
	(save-excursion
	  (setq str (if (stringp quail-current-str)
			quail-current-str
		      (if (numberp quail-current-str)
			  (char-to-string quail-current-str)))
		key quail-current-key)
	  (set-buffer quail-completion-buf)
	  (goto-char (point-min))
	  (if (null (search-forward (concat " " key ":") nil t))
	      (delete-overlay quail-overlay)
	    (setq pos (point))
	    (if (and str (search-forward (concat "." str) nil t))
		(move-overlay quail-overlay (1+ (match-beginning 0)) (point))
	      (move-overlay quail-overlay (match-beginning 0) (point)))
	    ;; Now POS points end of KEY and (point) points end of STR.
	    (if (pos-visible-in-window-p (point) win)
		;; STR is already visible.
		nil
	      ;; We want to make both KEY and STR visible, but if the
	      ;; window is too short, make at least STR visible.
	      (setq pos (progn (point) (goto-char pos)))
	      (beginning-of-line)
	      (set-window-start win (point))
	      (if (not (pos-visible-in-window-p pos win))
		  (set-window-start win pos))
	      ))))))