emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Anthony Carrico <acarrico@memebeam.org>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Include missing files when sitemap style is tree
Date: Fri, 11 Sep 2020 23:26:33 -0400	[thread overview]
Message-ID: <393d0ddf-894a-6183-c1fd-d8ab23a2163a@memebeam.org> (raw)

* ox-publish.el (org-publish-sitemap): Include files that have an 
ancestor below base-directory with no published files and sitemap style 
is tree.

This entire patch is released to the public domain by its author, 
Anthony Carrico.  TINYCHANGE
  lisp/ox-publish.el | 21 +++++++++++++++++++--
  1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index 7bb2fed6e..314b48ffc 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -747,6 +747,20 @@ return a string.  Return value is a list as returned by
  	 (funcall subtree-to-list root)))
        (_ (user-error "Unknown site-map style: `%s'" style)))))

+(defun org-publish-dir-name-parent (dir-name)
+  (file-name-as-directory (expand-file-name (concat dir-name ".."))))
+(defun org-publish-dir-name-and-parents (dir-name root-dir-name)
+  (pcase dir-name
+     ("" nil)
+     ((or "./" "/" (pred (string= root-dir-name))) (list dir-name))
+     (_ (cons dir-name (org-publish-dir-name-and-parents
+			(org-publish-dir-name-parent dir-name) root-dir-name)))))
+(defun org-publish-file-name-parents (file root)
+  (org-publish-dir-name-and-parents (file-name-directory file)
+				    (file-name-as-directory root)))
  (defun org-publish-sitemap (project &optional sitemap-filename)
    "Create a sitemap of pages in set defined by PROJECT.
  Optionally set the filename of the sitemap with SITEMAP-FILENAME.
@@ -819,8 +833,11 @@ Default for SITEMAP-FILENAME is `sitemap.org'."
  	 ;; Add directories, if applicable.
  	 (unless (and (eq style 'list) (eq sort-folders 'ignore))
  	   (setq files
-		 (nconc (remove root (org-uniquify
-				      (mapcar #'file-name-directory files)))
+		 (nconc (remove
+			 root
+			 (org-uniquify
+			  (mapcan (lambda (f) (org-publish-file-name-parents f root))
+				  files)))
  	 ;; Eventually sort all entries.
  	 (when (or sort-files (not (memq sort-folders 'ignore)))

             reply	other threads:[~2020-09-12  3:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-12  3:26 Anthony Carrico [this message]
2020-10-24 12:21 ` [PATCH] Include missing files when sitemap style is tree Bastien
2020-10-27  0:38   ` Anthony Carrico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=393d0ddf-894a-6183-c1fd-d8ab23a2163a@memebeam.org \
    --to=acarrico@memebeam.org \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).