From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: Re: project--completing-read-strict breaks ada-mode project completion table Date: Thu, 17 Jan 2019 15:17:40 -0800 Message-ID: <86zhrynaaz.fsf@stephe-leake.org> References: <20180922154639.23195.66360@vcs0.savannah.gnu.org> <20180922154640.9D58220310@vcs0.savannah.gnu.org> <54108dbc-9d12-06ff-3f1d-151118e9b234@yandex.ru> <4e729d1e-bb31-455f-fd44-e99ae5a6b9fa@yandex.ru> <86zhs5r9lr.fsf_-_@stephe-leake.org> <08de4d90-d678-0524-9356-f9a3515bf0c4@yandex.ru> <86a7k2rabi.fsf@stephe-leake.org> <86sgxso27d.fsf@stephe-leake.org> <86fttsntw5.fsf@stephe-leake.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1547766952 2179 195.159.176.226 (17 Jan 2019 23:15:52 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 17 Jan 2019 23:15:52 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (windows-nt) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 18 00:15:48 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gkGsx-0000Lv-NR for ged-emacs-devel@m.gmane.org; Fri, 18 Jan 2019 00:15:43 +0100 Original-Received: from localhost ([127.0.0.1]:57349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkGv4-0006is-LA for ged-emacs-devel@m.gmane.org; Thu, 17 Jan 2019 18:17:54 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkGux-0006ij-Jb for emacs-devel@gnu.org; Thu, 17 Jan 2019 18:17:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkGuw-0002mJ-M9 for emacs-devel@gnu.org; Thu, 17 Jan 2019 18:17:47 -0500 Original-Received: from smtp105.ord1d.emailsrvr.com ([184.106.54.105]:43448) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gkGuw-0002g7-G1 for emacs-devel@gnu.org; Thu, 17 Jan 2019 18:17:46 -0500 Original-Received: from smtp6.relay.ord1d.emailsrvr.com (localhost [127.0.0.1]) by smtp6.relay.ord1d.emailsrvr.com (SMTP Server) with ESMTP id 11AF0E05BC for ; Thu, 17 Jan 2019 18:17:44 -0500 (EST) X-Auth-ID: board-president@tomahawk-creek-hoa.com Original-Received: by smtp6.relay.ord1d.emailsrvr.com (Authenticated sender: board-president-AT-tomahawk-creek-hoa.com) with ESMTPSA id B7409E0605 for ; Thu, 17 Jan 2019 18:17:43 -0500 (EST) X-Sender-Id: board-president@tomahawk-creek-hoa.com Original-Received: from Takver4 ([UNAVAILABLE]. [76.77.182.20]) (using TLSv1.2 with cipher AES256-GCM-SHA384) by 0.0.0.0:25 (trex/5.7.12); Thu, 17 Jan 2019 18:17:44 -0500 In-Reply-To: <86fttsntw5.fsf@stephe-leake.org> (Stephen Leake's message of "Wed, 16 Jan 2019 14:02:18 -0800") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 184.106.54.105 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:232444 Archived-At: --=-=-= Content-Type: text/plain Stephen Leake writes: > These are now in the ELPA master branch: > > elpa/packages/ada-mode/ada-project.el > elpa/packages/ada-mode/env-package.el > elpa/packages/path-iterator/path-iterator.el > elpa/packages/uniquify-files/uniquify-files.el Attached is an example project for emacs source to play with. To use it, eval the following in emacs master *scratch* (adjust paths); ---------------- (add-to-list 'load-path "c:/Projects/elpa/packages/uniquify-files") (add-to-list 'load-path "c:/Projects/elpa/packages/path-iterator") (load-file "c:/Projects/emacs_stephe.main/projects/emacs-project.el") ;; revert to emacs-26 version of project--completing-read-strict ;; (skip this to show the problem with the master version) (defun project--completing-read-strict (prompt collection &optional predicate hist default inherit-input-method) ;; Tried both expanding the default before showing the prompt, and ;; removing it when it has no matches. Neither seems natural ;; enough. Removal is confusing; early expansion makes the prompt ;; too long. (let* ((new-prompt (if default (format "%s (default %s): " prompt default) (format "%s: " prompt))) (res (completing-read new-prompt collection predicate t nil hist default inherit-input-method))) (if (and (equal res default) (not (test-completion res collection predicate))) (completing-read (format "%s: " prompt) collection predicate t res hist nil inherit-input-method) res))) (find-file "c:/Projects/emacs/master/lisp/files.el") ----------------- Then type "M-x project-find-file", followed by "proje" . Or use icomplete-mode, use C-. , C-, to rotate completions. There's a bug in path-iterator; I've set :ignore-function to ignore any dir under ".git", but they are showing up anyway. But that demonstrates how non-unique file names are handled, so it's good for this demo. -- -- Stephe --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=emacs-project.el Content-Transfer-Encoding: quoted-printable ;; emacs-project.el --- project for Emacs C source code -*- lexical-bindin= g: t -*-=0D =0D (require 'project)=0D (require 'uniquify-files)=0D =0D (cl-defstruct (emacs-project)=0D root=0D )=0D =0D (defun emacs-project-try (dir)=0D "For 'project-find-functions'."=0D (when (string-match "emacs" dir)=0D (make-emacs-project :root (locate-dominating-file dir "autogen.sh"))))= =0D =0D (cl-defmethod project-library-roots ((prj emacs-project))=0D nil)=0D =0D (cl-defmethod project-roots ((prj emacs-project))=0D (list (emacs-project-root prj)))=0D =0D (defun emacs-project-ignore-dir (dir)=0D "Return non-nil if 'dir' should be ignored in file-completion-table."=0D (string-match dir ".*\\.git.*"))=0D =0D (cl-defmethod project-file-completion-table ((prj emacs-project) dirs)=0D (let ((iter (make-path-iterator=0D :user-path-non-recursive nil=0D :user-path-recursive (or dirs (list root))=0D :ignore-function #'emacs-project-ignore-dir)))=0D (apply-partially #'uniq-file-completion-table iter)=0D ))=0D =0D (add-to-list 'project-find-functions #'emacs-project-try)=0D =0D (provide 'emacs-project)=0D ;; end of file=0D --=-=-=--