[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] kill contents of a headline, but retain properties
From: |
Rasmus |
Subject: |
Re: [O] kill contents of a headline, but retain properties |
Date: |
Fri, 07 Aug 2015 16:40:16 +0200 |
User-agent: |
Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) |
Matt Price <address@hidden> writes:
> can you just provide a skeletal example so I understand better wha that
> means? thanks so much!
There's an example in the manual. Here's another example:
In org:
#+begin: thanks :pretext "We have received valuable comments from"
#+end:
The function:
(defun org-dblock-write:thanks (params)
"Reads THANKS file in same folder and format.
PARAMS can hold :filename, :keyword, and :prefix"
(when (file-exists-p (or (plist-get params :filename) "THANKS"))
(insert (or (plist-get params :keyword) "#+thanks: ")
(plist-get params :prefix) " "
(replace-regexp-in-string
".*?\\(,\\)[^,]*\\'" ", and"
(mapconcat
'identity
(remove-if
(lambda (str) (string-match-p "^\\s-*$" str))
(split-string
(with-temp-buffer (save-excursion
(insert-file-contents "THANKS"))
(flush-lines "^\\s-*$" (point-min)
(point-max))
(buffer-string)) "\\s-*\n+\\s-*"))
", ")
nil nil 1)
".")))
You might want to add (org-dblock-update t) to some export hook.
Rasmus
--
This space is left intentionally blank