From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.bugs Subject: bug#29007: 25.3; [PATCH] Make filecache use extended completion Date: Sat, 04 Nov 2017 20:31:40 +0100 Message-ID: <87zi813ko3.fsf@hochschule-trier.de> References: <87k1zi75yn.fsf@hochschule-trier.de> <83wp37vg79.fsf@gnu.org> <878tfn478b.fsf@hochschule-trier.de> <83fu9vuq54.fsf@gnu.org> <874lqa3pmc.fsf@hochschule-trier.de> <83d14xucmm.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1509823938 4198 195.159.176.226 (4 Nov 2017 19:32:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 4 Nov 2017 19:32:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: 29007@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 04 20:32:14 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eB4As-0000dr-CF for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Nov 2017 20:32:10 +0100 Original-Received: from localhost ([::1]:41985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eB4Az-0003IJ-PT for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Nov 2017 15:32:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eB4Ao-0003Hd-U6 for bug-gnu-emacs@gnu.org; Sat, 04 Nov 2017 15:32:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eB4Aj-0001F2-Vs for bug-gnu-emacs@gnu.org; Sat, 04 Nov 2017 15:32:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42254) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eB4Aj-0001Eu-Rt for bug-gnu-emacs@gnu.org; Sat, 04 Nov 2017 15:32:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eB4Aj-0005f6-MH for bug-gnu-emacs@gnu.org; Sat, 04 Nov 2017 15:32:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas Politz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Nov 2017 19:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29007 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 29007-submit@debbugs.gnu.org id=B29007.150982391321748 (code B ref 29007); Sat, 04 Nov 2017 19:32:01 +0000 Original-Received: (at 29007) by debbugs.gnu.org; 4 Nov 2017 19:31:53 +0000 Original-Received: from localhost ([127.0.0.1]:50935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eB4Aa-0005ei-Vy for submit@debbugs.gnu.org; Sat, 04 Nov 2017 15:31:53 -0400 Original-Received: from gateway-a.fh-trier.de ([143.93.54.181]:37689) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eB4AY-0005eU-CP for 29007@debbugs.gnu.org; Sat, 04 Nov 2017 15:31:51 -0400 X-Virus-Scanned: by Amavisd-new + Sophos + ClamAV [Rechenzentrum Hochschule Trier (RZ/HT)] Original-Received: from localhost (ip5886048c.dynamic.kabel-deutschland.de [88.134.4.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: politza) by gateway-a.fh-trier.de (Postfix) with ESMTPSA id CF12717B0AD3; Sat, 4 Nov 2017 20:31:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha1; c=simple/simple; d=hochschule-trier.de; s=default; t=1509823903; bh=V4CJbXSoB4bz8K+q065djdEaoGM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID: MIME-Version:Content-Type; b=js3T+TJJ6mm7jNErYgj2GeCnXnSZYxUqgesX0tDhhCQ8K6cLTh/pp0mAKjkid+yks inliV9JRAysnqOd1IClANT7MlaNgL/9GHzT+/nC6V16rcXodXD96EFp+UY6iuWcJzh S/TnTIssumbGRonHuwn5CI5OkLu2s2tJ4s+WEnes= In-Reply-To: <83d14xucmm.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 04 Nov 2017 20:23:13 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:139446 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Thanks. I think your patch is good for the master branch, but I think > it should include a NEWS entry about the change. Take a look and see if it's OK. --=-=-= Content-Type: text/x-diff Content-Disposition: inline diff --git a/etc/NEWS b/etc/NEWS index 0dd6e36c70..c47ca42d27 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -103,6 +103,12 @@ less verbose by removing non-essential information. dimensions, instead of always using 16 pixels. As a result, Tetris, Snake and Pong are more playable on HiDPI displays. +** Filecache + +--- +*** Completing filenames in the minibuffer via 'C-TAB' now uses the +styles as configured by the variable 'completion-styles'. + * New Modes and Packages in Emacs 27.1 diff --git a/lisp/filecache.el b/lisp/filecache.el index 38a434b11b..aac4f488cd 100644 --- a/lisp/filecache.el +++ b/lisp/filecache.el @@ -566,68 +566,67 @@ file-cache-minibuffer-complete the name is considered already unique; only the second substitution \(directories) is done." (interactive "P") - (let* - ( - (completion-ignore-case file-cache-completion-ignore-case) - (case-fold-search file-cache-case-fold-search) - (string (file-name-nondirectory (minibuffer-contents))) - (completion-string (try-completion string file-cache-alist)) - (completion-list) - (len) - (file-cache-string)) + (let* ((completion-ignore-case file-cache-completion-ignore-case) + (case-fold-search file-cache-case-fold-search) + (string (file-name-nondirectory (minibuffer-contents))) + (completion (completion-try-completion + string file-cache-alist nil 0))) (cond ;; If it's the only match, replace the original contents - ((or arg (eq completion-string t)) - (setq file-cache-string (file-cache-file-name string)) - (if (string= file-cache-string (minibuffer-contents)) - (minibuffer-message file-cache-sole-match-message) - (delete-minibuffer-contents) - (insert file-cache-string) - (if file-cache-multiple-directory-message - (minibuffer-message file-cache-multiple-directory-message)))) + ((or arg (eq completion t)) + (let ((file-name (file-cache-file-name string))) + (if (string= file-name (minibuffer-contents)) + (minibuffer-message file-cache-sole-match-message) + (delete-minibuffer-contents) + (insert file-name) + (if file-cache-multiple-directory-message + (minibuffer-message file-cache-multiple-directory-message))))) ;; If it's the longest match, insert it - ((stringp completion-string) - ;; If we've already inserted a unique string, see if the user - ;; wants to use that one - (if (and (string= string completion-string) - (assoc-string string file-cache-alist - file-cache-ignore-case)) - (if (and (eq last-command this-command) - (string= file-cache-last-completion completion-string)) - (progn - (delete-minibuffer-contents) - (insert (file-cache-file-name completion-string)) - (setq file-cache-last-completion nil)) - (minibuffer-message file-cache-non-unique-message) - (setq file-cache-last-completion string)) - (setq file-cache-last-completion string) - (setq completion-list (all-completions string file-cache-alist) - len (length completion-list)) - (if (> len 1) - (progn - (goto-char (point-max)) - (insert - (substring completion-string (length string))) - ;; Add our own setup function to the Completions Buffer - (let ((completion-setup-hook - (append completion-setup-hook - (list 'file-cache-completion-setup-function)))) - (with-output-to-temp-buffer file-cache-completions-buffer - (display-completion-list - (completion-hilit-commonality completion-list - (length string)))))) - (setq file-cache-string (file-cache-file-name completion-string)) - (if (string= file-cache-string (minibuffer-contents)) - (minibuffer-message file-cache-sole-match-message) - (delete-minibuffer-contents) - (insert file-cache-string) - (if file-cache-multiple-directory-message - (minibuffer-message file-cache-multiple-directory-message))) - ))) + ((consp completion) + (let ((newstring (car completion)) + (newpoint (cdr completion))) + ;; If we've already inserted a unique string, see if the user + ;; wants to use that one + (if (and (string= string newstring) + (assoc-string string file-cache-alist + file-cache-ignore-case)) + (if (and (eq last-command this-command) + (string= file-cache-last-completion newstring)) + (progn + (delete-minibuffer-contents) + (insert (file-cache-file-name newstring)) + (setq file-cache-last-completion nil)) + (minibuffer-message file-cache-non-unique-message) + (setq file-cache-last-completion string)) + (setq file-cache-last-completion string) + (let* ((completion-list (completion-all-completions + newstring file-cache-alist nil newpoint)) + (base-size (cdr (last completion-list)))) + (when base-size + (setcdr (last completion-list) nil)) + (if (> (length completion-list) 1) + (progn + (delete-region (- (point-max) (length string)) (point-max)) + (save-excursion (insert newstring)) + (forward-char newpoint) + ;; Add our own setup function to the Completions Buffer + (let ((completion-setup-hook + (append completion-setup-hook + (list 'file-cache-completion-setup-function)))) + (with-output-to-temp-buffer file-cache-completions-buffer + (display-completion-list + (completion-hilit-commonality completion-list newpoint))))) + (let ((file-name (file-cache-file-name newstring))) + (if (string= file-name (minibuffer-contents)) + (minibuffer-message file-cache-sole-match-message) + (delete-minibuffer-contents) + (insert file-name) + (if file-cache-multiple-directory-message + (minibuffer-message file-cache-multiple-directory-message))))))))) ;; No match - ((eq completion-string nil) + ((eq completion nil) (minibuffer-message file-cache-no-match-message))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; --=-=-= Content-Type: text/plain -ap --=-=-=--