Function: quail-mouse-choose-completion

quail-mouse-choose-completion is an interactive and byte-compiled function defined in quail.el.gz.

Signature

(quail-mouse-choose-completion EVENT)

Documentation

Click on an alternative in the *Quail Completions* buffer to choose it.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/international/quail.el.gz
(defun quail-mouse-choose-completion (event)
  "Click on an alternative in the `*Quail Completions*' buffer to choose it."
  ;; This function is an exact copy of the mouse.el function
  ;; `mouse-choose-completion' except that we:
  ;; 2) don't bury *Quail Completions* buffer, so comment a section, and
  ;; 3) delete/terminate the current quail selection here.
  ;; FIXME: Consolidate with `choose-completion'.  The point number
  ;; 1 has been done, already.  The point number 3 should be fairly
  ;; easy to move to a choose-completion-string-function.  So all
  ;; that's left is point number 2.
  (interactive "e")
  ;; Give temporary modes such as isearch a chance to turn off.
  (run-hooks 'mouse-leave-buffer-hook)
  (let ((buffer (window-buffer))
        choice)
    (with-current-buffer (window-buffer (posn-window (event-start event)))
      (if completion-reference-buffer
	  (setq buffer completion-reference-buffer))
      (save-excursion
	(goto-char (posn-point (event-start event)))
	(let (beg end)
	  (if (and (not (eobp)) (get-text-property (point) 'mouse-face))
	      (setq end (point) beg (1+ (point))))
	  (if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face))
	      (setq end (1- (point)) beg (point)))
	  (if (null beg)
	      (quail-error "No completion here"))
	  (setq beg (previous-single-property-change beg 'mouse-face))
	  (setq end (or (next-single-property-change end 'mouse-face)
			(point-max)))
	  (setq choice (buffer-substring beg end)))))
    ;; (let ((owindow (selected-window)))
    ;;   (select-window (posn-window (event-start event)))
    ;;   (if (and (one-window-p t 'selected-frame)
    ;;            (window-dedicated-p (selected-window)))
    ;;       ;; This is a special buffer's frame
    ;;       (iconify-frame (selected-frame))
    ;;     (or (window-dedicated-p (selected-window))
    ;;         (bury-buffer)))
    ;;   (select-window owindow))
    (quail-delete-region)
    (setq quail-current-str choice)
    ;; FIXME: We need to pass `base-position' here.
    ;; FIXME: why do we need choose-completion-string with all its
    ;; completion-specific logic?
    (choose-completion-string choice buffer)
    (quail-terminate-translation)))