aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1997-10-24 01:14:24 +0000
committerKenichi Handa1997-10-24 01:14:24 +0000
commit5611ce7c860707e87badda74741a63e0618fc87b (patch)
tree3715dc3217e839f17d0c817c3446fb62cde71703
parentdb5cae4b2d64e5ee3499a4d430816df3d0f0e2a2 (diff)
downloademacs-5611ce7c860707e87badda74741a63e0618fc87b.tar.gz
emacs-5611ce7c860707e87badda74741a63e0618fc87b.zip
(quail-translation-keymap): KP_Enter key
emulates `C-SPC'. `mouse-2' bound to `quail-mouse-choose-completion'. (quail-completion-list-translations): Set text property `mouse-face' of character `translations' to `highlight'. Changed `newline' to `insert "\n"' to prevent text property inheritance. (quail-mouse-choose-completion): New function bound to `mouse-2' selects highlighted characters from *Quail Completions* buffer. (quail-choose-completion-string): New function called by `quail-mouse-choose-completion'.
-rw-r--r--lisp/international/quail.el106
1 files changed, 102 insertions, 4 deletions
diff --git a/lisp/international/quail.el b/lisp/international/quail.el
index f4acccbc411..7b3e05f8b9b 100644
--- a/lisp/international/quail.el
+++ b/lisp/international/quail.el
@@ -293,6 +293,12 @@ LEIM is available from the same ftp directory as Emacs."))
293 (define-key map [up] 'quail-prev-translation-block) 293 (define-key map [up] 'quail-prev-translation-block)
294 (define-key map "\C-i" 'quail-completion) 294 (define-key map "\C-i" 'quail-completion)
295 (define-key map "\C-@" 'quail-select-current) 295 (define-key map "\C-@" 'quail-select-current)
296 ;; Following simple.el, Enter key on numeric keypad selects the
297 ;; current translation just like `C-SPC', and `mouse-2' chooses
298 ;; any completion visible in the *Quail Completions* buffer.
299 (define-key map [kp-enter] 'quail-select-current)
300 (define-key map [mouse-2] 'quail-mouse-choose-completion)
301 (define-key map [down-mouse-2] nil)
296 (define-key map "\C-h" 'quail-translation-help) 302 (define-key map "\C-h" 'quail-translation-help)
297;;; This interferes with handling of escape sequences on non-X terminals. 303;;; This interferes with handling of escape sequences on non-X terminals.
298;;; (define-key map "\e" '(keymap (t . quail-execute-non-quail-command))) 304;;; (define-key map "\e" '(keymap (t . quail-execute-non-quail-command)))
@@ -1661,10 +1667,17 @@ All possible translations of the current key and whole possible longer keys
1661;; List all possible translations of KEY in Quail map MAP with 1667;; List all possible translations of KEY in Quail map MAP with
1662;; indentation INDENT. 1668;; indentation INDENT.
1663(defun quail-completion-list-translations (map key indent) 1669(defun quail-completion-list-translations (map key indent)
1664 (let ((translations 1670 (let (beg (translations
1665 (quail-get-translation (car map) key (length key)))) 1671 (quail-get-translation (car map) key (length key))))
1666 (if (integerp translations) 1672 (if (integerp translations)
1667 (insert "(1/1) 1." translations "\n") 1673 (progn
1674 (insert "(1/1) 1.")
1675 ;; Endow the character `translations' with `mouse-face' text
1676 ;; property to enable `mouse-2' completion.
1677 (setq beg (point))
1678 (insert translations)
1679 (put-text-property beg (point) 'mouse-face 'highlight)
1680 (insert "\n"))
1668 ;; We need only vector part. 1681 ;; We need only vector part.
1669 (setq translations (cdr translations)) 1682 (setq translations (cdr translations))
1670 ;; Insert every 10 elements with indices in a line. 1683 ;; Insert every 10 elements with indices in a line.
@@ -1674,15 +1687,100 @@ All possible translations of the current key and whole possible longer keys
1674 (while (< i len) 1687 (while (< i len)
1675 (when (zerop (% i 10)) 1688 (when (zerop (% i 10))
1676 (when (>= i 10) 1689 (when (>= i 10)
1677 (newline) 1690 (insert "\n")
1678 (indent-to indent)) 1691 (indent-to indent))
1679 (insert (format "(%d/%d)" (1+ (/ i 10)) (1+ (/ len 10))))) 1692 (insert (format "(%d/%d)" (1+ (/ i 10)) (1+ (/ len 10)))))
1680 ;; We show the last digit of FROM while converting 1693 ;; We show the last digit of FROM while converting
1681 ;; 0,1,..,9 to 1,2,..,0. 1694 ;; 0,1,..,9 to 1,2,..,0.
1682 (insert (format " %d." (% (1+ i) 10))) 1695 (insert (format " %d." (% (1+ i) 10)))
1696 (setq beg (point))
1683 (insert (aref translations i)) 1697 (insert (aref translations i))
1698 ;; Passing the mouse over a character will highlight.
1699 (put-text-property beg (point) 'mouse-face 'highlight)
1684 (setq i (1+ i))) 1700 (setq i (1+ i)))
1685 (newline))))) 1701 (insert "\n")))))
1702
1703;; Choose a completion in *Quail Completions* buffer with mouse-2.
1704
1705(defun quail-mouse-choose-completion (event)
1706 "Click on an alternative in the `*Quail Completions*' buffer to choose it."
1707 (interactive "e")
1708 ;; This function is an exact copy of the mouse.el function
1709 ;; `mouse-choose-completion' except that we:
1710 ;; 1) add two lines from `choose-completion' in simple.el to give
1711 ;; the `mouse-2' click a little more leeway.
1712 ;; 2) don't bury *Quail Completions* buffer so comment a section, and
1713 ;; 3) delete/terminate the current quail selection here.
1714 ;; Give temporary modes such as isearch a chance to turn off.
1715 (run-hooks 'mouse-leave-buffer-hook)
1716 (let ((buffer (window-buffer))
1717 choice
1718 base-size)
1719 (save-excursion
1720 (set-buffer (window-buffer (posn-window (event-start event))))
1721 (if completion-reference-buffer
1722 (setq buffer completion-reference-buffer))
1723 (setq base-size completion-base-size)
1724 (save-excursion
1725 (goto-char (posn-point (event-start event)))
1726 (let (beg end)
1727 (if (and (not (eobp)) (get-text-property (point) 'mouse-face))
1728 (setq end (point) beg (1+ (point))))
1729 (if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face))
1730 (setq end (1- (point)) beg (point)))
1731 (if (null beg)
1732 (error "No completion here"))
1733 (setq beg (previous-single-property-change beg 'mouse-face))
1734 (setq end (or (next-single-property-change end 'mouse-face)
1735 (point-max)))
1736 (setq choice (buffer-substring beg end)))))
1737; (let ((owindow (selected-window)))
1738; (select-window (posn-window (event-start event)))
1739; (if (and (one-window-p t 'selected-frame)
1740; (window-dedicated-p (selected-window)))
1741; ;; This is a special buffer's frame
1742; (iconify-frame (selected-frame))
1743; (or (window-dedicated-p (selected-window))
1744; (bury-buffer)))
1745; (select-window owindow))
1746 (quail-delete-region)
1747 (quail-choose-completion-string choice buffer base-size)
1748 (quail-terminate-translation)))
1749
1750;; Modify the simple.el function `choose-completion-string', because
1751;; the simple.el function `choose-completion-delete-max-match' breaks
1752;; on Mule data, since the semantics of `forward-char' have changed.
1753
1754(defun quail-choose-completion-string (choice &optional buffer base-size)
1755 (let ((buffer (or buffer completion-reference-buffer)))
1756 ;; If BUFFER is a minibuffer, barf unless it's the currently
1757 ;; active minibuffer.
1758 (if (and (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer))
1759 (or (not (active-minibuffer-window))
1760 (not (equal buffer
1761 (window-buffer (active-minibuffer-window))))))
1762 (error "Minibuffer is not active for completion")
1763 ;; Insert the completion into the buffer where completion was requested.
1764 (set-buffer buffer)
1765; (if base-size
1766; (delete-region (+ base-size (point-min)) (point))
1767; (choose-completion-delete-max-match choice))
1768 (insert choice)
1769 (remove-text-properties (- (point) (length choice)) (point)
1770 '(mouse-face nil))
1771 ;; Update point in the window that BUFFER is showing in.
1772 (let ((window (get-buffer-window buffer t)))
1773 (set-window-point window (point)))
1774 ;; If completing for the minibuffer, exit it with this choice.
1775 (and (not completion-no-auto-exit)
1776 (equal buffer (window-buffer (minibuffer-window)))
1777 minibuffer-completion-table
1778 ;; If this is reading a file name, and the file name chosen
1779 ;; is a directory, don't exit the minibuffer.
1780 (if (and (eq minibuffer-completion-table 'read-file-name-internal)
1781 (file-directory-p (buffer-string)))
1782 (select-window (active-minibuffer-window))
1783 (exit-minibuffer))))))
1686 1784
1687(defun quail-help () 1785(defun quail-help ()
1688 "Show brief description of the current Quail package." 1786 "Show brief description of the current Quail package."