From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.bugs Subject: bug#12939: 24.3.50; [PATCH] `icomplete-mode' should respect `completion-ignored-extensions' Date: Mon, 19 Nov 2012 14:15:39 -0800 Message-ID: <0698DAE413DC4AF9827C54F4C6206C07@us.oracle.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0092_01CDC660.5AE32C90" X-Trace: ger.gmane.org 1353363366 3242 80.91.229.3 (19 Nov 2012 22:16:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 19 Nov 2012 22:16:06 +0000 (UTC) To: 12939@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 19 23:16:17 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TaZdU-0004nE-GC for geb-bug-gnu-emacs@m.gmane.org; Mon, 19 Nov 2012 23:16:12 +0100 Original-Received: from localhost ([::1]:52172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaZdJ-0001Vr-UO for geb-bug-gnu-emacs@m.gmane.org; Mon, 19 Nov 2012 17:16:01 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaZdG-0001VY-72 for bug-gnu-emacs@gnu.org; Mon, 19 Nov 2012 17:15:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TaZdE-0000Rn-T5 for bug-gnu-emacs@gnu.org; Mon, 19 Nov 2012 17:15:58 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaZdE-0000Ri-P3 for bug-gnu-emacs@gnu.org; Mon, 19 Nov 2012 17:15:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TaZeH-0003Uw-S7 for bug-gnu-emacs@gnu.org; Mon, 19 Nov 2012 17:17:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "Drew Adams" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Nov 2012 22:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 12939 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Original-Received: via spool by submit@debbugs.gnu.org id=B.135336341913432 (code B ref -1); Mon, 19 Nov 2012 22:17:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Nov 2012 22:16:59 +0000 Original-Received: from localhost ([127.0.0.1]:55734 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TaZeF-0003Ua-6h for submit@debbugs.gnu.org; Mon, 19 Nov 2012 17:16:59 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:55334) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TaZeC-0003US-3I for submit@debbugs.gnu.org; Mon, 19 Nov 2012 17:16:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TaZd7-0000Qe-3b for submit@debbugs.gnu.org; Mon, 19 Nov 2012 17:15:50 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:33515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaZd6-0000QU-Vr for submit@debbugs.gnu.org; Mon, 19 Nov 2012 17:15:49 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaZd5-0001Uv-Mn for bug-gnu-emacs@gnu.org; Mon, 19 Nov 2012 17:15:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TaZd3-0000Py-T2 for bug-gnu-emacs@gnu.org; Mon, 19 Nov 2012 17:15:47 -0500 Original-Received: from userp1040.oracle.com ([156.151.31.81]:38129) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaZd3-0000Ou-EQ for bug-gnu-emacs@gnu.org; Mon, 19 Nov 2012 17:15:45 -0500 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qAJMFhDu026531 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 19 Nov 2012 22:15:43 GMT Original-Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id qAJMFgqS009856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 19 Nov 2012 22:15:42 GMT Original-Received: from abhmt112.oracle.com (abhmt112.oracle.com [141.146.116.64]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id qAJMFgO1024469 for ; Mon, 19 Nov 2012 16:15:42 -0600 Original-Received: from dradamslap1 (/130.35.178.8) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 19 Nov 2012 14:15:41 -0800 X-Mailer: Microsoft Office Outlook 11 Thread-Index: Ac3Go2hk2jTZv7G4Tresv5166XmkDA== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:67189 Archived-At: This is a multi-part message in MIME format. ------=_NextPart_000_0092_01CDC660.5AE32C90 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit (setq icomplete-with-completion-tables t) `icomplete-mode' shows, e.g., names of files ending with `~'. It should, but it does not, respect `completion-ignored-extensions'. This is apparently because `completion-all-sorted-completions' does not respect it either (which is, however, TRT). Seems like some other function should be used, which returns all completions like `completion-all-sorted-completions' does (and like `all-completions' does), but which also respects `completion-ignored-extensions'. I see comments in minibuffer.el indicating that this is a more general bug, which you presumably intend to fix in a more general way. But this problem for icomplete.el has existed since Emacs 23.1, so why not fix it there while waiting for an ideal, general solution. Attached is a patch that I think DTRT. (FWIW, I do something similar in icomplete+.el, and it seems to work fine. I use `all-completions' instead of `completion-all-sorted-completions', however, so the call to `completion-pcm--filename-try-filter' need not come after setting the last cdr to nil.) [BTW - `completion-pcm--filename-try-filter' should not be considered internal (internal to what?), IMO. And it should be renamed. It has nothing to do with pcm (or with icompletion, for that matter). And it really doesn't have anything particular to do with `all-completions' vs `try-completion'. All it does is filter its list arg ALL to make the elements respect `completion-ignored-extensions'. It is essentially a remove-if ignored-extension function - name it accordingly.] [BTW2 - Remind me again why `icomplete-with-completion-tables' is not a defcustom? And why the default value, even for the defvar, is not t?] In GNU Emacs 24.3.50.1 (i386-mingw-nt5.1.2600) of 2012-11-05 on MS-W7-DANI Bzr revision: 110809 lekktu@gmail.com-20121105172930-a5gn0bwi4lndchhw Windowing system distributor `Microsoft Corp.', version 5.1.2600 Configured using: `configure --with-gcc (4.7) --no-opt --enable-checking --cflags -I../../libs/libXpm-3.5.10/include -I../../libs/libXpm-3.5.10/src -I../../libs/libpng-1.2.37-lib/include -I../../libs/zlib-1.2.5 -I../../libs/giflib-4.1.4-1-lib/include -I../../libs/jpeg-6b-4-lib/include -I../../libs/tiff-3.8.2-1-lib/include -I../../libs/libxml2-2.7.8-w32-bin/include/libxml2 -I../../libs/gnutls-3.0.9-w32-bin/include -I../../libs/libiconv-1.9.2-1-lib/include' ------=_NextPart_000_0092_01CDC660.5AE32C90 Content-Type: application/octet-stream; name="icomplete-patched-2012-11-19.el" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="icomplete-patched-2012-11-19.el" ;;; icomplete.el --- minibuffer completion incremental feedback=0A= =0A= ;; Copyright (C) 1992-1994, 1997, 1999, 2001-2012=0A= ;; Free Software Foundation, Inc.=0A= =0A= ;; Author: Ken Manheimer =0A= ;; Maintainer: Ken Manheimer =0A= ;; Created: Mar 1993 Ken Manheimer, klm@nist.gov - first release to = usenet=0A= ;; Last update: Ken Manheimer , 11/18/1999.=0A= ;; Keywords: help, abbrev=0A= =0A= ;; This file is part of GNU Emacs.=0A= =0A= ;; GNU Emacs is free software: you can redistribute it and/or modify=0A= ;; it under the terms of the GNU General Public License as published by=0A= ;; the Free Software Foundation, either version 3 of the License, or=0A= ;; (at your option) any later version.=0A= =0A= ;; GNU Emacs is distributed in the hope that it will be useful,=0A= ;; but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= ;; GNU General Public License for more details.=0A= =0A= ;; You should have received a copy of the GNU General Public License=0A= ;; along with GNU Emacs. If not, see .=0A= =0A= ;;; Commentary:=0A= =0A= ;; Loading this package implements a more fine-grained minibuffer=0A= ;; completion feedback scheme. Prospective completions are concisely=0A= ;; indicated within the minibuffer itself, with each successive=0A= ;; keystroke.=0A= =0A= ;; See `icomplete-completions' docstring for a description of the=0A= ;; icomplete display format.=0A= =0A= ;; See the `icomplete-minibuffer-setup-hook' docstring for a means to=0A= ;; customize icomplete setup for interoperation with other=0A= ;; minibuffer-oriented packages.=0A= =0A= ;; To activate icomplete mode, load the package and use the=0A= ;; `icomplete-mode' function. You can subsequently deactivate it by=0A= ;; invoking the function icomplete-mode with a negative prefix-arg=0A= ;; (C-U -1 ESC-x icomplete-mode). Also, you can prevent activation of=0A= ;; the mode during package load by first setting the variable=0A= ;; `icomplete-mode' to nil. Icompletion can be enabled any time after=0A= ;; the package is loaded by invoking icomplete-mode without a prefix=0A= ;; arg.=0A= =0A= ;; Thanks to everyone for their suggestions for refinements of this=0A= ;; package. I particularly have to credit Michael Cook, who=0A= ;; implemented an incremental completion style in his 'iswitch'=0A= ;; functions that served as a model for icomplete. Some other=0A= ;; contributors: Noah Friedman (restructuring as minor mode), Colin=0A= ;; Rafferty (lemacs reconciliation), Lars Lindberg, RMS, and others.=0A= =0A= ;; klm.=0A= =0A= ;;; Code:=0A= =0A= ;;;_* Provide=0A= (provide 'icomplete)=0A= =0A= =0A= (defgroup icomplete nil=0A= "Show completions dynamically in minibuffer."=0A= :prefix "icomplete-"=0A= :group 'minibuffer)=0A= =0A= (defvar icomplete-prospects-length 80)=0A= (make-obsolete-variable=0A= 'icomplete-prospects-length 'icomplete-prospects-height "23.1")=0A= =0A= ;;;_* User Customization variables=0A= (defcustom icomplete-prospects-height=0A= ;; 20 is an estimated common size for the prompt + minibuffer content, = to=0A= ;; try to guess the number of lines used up by = icomplete-prospects-length.=0A= (+ 1 (/ (+ icomplete-prospects-length 20) (window-width)))=0A= "Maximum number of lines to use in the minibuffer."=0A= :type 'integer=0A= :group 'icomplete=0A= :version "23.1")=0A= =0A= (defcustom icomplete-compute-delay .3=0A= "Completions-computation stall, used only with large-number = completions.=0A= See `icomplete-delay-completions-threshold'."=0A= :type 'number=0A= :group 'icomplete)=0A= =0A= (defcustom icomplete-delay-completions-threshold 400=0A= "Pending-completions number over which to apply = `icomplete-compute-delay'."=0A= :type 'integer=0A= :group 'icomplete)=0A= =0A= (defcustom icomplete-max-delay-chars 3=0A= "Maximum number of initial chars to apply icomplete compute delay."=0A= :type 'integer=0A= :group 'icomplete)=0A= =0A= (defcustom icomplete-show-key-bindings t=0A= "If non-nil, show key bindings as well as completion for sole matches."=0A= :type 'boolean=0A= :group 'icomplete)=0A= =0A= (defcustom icomplete-minibuffer-setup-hook nil=0A= "Icomplete-specific customization of minibuffer setup.=0A= =0A= This hook is run during minibuffer setup if icomplete is active.=0A= It is intended for use in customizing icomplete for interoperation=0A= with other features and packages. For instance:=0A= =0A= \(add-hook 'icomplete-minibuffer-setup-hook=0A= \(function=0A= \(lambda ()=0A= \(make-local-variable 'max-mini-window-height)=0A= \(setq max-mini-window-height 3))))=0A= =0A= will constrain Emacs to a maximum minibuffer height of 3 lines when=0A= icompletion is occurring."=0A= :type 'hook=0A= :group 'icomplete)=0A= =0A= =0A= ;;;_* Initialization=0A= =0A= ;;;_ + Internal Variables=0A= ;;;_ =3D icomplete-eoinput nil=0A= (defvar icomplete-overlay (make-overlay (point-min) (point-min) nil t t)=0A= "Overlay used to display the list of completions.")=0A= =0A= ;;;_ =3D icomplete-pre-command-hook=0A= (defvar icomplete-pre-command-hook nil=0A= "Incremental-minibuffer-completion pre-command-hook.=0A= =0A= Is run in minibuffer before user input when `icomplete-mode' is non-nil.=0A= Use `icomplete-mode' function to set it up properly for incremental=0A= minibuffer completion.")=0A= (add-hook 'icomplete-pre-command-hook 'icomplete-tidy)=0A= ;;;_ =3D icomplete-post-command-hook=0A= (defvar icomplete-post-command-hook nil=0A= "Incremental-minibuffer-completion post-command-hook.=0A= =0A= Is run in minibuffer after user input when `icomplete-mode' is non-nil.=0A= Use `icomplete-mode' function to set it up properly for incremental=0A= minibuffer completion.")=0A= (add-hook 'icomplete-post-command-hook 'icomplete-exhibit)=0A= =0A= (defun icomplete-get-keys (func-name)=0A= "Return strings naming keys bound to FUNC-NAME, or nil if none.=0A= Examines the prior, not current, buffer, presuming that current buffer=0A= is minibuffer."=0A= (when (commandp func-name)=0A= (save-excursion=0A= (let* ((sym (intern func-name))=0A= (buf (other-buffer nil t))=0A= (keys (with-current-buffer buf (where-is-internal sym))))=0A= (when keys=0A= (concat "<"=0A= (mapconcat 'key-description=0A= (sort keys=0A= #'(lambda (x y)=0A= (< (length x) (length y))))=0A= ", ")=0A= ">"))))))=0A= ;;;_ =3D icomplete-with-completion-tables=0A= (defvar icomplete-with-completion-tables '(internal-complete-buffer)=0A= "Specialized completion tables with which icomplete should operate.=0A= =0A= Icomplete does not operate with any specialized completion tables=0A= except those on this list.")=0A= =0A= ;;;_ > icomplete-mode (&optional prefix)=0A= ;;;###autoload=0A= (define-minor-mode icomplete-mode=0A= "Toggle incremental minibuffer completion (Icomplete mode).=0A= With a prefix argument ARG, enable Icomplete mode if ARG is=0A= positive, and disable it otherwise. If called from Lisp, enable=0A= the mode if ARG is omitted or nil."=0A= :global t :group 'icomplete=0A= (if icomplete-mode=0A= ;; The following is not really necessary after first time -=0A= ;; no great loss.=0A= (add-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup)=0A= (remove-hook 'minibuffer-setup-hook 'icomplete-minibuffer-setup)))=0A= =0A= ;;;_ > icomplete-simple-completing-p ()=0A= (defun icomplete-simple-completing-p ()=0A= "Non-nil if current window is minibuffer that's doing simple = completion.=0A= =0A= Conditions are:=0A= the selected window is a minibuffer,=0A= and not in the middle of macro execution,=0A= and `minibuffer-completion-table' is not a symbol (which would=0A= indicate some non-standard, non-simple completion mechanism,=0A= like file-name and other custom-func completions)."=0A= =0A= (and (window-minibuffer-p (selected-window))=0A= (not executing-kbd-macro)=0A= minibuffer-completion-table=0A= (or (not (functionp minibuffer-completion-table))=0A= (eq icomplete-with-completion-tables t)=0A= (member minibuffer-completion-table=0A= icomplete-with-completion-tables))))=0A= =0A= ;;;_ > icomplete-minibuffer-setup ()=0A= (defun icomplete-minibuffer-setup ()=0A= "Run in minibuffer on activation to establish incremental completion.=0A= Usually run by inclusion in `minibuffer-setup-hook'."=0A= (when (and icomplete-mode (icomplete-simple-completing-p))=0A= (set (make-local-variable 'completion-show-inline-help) nil)=0A= (add-hook 'pre-command-hook=0A= (lambda () (let ((non-essential t))=0A= (run-hooks 'icomplete-pre-command-hook)))=0A= nil t)=0A= (add-hook 'post-command-hook=0A= (lambda () (let ((non-essential t)) ;E.g. don't prompt for = password!=0A= (run-hooks 'icomplete-post-command-hook)))=0A= nil t)=0A= (run-hooks 'icomplete-minibuffer-setup-hook)))=0A= ;=0C=0A= =0A= =0A= ;;;_* Completion=0A= =0A= ;;;_ > icomplete-tidy ()=0A= (defun icomplete-tidy ()=0A= "Remove completions display \(if any) prior to new user input.=0A= Should be run in on the minibuffer `pre-command-hook'. See = `icomplete-mode'=0A= and `minibuffer-setup-hook'."=0A= (delete-overlay icomplete-overlay))=0A= =0A= ;;;_ > icomplete-exhibit ()=0A= (defun icomplete-exhibit ()=0A= "Insert icomplete completions display.=0A= Should be run via minibuffer `post-command-hook'. See `icomplete-mode'=0A= and `minibuffer-setup-hook'."=0A= (when (and icomplete-mode (icomplete-simple-completing-p))=0A= (save-excursion=0A= (goto-char (point-max))=0A= ; Insert the match-status = information:=0A= (if (and (> (point-max) (minibuffer-prompt-end))=0A= buffer-undo-list ; Wait for some user input.=0A= (or=0A= ;; Don't bother with delay after certain number of chars:=0A= (> (- (point) (field-beginning)) icomplete-max-delay-chars)=0A= ;; Don't delay if alternatives number is small enough:=0A= (and (sequencep minibuffer-completion-table)=0A= (< (length minibuffer-completion-table)=0A= icomplete-delay-completions-threshold))=0A= ;; Delay - give some grace time for next keystroke, before=0A= ;; embarking on computing completions:=0A= (sit-for icomplete-compute-delay)))=0A= (let ((text (while-no-input=0A= (icomplete-completions=0A= (field-string)=0A= minibuffer-completion-table=0A= minibuffer-completion-predicate=0A= (not minibuffer-completion-confirm))))=0A= (buffer-undo-list t)=0A= deactivate-mark)=0A= ;; Do nothing if while-no-input was aborted.=0A= (when (stringp text)=0A= (move-overlay icomplete-overlay (point) (point) = (current-buffer))=0A= ;; The current C cursor code doesn't know to use the = overlay's=0A= ;; marker's stickiness to figure out whether to place the = cursor=0A= ;; before or after the string, so let's spoon-feed it the = pos.=0A= (put-text-property 0 1 'cursor t text)=0A= (overlay-put icomplete-overlay 'after-string text)))))))=0A= =0A= ;;;_ > icomplete-completions (name candidates predicate require-match)=0A= (defun icomplete-completions (name candidates predicate require-match)=0A= "Identify prospective candidates for minibuffer completion.=0A= =0A= The display is updated with each minibuffer keystroke during=0A= minibuffer completion.=0A= =0A= Prospective completion suffixes (if any) are displayed, bracketed by=0A= one of \(), \[], or \{} pairs. The choice of brackets is as follows:=0A= =0A= \(...) - a single prospect is identified and matching is enforced,=0A= \[...] - a single prospect is identified but matching is optional, or=0A= \{...} - multiple prospects, separated by commas, are indicated, and=0A= further input is required to distinguish a single one.=0A= =0A= The displays for unambiguous matches have ` [Matched]' appended=0A= \(whether complete or not), or ` \[No matches]', if no eligible=0A= matches exist. \(Keybindings for uniquely matched commands=0A= are exhibited within the square braces.)"=0A= =0A= (let* ((md (completion--field-metadata (field-beginning)))=0A= (comps (completion-all-sorted-completions))=0A= (last (if (consp comps) (last comps)))=0A= (base-size (cdr last))=0A= (open-bracket (if require-match "(" "["))=0A= (close-bracket (if require-match ")" "]")))=0A= ;; `concat'/`mapconcat' is the slow part.=0A= (if (not (consp comps))=0A= (format " %sNo matches%s" open-bracket close-bracket)=0A= (if last (setcdr last nil))=0A= (when (and minibuffer-completing-file-name=0A= icomplete-with-completion-tables)=0A= (setq comps (completion-pcm--filename-try-filter comps)))=0A= (let* ((most-try=0A= (if (and base-size (> base-size 0))=0A= (completion-try-completion=0A= name candidates predicate (length name) md)=0A= ;; If the `comps' are 0-based, the result should be=0A= ;; the same with `comps'.=0A= (completion-try-completion=0A= name comps nil (length name) md)))=0A= (most (if (consp most-try) (car most-try)=0A= (if most-try (car comps) "")))=0A= ;; Compare name and most, so we can determine if name is=0A= ;; a prefix of most, or something else.=0A= (compare (compare-strings name nil nil=0A= most nil nil completion-ignore-case))=0A= (determ (unless (or (eq t compare) (eq t most-try)=0A= (=3D (setq compare (1- (abs compare)))=0A= (length most)))=0A= (concat open-bracket=0A= (cond=0A= ((=3D compare (length name))=0A= ;; Typical case: name is a prefix.=0A= (substring most compare))=0A= ((< compare 5) most)=0A= (t (concat "..." (substring most compare))))=0A= close-bracket)))=0A= ;;"-prospects" - more than one candidate=0A= (prospects-len (+ (length determ) 6 ;; take {,...} into account=0A= (string-width (buffer-string))))=0A= (prospects-max=0A= ;; Max total length to use, including the minibuffer = content.=0A= (* (+ icomplete-prospects-height=0A= ;; If the minibuffer content already uses up more = than=0A= ;; one line, increase the allowable space = accordingly.=0A= (/ prospects-len (window-width)))=0A= (window-width)))=0A= (prefix-len=0A= ;; Find the common prefix among `comps'.=0A= ;; We can't use the optimization below because its assumptions=0A= ;; aren't always true, e.g. when completion-cycling (bug#10850):=0A= ;; (if (eq t (compare-strings (car comps) nil (length most)=0A= ;; most nil nil completion-ignore-case))=0A= ;; ;; Common case.=0A= ;; (length most)=0A= ;; Else, use try-completion.=0A= (let ((comps-prefix (try-completion "" comps)))=0A= (and (stringp comps-prefix)=0A= (length comps-prefix)))) ;;)=0A= =0A= prospects most-is-exact comp limit)=0A= (if (eq most-try t) ;; (or (null (cdr comps))=0A= (setq prospects nil)=0A= (while (and comps (not limit))=0A= (setq comp=0A= (if prefix-len (substring (car comps) prefix-len) (car comps))=0A= comps (cdr comps))=0A= (cond ((string-equal comp "") (setq most-is-exact t))=0A= ((member comp prospects))=0A= (t (setq prospects-len=0A= (+ (string-width comp) 1 prospects-len))=0A= (if (< prospects-len prospects-max)=0A= (push comp prospects)=0A= (setq limit t))))))=0A= ;; Restore the base-size info, since = completion-all-sorted-completions=0A= ;; is cached.=0A= (if last (setcdr last base-size))=0A= (if prospects=0A= (concat determ=0A= "{"=0A= (and most-is-exact ",")=0A= (mapconcat 'identity (nreverse prospects) ",")=0A= (and limit ",...")=0A= "}")=0A= (concat determ=0A= " [Matched"=0A= (let ((keys (and icomplete-show-key-bindings=0A= (commandp (intern-soft most))=0A= (icomplete-get-keys most))))=0A= (if keys (concat "; " keys) ""))=0A= "]"))))))=0A= =0A= ;;_* Local emacs vars.=0A= ;;Local variables:=0A= ;;allout-layout: (-2 :)=0A= ;;End:=0A= =0A= ;;; icomplete.el ends here=0A= ------=_NextPart_000_0092_01CDC660.5AE32C90--