all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Peter Seibel <peter@gigamonkeys.com>
To: 75336@debbugs.gnu.org
Subject: bug#75336: [PATCH] Allow pcomplete of git add to include untracked files.
Date: Fri, 3 Jan 2025 16:00:27 -0800	[thread overview]
Message-ID: <CALHiJMYo-j+mttuMkan=2nkuSK0kYEiY32BrR+oWfAi=bkfKYA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 482 bytes --]

I was going a bit crazy trying to figure out why tab completion in *shell*
wasn't working for git add when I was trying to add a new file to my repo.
Turns out pcomplete was only completing modified tracked files.This patch
changes it so after git add it also completes untracked non-ignored files.

I believe I long ago signed a Copyright assignment to the Emacs project but
I'm happy to do it again if that's still required. Cheers!


-- 
Peter Seibel
http://www.gigamonkeys.com/

[-- Attachment #1.2: Type: text/html, Size: 764 bytes --]

[-- Attachment #2: 0001-Allow-pcomplete-of-git-add-to-include-untracked-file.patch --]
[-- Type: application/octet-stream, Size: 1581 bytes --]

From 7890a230953c081d93c806c8a802aa69452d7e28 Mon Sep 17 00:00:00 2001
From: Peter Seibel <peter@gigamonkeys.com>
Date: Fri, 3 Jan 2025 15:56:01 -0800
Subject: [PATCH] Allow pcomplete of git add to include untracked files.

---
 lisp/pcmpl-git.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/pcmpl-git.el b/lisp/pcmpl-git.el
index f57c2d5470a..498918ac1c4 100644
--- a/lisp/pcmpl-git.el
+++ b/lisp/pcmpl-git.el
@@ -82,8 +82,18 @@ Files listed by `git ls-files ARGS' satisfy the predicate."
                   (pcomplete-from-help `(,vc-git-program "help" ,subcmd)
                                        :argument
                                        "-+\\(?:\\[no-\\]\\)?[a-z-]+=?"))))
+               ;; Complete modified tracked files and untracked files
+               ("add"
+                (pcomplete-here
+                 (pcomplete-entries
+                  nil (let ((modified (pcmpl-git--tracked-file-predicate "-m"))
+                            (untracked (pcmpl-git--tracked-file-predicate "-o" "--exclude-standard")))
+                        (lambda (file)
+                          (or
+                           (and modified (funcall modified file))
+                           (and untracked (funcall untracked file))))))))
                ;; Complete modified tracked files
-               ((or "add" "commit" "restore")
+               ((or "commit" "restore")
                 (pcomplete-here
                  (pcomplete-entries
                   nil (pcmpl-git--tracked-file-predicate "-m"))))
-- 
2.47.1


             reply	other threads:[~2025-01-04  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-04  0:00 Peter Seibel [this message]
2025-01-04  7:52 ` bug#75336: [PATCH] Allow pcomplete of git add to include untracked files Eli Zaretskii
2025-01-04  7:54 ` Eli Zaretskii
2025-01-04 13:59   ` Peter Seibel
2025-01-04 15:04     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2025-01-04 15:52       ` Peter Seibel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALHiJMYo-j+mttuMkan=2nkuSK0kYEiY32BrR+oWfAi=bkfKYA@mail.gmail.com' \
    --to=peter@gigamonkeys.com \
    --cc=75336@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.