l3kn / org-fc

Spaced Repetition System for Emacs org-mode
https://www.leonrische.me/fc/index.html
GNU General Public License v3.0
259 stars 31 forks source link

Option for use ripgrep instead of find in org-fc-awk--find #69

Open mithraen opened 2 years ago

mithraen commented 2 years ago

When use org-fc in directory when files with flashcards mixed with files without flash cards, with ripgrep instead of file

It can be done like this:

(defun org-fc-awk--find (paths)
  "Generate shell code to search PATHS for org files.
Matches all .org files ignoring ones with names don't start with
a '.' to exclude temporary / backup files.
With the '-L' option, 'find' follows symlinks."
  (format
   (if
       org-fc-use-ripgrep
       "rg ^:REVIEW_DATA: -L %s -g \"*.org\" -l -0"
       "find -L %s -name \"*.org\" -not -name \".*\" -print0")
   (mapconcat
    (lambda (path) (shell-quote-argument (expand-file-name path)))
    paths " ")))
l3kn commented 2 years ago

Searching only for files containing flashcards is a great idea, maybe a org-fc-find-command variable would be more flexible?

mithraen commented 2 years ago

Yes, it would be better solution. Maybe with sample in documentation for 'find + grep' and 'ripgrep'.

I prefer ripgrep, but find + xargs + grep works fast enough.

Maybe set default for this variable to something like:

find -L . -name "*.org" -not -name ".*" -print0 | xargs -0r grep -lZ ^:REVIEW_DATA: