0

Under a given task I have a list of lines, some of which are done sub-tasks which I have tagged with :done. For example:

- this thing I completed earlier :done
- this is stuff I did this week
  - I might have a sublist with a link in it
- and other stuff this week
- and stuff for next week :todo

When I export this to my report I want to hide the :done line. I think the solution for this is to use filters but:

(defun my-filter-out-done-lines (s backend info)
    "Filter out lines ending in :done"
    (apply 'concat
           (--remove (s-matches? (rx ":done" (zero-or-more blank) eol) it)
                     (s-slice-at (rx bol (one-or-more blank) "-") s))))

(org-export-define-derived-backend 'my-status-report 'ascii
    :filters-alist
    '((:filter-plain-list . my-filter-out-done-lines)))

But I'm still removing lines that don't end in :done (I think it's being greedy) and links in removed lines are being rendered at the bottom.

Am I on the right path or is there a simpler way? I don't really want all these additional notes to become full subtasks.

  • 1
    Replace concat with apply 'concat. --remove returns a list of strings and concat should get the strings as arguments. It should not get the list of strings as argument. – Tobias Jan 20 '18 at 22:33
  • OK I've manged to get the thing executing OK but I have two problems left. Firstly my test is overly greedy at throwing away lines. Secondly I need to supress the generation of links for lines I threw away. – stsquad Jan 21 '18 at 14:53
  • So I've solved the first problem once I figured out that s-slice doesn't need the one-or-more blank regex as the strings are already stipped of leading spaces. However for hiding the links I need to somehow get the location of the link being processed out of the text properties. – stsquad Jan 21 '18 at 19:52
0

So it turned out you just needed to know the string for plain lists didn't have leading spaces. Also although the :done tags may look as though they are on the same line in display there may be newlines in the actual string data. So tweaking you got:

(defun my-filter-out-done-lines (s backend info)                                                                                                                           
  "Filter out lines ending in :done"                                                                                                                                       
  (apply 
    'concat                                                                                                                                                           
    (--remove 
      (s-matches? (rx ":done" (zero-or-more blank) eol) it)                                                                                                   
      (s-slice-at (rx bol "-") s))))                                                                                                                          

(org-export-define-derived-backend 'my-status-report 'ascii
  :filters-alist                                                                                                                                                           
  '((:filter-plain-list . my-filter-out-done-lines)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.