aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorStefan Kangas2022-09-16 19:33:02 +0200
committerStefan Kangas2022-09-16 19:34:46 +0200
commitbcc84ac7feccf285811d3bc3254fa10062c9334c (patch)
treea54cffb8aae39b879889edfffcf6b10ad4871332 /admin
parent5d227ae83e57eb5ef2144e3af3e3431d26d77bc1 (diff)
downloademacs-bcc84ac7feccf285811d3bc3254fa10062c9334c.tar.gz
emacs-bcc84ac7feccf285811d3bc3254fa10062c9334c.zip
Add version headlines to HTML NEWS export
This allows linking to, e.g. "NEWS.28.html#28.1" to go directly to those release notes. * admin/admin.el (admin--org-export-headers-format) (make-news-html-file): Add XX.Y version headlines with an HTML anchor.
Diffstat (limited to 'admin')
-rw-r--r--admin/admin.el49
1 files changed, 39 insertions, 10 deletions
diff --git a/admin/admin.el b/admin/admin.el
index 60b043a3516..14f0f80188b 100644
--- a/admin/admin.el
+++ b/admin/admin.el
@@ -773,7 +773,7 @@ Optional argument TYPE is type of output (nil means all)."
773(defvar admin--org-export-headers-format "\ 773(defvar admin--org-export-headers-format "\
774#+title: GNU Emacs %s NEWS -- history of user-visible changes 774#+title: GNU Emacs %s NEWS -- history of user-visible changes
775#+author: 775#+author:
776#+options: author:nil creator:nil toc:1 num:2 *:nil \\n:t ^:nil tex:nil 776#+options: author:nil creator:nil toc:2 num:3 *:nil \\n:t ^:nil tex:nil
777#+language: en 777#+language: en
778#+HTML_LINK_HOME: /software/emacs 778#+HTML_LINK_HOME: /software/emacs
779#+HTML_LINK_UP: /software/emacs 779#+HTML_LINK_UP: /software/emacs
@@ -851,12 +851,13 @@ $Date: %s $
851 (unless (file-exists-p (expand-file-name "src/emacs.c" root)) 851 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
852 (user-error "%s doesn't seem to be the root of an Emacs source tree" root)) 852 (user-error "%s doesn't seem to be the root of an Emacs source tree" root))
853 (admin--require-external-package 'htmlize) 853 (admin--require-external-package 'htmlize)
854 (let* ((orig (expand-file-name "etc/NEWS" root)) 854 (let* ((newsfile (expand-file-name "etc/NEWS" root))
855 (new (expand-file-name (format "etc/NEWS.%s.org" version) root)) 855 (orgfile (expand-file-name (format "etc/NEWS.%s.org" version) root))
856 (html-file (format "%s.html" (file-name-base new))) 856 (html (format "%s.html" (file-name-base orgfile)))
857 (copyright-years (format-time-string "%Y"))) 857 (copyright-years (format-time-string "%Y")))
858 (copy-file orig new t) 858 (delete-file orgfile)
859 (find-file new) 859 (copy-file newsfile orgfile t)
860 (find-file orgfile)
860 861
861 ;; Find the copyright range. 862 ;; Find the copyright range.
862 (goto-char (point-min)) 863 (goto-char (point-min))
@@ -931,6 +932,34 @@ $Date: %s $
931 (org-mode) 932 (org-mode)
932 (save-buffer) 933 (save-buffer)
933 934
935 ;; Make everything one level lower.
936 (goto-char (point-min))
937 (while (re-search-forward (rx bol (group (+ "*")) " ") nil t)
938 (replace-match "*\\1" nil nil nil 1))
939
940 ;; Insert anchors for different versions.
941 (goto-char (point-min))
942 (let (last-major last-minor)
943 (while (re-search-forward (rx bol "** " (+ (not "\n")) "in Emacs "
944 (group digit digit) "." (group digit)
945 eol)
946 nil t)
947 (unless (and (equal (match-string 1) last-major)
948 (equal (match-string 2) last-minor))
949 (setq last-major (match-string 1))
950 (setq last-minor (match-string 2))
951 (forward-line -1)
952 (insert (format
953 (concat
954 ;; Add anchor to allow linking to
955 ;; e.g. "NEWS.28.html#28.1".
956 "#+HTML: <p id=\"%s.%s\">&nbsp;</p>\n"
957 "* Changes in Emacs %s.%s\n")
958 last-major last-minor
959 last-major last-minor)))))
960
961 (save-buffer)
962
934 ;; Make the HTML export. 963 ;; Make the HTML export.
935 (let* ((org-html-postamble 964 (let* ((org-html-postamble
936 (format admin--org-html-postamble 965 (format admin--org-html-postamble
@@ -942,12 +971,12 @@ $Date: %s $
942 (org-html-export-as-html)) 971 (org-html-export-as-html))
943 972
944 ;; Write HTML to file. 973 ;; Write HTML to file.
945 (let ((new (expand-file-name html-file (expand-file-name "etc" root)))) 974 (let ((html (expand-file-name html (expand-file-name "etc" root))))
946 (write-file new) 975 (write-file html)
947 (unless noninteractive 976 (unless noninteractive
948 (find-file new) 977 (find-file html)
949 (html-mode)) 978 (html-mode))
950 (message "Successfully exported HTML to %s" new)))) 979 (message "Successfully exported HTML to %s" html))))
951 980
952 981
953;; Stuff to check new `defcustom's got :version tags. 982;; Stuff to check new `defcustom's got :version tags.