Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-introduce using the buffer-local value of org-list-indent-offset. #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion toc-org-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
(should (equal (toc-org-hrefify-toc "* About\n"
(lambda (str &optional hash) (upcase str))
(car params)
0
hash)
(cdr params)))
(should (equal (gethash "ABOUT" hash) "About"))))
Expand All @@ -163,11 +164,12 @@
(should (equal (toc-org-hrefify-toc "* About \n"
(lambda (str &optional hash) (upcase str))
nil
0
hash)
"- [[ABOUT][About]]\n"))
(should (equal (gethash "ABOUT" hash) "About")))
(let ((hash (make-hash-table :test 'equal)))
(should (equal (toc-org-hrefify-toc "* About\n* Installation\n** via package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" (lambda (str &optional hash) (upcase str)) nil hash)
(should (equal (toc-org-hrefify-toc "* About\n* Installation\n** via package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" (lambda (str &optional hash) (upcase str)) nil 0 hash)
"- [[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"))
(should (equal (gethash "ABOUT" hash) "About"))
(should (equal (gethash "INSTALLATION" hash) "Installation"))
Expand Down
7 changes: 3 additions & 4 deletions toc-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ rules."
(setq ret-path original-path))))
(cons ret-type ret-path)))

(defun toc-org-hrefify-toc (toc hrefify markdown-syntax-p &optional hash)
(defun toc-org-hrefify-toc (toc hrefify markdown-syntax-p list-offset &optional hash)
"Format the raw `toc' using the `hrefify' function to transform
each heading into a link."
(with-temp-buffer
Expand All @@ -298,9 +298,7 @@ each heading into a link."

(while (looking-at "\\*")
(delete-char 1)
(insert (make-string
(+ 2 (or (bound-and-true-p org-list-indent-offset) 0))
?\s)))
(insert (make-string (+ 2 list-offset) ?\s)))

(insert "-")
(skip-chars-forward " ")
Expand Down Expand Up @@ -409,6 +407,7 @@ not :noexport_#:."
(toc-org-flush-subheadings (toc-org-raw-toc markdown-syntax-p) depth)
hrefify
markdown-syntax-p
(or (bound-and-true-p org-list-indent-offset) 0)
(when toc-org-hrefify-hash
(clrhash toc-org-hrefify-hash)))
toc-suffix)))
Expand Down