Closed mohkale closed 3 years ago
emmm why not use recentf/find-file directly if you're inserting the pdf link (path) manually?
I'm not opening the PDFs with emacs (using zathura instead) so I'm not sure how that would work. Could you please elaborate?
If you are not using emacs for PDF, how would emacs know which PDF have you opened? If you open PDF in zathura from emacs find-file, I think you can find it in recentf? If you are using Ivy, you can customize counsel-recentf to have an action to insert the selected path with 'pdftools:' prefix:
(defun counsel-recentf-insert-pdftools-link-action (x)
(with-ivy-window
(insert (concat "pdftools:" x))))
(ivy-set-actions
'counsel-recentf
'(("i" counsel-recentf-insert-pdftools-link-action "insert pdftools link")))
If you are not using emacs for PDF, how would emacs know which PDF have you opened?
I'm not sure I'm being clear enough with what I'm trying to achieve here 😓. I've got PDFs in a sub directory, let's suppose their 6 directories down.
org-insert-link
find-file
dialog. point
. Now I'd like to insert a link to the same document, perhaps with a different page. I'd like it to be as seamless as possible so the process I'd like would be:
org-insert-link
I believe, seeing as org-pdftools knows which PDFs it's inserted in the past, you could introduce an intermediary variable to store the last inserted PDF or a history of them.
Then instead of using org-link-complete-file
in org-pdftools-complete-link
, you create your own file selection dialog, which also presents recently inserted PDFs to the user. I believe initial
argument in read-file-name
could achieve something like this, albeit it only supports a single file/candidate.
S.N.
As an alternative, I'd also be okay with an optional feature wherein once org-pdftools
inserts a PDF link, it updates the value set by org-store-link
. Such that the current value of org-store-link
is equivalent to if I had opened the last inserted pdf at the desired page and then run M-x org-store-link
manually. This option is probably easier to implement.
read-file-name
looks like an infinite rabbit hole so I'd rather not jump into it. Mess with org-store-link history will potentially pollute the history with a lot of repetitive entries. I prefer this to be implemented as an extra function:
(defun org-pdftools-get-previous-link ()
(interactive)
(completing-read "org-pdftools history: " org-link--insert-history nil nil "^pdftools:"))
Is there a recommended way of choosing PDFs, as it stands I've got PDFs put into sub-directories and am quite often only working with one PDF at a time. Whenever I decide to insert a link to that PDF, I have to navigate to the same file which is an error-prone and tasking process.
It'd be nice if, when I decide to insert a PDF link,
org-pdftools
offers to use my last PDF file or at least shows it as an option alongside the rest of the files in the current directory.NOTE I'm not using emacs to view the PDFs (so I'm really only using this plugin to create links to PDF slides), so
org-store-link
isn't really a viable option.