emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/consult-denote d74e556011 1/2: Remove faulty duplicate


From: ELPA Syncer
Subject: [elpa] externals/consult-denote d74e556011 1/2: Remove faulty duplicate of consult-denote-select-linked-file-prompt
Date: Mon, 4 Nov 2024 03:58:00 -0500 (EST)

branch: externals/consult-denote
commit d74e5560116d61802844e355815c4e3cdd0f4b4e
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Remove faulty duplicate of consult-denote-select-linked-file-prompt
---
 consult-denote.el | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/consult-denote.el b/consult-denote.el
index 8790053b6f..f00021405a 100644
--- a/consult-denote.el
+++ b/consult-denote.el
@@ -147,17 +147,6 @@ Return the absolute path to the matching file."
      :history 'denote-link-find-file-history
      :prompt "Find linked file")))
 
-(defun consult-denote-select-linked-file-prompt (files)
-  "Prompt for Denote file among FILES."
-  (let* ((default-directory denote-directory)
-         (file-names (mapcar 
#'denote-get-file-name-relative-to-denote-directory files)))
-    (consult--read
-     (denote--completion-table 'file file-names)
-     :prompt "Select FILE: "
-     :require-match t
-     :state (consult--file-preview)
-     :history 'denote-link-find-file-history)))
-
 (defun consult-denote-silo-directory-prompt ()
   "Like the `denote-silo-extras-directory-prompt' with Consult preview."
   (let ((default (car denote-silo-extras-directory-history)))
@@ -292,5 +281,29 @@ FILE has the same meaning as in 
`denote-org-extras-outline-prompt'."
     (advice-remove #'denote-org-extras-outline-prompt 
#'consult-denote-outline-prompt)
     (advice-remove #'denote-silo-extras-directory-prompt 
#'consult-denote-silo-directory-prompt)))
 
+;;;; Alternatives to Denote functions
+
+(defun consult-denote--subdirectory-p (directory)
+  "Return non-nil if DIRECTORY is a subdirectory of variable 
`denote-directory'."
+  (member directory (denote-directory-subdirectories)))
+
+(defun consult-denote--get-subdir-or-root ()
+  "Return current subdirectory of the variable `denote-directory'.
+If that is not available, return the value of variable
+`denote-directory'."
+  (if-let* ((current-dir (expand-file-name default-directory))
+            ((consult-denote--subdirectory-p current-dir)))
+      current-dir
+    (denote-directory)))
+
+(defun consult-denote--get-file-with-find (&optional directory)
+  "Use Consult to find a file in the variable `denote-directory'.
+With optional DIRECTORY, search that directory instead."
+  (let ((dir (or directory (consult-denote--get-subdir-or-root))))
+    (pcase-let* ((`(,prompt ,paths ,dir) (consult--directory-prompt "Find" 
dir))
+                 (default-directory dir)
+                 (builder (consult--find-make-builder paths)))
+      (consult--find prompt builder nil))))
+
 (provide 'consult-denote)
 ;;; consult-denote.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]