Critique my org elisp

Table of Contents

Someday I’ll get around to writing about code quality in elisp, but for now I don’t know it well enough to know idioms and avoid code-smell. Orgmode has a massive code-base and the documentation has a hard-time keeping up, so I asked,

How is the following code, aimed at getting the list of header tags and making them into a comma-separated string? org-get-tags didn’t work because I needed to support when the cursor is in the text of an entry, not just on the headline. Although this function works, I’m uncomfortable with the many layers of parens here, hence this question.

(string-join
 (-filter (lambda (s) (not (string-empty-p s)))
          (split-string (nth 5 (org-heading-components)) ":"))
 ", ")

Note that -filter comes from dash.el.

Answer: org-get-local-tags

On Reddit the answer was given very simply; when you can pare your code down to a clear single line and just two function calls, code-smell is a non-issue.

(string-join (org-get-local-tags) ", ")

Resources

Tory Anderson avatar
Tory Anderson
Full-time Web App Engineer, Digital Humanist, Researcher, Computer Psychologist