emacs-elpa-diffs
[Top][All Lists]
Advanced

[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   -  [...]
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]