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: Tue, 5 Oct 2021 22:47:41 +0300 Message-ID: <2b9ae9f3-a253-f4f4-c08c-05e3c8ef1115@yandex.ru> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------96D874522264C92E25B35F4A" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19590"; 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 Tue Oct 05 21:49:42 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 1mXqRY-0004w5-FS for ged-emacs-devel@m.gmane-mx.org; Tue, 05 Oct 2021 21:49:40 +0200 Original-Received: from localhost ([::1]:37268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXqRX-0005F3-Hg for ged-emacs-devel@m.gmane-mx.org; Tue, 05 Oct 2021 15:49:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXqPj-0003bP-H2 for emacs-devel@gnu.org; Tue, 05 Oct 2021 15:47:47 -0400 Original-Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]:36584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mXqPh-0001B1-Lb for emacs-devel@gnu.org; Tue, 05 Oct 2021 15:47:47 -0400 Original-Received: by mail-lf1-x12e.google.com with SMTP id b20so651665lfv.3 for ; Tue, 05 Oct 2021 12:47:43 -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=LaMgQDo+GekUwzWX/ERvV+dhAFGAawce2mj8ACeVj5M=; b=oNLFF7qd9o8QxAytbsVUD6tX7KNVvGrIUd/DIrhxxyxxUFhmv2y3PV4EQdnfMRigTG FlESNFziWg+NS065GaYnpzFwbE919eXN9C6byTk5JAKEGrFHYEw89xOwsnzu1x7KUQVG dc7bpRpBYWpfBEt9BAFaVXJfPQAzAR/ksr/+moJnGhmywUNv4lwhs7pbytl8wD8sdx40 lEfkZH+N3MONhxDhJsjqSsGWFp3ThY5wRw1jw4QiVX7GwtRAHugCVmsZRuggM/CaApLb +B3O/1IwL1aTSETIoCFMAfYJiHCMiMHndZMofQRbv2XDfG50Y33uMrWHzP4xijQhoEKx bs/Q== 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=LaMgQDo+GekUwzWX/ERvV+dhAFGAawce2mj8ACeVj5M=; b=BxwlAiiWlLF7+PcHJWLMoQ/XviWzl4Pa4PlCpfHwA2gX/Z44coRPF0IF1HjTyV7GXB fjzwDBQocXppRkdfyDkOTlSv+htCxV4z7nkBqtj1dICeC6Yybw2w/hrOZ8BFDogJek6C ZdWbFf/tuclU5uWhJF05Qgx37Vk7M00BkiRffztBummC79cGqV38ffmwMOiHSyeGWhHU H1YMtqvYd0/eOxKu3aCmXVrWZAfqXHhZK79UojGpfAroXZSjb2YC+nKyZYuITIDw8r8h a+NBHjz/AZ8GhpbI/4q6YposnhpAANW4fEGmYpm04FHGsOy6j71rxCj0NiZeR0ajW/iV KWXA== X-Gm-Message-State: AOAM5301B1YmLeiAuSyLJ45qEKStXIIDmkG74+ttwFBjSMOYCXSSdmpR Bvv/8a7bhZQOMRbkPfQMvphzhCuypnM= X-Google-Smtp-Source: ABdhPJyL9mQqy0CzVAHyXHSYlbhc7oZXVaNZE5HRZL2kWv0jjzwgdq3/yhF61+3VzyJ0bg6fKHc1NQ== X-Received: by 2002:a19:550c:: with SMTP id n12mr5477505lfe.511.1633463262340; Tue, 05 Oct 2021 12:47:42 -0700 (PDT) Original-Received: from [192.168.1.113] ([178.252.127.239]) by smtp.googlemail.com with ESMTPSA id t9sm313078lfk.161.2021.10.05.12.47.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Oct 2021 12:47:41 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=raaahh@gmail.com; helo=mail-lf1-x12e.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:276380 Archived-At: This is a multi-part message in MIME format. --------------96D874522264C92E25B35F4A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi Manuel, On 04.10.2021 11:33, Manuel Uberti wrote: > Sorry to bring up this again, but is there anything that can be done on > this? > > The proposed solution with C-u C-x p f seems very reasonable to me, I > don't know what others project.el users think though. 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. Now, I've whipped up a small POC. See the attachment, try it out. Since 'find' without ignore instructions is as fast as 'git ls-files' (even faster, in my testing, on my machine), it didn't require any changes in the API so far. But is that the behavior we want? Currently it lists _all_ files in the directory, including, say, all contents of .git/ (of which there can be a lot, depending on the project, whether it uses 'git flow', etc). Should we add the common ignores from vc-directory-exclusion-list? To simply filter those dirs out? Maybe something else too? Like grep-find-ignored-files (it lists common compiled/object files which one usually doesn't want to search, or even visit)? Combining the vars above would bring the file listing to the default 'project-ignores' behavior. Which the 'transient' backend uses, for example. 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? 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. That *would* require a more involved change in project.el, but at least we'd make it after carefully weighing the options. --------------96D874522264C92E25B35F4A 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..15fa86f07c 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,19 @@ 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." + (let* ((all-files + (if no-ignores + (mapcan + (lambda (dir) (project--files-in-directory dir nil)) + 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 --------------96D874522264C92E25B35F4A--