[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/toc-org 11ce8a843f 052/128: strip priorities (fixes #18)
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/toc-org 11ce8a843f 052/128: strip priorities (fixes #18) |
Date: |
Sun, 2 Jan 2022 09:59:09 -0500 (EST) |
branch: elpa/toc-org
commit 11ce8a843f6a9020ab82cb6a3e5ec6642a3af632
Author: Sergei Nosov <sergei.nosov@gmail.com>
Commit: Sergei Nosov <sergei.nosov@gmail.com>
strip priorities (fixes #18)
---
toc-org.el | 57 ++++++++++++++++++++++++++++++++-------------------------
1 file changed, 32 insertions(+), 25 deletions(-)
diff --git a/toc-org.el b/toc-org.el
index 30bb306f55..f092954418 100644
--- a/toc-org.el
+++ b/toc-org.el
@@ -59,6 +59,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-priorities-regexp "^*+\s+\\(\\[#.\\]\s+\\)"
+ "Regexp to find states on the line")
(defconst toc-org-links-regexp "\\[\\[\\(.*?\\)\\]\\[\\(.*?\\)\\]\\]"
"Regexp to find states on the line")
(defconst toc-org-special-chars-regexp "[^[:alnum:]_-]"
@@ -88,7 +90,7 @@ headings.")
(defun toc-org-raw-toc ()
"Return the \"raw\" table of contents of the current file,
i.e. simply flush everything that's not a heading and strip
-tags."
+auxiliary text."
(let ((content (buffer-substring-no-properties
(point-min) (point-max))))
(with-temp-buffer
@@ -107,6 +109,11 @@ tags."
(while (re-search-forward toc-org-states-regexp nil t)
(replace-match "" nil nil nil 1))
+ ;; 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
@@ -122,35 +129,35 @@ tags."
(buffer-substring-no-properties
(point-min) (point-max)))))
-(ert-deftest toc-org-test-raw-toc ()
+(ert-deftest test-toc-org-raw-toc ()
"Test the `toc-org-raw-toc' function"
- (defun toc-org-test-raw-toc-gold-test (content gold)
+ (defun test-toc-org-raw-toc-gold-test (content gold)
(should (equal
(with-temp-buffer
(insert content)
(toc-org-raw-toc))
gold)))
- (declare-function toc-org-test-raw-toc-gold-test "toc-org") ;; suppress
compiler warning
+ (declare-function test-toc-org-raw-toc-gold-test "toc-org") ;; suppress
compiler warning
(let ((beg "* TODO [[http://somewhere.com][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
")
(gold "* About\n"))
;; different TOC styles
- (toc-org-test-raw-toc-gold-test (concat beg ":TOC:" ) gold)
- (toc-org-test-raw-toc-gold-test (concat beg ":TOC_1:" ) gold)
- (toc-org-test-raw-toc-gold-test (concat beg ":TOC_1_qqq:" ) gold)
- (toc-org-test-raw-toc-gold-test (concat beg ":TOC@1:" ) gold)
- (toc-org-test-raw-toc-gold-test (concat beg ":TOC@1@cxv:" ) gold)
- (toc-org-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" ) gold)
+ (test-toc-org-raw-toc-gold-test (concat beg ":TOC:" ) gold)
+ (test-toc-org-raw-toc-gold-test (concat beg ":TOC_1:" ) gold)
+ (test-toc-org-raw-toc-gold-test (concat beg ":TOC_1_qqq:" ) gold)
+ (test-toc-org-raw-toc-gold-test (concat beg ":TOC@1:" ) gold)
+ (test-toc-org-raw-toc-gold-test (concat beg ":TOC@1@cxv:" ) gold)
+ (test-toc-org-raw-toc-gold-test (concat beg ":TOC@1_hello:" ) gold)
;; trailing symbols
- (toc-org-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" "\n\n\n") gold)
- (toc-org-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" "\n\n\nsdfd")
gold))
+ (test-toc-org-raw-toc-gold-test (concat beg ":TOC@1_hello:" "\n\n\n") gold)
+ (test-toc-org-raw-toc-gold-test (concat beg ":TOC@1_hello:" "\n\n\nsdfd")
gold))
;; more complex case
- (toc-org-test-raw-toc-gold-test
- "* 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 [...]
+ (test-toc-org-raw-toc-gold-test
+ "* 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"))
(defun toc-org-hrefify-gh (str)
@@ -161,7 +168,7 @@ rules."
(special-chars-fix (replace-regexp-in-string
toc-org-special-chars-regexp "" upcase-fix t)))
(concat "#" special-chars-fix)))
-(ert-deftest toc-org-test-hrefify-gh ()
+(ert-deftest test-toc-org-hrefify-gh ()
"Test the `toc-org-hrefify-gh' function"
(should (equal (toc-org-hrefify-gh "About") "#about"))
(should (equal (toc-org-hrefify-gh "!h@#$%^&*(){}|][:;\"'/?.>,<`~") "#h"))
@@ -235,7 +242,7 @@ each heading into a link."
(buffer-substring-no-properties
(point-min) (point-max))))
-(ert-deftest toc-org-test-hrefify-toc ()
+(ert-deftest test-toc-org-hrefify-toc ()
(let ((hash (make-hash-table :test 'equal)))
(should (equal (toc-org-hrefify-toc "* About\n" 'upcase hash)
" - [[ABOUT][About]]\n"))
@@ -265,7 +272,7 @@ each heading into a link."
(buffer-substring-no-properties
(point-min) (point-max))))
-(ert-deftest toc-org-test-flush-subheadings ()
+(ert-deftest test-toc-org-flush-subheadings ()
(should (equal (toc-org-flush-subheadings "* About\n" 0)
""))
(should (equal (toc-org-flush-subheadings "* About\n" 1)
@@ -365,10 +372,10 @@ following tag formats:
(setq org-link-translation-function 'toc-org-unhrefify)
(toc-org-insert-toc t)))
-(ert-deftest toc-org-test-insert-toc ()
+(ert-deftest test-toc-org-insert-toc ()
"Test the `toc-org-insert-toc' function"
- (defun toc-org-test-insert-toc-gold-test (content gold)
+ (defun test-toc-org-insert-toc-gold-test (content gold)
(with-temp-buffer
(org-mode)
(insert content)
@@ -378,26 +385,26 @@ following tag formats:
(buffer-substring-no-properties
(point-min) (point-max))
gold))))
- (declare-function toc-org-test-insert-toc-gold-test "toc-org") ;; suppress
compiler warning
+ (declare-function test-toc-org-insert-toc-gold-test "toc-org") ;; suppress
compiler warning
(let ((beg "* 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* Hello\n** Good-bye\n*** Salut\n*
Table of Contents "))
- (toc-org-test-insert-toc-gold-test
+ (test-toc-org-insert-toc-gold-test
(concat beg ":TOC:")
"* 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* Hello\n** Good-bye\n*** Salut\n*
Table of Contents :TOC:\n -
[[#about][About]]\n - [[#hello][Hello]]\n - [[#g [...]
- (toc-org-test-insert-toc-gold-test
+ (test-toc-org-insert-toc-gold-test
(concat beg ":TOC_1:")
"* 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* Hello\n** Good-bye\n*** Salut\n*
Table of Contents :TOC_1:\n
- [[#about][About]]\n - [[#hello][Hello]]\n")
- (toc-org-test-insert-toc-gold-test
+ (test-toc-org-insert-toc-gold-test
(concat beg ":TOC_3:")
"* 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* Hello\n** Good-bye\n*** Salut\n*
Table of Contents :TOC_3:\n
- [[#about][About]]\n - [[#hello][Hello]]\n - [[ [...]
- (toc-org-test-insert-toc-gold-test
+ (test-toc-org-insert-toc-gold-test
(concat beg ":TOC_1_org:")
"* 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* Hello\n** Good-bye\n*** Salut\n*
Table of Contents
:TOC_1_org:\n - [[About][About]]\n - [[Hello][Hello]]\n")
- (toc-org-test-insert-toc-gold-test
+ (test-toc-org-insert-toc-gold-test
(concat beg ":TOC_3_org:")
"* 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* Hello\n** Good-bye\n*** Salut\n*
Table of Contents
:TOC_3_org:\n - [[About][About]]\n - [[Hello][Hello]]\n - [...]
- [nongnu] elpa/toc-org 72883a08b0 049/128: update the TOC only if it's actually different from the current one, (continued)
- [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, 2022/01/02
- [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 <=
- [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
- [nongnu] elpa/toc-org 827dc448e0 013/128: push .travis.yml, ELPA Syncer, 2022/01/02
- [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