From 1b64d9582ef288141b764c584fbfb17d2b7f91bc Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 21 Jul 2012 15:12:02 +0200 Subject: [PATCH] org-export: Add optional argument to `org-export-read-attribute' * contrib/lisp/org-export.el (org-export-read-attribute): Add optional argument to `org-export-read-attribute'. * contrib/lisp/org-e-ascii.el (org-e-ascii-horizontal-rule): Use additional argument. --- contrib/lisp/org-e-ascii.el | 12 ++---------- contrib/lisp/org-export.el | 14 ++++++++++---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/contrib/lisp/org-e-ascii.el b/contrib/lisp/org-e-ascii.el index 0881e9499..185127305 100644 --- a/contrib/lisp/org-e-ascii.el +++ b/contrib/lisp/org-e-ascii.el @@ -1100,16 +1100,8 @@ holding contextual information." "Transcode an HORIZONTAL-RULE object from Org to ASCII. CONTENTS is nil. INFO is a plist holding contextual information." - (let ((attr - (read - (format - "(%s)" - (mapconcat - #'identity - (org-element-property :attr_ascii horizontal-rule) - " "))))) - (make-string (or (and (wholenump (plist-get attr :width)) - (plist-get attr :width)) + (let ((width (org-export-read-attribte :attr_ascii horizontal-rule :width))) + (make-string (or (and (wholenump width) width) (org-e-ascii--current-text-width horizontal-rule info)) (if (eq (plist-get info :ascii-charset) 'utf-8) ?― ?-)))) diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index 224260e4c..8daa335e6 100644 --- a/contrib/lisp/org-export.el +++ b/contrib/lisp/org-export.el @@ -2706,14 +2706,20 @@ file should have." ;; as a plist. It can be used to normalize affiliated keywords' ;; syntax. -(defun org-export-read-attribute (attribute element) +(defun org-export-read-attribute (attribute element &optional property) "Turn ATTRIBUTE property from ELEMENT into a plist. + +When optional argument PROPERTY is non-nil, return the value of +that property within attributes. + This function assumes attributes are defined as \":keyword value\" pairs. It is appropriate for `:attr_html' like properties." - (let ((value (org-element-property attribute element))) - (and value - (read (format "(%s)" (mapconcat 'identity value " ")))))) + (let ((attributes + (let ((value (org-element-property attribute element))) + (and value + (read (format "(%s)" (mapconcat 'identity value " "))))))) + (if property (plist-get attributes property) attributes))) ;;;; For Export Snippets