d12frosted / d12frosted.io

Personal site
https://d12frosted.io
BSD 3-Clause "New" or "Revised" License
8 stars 3 forks source link

posts/2020-06-24-task-management-with-roam-vol2 #19

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Task management with org-roam Vol. 2: Categories

Automatic category extraction from org-roam

https://d12frosted.io/posts/2020-06-24-task-management-with-roam-vol2.html

arampp commented 3 years ago

Thx for your awesome series on org-mode and roam. Helps me a lot tweaking my setup and provides great inspiration.

d12frosted commented 3 years ago

Hey @BitSchupser

I am glad you find it useful! Thank you for reaching me out :) Please let me know if you have any troubles with examples in theses posts.

Xalielt commented 3 years ago

Fantastic @d12frosted! I am truly standing on the shoulders of giants with this.

d4ncer commented 2 years ago

Thanks for this set of articles @d12frosted! It's helped me with a short term problem of setting up a GTD workflow within the org-roam paradigm, and more importantly - pushed me to dig further into my elisp.

One small typo in your final codeblock with the s.el optimization:

(setq org-agenda-prefix-format
      '((agenda . " %i %(vulpea-agenda-category 12)%?-12t% s")
        (todo . " %i %(vulpea-agenda-category 12) ")
        (tags . " %i %(vulpea-agenda-category 12) ")
        (search . " %i %(vaulpea-agenda-category 12) "))) ;; This should be vulpea, not vaulpea
d12frosted commented 2 years ago

@d4ncer thanks! fixed typo in master, should be GAed soon.

cjbarroso commented 2 years ago

I'm using the whole package and I want to say THANK YOU, my agenda is fast, I can navigate / search easily and my workflow improved. I rely heavily on zettelkasten / roam so this has been the perfect solution to bring everything together.

d12frosted commented 2 years ago

@cjbarroso great to hear 🙃 enjoy your fast note taking system!

Cycatz commented 3 months ago

Thanks for writing such an amazing guide, it's really helpful!

There is a small problem when using the vulpea-agenda-category function. When opening the agenda view, the following warning appears:

⛔ Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer *Org Agenda*> (org-agenda-mode)

In addition, lines without tasks will display "???" (which is returned by org-get-category)

  ???                    16:00...... -----------------------------------------------------
  ???                    18:00...... -----------------------------------------------------
  ???                    20:00...... -----------------------------------------------------

The solution is to add a file buffer check when assigning category variable, as the warning originates from org-element-at-point, which is caused by org-get-category

@@ -22,7 +22,7 @@
                       (file-name-sans-extension
                        (file-name-nondirectory buffer-file-name))))
          (title (vulpea-buffer-prop-get "title"))
-         (category  (org-get-category))
+         (category (when buffer-file-name (org-get-category)))
          (result
           (or (if (and
                    title
d12frosted commented 3 months ago

@Cycatz glad to hear you find it helpful 🙏

There is a small problem when using the vulpea-agenda-category function. When opening the agenda view, the following warning appears:

Aaaah, I completely forgot about log mode, which actually calls vulpea-agenda-category outside org mode buffer. Even title should not be calculated in such cases! You fix does the trick, but you can avoid any unnecessary calculations like this:

(defun vulpea-agenda-category (&optional len)
  "Get category of item at point for agenda.

Category is defined by one of the following items:

- CATEGORY property
- TITLE keyword
- TITLE property
- filename without directory and extension

When LEN is a number, resulting string is padded right with
spaces and then truncated with ... on the right if result is
longer than LEN.

Usage example:

  (setq org-agenda-prefix-format
        \\='((agenda . \" %(vulpea-agenda-category) %?-12t %12s\")))

Refer to `org-agenda-prefix-format' for more information."
  (if (eq major-mode 'org-mode)
      (let* ((file-name (when buffer-file-name
                      (file-name-sans-extension
                       (file-name-nondirectory buffer-file-name))))
         (title (vulpea-buffer-prop-get "title"))
         (category (org-get-category))
         (result
          (or (if (and
                   title
                   (string-equal category file-name))
                  title
                category)
              "")))
    (if (numberp len)
        (s-truncate len (s-pad-right len " " result))
      result))
    (s-repeat (or len 0) " ")))
Cycatz commented 3 months ago

@d12frosted You're absolutely right! Much appreciated!