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

Outline path is ignored when org-roam-ref-capture at second time #2199

Open
hwiorn opened this issue May 19, 2022 · 3 comments · May be fixed by #2337
Open

Outline path is ignored when org-roam-ref-capture at second time #2199

hwiorn opened this issue May 19, 2022 · 3 comments · May be fixed by #2337

Comments

@hwiorn
Copy link
Contributor

hwiorn commented May 19, 2022

Description

I'm trying to capture some text to a sub headline. Capturing works at first. At the second time, But, It inserts org headline into the wrong place.

Steps to Reproduce

  1. Set the below org-roam-capture-ref-templates and Reload it.
  (setq org-roam-capture-ref-templates
        '(("r" "ref" plain ;; "%?"
           "** ${body}\n%U\n%?\n"
           :target (file+head+olp
                        "literature/${slug}.org"
                        ":PROPERTIES:\n:ROAM_REFS: ${ref}\n:END:\n#+title: ${title}\n"
                        ("Note")
                        )
           :jump-to-captured t
           :unnarrowed t
           )))
  1. Capture some text
xdg-open 'org-protocol://roam-ref?template=r&ref=https%3A%2F%2Fgithub.com%2Fyuchen-lea%2Forg-media-note&title=yuchen-lea%2Forg-media-note%3A%20Taking%20interactive%20notes%20when%20watching%20videos%20or%20listening%20to%20audios%20in%20org-mode.&body=Now%2C%20you%20can%20access%20all%20functions%20in%20org-media-note-hydra%2Fbody'
  1. Capture another text again!
xdg-open 'org-protocol://roam-ref?template=r&ref=https%3A%2F%2Fgithub.com%2Fyuchen-lea%2Forg-media-note&title=yuchen-lea%2Forg-media-note%3A%20Taking%20interactive%20notes%20when%20watching%20videos%20or%20listening%20to%20audios%20in%20org-mode.&body=%20Here%2C%20I%20use%20Hyper%20key%20H%20for%20keybinding.%20In%20this%20way%2C%20I%20can%20quickly%20access%20personal%20functions%2C%20and%20no%20major%20or%20minor%20modes%20will%20stamp%20on%20my%20keys.%20Look%20into%20this%20for%20more%20information%3A%20Emacs%3A%20How%20to%20Bind%20Super%20Hyper%20Keys.%20Or%20you%20can%20bind%20it%20to%20any%20other%20key%20you%20like.%20After%20all%2C%20it%E2%80%99s%20Emacs%20%3B)'

Backtrace

Expected Results

  1. First capturing
:PROPERTIES:
:ROAM_REFS: https://github.com/yuchen-lea/org-media-note
:ID:       658ba536-3b33-4190-ba2c-b2171cb845f8
:END:
#+title: yuchen-lea/org-media-note: Taking interactive notes when watching videos or listening to audios in org-mode.
* Note
** Now, you can access all functions in org-media-note-hydra/body
[2022-05-19 Thu 22:19]

  1. Second capturing
:PROPERTIES:
:ROAM_REFS: https://github.com/yuchen-lea/org-media-note
:ID:       658ba536-3b33-4190-ba2c-b2171cb845f8
:END:
#+title: yuchen-lea/org-media-note: Taking interactive notes when watching videos or listening to audios in org-mode.
* Note
** Now, you can access all functions in org-media-note-hydra/body
[2022-05-19 Thu 22:19]
**  Here, I use Hyper key H for keybinding. In this way, I can quickly access personal functions, and no major or minor modes will stamp on my keys. Look into this for more information: Emacs: How to Bind Super Hyper Keys. Or you can bind it to any other key you like. After all, it’s Emacs ;)
[2022-05-19 Thu 22:20]

Actual Results

  1. First capturing
:PROPERTIES:
:ROAM_REFS: https://github.com/yuchen-lea/org-media-note
:ID:       658ba536-3b33-4190-ba2c-b2171cb845f8
:END:
#+title: yuchen-lea/org-media-note: Taking interactive notes when watching videos or listening to audios in org-mode.
* Note
** Now, you can access all functions in org-media-note-hydra/body
[2022-05-19 Thu 22:19]

  1. Second capturing
:PROPERTIES:
:ROAM_REFS: https://github.com/yuchen-lea/org-media-note
:ID:       658ba536-3b33-4190-ba2c-b2171cb845f8
:END:
#+title: yuchen-lea/org-media-note: Taking interactive notes when watching videos or listening to audios in org-mode.
**  Here, I use Hyper key H for keybinding. In this way, I can quickly access personal functions, and no major or minor modes will stamp on my keys. Look into this for more information: Emacs: How to Bind Super Hyper Keys. Or you can bind it to any other key you like. After all, it’s Emacs ;)
[2022-05-19 Thu 22:20]

* Note
** Now, you can access all functions in org-media-note-hydra/body
[2022-05-19 Thu 22:19]

Environment

  • Emacs: GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0)
    of 2022-05-16
  • Framework: Doom
  • Org: Org mode version 9.6 (9.6-??-971eb68 @ /home/gglee/.emacs.d/.local/straight/build-29.0.50/org/)
  • Org-roam: 01843a6
  • sqlite-connector: sqlite
@hwiorn
Copy link
Contributor Author

hwiorn commented Jun 21, 2022

I attempted to use olp in org-roam-capture by fixing org-roam-capture--try-capture-to-ref-h like below.
It works. But I don't know how to goto-char to the end of a subtree.
I tried org-end-of-subtree but it doesn't work.

(defun org-roam-capture--try-capture-to-ref-h ()
  "Try to capture to an existing node that match the ref."
  (when-let ((node (and (plist-get org-roam-capture--info :ref)
                        (org-roam-node-from-ref
                         (plist-get org-roam-capture--info :ref)))))
    (set-buffer (org-capture-target-buffer (org-roam-node-file node)))
    (let* ((target (org-roam-capture--get-target))
           (entry (car target))
           (olp-point nil))
      (when (or (eq 'file+olp entry) (eq 'file+head+olp entry))
        (setq olp-point (org-roam-capture-find-or-create-olp (car (last target)))))
      (goto-char (or olp-point (org-roam-node-point node))))
    (widen)
    (org-roam-node-id node)))

@MagicRB
Copy link

MagicRB commented Aug 30, 2022

I'm hitting the same thing.

@hwiorn hwiorn linked a pull request Mar 28, 2023 that will close this issue
@bitozoid
Copy link

I haven't tried, but I wonder whether the plain type is what you need. Have you tried with an entry type? I think that the point is adjusted as a function of the type.

I think that one asterisk is fine for the template as well:

"* ${body}\n%U\n%?\n"

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 a pull request may close this issue.

3 participants