From dbaaff2b0d9250a0b7fdbde179c0bc5ee5d79838 Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 29 Mar 2021 04:58:00 +0100 Subject: org-links: pdf <-> org admitting any notes subdir --- lib/org/jao-org-links.el | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lib/org') diff --git a/lib/org/jao-org-links.el b/lib/org/jao-org-links.el index f8080f5..019d26b 100644 --- a/lib/org/jao-org-links.el +++ b/lib/org/jao-org-links.el @@ -1,3 +1,5 @@ +-*- lexical-binding: t; -*- + (require 'jao-org-utils) (require 'jao-maildir) (require 'pdf-info) @@ -121,20 +123,23 @@ (org-link-set-parameters "message" :follow #'jao-org-links-open-mail) (setq jao-org--sink-dir (file-name-as-directory sink-dir))) -;;;###autoload -(defvar jao-org-doc-notes-dir "notes/books") +(defvar jao-doc-notes-dir) ;;;###autoload (defun jao-org-org-to-pdf-file () - (replace-regexp-in-string (format "/%s/\\(.+\\)\\.org$" jao-org-doc-notes-dir) - "/doc/\\1.org" - buffer-file-name)) + (expand-file-name (concat "doc/" (file-name-base buffer-file-name) ".pdf") + jao-org-notes-dir)) ;;;###autoload (defun jao-org-pdf-to-org-file (&optional file-name) - (replace-regexp-in-string "/doc/\\(.+\\)\\.pdf$" - (format "/%s/\\1.org" jao-org-doc-notes-dir) - (or file-name buffer-file-name))) + (let* ((file-name (or file-name buffer-file-name)) + (bn (file-name-base file-name)) + (rx (format "%s\\.org$" (regexp-quote bn)))) + (or (car (directory-files-recursively jao-org-notes-dir rx)) + (let* ((dirs (seq-difference (directory-files jao-org-notes-dir) + '("." ".." "attic"))) + (dir (completing-read "Notes subdir: " dirs nil t))) + (expand-file-name (concat dir "/" bn ".org") jao-org-notes-dir))))) ;;;###autoload (defun jao-org-insert-doc-skeleton (&optional title) -- cgit v1.2.3