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

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

[nongnu] elpa/markdown-mode 779a4c6 3/3: Merge pull request #589 from jr


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode 779a4c6 3/3: Merge pull request #589 from jrblevin/pr-588
Date: Sat, 23 Jan 2021 10:57:14 -0500 (EST)

branch: elpa/markdown-mode
commit 779a4c637719f5a192c128ed60ecffed3ff1760c
Merge: 3e38057 fcb3245
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #589 from jrblevin/pr-588
    
    Improve #588
---
 CHANGES.md             |  2 ++
 README.md              |  4 ++++
 markdown-mode.el       | 14 ++++++++++++--
 tests/markdown-test.el | 19 +++++++++++++++++++
 4 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 1fe76f8..518353c 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -10,6 +10,7 @@
         to automatically define a default link text before prompting the user.
     -   Option to inhibit the prompt for a tooltip text via
         `markdown-disable-tooltip-prompt`.
+    -   Introduce `markdown-ordered-list-enumeration` variable [GH-587][]
 
 *   Improvements:
     -   Correct indirect buffer's indentation in `markdown-edit-code-block` 
[GH-375][]
@@ -60,6 +61,7 @@
   [gh-569]: https://github.com/jrblevin/markdown-mode/issues/569
   [gh-571]: https://github.com/jrblevin/markdown-mode/issues/571
   [gh-584]: https://github.com/jrblevin/markdown-mode/issues/584
+  [gh-587]: https://github.com/jrblevin/markdown-mode/issues/587
 
 # Markdown Mode 2.4
 
diff --git a/README.md b/README.md
index 216e180..55ba1b4 100644
--- a/README.md
+++ b/README.md
@@ -905,6 +905,10 @@ provides an interface to all of the possible 
customizations:
   * `markdown-translate-filename-function` - A function to be used to
     translate filenames in links.
 
+  * `markdown-unordered-list-item-prefix` - When non-nil,
+    `markdown-insert-list-item` inserts enumerated numbers for
+    ordered list marker. While nil, it always inserts `1.`.
+
 Additionally, the faces used for syntax highlighting can be modified to
 your liking by issuing <kbd>M-x customize-group RET markdown-faces</kbd>
 or by using the "Markdown Faces" link at the bottom of the mode
diff --git a/markdown-mode.el b/markdown-mode.el
index 542de4e..66e1744 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -427,6 +427,13 @@ The car is used for subscript, the cdr is used for 
superscripts."
   :group 'markdown
   :type 'string)
 
+(defcustom markdown-ordered-list-enumeration t
+  "When non-nil, use enumerated numbers(1. 2. 3. etc.) for ordered list marker.
+While nil, always uses '1.' for the marker"
+  :group 'markdown
+  :type 'boolean
+  :package-version '(markdown-mode . "2.5"))
+
 (defcustom markdown-nested-imenu-heading-index t
   "Use nested or flat imenu heading index.
 A nested index may provide more natural browsing from the menu,
@@ -6048,7 +6055,7 @@ increase the indentation by one level."
                           (>= (forward-line -1) 0))))
             (let* ((old-prefix (match-string 1))
                    (old-spacing (match-string 2))
-                   (new-prefix (if old-prefix
+                   (new-prefix (if (and old-prefix 
markdown-ordered-list-enumeration)
                                    (int-to-string (1+ (string-to-number 
old-prefix)))
                                  "1"))
                    (space-adjust (- (length old-prefix) (length new-prefix)))
@@ -6173,7 +6180,10 @@ a list."
               (= (length cur-item) (length prev-item)))
           (save-excursion
             (replace-match
-             (concat pfx (number-to-string (setq idx (1+ idx))) ". ")))
+             (if (not markdown-ordered-list-enumeration)
+                 (concat pfx "1. ")
+               (cl-incf idx)
+               (concat pfx (number-to-string idx) ". "))))
           (setq sep nil))
          ;; indented a level
          ((< (length pfx) (length cpfx))
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 6d072b0..db9c98a 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -1157,6 +1157,25 @@ Don't adjust spacing if tabs are used as whitespace."
             (buffer-string)
             "1. A\n    * AA\n        1. AAA\n    * \n2. \n3. "))))
 
+(ert-deftest test-markdown-insertion/with-markdown-ordered-list-enumeration ()
+  "Test for `markdown-ordered-list-enumeration'.
+Detail: https://github.com/jrblevin/markdown-mode/issues";
+  (markdown-test-string "1. A"
+    (goto-char (point-max))
+    (let ((markdown-ordered-list-enumeration t))
+      (call-interactively 'markdown-insert-list-item)
+      (let ((line (buffer-substring-no-properties
+                   (line-beginning-position) (line-end-position))))
+        (should (string= line "2. "))))
+
+    (markdown-test-string "1. A"
+      (goto-char (point-max))
+      (let ((markdown-ordered-list-enumeration nil))
+        (call-interactively 'markdown-insert-list-item)
+        (let ((line (buffer-substring-no-properties
+                     (line-beginning-position) (line-end-position))))
+          (should (string= line "1. ")))))))
+
 (ert-deftest test-markdown-insertion/reference-link ()
   "Basic tests for `markdown-insert-reference-link'."
   ;; Test optional parameters (leave point after link)



reply via email to

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