renard / o-blog

Standalone orgmode blog exporter. DEPECATED, NOT MAINTAINED
http://renard.github.com/o-blog-v2
260 stars 58 forks source link

problem with org-get-header #111

Closed jave closed 10 years ago

jave commented 10 years ago

This is a not very good fix, but it seems to work:

(defmethod ob:org-get-header ((self ob:backend:org) header &optional all) "Return value of HEADER option as a string from current org-buffer. If ALL is T, returns all occurrences of HEADER in a list." (ob:with-source-buffer self (save-excursion (save-restriction (save-match-data (widen) (goto-char (point-min)) (let (values) (while (re-search-forward (format "^#+%s:?[ \t](.)" (replace-regexp-in-string "[_-]" "-" (format "%s" header))) nil t) (add-to-list 'values (substring-no-properties (match-string 1)))) (if all values (car values))))))))

renard commented 10 years ago

Can you please provide a clean diff or a pull request? Thanks in advance.

jave commented 10 years ago

Changes from HEAD to working tree 1 file changed, 1 insertion(+), 1 deletion(-) lisp/o-blog-backend-org.el | 2 +-

Modified   lisp/o-blog-backend-org.el

diff --git a/lisp/o-blog-backend-org.el b/lisp/o-blog-backend-org.el index a4aacfd..4260481 100644 --- a/lisp/o-blog-backend-org.el +++ b/lisp/o-blog-backend-org.el @@ -58,7 +58,7 @@ T, returns all occurrences of HEADER in a list." (let (values) (while (re-search-forward (format "^#+%s:?[ \t](.)"

renard commented 10 years ago

Are you shire about the order of "[_-]" "-"?

(replace-regexp-in-string "-" "[_-]" header) (the opposite order) would change: publish-directory into publish[_-]directory thus it would match both #+DEFAULT_DIRECTORY: and #+DEFAULT-DIRECTORY:

jave commented 10 years ago

(replace-regexp-in-string REGEXP REP STRING &optional FIXEDCASE LITERAL SUBEXP START)

shouldnt the regexp go first then, and the replacement second?

renard commented 10 years ago

Yes you are right the REGEXP comes first. In that case we want to convert - into [_-] as long as we actually built the regexp for the format for re-search-forward

Well the problem actually was that header was a symbol not a string. This has been fixed in 2a8421d.