[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/toc-org f0b94e07bb 075/128: Merge pull request #39 from sn
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/toc-org f0b94e07bb 075/128: Merge pull request #39 from snosov1/add-noexport-support |
Date: |
Sun, 2 Jan 2022 09:59:10 -0500 (EST) |
branch: elpa/toc-org
commit f0b94e07bb4b32db039088a58578bced29256431
Merge: cda8f73640 39d983c381
Author: Sergei Nosov <sergei.nosov@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #39 from snosov1/add-noexport-support
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 11be82816a 019/128: Merge pull request #4 from ardumont/add-tag-setup, (continued)
- [nongnu] elpa/toc-org 11be82816a 019/128: Merge pull request #4 from ardumont/add-tag-setup, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org b4dbeb936c 024/128: simply require ert, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 3dd30029b6 043/128: strip TODO and DONE states, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 7eb2874ed3 041/128: require org, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 3e0bdb5a29 054/128: fix properties handling (see #20), ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 7c54f809d6 058/128: Merge pull request #23 from snosov1/fix-eof-toc, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org b0cac21cdf 059/128: handle statistics cookies and #+OPTIONS: todo:t, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 44c2e17543 070/128: Merge pull request #36 from snosov1/move-tests, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 421956e9cc 078/128: remove opening space in each toc item, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 379b457fcf 107/128: fix subheading link in readme, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org f0b94e07bb 075/128: Merge pull request #39 from snosov1/add-noexport-support,
ELPA Syncer <=
- [nongnu] elpa/toc-org 274e821fd4 079/128: update emacs to 25 for travis testing, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 5deaec41ed 109/128: Update README.org, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org aef220c266 115/128: Merge pull request #71 from snosov1/fix-70, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 4798d15365 110/128: WIP Fix stripping of word "Comment" in headlines, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org e76e6d4044 085/128: make toc-org work in derived modes, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org d992b1f76a 108/128: Update README.org, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org ce9e49303c 089/128: simply use downcase instead of replace-regexp-in-string, ELPA Syncer, 2022/01/02