gizmomogwai / org-kanban

Kanban table for org-mode
MIT License
238 stars 18 forks source link

Problems with TODO items with org links. #44

Closed dschaehi closed 5 months ago

dschaehi commented 5 months ago

Hi @gizmomogwai,

I am now trying to integrate org-kanban in my workflow (also thanks to the feature by :match that allows for filtering tasks by their scheduled time #43 ). One issue that I had to come across several times is handling org links. If a column of the kanban board does not allow to contain the whole heading of a TODO item with an org link, the link gets broken and jumping to the TODO item is not possible anymore. In the minimal example below, it is possible to jump to TODO item Task 2: this is supposed to be a long heading, but not to Task 1 [[id:065b4011-5263-48f7-88c1-7ee9b45ce351][Link]]. Can you confirm the problem? I hope that there is an easy solution for this. Thanks!

* Kanban
#+BEGIN: kanban :mirrored nil :scope tree :range ("TODO" . "DONE") :layout ("..." . 36)
| TODO                                 | DONE |
|--------------------------------------+------|
| [[file:work.org::*Task 1 Link][Task 1 {{id:065b4011-5263-48f7-88...]] |      |
| [[file:work.org::*Task 2: this is supposed to be a long heading][Task 2: this is supposed to be a ...]] |      |
#+END:
** TODO Task 1 [[id:065b4011-5263-48f7-88c1-7ee9b45ce351][Link]]
*** Link
:PROPERTIES:
:ID:       065b4011-5263-48f7-88c1-7ee9b45ce351
:END:
** TODO Task 2: this is supposed to be a long heading
gizmomogwai commented 5 months ago

Thanks for this real world use-case. Seems to be (again) a problem that involves escaping :)) (to some degree). A workaround for you for now could be, if you assign an id to Task 1 that includes the link ... then org-kanban prefers to link to the task by id (instead of todo title). I played around now how to get a textual representation and org-store-link created this beast for me [[*Task 1 \[\[id:065b4011-5263-48f7-88c1-7ee9b45ce351\]\[Link\]\]][Task 1 Link]]. You can see (as expected above) those additional escape backslashes.

org-kanban does not do this correctly atm. So this needs to be fixed. As a workaround I can recommend the above approach of using ids.

Would you like a real fix?

dschaehi commented 5 months ago

Thanks again @gizmomogwai ! Your workaround solved the problem. At the same time, it would be nice if there was no need to intervene and create ids for those tasks with links. A permanent fix is not urgent though.

gizmomogwai commented 5 months ago

@dschaehi, please try out version 0.6.6 ... it should have a "proper" fix (if thats possible at all) in place. please let me know if your real world usecases show any other problems. the string replacements that i have todo are unfortunately quite messy (i think the most stable solution is really to go with id's or custom id's).

dschaehi commented 5 months ago

Hi @gizmomogwai,

Thank you for your effort! I played around with the new version and faced a problem. I use org-cite (cf. https://orgmode.org/manual/Citations.html) for my academic references and it seems that with the current version the citation links aren't processed properly. Here a minimal example:

#+BEGIN: kanban :mirrored nil :scope tree :range ("TODO" . "DONE") :layout ("..." . 5)
| TODO                                            | DONE |
|-------------------------------------------------+------|
| [[file:work.org::*[cite:@chen_models_2023]][[c...]] |      |
#+END:
** TODO [cite:@chen_models_2023]

As you can see the column width is bigger than the set limit (i.e., 5) and jumping to the task from the table does not work. If you think a permanent fix is difficult than I would be ok to use the other solution (i.e., creating ids).

gizmomogwai commented 5 months ago

Thank you very much, this is exact the real world problem I was looking for. Sorry for breaking your workflow, but I will try to fix this as soon as possible :)

gizmomogwai commented 5 months ago

I created Issue #45 for this

dschaehi commented 5 months ago

I have to thank you, @gizmomogwai!

gizmomogwai commented 5 months ago

Also the problem with layout looks strange to me. One tip in general for layout and shortening: I like to use e.g. (the ellipsis unicode character) to get ... but with just one charachter, which gives two more characters for real text.

dschaehi commented 5 months ago

Thank you for the tip!

gizmomogwai commented 5 months ago

please also check issue 45 ... should be fixed by now ... let me know if it works for you. unfortunately i cannot mention you on the other issue :/

dschaehi commented 5 months ago

Perfect! Thanks again, @gizmomogwai, for the quick fix!

One minor suggestion: Regarding tasks with normal org links (e.g., [[id:...][link tex]]), will it be possible to only show the link text instead of the (truncated) whole link expression in the kanban table (e.g., | Task 1 [[id:065b4011-5263-48f7-88c1… |)? This would make unnecessary the extra effort of jumping to the corresponding heading to see the link text.

gizmomogwai commented 5 months ago

Mhh ... as not every Task has a link embedded I would not do this. You could use another function to double jump to the link in the linked heading and bind this to another convenient shortcut. The function could look like this:

(defun goto-link-in-heading ()
  "Jump to the link that is part of the heading at point."
  (interactive)
  (org-open-at-point)
  (org-next-link)
  (org-open-at-point))
dschaehi commented 5 months ago

Oh, my question was not about jumping to the link in the table directly, but seeing the link text in the kanban table. Currently the kanban table shows the whole org link representation, i.e., [[link path][link text]]. This is in particular problematic if the column width is small, as one then only sees some part of the link path (link paths are usually very long) and not the link text it self. In the example at the top, the kanban table shows |Task 1 [[id:065b4011-5263-48f7-88...| instead of |Task 1 Link|. It would be more useful to see the latter than the former. (Org agenda also shows the link text only).

gizmomogwai commented 5 months ago

thats interesting, because thats not happening in my version here. For me it looks like this (which I think might be what you are looking for). I am using version 0.6.8 of org-kanban (M-x org-kanban/version)?. Screenshot 2024-
06-07 at 15 46 52 should be sha: 7eaefbf0c48c107ee27ed756c3b1b5b5d7dc3598 of the git repository.

dschaehi commented 5 months ago

Can you try :layout ("…". 20)? In my case the issue arises if the column width is not large enough to contain the whole heading.

gizmomogwai commented 5 months ago

That's it, now I see what you mean, let me think a little about it

gizmomogwai commented 5 months ago

What would be the best representation for cite links?

dschaehi commented 5 months ago

Oh I didn't notice that you already added a commit and fixed the issue. Many Thanks, @gizmomogwai! As for the cite links, one could remove the cite: prefix and the @ sign to save space and look them more like normal citations in papers (e.g.,[cite:@knuth:1984;@knuth:1985] becomes [knuth:1984;knuth:1985])

gizmomogwai commented 5 months ago

I hope it works better now in your cases!

mhh .. i double checked what e.g. org-export to html does and it translates the @knuth to the author from my example bibtex file ... that would be awesome i think. i also tried to understand https://orgmode.org/manual/Citations.html but its not clear for me how one really would use citations in org files. There are just so many options ... one for how to print them inline, then all those processors and then how to print the bibliography itself ...

dschaehi commented 5 months ago

Yes, the link texts are now shown correctly.

If you're asking about how I use citations in org files, I use them with org-citar, citar-org-roam and org-roam for inserting citations from my bib files, viewing PDFs and creating notes.

gizmomogwai commented 5 months ago

thanks!