From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: project-find-file: switch to include non-tracked files Date: Wed, 6 Oct 2021 09:05:29 +0300 Message-ID: <9995e361-34f1-9aa6-f854-eb197723a8fd@yandex.ru> References: <2b9ae9f3-a253-f4f4-c08c-05e3c8ef1115@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------5226FA05915A6F06058DC6E0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14971"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 To: Manuel Uberti , emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Oct 06 08:07:24 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mY05L-0003ms-BF for ged-emacs-devel@m.gmane-mx.org; Wed, 06 Oct 2021 08:07:23 +0200 Original-Received: from localhost ([::1]:37782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mY05J-0005J9-Vm for ged-emacs-devel@m.gmane-mx.org; Wed, 06 Oct 2021 02:07:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mY03b-0004S2-U7 for emacs-devel@gnu.org; Wed, 06 Oct 2021 02:05:36 -0400 Original-Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]:42595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mY03Z-0005Sq-QP for emacs-devel@gnu.org; Wed, 06 Oct 2021 02:05:35 -0400 Original-Received: by mail-lf1-x12b.google.com with SMTP id x27so5612938lfa.9 for ; Tue, 05 Oct 2021 23:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=ZaXWwe66SMCqiqleeJaq7SYFGEuW9XPEuuVXB2a2LJ4=; b=dLCGKLSMSG/17lTuqmgI3HnHSxApF32MnUAVYrgNFV9RpAZ46LsjVt3/+nDzihLGZ4 sJLhbczM+KZkPfTNj7fXs8h1GzurnGu2n83QSo7mBMV/4PtGveZyBOHmpL1QlF++nS1a ltV2nPDUOgmDcFpZ9IUMiGK/GwPB15iVYwBjBvtpfctfAVoJTpcye7AK+TnIdyFBUKAk 34KVpLz09BOfs/MnL5UkcqAR8T4xbkBvngKEmgiHr+v9yFDv5PzDfIRU+AqbRbbaA9oQ uEzgtqrJZXPlzfCD6a2ksJfVrOjfm1f41mvJR4h+PRfIMXW/EZrqznUSpx4BBcgtPJcl J4BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=ZaXWwe66SMCqiqleeJaq7SYFGEuW9XPEuuVXB2a2LJ4=; b=ajymHpu2jtIfpdhzOBLtmSS/dkCeppKPGDiByuS+70OmOWPwRtSAXDgpmn81cZEYs7 mv5+vGSzVcM7UpBaxbO0hvigtkjZu6SmCrqYKz2MWVjZzSwPXjxsB8nhdPpUPprFDIrI dUH9diSCLx7zFyuoipj8yn7iwwmzOj5wPj04A8h66/W080ZpDfAEYmBjMpdNTgdl6btz kYB+SubMpCc45heDqhwN8pLweYXUrtroLCYznvv2b/TRg6P9+xu9UxADBEPub1mfvUSm s9OEP3ZtNc8nGAWgenkQzKrZ5v6fYbFShrL/lNFA++ZI9ZdOEUgT2ijyC72NpVOE1otq PSRg== X-Gm-Message-State: AOAM531WNJ3nS6A6y+o8NydEwLzh1rr62bPp8dcdByg90WhYTuRy7Tfe s2zKGv9erWpE1XEAz/fUP1WiZH/dALQ= X-Google-Smtp-Source: ABdhPJyEuu2Hf4FHBJ7M0l0+PMoKAT63KJ5zSZV/Y3S95kHQC8Y8EEPhvoksPQIhm8ZdAZW5KKeVbA== X-Received: by 2002:a2e:9752:: with SMTP id f18mr1217138ljj.354.1633500330884; Tue, 05 Oct 2021 23:05:30 -0700 (PDT) Original-Received: from [192.168.1.113] ([178.252.127.239]) by smtp.googlemail.com with ESMTPSA id o5sm2169852lft.278.2021.10.05.23.05.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Oct 2021 23:05:30 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=raaahh@gmail.com; helo=mail-lf1-x12b.google.com X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:276407 Archived-At: This is a multi-part message in MIME format. --------------5226FA05915A6F06058DC6E0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 06.10.2021 08:18, Manuel Uberti wrote: > On 05/10/21 21:47, Dmitry Gutov wrote: >> It kind of got lost among other issues, sorry. That's doubly easy to >> do with emacs-devel threads, so if you could use Debbugs for feature >> requests in the future, that would be great. > > Do you want me to move the discussion on Debbugs? No, it's fine here now. > I think ignoring directories such as .git would be good to speed up the > command and make the candidate list cleaner. OK, see the updated patch. find's performance is really sensitive to the number of ignore entries it has to process, so if the difference in performance between two invocation types gets too noticeable, while they return approximately the same number of entries, customizing vc-directory-exclusion-list to have fewer entries can help. >> But in the previous iteration of this thread you also referred to >> Helm's 'C-c i' behavior. Does it only list the ignored files? > > 'C-c i' in helm-ls-git toggles the '-o' switch for git ls-files, so it > does not include the listing of the .git directory in its result. All right, this does seem to include all files, not just the ignored ones. >> In any case, we could make 'C-u project-find-file' have this behavior: >> listing only ignored files instead. And maybe not all of them: >> skipping the contents of .git/, .bzr/, etc, still sounds useful. The >> upside is possibly having a lot fewer files to choose from. > > I agree with you. Which of the two behaviors would you like it to have, though? --------------5226FA05915A6F06058DC6E0 Content-Type: text/x-patch; charset=UTF-8; name="project-find-file-no-ignores.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="project-find-file-no-ignores.diff" diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 3eaa789b3e..65ae43ff4c 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -835,28 +835,28 @@ project--read-regexp project-regexp-history-variable))) ;;;###autoload -(defun project-find-file () +(defun project-find-file (&optional no-ignores) "Visit a file (with completion) in the current project. The filename at point (determined by `thing-at-point'), if any, is available as part of \"future history\"." - (interactive) + (interactive "P") (let* ((pr (project-current t)) (dirs (list (project-root pr)))) - (project-find-file-in (thing-at-point 'filename) dirs pr))) + (project-find-file-in (thing-at-point 'filename) dirs pr no-ignores))) ;;;###autoload -(defun project-or-external-find-file () +(defun project-or-external-find-file (&optional no-ignores) "Visit a file (with completion) in the current project or external roots. The filename at point (determined by `thing-at-point'), if any, is available as part of \"future history\"." - (interactive) + (interactive "P") (let* ((pr (project-current t)) (dirs (cons (project-root pr) (project-external-roots pr)))) - (project-find-file-in (thing-at-point 'filename) dirs pr))) + (project-find-file-in (thing-at-point 'filename) dirs pr no-ignores))) (defcustom project-read-file-name-function #'project--read-file-cpd-relative "Function to call to read a file name from a list. @@ -909,12 +909,24 @@ project--read-file-absolute predicate hist mb-default)) -(defun project-find-file-in (suggested-filename dirs project) +(defun project-find-file-in (suggested-filename dirs project &optional no-ignores) "Complete a file name in DIRS in PROJECT and visit the result. SUGGESTED-FILENAME is a relative file name, or part of it, which -is used as part of \"future history\"." - (let* ((all-files (project-files project dirs)) +is used as part of \"future history\". + +If NO-IGNORES is specified, include all files from DIRS, except +for VCS metadata directories enumerated in `vc-directory-exclusion-list'." + (let* ((vc-dirs-ignores (mapcar + (lambda (dir) + (concat dir "/")) + vc-directory-exclusion-list)) + (all-files + (if no-ignores + (mapcan + (lambda (dir) (project--files-in-directory dir vc-dirs-ignores)) + dirs) + (project-files project dirs))) (completion-ignore-case read-file-name-completion-ignore-case) (file (funcall project-read-file-name-function "Find file" all-files nil nil --------------5226FA05915A6F06058DC6E0--