Skip to content

Commit 18ca83a

Browse files
committed
[emacs] project-management: add jj support for find-file-git-changed
If we are using jj, show list of files changed since last bookmark instead of the ones in the current commit.
1 parent 91d902a commit 18ca83a

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

emacs/.config/emacs/lisp/project-management.el

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,22 @@
2727
(project-root (project-current))))))
2828

2929
(defun meain/find-file-git-changed ()
30-
"Fuzzy find git changed files."
30+
"Fuzzy find git or jj changed files."
3131
(interactive)
32-
(let* ((untracked-files (shell-command-to-string "git ls-files --others --exclude-standard"))
33-
(changed-files (shell-command-to-string "git diff --name-only"))
34-
(files (split-string (concat untracked-files "\n" changed-files) "\n" t)))
35-
(find-file (completing-read "Pick file: " files))))
32+
(let* ((project-root (locate-dominating-file default-directory ".jj"))
33+
(get-changed-files
34+
(if project-root
35+
;; Use jj (use `jj diff --name-only -r 'trunk()..@'` for since trunk)
36+
(lambda ()
37+
(let ((changed (shell-command-to-string "jj diff --name-only -r 'latest(bookmarks() & ::@)..@'")))
38+
(split-string changed "\n" t)))
39+
;; Use git
40+
(lambda ()
41+
(let ((untracked-files (shell-command-to-string "git ls-files --others --exclude-standard"))
42+
(changed-files (shell-command-to-string "git diff --name-only")))
43+
(split-string (concat untracked-files "\n" changed-files) "\n" t)))))
44+
(files (funcall get-changed-files)))
45+
(find-file (completing-read "Find git/jj changed file: " files))))
3646

3747
(defun meain/find-file-semantic ()
3848
(interactive)

0 commit comments

Comments
 (0)