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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/toc-org 56b48ec37b 033/128: rename to toc-org


From: ELPA Syncer
Subject: [nongnu] elpa/toc-org 56b48ec37b 033/128: rename to toc-org
Date: Sun, 2 Jan 2022 09:59:07 -0500 (EST)

branch: elpa/toc-org
commit 56b48ec37bec1b610b41ee4a645f55797f57853b
Author: Sergei Nosov <sergei.nosov@gmail.com>
Commit: Sergei Nosov <sergei.nosov@gmail.com>

    rename to toc-org
---
 README.org               |  34 +++++-------
 org-toc.el => toc-org.el | 135 +++++++++++++++++++++++------------------------
 2 files changed, 80 insertions(+), 89 deletions(-)

diff --git a/README.org b/README.org
index 1e64727795..2d60e350df 100644
--- a/README.org
+++ b/README.org
@@ -1,10 +1,8 @@
-[[https://travis-ci.org/snosov1/org-toc][file:https://api.travis-ci.org/snosov1/org-toc.svg?branch=master]]
-
-#+TITLE: NOTE: The package was renamed to toc-org and moved to 
https://github.com/snosov1/toc-org Please, update your configuration files!
+[[https://travis-ci.org/snosov1/toc-org][file:https://api.travis-ci.org/snosov1/toc-org.svg?branch=master]]
 
 * About
 
-org-toc helps you to have an up-to-date table of contents in org files without
+toc-org helps you to have an up-to-date table of contents in org files without
 exporting (useful primarily for readme files on GitHub).
 
 It is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works 
for org files.
@@ -14,7 +12,6 @@ It is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]]
  - [[#installation][Installation]]
      - [[#via-packageel][via package.el]]
      - [[#manual][Manual]]
-     - [[#potential-name-conflict][Potential name conflict]]
  - [[#use][Use]]
  - [[#different-href-styles][Different href styles]]
  - [[#example][Example]]
@@ -29,31 +26,26 @@ Emacs 24.1) you can simply use =M-x package-install= after 
setting up the [[http
 repository and then put the following snippet in your ~/.emacs file
 
 #+BEGIN_SRC elisp
-  (if (require 'org-toc nil t)
-      (add-hook 'org-mode-hook 'org-toc-enable)
-    (warn "org-toc not found"))
+  (if (require 'toc-org nil t)
+      (add-hook 'org-mode-hook 'toc-org-enable)
+    (warn "toc-org not found"))
 #+END_SRC
 
 ** Manual
 
 - Create folder ~/.emacs.d if you don't have it
-- Go to it and clone org-toc there
+- Go to it and clone toc-org there
   #+BEGIN_SRC sh
-    git clone https://github.com/snosov1/org-toc.git
+    git clone https://github.com/snosov1/toc-org.git
   #+END_SRC
 - Put this in your ~/.emacs file
   #+BEGIN_SRC elisp
-    (add-to-list 'load-path "~/.emacs.d/org-toc")
-    (if (require 'org-toc nil t)
-        (add-hook 'org-mode-hook 'org-toc-enable)
-      (warn "org-toc not found"))
+    (add-to-list 'load-path "~/.emacs.d/toc-org")
+    (if (require 'toc-org nil t)
+        (add-hook 'org-mode-hook 'toc-org-enable)
+      (warn "toc-org not found"))
   #+END_SRC
 
-** Potential name conflict
-
-If you install =contrib= Org modules, you may face a name conflict, since
-there's a package with the same name there.
-
 * Use
 
 After the installation, every time you'll be saving an org file, the first
@@ -88,13 +80,13 @@ Now =C-c C-q T RET= and you are done putting the =:TOC:= 
entry.
 Currently, only 2 href styles are supported: =gh= and =org=. You can easily
 define your own styles. If you use the tag =:TOC_2_STYLE:= (=STYLE= being a
 style name), then the package will look for a function named
-=org-toc-hrefify-STYLE=, which accepts a heading string and returns a href
+=toc-org-hrefify-STYLE=, which accepts a heading string and returns a href
 corresponding to that heading.
 
 E.g. for =org= style it simply returns input as is:
 
 #+BEGIN_SRC emacs-lisp
-  (defun org-toc-hrefify-org (str)
+  (defun toc-org-hrefify-org (str)
     "Given a heading, transform it into a href using the org-mode
   rules."
     str)
diff --git a/org-toc.el b/toc-org.el
similarity index 72%
rename from org-toc.el
rename to toc-org.el
index 3369a0ba10..f09aef9dd5 100644
--- a/org-toc.el
+++ b/toc-org.el
@@ -1,11 +1,11 @@
-;;; org-toc.el --- add table of contents to org-mode files
+;;; toc-org.el --- add table of contents to org-mode files
 
 ;; Copyright (C) 2014 Sergei Nosov
 
 ;; Author: Sergei Nosov <sergei.nosov [at] gmail.com>
 ;; Version: 1.0
 ;; Keywords: org-mode org toc table of contents
-;; URL: https://github.com/snosov1/org-toc
+;; URL: https://github.com/snosov1/toc-org
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
@@ -24,50 +24,50 @@
 
 ;;; Commentary:
 
-;; org-toc helps you to have an up-to-date table of contents in org files
+;; toc-org helps you to have an up-to-date table of contents in org files
 ;; without exporting (useful primarily for readme files on GitHub).
 
 ;; After installation put into your .emacs file something like
 
-;; (if (require 'org-toc nil t)
-;;     (add-hook 'org-mode-hook 'org-toc-enable)
-;;   (warn "org-toc not found"))
+;; (if (require 'toc-org nil t)
+;;     (add-hook 'org-mode-hook 'toc-org-enable)
+;;   (warn "toc-org not found"))
 
 ;; And every time you'll be saving an org file, the first headline with a :TOC:
 ;; tag will be updated with the current table of contents.
 
-;; For details, see https://github.com/snosov1/org-toc
+;; For details, see https://github.com/snosov1/toc-org
 
 ;;; Code:
 
 (require 'ert)
 
-(defgroup org-toc nil
-  "org-toc is a utility to have an up-to-date table of contents
+(defgroup toc-org nil
+  "toc-org is a utility to have an up-to-date table of contents
 in the org files without exporting (useful primarily for readme
 files on GitHub)"
   :group 'org)
 
 ;; just in case, simple regexp "^*.*:toc:\\($\\|[^ ]*:$\\)"
-(defconst org-toc-org-toc-regexp 
"^*.*:toc\\([@_][0-9]\\|\\([@_][0-9][@_][a-zA-Z]+\\)\\)?:\\($\\|[^ ]*:$\\)"
+(defconst toc-org-toc-org-regexp 
"^*.*:toc\\([@_][0-9]\\|\\([@_][0-9][@_][a-zA-Z]+\\)\\)?:\\($\\|[^ ]*:$\\)"
   "Regexp to find the heading with the :toc: tag")
-(defconst org-toc-tags-regexp "\s*:[[:word:]:@]*:\s*$"
+(defconst toc-org-tags-regexp "\s*:[[:word:]:@]*:\s*$"
   "Regexp to find tags on the line")
-(defconst org-toc-special-chars-regexp "[][~`!@#$%^&*()+={}|\:;\"'<,>.?/]"
+(defconst toc-org-special-chars-regexp "[][~`!@#$%^&*()+={}|\:;\"'<,>.?/]"
   "Regexp with the special characters (which are omitted in hrefs
   by GitHub)")
 
-(defcustom org-toc-max-depth 2
+(defcustom toc-org-max-depth 2
   "Maximum depth of the headings to use in the table of
 contents. The default of 2 uses only the highest level headings
 and their subheadings (one and two stars)."
-  :group 'org-toc)
+  :group 'toc-org)
 
-(defcustom org-toc-hrefify-default "gh"
+(defcustom toc-org-hrefify-default "gh"
   "Default hrefify function to use."
-  :group 'org-toc)
+  :group 'toc-org)
 
-(defun org-toc-raw-toc ()
+(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."
@@ -80,7 +80,7 @@ tags."
 
       ;; don't include the TOC itself
       (goto-char (point-min))
-      (re-search-forward org-toc-org-toc-regexp)
+      (re-search-forward toc-org-toc-org-regexp)
       (beginning-of-line)
       (delete-region (point) (progn (forward-line 1) (point)))
 
@@ -89,63 +89,63 @@ tags."
       ;; TODO :export: and :noexport: tags semantic should be probably
       ;; implemented
       (goto-char (point-min))
-      (while (re-search-forward org-toc-tags-regexp nil t)
+      (while (re-search-forward toc-org-tags-regexp nil t)
         (replace-match "" nil nil))
 
       (buffer-substring-no-properties
        (point-min) (point-max)))))
 
-(ert-deftest org-toc-test-raw-toc ()
-  "Test the `org-toc-raw-toc' function"
+(ert-deftest toc-org-test-raw-toc ()
+  "Test the `toc-org-raw-toc' function"
 
-  (defun org-toc-test-raw-toc-gold-test (content gold)
+  (defun toc-org-test-raw-toc-gold-test (content gold)
     (should (equal
              (with-temp-buffer
                (insert content)
-               (org-toc-raw-toc))
+               (toc-org-raw-toc))
              gold)))
-  (declare-function org-toc-test-raw-toc-gold-test "org-toc") ;; suppress 
compiler warning
+  (declare-function toc-org-test-raw-toc-gold-test "toc-org") ;; suppress 
compiler warning
 
-  (let ((beg "* About\n:TOC:\n drawer\n:END:\n\norg-toc 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                   
                                  ")
+  (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\n* Table of Contents                   
                                  ")
         (gold "* About\n"))
 
     ;; different TOC styles
-    (org-toc-test-raw-toc-gold-test (concat beg ":TOC:"         ) gold)
-    (org-toc-test-raw-toc-gold-test (concat beg ":TOC_1:"       ) gold)
-    (org-toc-test-raw-toc-gold-test (concat beg ":TOC_1_qqq:"   ) gold)
-    (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1:"       ) gold)
-    (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1@cxv:"   ) gold)
-    (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" ) gold)
+    (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)
 
     ;; trailing symbols
-    (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" "\n\n\n") gold)
-    (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" "\n\n\nsdfd") 
gold))
+    (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))
 
   ;; more complex case
-  (org-toc-test-raw-toc-gold-test
-   "* About\n:TOC:\n drawer\n:END:\n\norg-toc 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 [...]
+  (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 [...]
    "* About\n* Installation\n** via package.el\n** Manual\n* Use\n* Different 
href styles\n* Example\n"))
 
-(defun org-toc-hrefify-gh (str)
+(defun toc-org-hrefify-gh (str)
   "Given a heading, transform it into a href using the GitHub
 rules."
   (let* ((spc-fix (replace-regexp-in-string " " "-" str))
          (upcase-fix (replace-regexp-in-string "[A-Z]" 'downcase spc-fix t))
-         (special-chars-fix (replace-regexp-in-string 
org-toc-special-chars-regexp "" upcase-fix t)))
+         (special-chars-fix (replace-regexp-in-string 
toc-org-special-chars-regexp "" upcase-fix t)))
     (concat "#" special-chars-fix)))
 
-(ert-deftest org-toc-test-hrefify-gh ()
-  "Test the `org-toc-hrefify-gh' function"
-  (should (equal (org-toc-hrefify-gh "About") "#about"))
-  (should (equal (org-toc-hrefify-gh "!h@#$%^&*(){}|][:;\"'/?.>,<`~") "#h"))
-  (should (equal (org-toc-hrefify-gh "!h@#$% ^&*(S){}|][:;\"'/?.>,<`~") 
"#h-s")))
+(ert-deftest toc-org-test-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"))
+  (should (equal (toc-org-hrefify-gh "!h@#$% ^&*(S){}|][:;\"'/?.>,<`~") 
"#h-s")))
 
-(defun org-toc-hrefify-org (str)
+(defun toc-org-hrefify-org (str)
   "Given a heading, transform it into a href using the org-mode
 rules."
   str)
 
-(defun org-toc-hrefify-toc (toc hrefify)
+(defun toc-org-hrefify-toc (toc hrefify)
   "Format the raw `toc' using the `hrefify' function to transform
 each heading into a link."
   (with-temp-buffer
@@ -178,13 +178,13 @@ each heading into a link."
     (buffer-substring-no-properties
      (point-min) (point-max))))
 
-(ert-deftest org-toc-test-hrefify-toc ()
-  (should (equal (org-toc-hrefify-toc "* About\n" 'upcase)
+(ert-deftest toc-org-test-hrefify-toc ()
+  (should (equal (toc-org-hrefify-toc "* About\n" 'upcase)
                  " - [[ABOUT][About]]\n"))
-  (should (equal (org-toc-hrefify-toc "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 'upcase)
+  (should (equal (toc-org-hrefify-toc "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 'upcase)
                  " - [[ABOUT][About]]\n - [[INSTALLATION][Installation]]\n     
- [[VIA PACKAGE.EL][via package.el]]\n     - [[MANUAL][Manual]]\n - 
[[USE][Use]]\n - [[DIFFERENT HREF STYLES][Different href styles]]\n - 
[[EXAMPLE][Example]]\n")))
 
-(defun org-toc-flush-subheadings (toc max-depth)
+(defun toc-org-flush-subheadings (toc max-depth)
   "Flush subheadings of the raw `toc' deeper than `max-depth'."
   (with-temp-buffer
     (insert toc)
@@ -198,24 +198,24 @@ each heading into a link."
     (buffer-substring-no-properties
      (point-min) (point-max))))
 
-(ert-deftest org-toc-test-flush-subheadings ()
-  (should (equal (org-toc-flush-subheadings "* About\n" 0)
+(ert-deftest toc-org-test-flush-subheadings ()
+  (should (equal (toc-org-flush-subheadings "* About\n" 0)
                  ""))
-  (should (equal (org-toc-flush-subheadings "* About\n" 1)
+  (should (equal (toc-org-flush-subheadings "* About\n" 1)
                  "* About\n"))
-  (should (equal (org-toc-flush-subheadings "* About\n" 2)
+  (should (equal (toc-org-flush-subheadings "* About\n" 2)
                  "* About\n"))
 
-  (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 0)
+  (should (equal (toc-org-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 0)
                  ""))
-  (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 1)
+  (should (equal (toc-org-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 1)
                  "* About\n* Installation\n* Use\n* Different href styles\n* 
Example\n"))
-  (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 2)
+  (should (equal (toc-org-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 2)
                  "* About\n* Installation\n** via package.el\n** Manual\n* 
Use\n* Different href styles\n* Example\n"))
-  (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 3)
+  (should (equal (toc-org-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 3)
                  "* About\n* Installation\n** via package.el\n** Manual\n* 
Use\n* Different href styles\n* Example\n")))
 
-(defun org-toc-insert-toc ()
+(defun toc-org-insert-toc ()
   "Looks for a headline with the TOC tag and updates it with the
 current table of contents.
 
@@ -239,16 +239,16 @@ following tag formats:
       (goto-char (point-min))
       (let ((case-fold-search t))
         ;; find the first heading with the :TOC: tag
-        (when (re-search-forward org-toc-org-toc-regexp (point-max) t)
+        (when (re-search-forward toc-org-toc-org-regexp (point-max) t)
 
           (let* ((tag (match-string 1))
                  (depth (if tag
                             (- (aref tag 1) ?0) ;; is there a better way to 
convert char to number?
-                          org-toc-max-depth))
+                          toc-org-max-depth))
                  (hrefify-tag (if (and tag (>= (length tag) 4))
                                   (downcase (substring tag 3))
-                                org-toc-hrefify-default))
-                 (hrefify-string (concat "org-toc-hrefify-" hrefify-tag))
+                                toc-org-hrefify-default))
+                 (hrefify-string (concat "toc-org-hrefify-" hrefify-tag))
                  (hrefify (intern-soft hrefify-string)))
             (if hrefify
                 (progn
@@ -266,18 +266,17 @@ following tag formats:
                                    (end-of-line)
                                    (point)))
 
-                  (insert (org-toc-hrefify-toc (org-toc-flush-subheadings 
(org-toc-raw-toc) depth) hrefify)))
+                  (insert (toc-org-hrefify-toc (toc-org-flush-subheadings 
(toc-org-raw-toc) depth) hrefify)))
               (message (concat "Hrefify function " hrefify-string " is not 
found")))))))))
 
 ;;;###autoload
-(defun org-toc-enable ()
-  "Enable org-toc in this buffer."
-  (add-hook 'before-save-hook 'org-toc-insert-toc nil t))
+(defun toc-org-enable ()
+  "Enable toc-org in this buffer."
+  (add-hook 'before-save-hook 'toc-org-insert-toc nil t))
 
 ;; Local Variables:
 ;; compile-command: "emacs -batch -l ert -l *.el -f 
ert-run-tests-batch-and-exit && emacs -batch -f batch-byte-compile *.el 2>&1 | 
sed -n '/Warning\|Error/p' | xargs -r ls"
 ;; End:
 
-(provide 'org-toc-2)
-(provide 'org-toc)
-;;; org-toc.el ends here
+(provide 'toc-org)
+;;; toc-org.el ends here



reply via email to

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