Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert link to daily file using the date selector #1587

Open
1 task done
elsehow opened this issue Jul 17, 2021 · 3 comments
Open
1 task done

Insert link to daily file using the date selector #1587

elsehow opened this issue Jul 17, 2021 · 3 comments
Labels
1. enhancement Requests to add new functionality
Projects

Comments

@elsehow
Copy link

elsehow commented Jul 17, 2021

Brief Abstract

org-roam-dailies-insert-date could produce a link to a date using the date selection minibuffer interface.

Long Description

When inserting a timestamp with org-roam-dailies-find-date, a minibuffer interface appears, allowing the user to select a date. A command like org-roam-dailies-insert-date could produce the same minibuffer, but instead produce a link to the specified daily file.

Proposed Implementation (if any)

Conceptually: (org-roam-insert (org-roam-dailies-find-date))?

Please check the following:

  • No similar feature requests
@elsehow elsehow added the 1. enhancement Requests to add new functionality label Jul 17, 2021
@mchowning
Copy link
Contributor

mchowning commented Jul 17, 2021

A while back I made a org-roam-dailies-insert-date function to provide allow me to insert a linked reference to a specific "daily" file. I'm not super-familiar with elisp, so I wouldn't be at all surprised if there is a better way to write this, but it's worked well for me.

  (defun matt/org-insert-last-stored-link-without-newline (arg)
    "Insert the last link stored in `org-stored-links' like
`org-insert-last-stored-link', but without a trailing newline."
    (interactive "p")
    (org-insert-all-links arg "" ""))

  (defun matt/org-roam-dailies-insert-date ()
    (interactive)
    (save-window-excursion (save-excursion
                             (org-roam-dailies-find-date)
                             (save-buffer)
                             (org-store-link nil 'not-interactive)
                             (let* ((id (car (car org-stored-links)))
                                    (description (org-roam--file-keyword-get "TITLE"))
                                    (updated (list id description)))
                               (setq org-stored-links (cons updated (cdr org-stored-links))))))
    (call-interactively 'matt/org-insert-last-stored-link-without-newline))

@jethrokuan jethrokuan added this to Backlog in Org-roam Jul 29, 2021
@zipy124
Copy link

zipy124 commented Nov 16, 2021

@mchowning Does your code still work for you? I'm getting an error on "org-roam--file-keyword-get"?

@mchowning
Copy link
Contributor

👋 @zipy124 ! I did have to modify that function to work code with the latest changes to org-roam. This is my current function:

(defun matt/org-roam-dailies-insert-date ()
  (interactive)
  (save-window-excursion (save-excursion
                           (org-roam-dailies-goto-date)
                           (save-buffer)
                           (org-store-link nil 'not-interactive)
                           (let* ((id (caar org-stored-links))
                                  (description (cadar (org-collect-keywords '("TITLE" "title"))))
                                  (updated (list id description)))
                             (setq org-stored-links (cons updated (cdr org-stored-links))))))
  (call-interactively 'matt/org-insert-last-stored-link-without-newline))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. enhancement Requests to add new functionality
Projects
Org-roam
Backlog
Development

No branches or pull requests

3 participants