unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Enhanced enhanced visual feedback in `*Completions*' buffer
@ 2005-10-08  7:02 Masatake YAMATO
  2005-10-08 22:55 ` Richard M. Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Masatake YAMATO @ 2005-10-08  7:02 UTC (permalink / raw)


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  <jet@gyve.org>

	* 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))

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-10-10  4:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-08  7:02 Enhanced enhanced visual feedback in `*Completions*' buffer Masatake YAMATO
2005-10-08 22:55 ` Richard M. Stallman
2005-10-09  4:16   ` Masatake YAMATO
2005-10-09 19:12     ` Masatake YAMATO
2005-10-10  4:15     ` Richard M. Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).