From daf72956888af602c27f48a2558556f4fc2188ef Mon Sep 17 00:00:00 2001 From: Joseph LaFreniere Date: Fri, 14 Sep 2018 04:17:06 -0500 Subject: [PATCH] Default FROM as error and TO as "Present" If no FROM property is provided for a given cventry, throw an error. If no TO property is provided, use the atom "Present". --- ox-altacv.el | 16 +++++++++------- ox-hugocv.el | 18 ++++++++++-------- ox-moderncv.el | 16 +++++++++------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/ox-altacv.el b/ox-altacv.el index 99d0680..59653e7 100644 --- a/ox-altacv.el +++ b/ox-altacv.el @@ -204,18 +204,20 @@ e.g. <2002-08-12 Mon> => Aug 2012" "Format HEADLINE as as cventry. CONTENTS holds the contents of the headline. INFO is a plist used as a communication channel." - (let ((from-date (org-element-property :FROM headline)) - (to-date (org-element-property :TO headline)) - (title (org-export-data (org-element-property :title headline) info)) - (employer (org-element-property :EMPLOYER headline)) - (location (or (org-element-property :LOCATION headline) "")) - (divider (if (org-export-last-sibling-p headline info) "" "\\divider"))) + (let* ((title (org-export-data (org-element-property :title headline) info)) + (from-date (or (org-element-property :FROM headline) (error "No FROM property provided for cventry %s" title))) + (to-date (org-element-property :TO headline)) + (employer (org-element-property :EMPLOYER headline)) + (location (or (org-element-property :LOCATION headline) "")) + (divider (if (org-export-last-sibling-p headline info) "" "\\divider"))) (format "\n\\cvevent{%s}{%s}{%s}{%s}%s\n%s" title employer (concat (org-altacv-timestamp-to-shortdate from-date) " -- " - (org-altacv-timestamp-to-shortdate to-date)) + (if (not to-date) + "Present" + (org-moderncv-timestamp-to-shortdate to-date))) location contents divider))) diff --git a/ox-hugocv.el b/ox-hugocv.el index 77b17ed..11d47d9 100644 --- a/ox-hugocv.el +++ b/ox-hugocv.el @@ -70,13 +70,13 @@ e.g. <2002-08-12 Mon> => Aug 2012" "Format HEADLINE as as cventry. CONTENTS holds the contents of the headline. INFO is a plist used as a communication channel." - (let ((from-date (org-element-property :FROM headline)) - (to-date (org-element-property :TO headline)) - (loffset (string-to-number (plist-get info :hugo-level-offset))) ;"" -> 0, "0" -> 0, "1" -> 1, .. - (level (org-export-get-relative-level headline info)) - (title (org-export-data (org-element-property :title headline) info)) - (employer (org-element-property :EMPLOYER headline)) - (location (or (org-element-property :LOCATION headline) ""))) + (let* ((title (org-export-data (org-element-property :title headline) info)) + (from-date (or (org-element-property :FROM headline) (error "No FROM property provided for cventry %s" title))) + (to-date (org-element-property :TO headline)) + (loffset (string-to-number (plist-get info :hugo-level-offset))) ;"" -> 0, "0" -> 0, "1" -> 1, .. + (level (org-export-get-relative-level headline info)) + (employer (org-element-property :EMPLOYER headline)) + (location (or (org-element-property :LOCATION headline) ""))) (format "\n%s