summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-03-29 04:58:00 +0100
committerjao <jao@gnu.org>2021-03-29 04:58:00 +0100
commitdbaaff2b0d9250a0b7fdbde179c0bc5ee5d79838 (patch)
tree2f4f9a7cb7d8c33092277537f70ce43e63c3bf24 /lib
parent083220ece2ba3ce36ea21a82abf3b305b97f03e4 (diff)
downloadelibs-dbaaff2b0d9250a0b7fdbde179c0bc5ee5d79838.tar.gz
elibs-dbaaff2b0d9250a0b7fdbde179c0bc5ee5d79838.tar.bz2
org-links: pdf <-> org admitting any notes subdir
Diffstat (limited to 'lib')
-rw-r--r--lib/org/jao-org-links.el21
1 files changed, 13 insertions, 8 deletions
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)