Magit: dired-untracked-files

Created on 18 Feb 2020  路  3Comments  路  Source: magit/magit

Hi,
I wrote some lisp to take the list of Untracked files in a magit buffer and create a dired from them. Have papers already with FSF so the code is yours if you want it (or suggestions for how else to implement this?)

Stephen

(require 's)

(defun dired-untracked-files ()
  "Create a dired buffer from the listed untracked files."
  (interactive)
  (let (beg end files)
    (save-excursion
      (goto-char (point-min))
      (re-search-forward "^Untracked files ([0-9]+)")
      (forward-char)
      (setq beg (point))
      ;; find the end of the list of Untracked files.
      (re-search-forward "^$")
      (beginning-of-line)
      (backward-char 1)
      (setq end (point))
      (setq files (s-lines (buffer-substring-no-properties beg end))))
    (dired (cons "dired-untracked" files))
    ))
support

Most helpful comment

Took a while, but I made this more general solution

https://github.com/sje30/emacs#dired--create-a-dired-buffer-of-files-listed-on-stdin

All 3 comments

I would recommend that you instead get the untracked files using git ls-files --exclude-standard --other. Once you do that this doesn't have much to do with Magit anymore but maybe it can find a home in some dired related package. Happy hacking!

Thanks! Will investigate.

Took a while, but I made this more general solution

https://github.com/sje30/emacs#dired--create-a-dired-buffer-of-files-listed-on-stdin

Was this page helpful?
0 / 5 - 0 ratings

Related issues

garvinguan picture garvinguan  路  3Comments

tarsius picture tarsius  路  5Comments

ipburbank picture ipburbank  路  3Comments

ninrod picture ninrod  路  4Comments

kpurdon picture kpurdon  路  4Comments