feat: convert-to-node accepts project-tag and context-tag
This commit is contained in:
@@ -3415,26 +3415,26 @@ CONTEXT-TAG is the mu4e/agenda context (e.g. 'TDNDE', 'Perso')."
|
|||||||
(message "ExoKortex Node '%s' created in %s with tag '%s' (context: %s)."
|
(message "ExoKortex Node '%s' created in %s with tag '%s' (context: %s)."
|
||||||
node-name category tag context-tag)))
|
node-name category tag context-tag)))
|
||||||
|
|
||||||
(defun gortium/convert-to-node (node-dirs)
|
(defun gortium/convert-to-node (node-dirs &optional project-tag context-tag)
|
||||||
"Retrofit existing workspace directories into tracked ExoKortex nodes.
|
"Retrofit existing workspace directories into tracked ExoKortex nodes.
|
||||||
If folders are explicitly marked in Dirvish/Dired, it batch-processes all of them.
|
If folders are explicitly marked in Dirvish/Dired, it batch-processes all of them.
|
||||||
Otherwise, prompts for a single directory, defaulting to the item under the cursor."
|
Otherwise, prompts for a single directory, defaulting to the item under the cursor.
|
||||||
|
Optional PROJECT-TAG and CONTEXT-TAG can be given to create .projectile and .dir-locals.el."
|
||||||
(interactive
|
(interactive
|
||||||
(list
|
(list
|
||||||
(let* ((dired-elements (when (derived-mode-p 'dired-mode)
|
(let* ((dired-elements (when (derived-mode-p 'dired-mode)
|
||||||
(dired-get-marked-files nil nil nil t)))
|
(dired-get-marked-files nil nil nil t)))
|
||||||
;; Dired returns (t . ("path")) if exactly ONE file is marked explicitly,
|
|
||||||
;; or a flat list if multiple are marked.
|
|
||||||
(has-explicit-marks (or (and (listp dired-elements) (> (length dired-elements) 1))
|
(has-explicit-marks (or (and (listp dired-elements) (> (length dired-elements) 1))
|
||||||
(and (consp dired-elements) (eq (car dired-elements) t))))
|
(and (consp dired-elements) (eq (car dired-elements) t))))
|
||||||
(marked-dirs (when has-explicit-marks
|
(marked-dirs (when has-explicit-marks
|
||||||
(cl-remove-if-not #'file-directory-p
|
(cl-remove-if-not #'file-directory-p
|
||||||
(if (eq (car-safe dired-elements) t)
|
(if (eq (car-safe dired-elements) t)
|
||||||
(cdr dired-elements)
|
(cdr dired-elements)
|
||||||
dired-elements)))))
|
dired-elements)))))
|
||||||
(if marked-dirs
|
(if marked-dirs
|
||||||
marked-dirs
|
(list marked-dirs
|
||||||
;; Fallback: No explicit marks found, prompt for a single target
|
(read-string "Project tag (blank to skip): ")
|
||||||
|
(completing-read "Context tag: " (quote ("TDNDE" "Perso" "")) nil t))
|
||||||
(let* ((cursor-path (when (derived-mode-p 'dired-mode)
|
(let* ((cursor-path (when (derived-mode-p 'dired-mode)
|
||||||
(dired-get-filename nil t)))
|
(dired-get-filename nil t)))
|
||||||
(initial-path (cond
|
(initial-path (cond
|
||||||
@@ -3443,22 +3443,23 @@ Otherwise, prompts for a single directory, defaulting to the item under the curs
|
|||||||
(cursor-path
|
(cursor-path
|
||||||
(file-name-directory cursor-path))
|
(file-name-directory cursor-path))
|
||||||
(t default-directory))))
|
(t default-directory))))
|
||||||
(list (read-directory-name "Directory to convert: " nil initial-path t initial-path)))))))
|
(list (list (read-directory-name "Directory to convert: " nil initial-path t initial-path))
|
||||||
|
(read-string "Project tag (blank to skip): ")
|
||||||
;; Execution Block
|
(completing-read "Context tag: " (quote ("TDNDE" "Perso" "")) nil t)))))))
|
||||||
|
|
||||||
(let ((count 0)
|
(let ((count 0)
|
||||||
last-org-file)
|
last-org-file)
|
||||||
(dolist (dir node-dirs)
|
(dolist (dir node-dirs)
|
||||||
(let* ((node-dir (expand-file-name dir))
|
(let* ((node-dir (expand-file-name dir))
|
||||||
(node-name (file-name-nondirectory (directory-file-name node-dir)))
|
(org-file (gortium/ensure-node-structure node-dir
|
||||||
(org-file (gortium/ensure-node-structure node-dir "Audit existing assets and reconcile tracking nodes")))
|
"Audit existing assets and reconcile tracking nodes"
|
||||||
|
(unless (string-empty-p project-tag) project-tag)
|
||||||
|
(unless (string-empty-p context-tag) context-tag))))
|
||||||
(setq last-org-file org-file)
|
(setq last-org-file org-file)
|
||||||
(cl-incf count)))
|
(cl-incf count)))
|
||||||
|
|
||||||
;; Contextual UI Feedback
|
|
||||||
(if (= count 1)
|
(if (= count 1)
|
||||||
(progn
|
(message "Directory successfully converted to ExoKortex node.")
|
||||||
(message "Directory successfully converted to ExoKortex node."))
|
|
||||||
(message "Successfully batch-converted %d directories to ExoKortex nodes!" count))))
|
(message "Successfully batch-converted %d directories to ExoKortex nodes!" count))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|||||||
@@ -2499,26 +2499,26 @@ CONTEXT-TAG is the mu4e/agenda context (e.g. 'TDNDE', 'Perso')."
|
|||||||
(message "ExoKortex Node '%s' created in %s with tag '%s' (context: %s)."
|
(message "ExoKortex Node '%s' created in %s with tag '%s' (context: %s)."
|
||||||
node-name category tag context-tag)))
|
node-name category tag context-tag)))
|
||||||
|
|
||||||
(defun gortium/convert-to-node (node-dirs)
|
(defun gortium/convert-to-node (node-dirs &optional project-tag context-tag)
|
||||||
"Retrofit existing workspace directories into tracked ExoKortex nodes.
|
"Retrofit existing workspace directories into tracked ExoKortex nodes.
|
||||||
If folders are explicitly marked in Dirvish/Dired, it batch-processes all of them.
|
If folders are explicitly marked in Dirvish/Dired, it batch-processes all of them.
|
||||||
Otherwise, prompts for a single directory, defaulting to the item under the cursor."
|
Otherwise, prompts for a single directory, defaulting to the item under the cursor.
|
||||||
|
Optional PROJECT-TAG and CONTEXT-TAG can be given to create .projectile and .dir-locals.el."
|
||||||
(interactive
|
(interactive
|
||||||
(list
|
(list
|
||||||
(let* ((dired-elements (when (derived-mode-p 'dired-mode)
|
(let* ((dired-elements (when (derived-mode-p 'dired-mode)
|
||||||
(dired-get-marked-files nil nil nil t)))
|
(dired-get-marked-files nil nil nil t)))
|
||||||
;; Dired returns (t . ("path")) if exactly ONE file is marked explicitly,
|
|
||||||
;; or a flat list if multiple are marked.
|
|
||||||
(has-explicit-marks (or (and (listp dired-elements) (> (length dired-elements) 1))
|
(has-explicit-marks (or (and (listp dired-elements) (> (length dired-elements) 1))
|
||||||
(and (consp dired-elements) (eq (car dired-elements) t))))
|
(and (consp dired-elements) (eq (car dired-elements) t))))
|
||||||
(marked-dirs (when has-explicit-marks
|
(marked-dirs (when has-explicit-marks
|
||||||
(cl-remove-if-not #'file-directory-p
|
(cl-remove-if-not #'file-directory-p
|
||||||
(if (eq (car-safe dired-elements) t)
|
(if (eq (car-safe dired-elements) t)
|
||||||
(cdr dired-elements)
|
(cdr dired-elements)
|
||||||
dired-elements)))))
|
dired-elements)))))
|
||||||
(if marked-dirs
|
(if marked-dirs
|
||||||
marked-dirs
|
(list marked-dirs
|
||||||
;; Fallback: No explicit marks found, prompt for a single target
|
(read-string "Project tag (blank to skip): ")
|
||||||
|
(completing-read "Context tag: " (quote ("TDNDE" "Perso" "")) nil t))
|
||||||
(let* ((cursor-path (when (derived-mode-p 'dired-mode)
|
(let* ((cursor-path (when (derived-mode-p 'dired-mode)
|
||||||
(dired-get-filename nil t)))
|
(dired-get-filename nil t)))
|
||||||
(initial-path (cond
|
(initial-path (cond
|
||||||
@@ -2527,22 +2527,23 @@ Otherwise, prompts for a single directory, defaulting to the item under the curs
|
|||||||
(cursor-path
|
(cursor-path
|
||||||
(file-name-directory cursor-path))
|
(file-name-directory cursor-path))
|
||||||
(t default-directory))))
|
(t default-directory))))
|
||||||
(list (read-directory-name "Directory to convert: " nil initial-path t initial-path)))))))
|
(list (list (read-directory-name "Directory to convert: " nil initial-path t initial-path))
|
||||||
|
(read-string "Project tag (blank to skip): ")
|
||||||
;; Execution Block
|
(completing-read "Context tag: " (quote ("TDNDE" "Perso" "")) nil t)))))))
|
||||||
|
|
||||||
(let ((count 0)
|
(let ((count 0)
|
||||||
last-org-file)
|
last-org-file)
|
||||||
(dolist (dir node-dirs)
|
(dolist (dir node-dirs)
|
||||||
(let* ((node-dir (expand-file-name dir))
|
(let* ((node-dir (expand-file-name dir))
|
||||||
(node-name (file-name-nondirectory (directory-file-name node-dir)))
|
(org-file (gortium/ensure-node-structure node-dir
|
||||||
(org-file (gortium/ensure-node-structure node-dir "Audit existing assets and reconcile tracking nodes")))
|
"Audit existing assets and reconcile tracking nodes"
|
||||||
|
(unless (string-empty-p project-tag) project-tag)
|
||||||
|
(unless (string-empty-p context-tag) context-tag))))
|
||||||
(setq last-org-file org-file)
|
(setq last-org-file org-file)
|
||||||
(cl-incf count)))
|
(cl-incf count)))
|
||||||
|
|
||||||
;; Contextual UI Feedback
|
|
||||||
(if (= count 1)
|
(if (= count 1)
|
||||||
(progn
|
(message "Directory successfully converted to ExoKortex node.")
|
||||||
(message "Directory successfully converted to ExoKortex node."))
|
|
||||||
(message "Successfully batch-converted %d directories to ExoKortex nodes!" count))))
|
(message "Successfully batch-converted %d directories to ExoKortex nodes!" count))))
|
||||||
|
|
||||||
(defun gortium/read-dir-local (var)
|
(defun gortium/read-dir-local (var)
|
||||||
|
|||||||
Reference in New Issue
Block a user