branch: elpa/adoc-mode
commit 4b6054b5c8f934f19b84b0f2467cfbadaf643d3e
Author: Florian Kaufmann <[email protected]>
Commit: Florian Kaufmann <[email protected]>
added adoc-insert-indented
---
adoc-mode-test.el | 11 +++++++++++
adoc-mode.el | 5 +++++
2 files changed, 16 insertions(+)
diff --git a/adoc-mode-test.el b/adoc-mode-test.el
index d6c8f7a701..8ad4079fdd 100644
--- a/adoc-mode-test.el
+++ b/adoc-mode-test.el
@@ -756,6 +756,17 @@ removed before TRANSFORM is evaluated.
(should (equal (adoc-repeat-string "lorem" 1) "lorem"))
(should (equal (adoc-repeat-string "lorem" 2) "loremlorem")))
+(ert-deftest adoctest-test-indent-by-example ()
+ (let ((tab-width 2)
+ (indent-tabs-mode nil))
+ (adoctest-trans "" " x" '(adoc-insert-indented "x" 1))
+ (adoctest-trans "" " x" '(adoc-insert-indented "x" 2)))
+
+ (let ((tab-width 3)
+ (indent-tabs-mode t))
+ (adoctest-trans "" " x" '(adoc-insert-indented "x" 1))
+ (adoctest-trans "" "\t x" '(adoc-insert-indented "x" 2))))
+
;; purpose
;; - ensure that the latest version, i.e. the one currently in buffer(s), of
;; adoc-mode and adoc-mode-test is used for the test
diff --git a/adoc-mode.el b/adoc-mode.el
index d65d964faa..7ab3e21186 100644
--- a/adoc-mode.el
+++ b/adoc-mode.el
@@ -2467,6 +2467,11 @@ Is influenced by customization variables such as
`adoc-title-style'."))))
;;;; misc
+(defun adoc-insert-indented (str indent-level)
+ "Indents and inserts STR such that point is at INDENT-LEVEL."
+ (indent-to (- (* tab-width indent-level) (length str)))
+ (insert str))
+
(defun adoc-repeat-string (str n)
"Returns str n times concatenated"
(let ((retval ""))