Simplified contact commands

Coalesced and simplified the code for inserting the commands
corresponding to contact and social network information.
This commit is contained in:
Diego Zamboni 2019-12-08 21:14:42 +01:00
parent 95c9051532
commit dc1889f543

View file

@ -31,7 +31,6 @@
(require 'cl-lib) (require 'cl-lib)
(require 'ox-latex) (require 'ox-latex)
(require 'org-cv-utils) (require 'org-cv-utils)
(require 'subr)
;; Install a default set-up for awesomecv export. ;; Install a default set-up for awesomecv export.
(unless (assoc "awesomecv" org-latex-classes) (unless (assoc "awesomecv" org-latex-classes)
@ -85,8 +84,7 @@
:translate-alist '((template . org-awesomecv-template) :translate-alist '((template . org-awesomecv-template)
(headline . org-awesomecv-headline) (headline . org-awesomecv-headline)
(plain-list . org-awesomecv-plain-list) (plain-list . org-awesomecv-plain-list)
(item . org-awesomecv-item)) (item . org-awesomecv-item)))
)
;;;; Template ;;;; Template
;; ;;
@ -116,12 +114,6 @@ holding export options."
(format "\\colorlet{awesome}{%s}\n" (plist-get info :cvcolor)) (format "\\colorlet{awesome}{%s}\n" (plist-get info :cvcolor))
(format "\\setbool{acvSectionColorHighlight}{%s}\n" (plist-get info :cvhighlights)) (format "\\setbool{acvSectionColorHighlight}{%s}\n" (plist-get info :cvhighlights))
;; photo
(let* ((photo (plist-get info :photo))
(photo-style (plist-get info :photostyle))
(style-str (if photo-style (format "[%s]" photo-style) "")))
(when (org-string-nw-p photo) (format "\\photo%s{%s}\n" style-str photo)))
;; Author. If FIRSTNAME or LASTNAME are not given, try to deduct ;; Author. If FIRSTNAME or LASTNAME are not given, try to deduct
;; their values by splitting AUTHOR on white space. ;; their values by splitting AUTHOR on white space.
(let* ((author (split-string (org-export-data (plist-get info :author) info))) (let* ((author (split-string (org-export-data (plist-get info :author) info)))
@ -134,10 +126,11 @@ holding export options."
;; Title ;; Title
(format "\\position{%s}\n" title) (format "\\position{%s}\n" title)
;; Hyperref options. ;; photo
(let ((template (plist-get info :latex-hyperref-template))) (let* ((photo (plist-get info :photo))
(and (stringp template) (photo-style (plist-get info :photostyle))
(format-spec template spec))) (style-str (if photo-style (format "[%s]" photo-style) "")))
(when (org-string-nw-p photo) (format "\\photo%s{%s}\n" style-str photo)))
;; address ;; address
(let ((address (org-export-data (plist-get info :address) info))) (let ((address (org-export-data (plist-get info :address) info)))
@ -150,29 +143,24 @@ holding export options."
(org-export-data (plist-get info :email) info)))) (org-export-data (plist-get info :email) info))))
(when (org-string-nw-p email) (when (org-string-nw-p email)
(format "\\email{%s}\n" email))) (format "\\email{%s}\n" email)))
;; phone
(let ((mobile (org-export-data (plist-get info :mobile) info))) ;; Other pieces of information
(when (org-string-nw-p mobile) (mapconcat (lambda (info-key)
(format "\\mobile{%s}\n" mobile))) (let ((info (org-export-data (plist-get info info-key) info)))
;; homepage (when (org-string-nw-p info) (format "\\%s{%s}\n"
(let ((homepage (org-export-data (plist-get info :homepage) info))) (substring (symbol-name info-key) 1)
(when (org-string-nw-p homepage) info))))
(format "\\homepage{%s}\n" homepage))) '(:mobile
;; Other social networks :homepage
(mapconcat (lambda (social-network) :github
(let ((command (org-export-data (plist-get info :gitlab
(car social-network)) :linkedin
info))) :twitter
(when (> (length command) 0) (format "\\%s{%s}\n" :skype
(nth 1 social-network) :reddit
command)))) :extrainfo)
'((:github "github")
(:gitlab "gitlab")
(:linkedin "linkedin")
(:twitter "twitter")
(:skype "skype")
(:reddit "reddit"))
"") "")
;; Stack overflow requires two values: ID and name ;; Stack overflow requires two values: ID and name
(let* ((so-list (plist-get info :stackoverflow)) (let* ((so-list (plist-get info :stackoverflow))
(so-id (when so-list (first so-list))) (so-id (when so-list (first so-list)))
@ -180,6 +168,11 @@ holding export options."
(when (and (org-string-nw-p so-id) (org-string-nw-p so-name)) (when (and (org-string-nw-p so-id) (org-string-nw-p so-name))
(format "\\stackoverflow{%s}{%s}\n" so-id so-name))) (format "\\stackoverflow{%s}{%s}\n" so-id so-name)))
;; Hyperref options.
(let ((template (plist-get info :latex-hyperref-template)))
(and (stringp template)
(format-spec template spec)))
;; Document start. ;; Document start.
"\\begin{document}\n\n" "\\begin{document}\n\n"