jdtsmith / org-modern-indent

modern block styling with org-indent
GNU General Public License v3.0
172 stars 4 forks source link

leaves org roam links in literal form #6

Closed ParetoOptimalDev closed 1 year ago

ParetoOptimalDev commented 1 year ago

When I have org-modern-indent activated I have this issue:

org-modern-indent-roam-link-stays-literal

I know that running (font-lock-flush) can fix it. Maybe this should be run by org-modern-indent?

In vanilla emacs with org-roam but without org-modern indent what happens is the link is immediately turned into the non literal version and appears to never be literal.

I originally thought this was an issue in org-roam and filed org-roam/org-roam#2291

jdtsmith commented 1 year ago

Hmm, not sure why that would be influenced by the indentation/line-prefix, especially given that there is no block in this buffer. That said, I just dropped a complete rewrite (v0.1) that uses a very different underlying approach. Before I relied on the org-block faces being set, so had to "force" font-locking sometimes to avoid the "race" between the various modification hooks. Take a look and let me know if your issue persists. I expect it should be fine now.

jdtsmith commented 1 year ago

Did v0.1 fix this?

ParetoOptimalDev commented 1 year ago

@jdtsmith I just checked, it did! :rocket:

However I'm getting a new error of lesser severity:

Debugger entered--Lisp error: (error "Selecting deleted buffer")
  org-modern-indent--wait-and-refresh(#<killed buffer>)
  apply(org-modern-indent--wait-and-refresh #<killed buffer>)
  timer-event-handler([t 25617 4610 854528 nil org-modern-indent--wait-and-refresh (#<killed buffer>) nil 894000 nil])

I think it might be trying to indent the deleted capture buffer?

Yep, I just verified that this version works but throws the "selecting deleted buffer" error with org-capture:

buf is Result: #<buffer *Capture*> in:

(defun org-modern-indent--wait-and-refresh (buf)
  "Wait for org-indent to finish initializing BUF, then refresh."
  (if (or (not (bound-and-true-p org-indent-agentized-buffers))
      (not (memq buf org-indent-agentized-buffers)))
      (progn
    (with-current-buffer buf
      (font-lock-add-keywords nil org-modern-indent--font-lock-keywords t)
      (font-lock-flush)))
    (run-at-time 0.1 nil #'org-modern-indent--wait-and-refresh buf)))

I think maybe org-capture isn't through initializing BUF?

Maybe you can just check if the buffer is killed and do nothing? Not sure the best way to handle this.

jdtsmith commented 1 year ago

Oh, good catch. Just added a guard for that scenario; check again?

benthamite commented 7 months ago

I'm getting what appears to be a related error. When I try to capture a message with org-store-link, I get this:

Debugger entered--Lisp error: (error "Selecting deleted buffer")
org-modern-indent--wait-and-refresh(#<killed buffer>)
apply(org-modern-indent--wait-and-refresh #<killed buffer>)
timer-event-handler([t 26094 24019 198723 nil org-modern-indent--wait-and-refresh (#<killed buffer>) nil 0 nil])

The exact function I use is

(defun telega-extras-chat-org-capture ()
  "Capture chat message at point with `org-capture'."
  (interactive)
  (org-store-link nil)
  (org-capture nil "n"))  

which in turn calls this capture template:

(setq org-capture-templates
        `(
        ...
          ("n" "Telegram" entry
           (id "4388B4D0-3830-48E0-A118-C3195B62F0D1")
           "** TODO Follow up with %a\nSCHEDULED: %t\n\n%i" :immediate-finish t :empty-lines 1 :prepend t)
          ...
          ))

And here’s my org-modern-indent config:

(use-package org-modern-indent
  :elpaca (org-modern-indent
             :host github
             :repo "jdtsmith/org-modern-indent")
  :after org-modern org-indent
  :demand t
  :config
  (add-hook 'org-mode-hook #'org-modern-indent-mode 90))
jdtsmith commented 6 months ago

I added a fix to this recently (see #17); let me know if it fixes it.

benthamite commented 6 months ago

Thank you. I confirm that the fix resolves the issue I reported.