all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#75336: [PATCH] Allow pcomplete of git add to include untracked files.
@ 2025-01-04  0:00 Peter Seibel
  2025-01-04  7:52 ` Eli Zaretskii
  2025-01-04  7:54 ` Eli Zaretskii
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Seibel @ 2025-01-04  0:00 UTC (permalink / raw)
  To: 75336


[-- 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-01-04 15:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-04  0:00 bug#75336: [PATCH] Allow pcomplete of git add to include untracked files Peter Seibel
2025-01-04  7:52 ` 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

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.