From 8e2a569e77a951c05a70f2974d225d1aa3386ca8 Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Sat, 2 Dec 2017 00:59:42 -0500 Subject: [PATCH] Makefile, ox-hugo.el message formatting improvements * ox-hugo.el: - Print the number of subtree being exported when doing C-c C-e H A. - Print the tag that caused a subtree/file to not be exported. - Misc message and code formatting improvements. * .travis.yml: Disable the Entering directory/Leaving directory noise from make. * Makefile: Add a blank line before each new instance of emacs in batch mode. --- .travis.yml | 6 +++--- Makefile | 4 +++- ox-hugo.el | 42 ++++++++++++++++++++++++------------------ 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 565eee5..d70c6da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,9 +18,9 @@ install: - export EMACS=/tmp/emacs/bin/emacs - $EMACS --version script: - - make doc EMACS=${EMACS} # Just ensure that "make doc" doesn't fail for any reason.. this is *not* used to do Org->Markdown doc conversion using Travis. - - make test EMACS=${EMACS} - - make vcheck EMACS=${EMACS} + - make --no-print-directory doc EMACS=${EMACS} # Just ensure that "make doc" doesn't fail for any reason.. this is *not* used to do Org->Markdown doc conversion using Travis. + - make --no-print-directory test EMACS=${EMACS} + - make --no-print-directory vcheck EMACS=${EMACS} notifications: email: # Default is change, but that includes a new branch's 1st success. diff --git a/Makefile b/Makefile index f50ad79..82e3092 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Time-stamp: <2017-12-01 10:44:11 kmodi> +# Time-stamp: <2017-12-02 00:57:10 kmodi> # Makefile to export org documents to md for Hugo from the command line # Run just "make" to see usage examples. @@ -104,6 +104,8 @@ help: # loads the new Org version.. and thus we'll end up with mixed Org in # the load-path. emacs-batch: + @echo "" + @echo "$(ORG_FILE) ::" @$(EMACS) --batch --eval "(progn\ (setenv \"OX_HUGO_ELPA\" \"$(OX_HUGO_ELPA)\")\ (when (> (length \"$(TIMEZONE)\") 0) (setenv \"TZ\" \"$(TIMEZONE)\"))\ diff --git a/ox-hugo.el b/ox-hugo.el index a22ffe9..afa3aba 100644 --- a/ox-hugo.el +++ b/ox-hugo.el @@ -1926,7 +1926,7 @@ INFO is a plist used as a communication channel." "true") ((and todo-keyword (string= "DRAFT" todo-keyword)) - (message "[ox-hugo] `%s' post is marked as a draft" title) + (message "[ox-hugo] `%s' post is marked as a DRAFT" title) "true") ((org-hugo--plist-get-true-p info :hugo-draft) (org-hugo--front-matter-value-booleanize (org-hugo--plist-get-true-p info :hugo-draft))) @@ -2378,24 +2378,26 @@ Return output file's name." ;; (message "[org-hugo-export-to-md DBG] section-dir = %s" section-dir) (unless subtreep ;; Below stuff applies only to per-file export flow. - (let ((org-use-tag-inheritance t) + (let ((fname (file-name-nondirectory (buffer-file-name))) + (org-use-tag-inheritance t) ;; `org-get-tags' returns a list of tags *only* ;; at the current heading; `org-get-tags-at' ;; returns inherited tags too. - (all-tags (org-get-tags-at))) - (dolist (exclude-tag org-export-exclude-tags) - (when (member exclude-tag all-tags) - (setq do-export nil))) + (all-tags (org-get-tags-at)) + matched-exclude-tag) + (when all-tags + (dolist (exclude-tag org-export-exclude-tags) + (when (member exclude-tag all-tags) + (setq matched-exclude-tag exclude-tag) + (setq do-export nil)))) (if do-export (progn ;; Reset the variables that are used only for subtree exports. (setq org-hugo--subtree-count 0) (setq org-hugo--subtree-coord nil) - (message "[ox-hugo file] Exporting `%s' (%s)" - title (file-name-nondirectory (buffer-file-name)))) - (message (concat "[ox-hugo file] `%s' was not exported as that file " - "was tagged with one of `org-export-exclude-tags'") - title)))) + (message "[ox-hugo] Exporting `%s' (%s)" title fname)) + (message "[ox-hugo] %s was not exported as it is tagged with an exclude tag `%s'" + fname matched-exclude-tag)))) (when do-export (prog1 (org-export-to-file 'hugo outfile async subtreep visible-only) @@ -2487,7 +2489,7 @@ approach)." (ignore-errors (org-back-to-heading :invisible-ok)) (let ((subtree (org-hugo--get-valid-subtree)) - is-commented is-excluded do-export) + is-commented is-excluded matched-exclude-tag do-export) (if subtree (progn ;; If subtree is a valid Hugo post subtree, proceed .. @@ -2498,9 +2500,11 @@ approach)." ;; at the current heading; `org-get-tags-at' ;; returns inherited tags too. (all-tags (org-get-tags-at))) - (dolist (exclude-tag org-export-exclude-tags) - (when (member exclude-tag all-tags) - (setq is-excluded t)))) + (when all-tags + (dolist (exclude-tag org-export-exclude-tags) + (when (member exclude-tag all-tags) + (setq matched-exclude-tag exclude-tag) + (setq is-excluded t))))) ;; (message "[current subtree DBG] subtree: %S" subtree) ;; (message "[current subtree DBG] is-commented:%S, tags:%S, is-excluded:%S" @@ -2508,13 +2512,15 @@ approach)." (let ((title (org-element-property :title subtree))) (cond (is-commented - (message "[ox-hugo] `%s' was not exported as that subtree is commented" title)) + (message "[ox-hugo] `%s' was not exported as that subtree is commented" + title)) (is-excluded - (message "[ox-hugo] `%s' was not exported as it is tagged with one of `org-export-exclude-tags'" title)) + (message "[ox-hugo] `%s' was not exported as it is tagged with an exclude tag `%s'" + title matched-exclude-tag)) (t - (message "[ox-hugo] Exporting `%s' .." title) (when (numberp org-hugo--subtree-count) (setq org-hugo--subtree-count (1+ org-hugo--subtree-count))) + (message "[ox-hugo] %d/ Exporting `%s' .." org-hugo--subtree-count title) ;; Get the current subtree coordinates for ;; auto-calculation of menu item weight or post ;; weight.