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

Use citar-always-prompt as default value when selecting resource #656

Closed
wants to merge 1 commit into from
Closed

Conversation

furkanusta
Copy link

Otherwise citar-open-files prompts even for a single resource

@bdarcus
Copy link
Contributor

bdarcus commented Jul 15, 2022

What if you don't want to open that particular resource?

With the more specific citar-open-notes etc, you know what you're looking for, so it's unlikely to result in surprises.

That's at least the justification for the current behavior.

Thoughts?

@furkanusta
Copy link
Author

furkanusta commented Jul 15, 2022

I get what you mean. I had a problem with the existing behavior and added this fix to solve it, didn't think about other use cases.

In my case I have one big Notes.org file with each paper as a heading and I have ROAM_REFS property with citation key.
I use the function below to open the corresponding PDF, and I wanted to not ask since I (almost) always have a single file associated with a key.

(defun my-citar-open-current-pdf ()
    "Open REFs of the node at point."
    (interactive)
    (let ((keys (when-let* ((prop (org-entry-get (point) "ROAM_REFS" t))
                            (refs (when prop (split-string-and-unquote prop)))
                            (oc-cites
                             (seq-map (lambda (ref) (substring ref 7 (- (length ref) 1))) refs)))
                  oc-cites)))
      (if keys
          (let ((citar-file-open-function (lambda (file)
                                            (other-window 1)
                                            (find-file file))))
            (citar-open-files (car keys)))
        (user-error "No ROAM_REFS found"))))

I thought about changing citar--select-resource to pass :always-prompt key but then realized there is already an existing variable, so why not use it?

For me both solutions work. If you do not want to change the existing behavior I am open for a workaround on my side as well (if possible).

Edit: After posting this I realized that there was no need for me to use citar-open-files. citar-open works fine since it already utilizes the citar-open-prompt variable and I only have a single resource.
I suppose I can close this.

@bdarcus
Copy link
Contributor

bdarcus commented Jul 15, 2022

I'll think on it a bit.

Can you post your function on the wiki, regardless?

Also, seen this?

https://github.com/emacs-citar/citar-org-roam

@roshanshariff
Copy link
Collaborator

Maybe it makes sense for citar-open-files, citar-attach-files, and citar-open-links to never prompt for single resources, because of what @bdarcus said. The other option would be to use the citar-always-prompt variable for all open commands, as in this PR, but then we should adjust its docstring.

@furkanusta
Copy link
Author

I've added the function to wiki and I didn't know citar-org-roam that looks quite useful. Thanks!

@roshanshariff
Copy link
Collaborator

This issue should be addressed by the changes to citar-open-prompt in #651. The default value will make Citar always prompt for citar-open, citar-attach-files, and citar-open-note, but not for any other commands when there's only a single item to act on. You can customize the value of the list and add any other commands you don't want to be prompted for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants