[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/toc-org 39d983c381 074/128: add noexport support
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/toc-org 39d983c381 074/128: add noexport support |
Date: |
Sun, 2 Jan 2022 09:59:10 -0500 (EST) |
branch: elpa/toc-org
commit 39d983c3817b66d6a790d472448fef79b8926b92
Author: Sergei Nosov <sergei.nosov@gmail.com>
Commit: Sergei Nosov <sergei.nosov@gmail.com>
add noexport support
---
README.org | 11 +++++++++++
toc-org-test.el | 44 +++++++++++++++++++++++++++++++++++++++++++-
toc-org.el | 25 ++++++++++++++++++++++---
3 files changed, 76 insertions(+), 4 deletions(-)
diff --git a/README.org b/README.org
index e5c218898e..470cd6df3a 100644
--- a/README.org
+++ b/README.org
@@ -17,6 +17,7 @@ name conflict with one of the org contrib modules.
- [[#manual][Manual]]
- [[#use][Use]]
- [[#follow-links][Follow links]]
+ - [[#exclude-headings][Exclude headings]]
- [[#shortcut-for-toc-tag][Shortcut for TOC tag]]
- [[#different-href-styles][Different href styles]]
- [[#example][Example]]
@@ -81,6 +82,16 @@ is not nil).
You can manually disable this functionality by setting
=toc-org-enable-links-opening= to nil.
+** Exclude headings
+
+Headings tagged with =:noexport:= will be excluded from the TOC. If you want to
+preserve the heading, but strip its children (for changelog entries, for
+example), you can tag it =:noexport_1:= (by analogy, you can use
=:noexport_2:=,
+=:noexport_3:=, etc. for children of deeper levels). Note, though, =:noexport:=
+has a similar meaning in =org-mode=, which I hope is a Good Thing (tm).
However,
+=:noexport_1:= and friends won't be recognized by =org-mode= as anything
+special. Look at =org-export-exclude-tags= variable for more details.
+
** Shortcut for TOC tag
In your emacs' setup, you can bind a tag =:TOC:= to a binding =T=:
diff --git a/toc-org-test.el b/toc-org-test.el
index b9777aa24c..34eb9d7be2 100644
--- a/toc-org-test.el
+++ b/toc-org-test.el
@@ -60,7 +60,49 @@
(test-toc-org-raw-toc-gold-test
"* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
- "* About\n* Installation\n** DONE via package.el\n*** Rather
commentious\n** No remove\n* Test ***\n"))
+ "* About\n* Installation\n** DONE via package.el\n*** Rather
commentious\n** No remove\n* Test ***\n")
+
+ ;; test noexport behavior
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
+ "* About\n* Installation\n** DONE via package.el\n")
+
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
+ "* About\n* Installation\n** DONE via package.el\n* Rather commentious\n")
+
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
+ "* About\n* Installation\n** DONE via package.el\n* Rather commentious\n**
No remove\n* Test\n")
+
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
+ "* About\n* Installation\n** DONE via package.el\n*** Rather
commentious\n** No remove\n* Test\n")
+
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
+ "* About\n* Installation\n** DONE via package.el\n*** Rather
commentious\n** No remove\n* Test ***\n")
+
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
+ "* About\n* Installation\n** DONE via package.el\n*** Rather
commentious\n** Manual\n** No remove\n* Test ***\n")
+
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
+ "* About\n* Installation\n** DONE via package.el\n*** Rather
commentious\n** Manual\n*** Commented\n** No remove\n* Test ***\n")
+
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
+ "* About\n* Installation\n** DONE via package.el\n*** Rather
commentious\n** Manual\n*** Commented\n** No remove\n* Test ***\n")
+
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
+ "* About\n* Installation\n** DONE via package.el\n*** Rather
commentious\n** Manual\n*** EWW\n** No remove\n* Test ***\n")
+
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
+ "* About\n* Installation\n** DONE via package.el\n*** Rather
commentious\n** Manual\n*** EWW\n*** Commented\n** No remove\n* Test ***\n")
+ )
(ert-deftest test-toc-org-hrefify-gh ()
"Test the `toc-org-hrefify-gh' function"
diff --git a/toc-org.el b/toc-org.el
index 3859910c48..8ca32899be 100644
--- a/toc-org.el
+++ b/toc-org.el
@@ -54,7 +54,9 @@ files on GitHub)"
;; just in case, simple regexp "^*.*:toc:\\($\\|[^ ]*:$\\)"
(defconst toc-org-toc-org-regexp
"^*.*:toc\\([@_][0-9]\\|\\([@_][0-9][@_][a-zA-Z]+\\)\\)?:\\($\\|[^ ]*?:$\\)"
"Regexp to find the heading with the :toc: tag")
-(defconst toc-org-tags-regexp "\s*:[[:word:]:@]*:\s*$"
+(defconst toc-org-noexport-regexp
"\\(^*+\\)\s+.*:noexport\\([@_][0-9]\\)?:\\($\\|[^ ]*?:$\\)"
+ "Regexp to find the extended version of :noexport: tag")
+(defconst toc-org-tags-regexp "\s*:[[:word:]:@_]*:\s*$"
"Regexp to find tags on the line")
(defconst toc-org-states-regexp "^*+\s+\\(TODO\s+\\|DONE\s+\\)"
"Regexp to find states on the line")
@@ -137,14 +139,31 @@ auxiliary text."
(delete-region (point) (min (1+ (line-end-position))
(point-max)))
(string-prefix-p skip-depth (or (current-word) ""))))))
+ ;; strip headings with :noexport: tag
+ (goto-char (point-min))
+ (while (re-search-forward toc-org-noexport-regexp nil t)
+ (save-excursion
+ (let* ((tag (match-string 2))
+ (depth (if tag (string-to-number (substring tag 1)) 0))
+ (subheading-depth (concat (match-string 1) "*"))
+ (skip-depth (concat subheading-depth (make-string (max (1-
depth) 0) ?*))))
+ (if (> depth 0)
+ (forward-line)
+ (beginning-of-line)
+ (delete-region (point) (min (1+ (line-end-position))
(point-max))))
+ (while (string-prefix-p subheading-depth (or (current-word) ""))
+ (if (string-prefix-p skip-depth (or (current-word) ""))
+ (progn
+ (beginning-of-line)
+ (delete-region (point) (min (1+ (line-end-position))
(point-max))))
+ (forward-line))))))
+
;; strip priorities
(goto-char (point-min))
(while (re-search-forward toc-org-priorities-regexp nil t)
(replace-match "" nil nil nil 1))
;; strip tags
- ;; TODO :export: and :noexport: tags semantic should be probably
- ;; implemented
(goto-char (point-min))
(while (re-search-forward toc-org-tags-regexp nil t)
(replace-match "" nil nil))
- [nongnu] elpa/toc-org cac667fabd 018/128: Add a small note about global tag setup, (continued)
- [nongnu] elpa/toc-org cac667fabd 018/128: Add a small note about global tag setup, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 752fe14c5b 042/128: fix "_1_org"-style suffixes, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 815c6d8c1b 044/128: flatten links when creating raw toc, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org e0cef2c6a1 027/128: print emacs version in travis log, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 8cf236450b 045/128: don't modify and save file on opening, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 114dcc9813 053/128: make GitHub hrefs unique (fixes #16), ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 72883a08b0 049/128: update the TOC only if it's actually different from the current one, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 4e4b4e6484 057/128: generate correct toc when it's the last heading, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 4380d99113 065/128: add unit test for #31, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 970560a874 069/128: fix travis build, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 39d983c381 074/128: add noexport support,
ELPA Syncer <=
- [nongnu] elpa/toc-org 663e5ec281 116/128: Correct sample configuration to valid code, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org c83c19ddb4 093/128: Merge pull request #59 from snosov1/add-quote, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 35781c6313 126/128: Merge pull request #82 from skangas/add-license, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 08ed3f0883 061/128: Merge pull request #30 from snosov1/fix-28, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 56b48ec37b 033/128: rename to toc-org, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 11ce8a843f 052/128: strip priorities (fixes #18), ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org a19c3f5f94 091/128: test quote functionality, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 32975071df 039/128: mention former name in description, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org c662f96040 090/128: add quote functionality, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 4cd71edc29 082/128: bump emacs25 version, ELPA Syncer, 2022/01/02