citar icon indicating copy to clipboard operation
citar copied to clipboard

Add citar-org-insert-keys ?

Open denismaier opened this issue 2 years ago • 4 comments

For markdown modes we have:

(defun citar-markdown-insert-keys (keys)
  "Insert semicolon-separated and @-prefixed KEYS in a markdown buffer."
  (insert (mapconcat (lambda (k) (concat "@" k)) keys "; ")))

Why not add the same for org?

denismaier avatar May 24 '22 08:05 denismaier

I didn't write the markdown stuff, but I suspect it's there because pandoc citations can be outside of brackets.

Not the case with org. So what would be the advantage there, beyond org-cite-insert?

bdarcus avatar May 24 '22 11:05 bdarcus

UX: I'd like to implement a workflow more or less like this:

  1. insert a citation fragment (I use the function below, but could also be done manually)
  2. add a prefix manually
  3. add a key (that's the missing piece)
  4. add a suffix
  5. if needed add a semicolon
  6. repeat steps 2-4
(defun dm/insert-style-fragment ()
(interactive)
  (let ((raw-style
             (citar-org-select-style)))
             (setq style
                   (if (string-equal raw-style "") raw-style
                     (concat "/" raw-style))))
  (insert (concat "[cite" style ":]"))
  (backward-char))

org-cite-insert doesn't work: if I call it with point inside a cite fragment [cite:X] I get [cite: [cite:@doe]

denismaier avatar May 24 '22 11:05 denismaier

With org-cite-insert:

  1. if you call with a prefix arg, you get prompted for the style
  2. insert one or more keys
  3. you can then add affixes in the buffer, or additional references with org-cite-insert, from there

E.g. to add a key to an existing citation using org-cite-insert, you'd put point here before calling it again: [cite:@one|]

The org command, in other words, is context-aware; behaves differently depending on where it is within the citation, or the larger org document.

bdarcus avatar May 24 '22 11:05 bdarcus

Ok, I'll try with this command.

denismaier avatar May 28 '22 10:05 denismaier