Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first thing I would do is to take advantage of <code>org-mode</code>'s tag support. Instead of</p> <pre><code>** Diego: b QI </code></pre> <p>You would have</p> <pre><code>** Diego :b:QI: </code></pre> <p>Which <code>org-mode</code> recognizes as the tags "b" and "QI".</p> <p>To transform your current format to the standard <code>org-mode</code> format, you can use the following (assuming the buffer with your source is called "asdf")</p> <pre><code>(with-current-buffer "asdf" (beginning-of-buffer) (replace-string " " ":") (beginning-of-buffer) (replace-string "**:" "** ") (beginning-of-buffer) (replace-string "::" " :") (beginning-of-buffer) (replace-string "\n" ":\n") (org-set-tags-command t t)) </code></pre> <p>It's not pretty or efficient, but it gets the job done.</p> <p>After that, you can use the following to produce a buffer that has the format you wanted from the shell script:</p> <pre><code>(let ((results (get-buffer-create "results")) tags) (with-current-buffer "asdf" (beginning-of-buffer) (while (org-on-heading-p) (mapc '(lambda (item) (when item (add-to-list 'tags item))) (org-get-local-tags)) (outline-next-visible-heading 1))) (setq tags (sort tags 'string&lt;)) (with-current-buffer results (erase-buffer) (mapc '(lambda (item) (insert (format "%s: %s\n" item (with-current-buffer "asdf" (org-map-entries '(substring-no-properties (org-get-heading t)) item))))) tags) (beginning-of-buffer) (replace-regexp "[()]" ""))) </code></pre> <p>This puts the results in a buffer called "results", creating it if it doesn't already exist. Basically, it is collecting all the tags in the buffer "asdf", sorting them, then looping through each tag and searching for each headline with that tag in "asdf" and inserting it to "results".</p> <p>With a bit of cleaning up, this could be made into a function; basically just replacing "asdf" and "results" with arguments. If you need that done, I can do that.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload