[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/adoc-mode 2322c32185 076/199: extracted make-two-line-titl
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/adoc-mode 2322c32185 076/199: extracted make-two-line-title-underline from make-two-line-title |
Date: |
Sun, 3 Sep 2023 06:59:35 -0400 (EDT) |
branch: elpa/adoc-mode
commit 2322c321852aa1aba6d79206132a6bce1c829a3b
Author: Florian Kaufmann <sensorflo@gmail.com>
Commit: Florian Kaufmann <sensorflo@gmail.com>
extracted make-two-line-title-underline from make-two-line-title
---
adoc-mode-test.el | 6 ++++++
adoc-mode.el | 26 +++++++++++++++++---------
2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/adoc-mode-test.el b/adoc-mode-test.el
index 7da1d10287..82ba796a2f 100644
--- a/adoc-mode-test.el
+++ b/adoc-mode-test.el
@@ -611,6 +611,12 @@ removed before TRANSFORM is evaluated.
(should (equal (line-number-at-pos) 3)))
(kill-buffer "adoc-test")))
+(ert-deftest adoctest-test-make-two-line-title-underline ()
+ (should (equal (adoc-make-two-line-title-underline 0 6)
+ "======"))
+ (should (equal (adoc-make-two-line-title-underline 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 7629b3fbd5..427a7e9884 100644
--- a/adoc-mode.el
+++ b/adoc-mode.el
@@ -503,19 +503,27 @@ match-data has his this sub groups:
;; 2nd line: underline
(adoc-re-two-line-title-undlerline del)))
-(defun adoc-make-two-line-title (del text)
- "Returns a two line title using given DEL containing given TEXT."
- (when (not (eq (length del) 2))
- (error "two line title delimiters must be 2 chars long"))
- (let ((repetition-cnt (if (>= (length text) 2) (/ (length text) 2) 1))
- (result (concat text "\n")))
+(defun adoc-make-two-line-title (level text)
+ "Returns a two line title of given LEVEL containing given TEXT.
+LEVEL starts at 1."
+ (concat text "\n" (adoc-make-two-line-title-underline level (length text))))
+
+(defun adoc-make-two-line-title-underline (level &optional length)
+ "Returns a two line title underline.
+LEVEL is the level of the title, starting at 1. LENGTH is the
+line of the title's text. When nil it defaults to 4."
+ (unless length
+ (setq length 4))
+ (let* ((repetition-cnt (if (>= length 2) (/ length 2) 1))
+ (del (nth level adoc-two-line-title-del))
+ (result ""))
(while (> repetition-cnt 0)
(setq result (concat result del))
(setq repetition-cnt (- repetition-cnt 1)))
- (when (eq (% (length text) 2) 1)
+ (when (eq (% length 2) 1)
(setq result (concat result (substring del 0 1))))
result))
-
+
(defun adoc-re-oulisti (type &optional level sub-type)
"Returns a regexp matching an (un)ordered list item.
@@ -2009,7 +2017,7 @@ trailing delimiter ('== my title ==').
(text (nth 3 descriptor)))
(if (eq type 1)
(adoc-make-one-line-title sub-type level text)
- (adoc-make-two-line-title (nth level adoc-two-line-title-del) text))))
+ (adoc-make-two-line-title level text))))
(defun adoc-modify-title (&optional new-level-rel new-level-abs new-type
new-sub-type create)
"Modify properties of title point is on.
- [nongnu] elpa/adoc-mode a88d4ea5d5 052/199: bugfix: some regexps did not handle end of buffer correctly, (continued)
- [nongnu] elpa/adoc-mode a88d4ea5d5 052/199: bugfix: some regexps did not handle end of buffer correctly, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode f1477f70cc 057/199: comment changes, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 601de95b01 062/199: modified regexp for xref for better find, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode b79c243241 059/199: adoc-re-anchor can now match a given id, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 9753b42821 065/199: bumped version to V0.5.0, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 3501940311 073/199: test: running the test is a bit more smoothly, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 734527e2d4 077/199: added link to markup-faces within customization group, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 569eff13b1 078/199: added lots of templates & easy-menu-entries, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 16fe6044b7 081/199: bumped version to 0.6.0, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 091f46e866 061/199: test: added test for goto-ref-label, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 2322c32185 076/199: extracted make-two-line-title-underline from make-two-line-title,
ELPA Syncer <=
- [nongnu] elpa/adoc-mode efa9ef97a0 080/199: list item tempos respect tab-width and indent-tabs-mode, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 9c395f4bf9 093/199: it's now less likely that text between two adjacent delimited blocks is misinterpreted as delimited block, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 06f9792fcd 011/199: added further simple tests for constrained/uncronstrained quotes, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode ead05da007 014/199: split up the current big test into smaller ones, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode f519baf304 022/199: addef *.elc files to .gitignore, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 886497d6a6 023/199: added a few medium complex tests for (un)constrained quotes, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode b65c7fcb92 026/199: block title now fits into the new concept, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 0f7619cfce 027/199: enheanced inline-subst-boundaries test, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode b8e8574afa 038/199: introduced adoc-attribute-face-alist, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode e03d63e0b3 039/199: extened anchors unittest and fixed revealed bug, ELPA Syncer, 2023/09/03