From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Masatake YAMATO Newsgroups: gmane.emacs.devel Subject: Enhanced enhanced visual feedback in `*Completions*' buffer Date: Sat, 08 Oct 2005 16:02:07 +0900 (JST) Message-ID: <20051008.160207.188502984.jet@gyve.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1128755733 15834 80.91.229.2 (8 Oct 2005 07:15:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 8 Oct 2005 07:15:33 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 08 09:15:31 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EO8ut-00032X-P5 for ged-emacs-devel@m.gmane.org; Sat, 08 Oct 2005 09:14:48 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EO8ur-0001BH-Ks for ged-emacs-devel@m.gmane.org; Sat, 08 Oct 2005 03:14:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EO8sP-0001B3-On for emacs-devel@gnu.org; Sat, 08 Oct 2005 03:12:14 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EO8sO-0001Ap-O7 for emacs-devel@gnu.org; Sat, 08 Oct 2005 03:12:13 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EO8sO-0001Am-Hm for emacs-devel@gnu.org; Sat, 08 Oct 2005 03:12:12 -0400 Original-Received: from [210.130.136.40] (helo=r-maa.spacetown.ne.jp) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EO8sO-0008MO-3m for emacs-devel@gnu.org; Sat, 08 Oct 2005 03:12:12 -0400 Original-Received: from localhost (h219-110-074-077.catv01.itscom.jp [219.110.74.77]) by r-maa.spacetown.ne.jp (8.11.6) with ESMTP id j987C7507643 for ; Sat, 8 Oct 2005 16:12:08 +0900 (JST) Original-To: emacs-devel@gnu.org X-Mailer: Mew version 4.2.53 on Emacs 22.0.50 / Mule 5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:43679 Archived-At: Hi, "Enhanced visual feedback in `*Completions*' buffer" was supported completion performed in minibuffer only. Attached patch generalizes the function; it supports completion performed outside of minibuffer. I introduce a variable, `completion-common-string' which is used as a hint in `completion-setup-function' to put faces to *Completions* buffer. Client code like `lisp-complete-symbol' sets `completion-common-string'. Masatake YAMATO 2005-10-08 Masatake YAMATO * simple.el (completion-common-string): New variable. (completion-setup-function): Use `completion-common-string'. * emacs-lisp/lisp.el (lisp-complete-symbol): Bind the completion pattern to `completion-common-string'. Index: lisp/emacs-lisp/lisp.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp.el,v retrieving revision 1.68 diff -u -r1.68 lisp.el --- lisp/emacs-lisp/lisp.el 6 Aug 2005 17:08:59 -0000 1.68 +++ lisp/emacs-lisp/lisp.el 8 Oct 2005 05:34:44 -0000 @@ -585,8 +585,9 @@ new)) (setq list (cdr list))) (setq list (nreverse new)))) - (with-output-to-temp-buffer "*Completions*" - (display-completion-list list))) + (let ((completion-common-string pattern)) + (with-output-to-temp-buffer "*Completions*" + (display-completion-list list)))) (message "Making completion list...%s" "done"))))))) ;;; arch-tag: aa7fa8a4-2e6f-4e9b-9cd9-fef06340e67e Index: lisp/simple.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v retrieving revision 1.754 diff -u -r1.754 simple.el --- lisp/simple.el 6 Oct 2005 06:55:45 -0000 1.754 +++ lisp/simple.el 8 Oct 2005 05:34:45 -0000 @@ -4867,6 +4867,20 @@ (defvar completion-root-regexp "^/" "Regexp to use in `completion-setup-function' to find the root directory.") +(defvar completion-common-string nil + "Common prefix substring to use in `completion-setup-function' to put faces. +Set this variable when completion is performed in a buffer other than minibuffer. + +To put faces, `completions-first-difference' and `completions-common-part' +into \"*Completions*\* buffer, the common prefix substring in completions is +needed as a hint. (Minibuffer is a special case. The content of minibuffer itself +is the substring.) + +Typical usage: +\(let ((completion-common-string pattern)) + (with-output-to-temp-buffer \"*Completions*\" + (display-completion-list (all-completions pattern obarray predicate)))))") + (defun completion-setup-function () (let ((mainbuf (current-buffer)) (mbuf-contents (minibuffer-contents))) @@ -4905,9 +4919,11 @@ (funcall (get minibuffer-completion-table 'completion-base-size-function))) (setq completion-base-size 0)))) ;; Put faces on first uncommon characters and common parts. - (when completion-base-size + (when (or completion-base-size completion-common-string) (let* ((common-string-length - (- (length mbuf-contents) completion-base-size)) + (if completion-base-size + (- (length mbuf-contents) completion-base-size) + (length completion-common-string))) (element-start (next-single-property-change (point-min) 'mouse-face))