[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/toc-org cda8f73640 073/128: Merge pull request #37 from sn
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/toc-org cda8f73640 073/128: Merge pull request #37 from snosov1/handle-comment |
Date: |
Sun, 2 Jan 2022 09:59:10 -0500 (EST) |
branch: elpa/toc-org
commit cda8f73640ae26c476990eae421e42627445f9d0
Merge: 44c2e17543 b1bab4c078
Author: Sergei Nosov <sergei.nosov@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #37 from snosov1/handle-comment
handle headlines with COMMENT
---
toc-org-test.el | 24 +++++++++++++++++++++++-
toc-org.el | 11 +++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/toc-org-test.el b/toc-org-test.el
index 7bf8233d14..b9777aa24c 100644
--- a/toc-org-test.el
+++ b/toc-org-test.el
@@ -32,13 +32,35 @@
"* About\n:TOC:\n drawer\n:END:\n\ntoc-org is a utility to have an
up-to-date table of contents in the\norg files without exporting (useful
primarily for readme files on\nGitHub).\n\nIt is similar to the
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works
for org files.\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n -
[[#use][Use]]\n - [[#different-href-styles][Different href st [...]
"* About\n* Installation\n** via package.el\n** Manual\n* Use\n* Different
href styles\n* Example\n")
+ ;; test #+OPTIONS 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: todo: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 ~/.emacs file\n#
[...]
"* About\n* Installation\n** DONE via package.el\n** TODO Manual\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** TODO Manual\n"))
+ "* About\n* Installation\n** DONE via package.el\n** TODO Manual\n")
+
+ ;; test COMMENT 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"))
(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 368b7305e8..3859910c48 100644
--- a/toc-org.el
+++ b/toc-org.el
@@ -58,6 +58,8 @@ files on GitHub)"
"Regexp to find tags on the line")
(defconst toc-org-states-regexp "^*+\s+\\(TODO\s+\\|DONE\s+\\)"
"Regexp to find states on the line")
+(defconst toc-org-COMMENT-regexp "\\(^*+\\)\s+\\(COMMENT\s+\\)"
+ "Regexp to find COMMENT headlines")
(defconst toc-org-priorities-regexp "^*+\s+\\(\\[#.\\]\s+\\)"
"Regexp to find states on the line")
(defconst toc-org-links-regexp "\\[\\[\\(.*?\\)\\]\\[\\(.*?\\)\\]\\]"
@@ -126,6 +128,15 @@ auxiliary text."
(while (re-search-forward toc-org-states-regexp nil t)
(replace-match "" nil nil nil 1)))
+ ;; strip COMMENT headlines
+ (goto-char (point-min))
+ (while (re-search-forward toc-org-COMMENT-regexp nil t)
+ (let ((skip-depth (concat (match-string 1) "*")))
+ (while (progn
+ (beginning-of-line)
+ (delete-region (point) (min (1+ (line-end-position))
(point-max)))
+ (string-prefix-p skip-depth (or (current-word) ""))))))
+
;; strip priorities
(goto-char (point-min))
(while (re-search-forward toc-org-priorities-regexp nil t)
- [nongnu] elpa/toc-org 4d076d1e9d 118/128: Respect the file-local value of org-list-indent-offset., (continued)
- [nongnu] elpa/toc-org 4d076d1e9d 118/128: Respect the file-local value of org-list-indent-offset., ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org f3218fdaf1 123/128: Add license and copyright header to toc-org-test.el, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 501f36db68 021/128: Merge pull request #5 from ardumont/wrap-tests-definition, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 658c03111b 017/128: add some more tests and fix wording, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org d3677cd8c8 022/128: make compile-command run the tests, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 0dee7197c8 026/128: fix byte-compilation check, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 242eecba19 034/128: add a note about previous name, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 90894242a6 046/128: treat org-list-indent-offset properly, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 4c0b28da59 037/128: add more tags for easier search, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org e38e81af3f 088/128: Merge pull request #57 from JAremko/master, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org cda8f73640 073/128: Merge pull request #37 from snosov1/handle-comment,
ELPA Syncer <=
- [nongnu] elpa/toc-org ee70dd23e1 104/128: resolve missing functions warnings, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org d52f95fae8 105/128: Handle trailing #'s, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 5ce7c24920 096/128: handle paranthesis in #+TODO line (fixes #65), ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org b1bab4c078 072/128: handle nil that is sometimes returned by (current-word), ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 9efeec690c 111/128: Remove the "backup" variable, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org ff8d49c2c7 113/128: Merge pull request #69 from htsr/comment-stripping, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 95a558b362 099/128: add tests for markdown-style syntax, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org e33e4cc00a 084/128: Merge pull request #50 from snosov1/handle-custom-keywords, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 7291a3b08d 100/128: Enable link following in markdown mode, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org f455bd4c88 103/128: Call batch compile before running the tests, ELPA Syncer, 2022/01/02