-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use mdfind on macos #18
Comments
Yes, sure. The reason I did not venture down that path is because of the idea I have to use ;; TODO 2022-06-15: Maybe we can do the same in a more standard way?
;; Perhaps with `xref-matches-in-files'?
;;
;; (xref-matches-in-files IDENTIFIER (denote--directory-files :absolute)) I was thinking that Ultimately, we can have the What do you think? |
Since you are here: I plan to expand the section in the manual about extending Denote. Will include |
That sounds great. I should have a look at
Cool -- it seems like consult-notes will work great with Denote. Please let me know though if there is any functionality you think should be added. |
If you have any ideas, please let me know.
Maybe the error you get is due to a different version of At any rate, this is a good reason to use
I used it over the weekend. It worked and I like the interface! Though |
With xref we delegate to a built-in facility instead of passing a hard-coded list of arguments to 'process-lines'. The old method is prone to errors, such as not working on builds of Emacs for macOS, as reported by Colin McLear in issue 18 over at the GitHub mirror: <#18>. Users of Emacs 28 or higher can configure 'xref-search-program' to change from the default 'grep' to 'ripgrep', 'ugrep', or a user-defined alternative. THIS CHANGE IS PROVISIONAL and subject to further edits.
I pushed a commit to the
The diff, if it helps you: denote-retrieve.el | 41 +++++++++++++++++++----------------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/denote-retrieve.el b/denote-retrieve.el
index fbd5534..75724f3 100644
--- a/denote-retrieve.el
+++ b/denote-retrieve.el
@@ -96,33 +96,30 @@ (defun denote-retrieve--files-in-output (files)
(when (denote--only-note-p f) f))
files)))
-;; TODO 2022-06-15: Maybe we can do the same in a more standard way?
-;; Perhaps with `xref-matches-in-files'?
-;;
-;; (xref-matches-in-files IDENTIFIER (denote--directory-files :absolute))
+(autoload 'xref--analyze "xref")
+
+(defun denote-retrieve--xrefs (identifier)
+ "Return xrefs of IDENTIFIER in variable `denote-directory'."
+ (xref--analyze
+ (xref-matches-in-files identifier (denote--directory-files :absolute))))
+
+(defun denote-retrieve--files-in-xrefs (xrefs)
+ "Return sorted file names sans directory from XREFS.
+Parse `denote-retrieve--xrefs'."
+ (sort
+ (mapcar (lambda (x)
+ (file-name-nondirectory (car x)))
+ xrefs)
+ #'string-lessp))
+
(defun denote-retrieve--proces-grep (identifier)
"Process lines matching IDENTIFIER and return list of files."
(let* ((default-directory (denote-directory))
(file (file-name-nondirectory (buffer-file-name))))
(denote-retrieve--files-in-output
- (sort
- (process-lines
- "find"
- default-directory
- "-maxdepth" "1"
- "-type" "f"
- "!" "-name" file
- "-exec"
- grep-program
- "--color=never"
- "-m"
- "1"
- "-e"
- identifier
- "{}"
- ";"
- "-print")
- #'string-lessp))))
+ (delete file
+ (denote-retrieve--files-in-xrefs
+ (denote-retrieve--xrefs identifier))))))
(provide 'denote-retrieve)
;;; denote-retrieve.el ends here |
Yes -- testing it a bit and it seems to work well! I'll close this but will let you know if I run into any problems. Thanks! |
Thank you! Merged it and added your name to the manual's "Acknowledgements". |
Hello and thanks for the very interesting package. I use macos and I've noticed a
process-lines-handling-status: find exited with status 1
error when I usedenote-link-backlinks
. I suspect this is because macos usesmdfind
rather than find. As far as I can tell the relevant function here isWould it be possible to allow for customization of this function? For example,
consult-locate
allows the user to specify arguments (like mdfind) usingconsult-locate-args
. Perhaps something similar could be done here. This is all just speculation though, because I haven't yet gotten the function to work appropriately usingmdfind
andgrep
.The text was updated successfully, but these errors were encountered: