]> git.neil.brown.name Git - edlib.git/commitdiff
handle text-fill in .md files better.
authorNeilBrown <neil@brown.name>
Mon, 22 May 2023 10:53:47 +0000 (20:53 +1000)
committerNeilBrown <neil@brown.name>
Fri, 26 May 2023 22:18:42 +0000 (08:18 +1000)
Enhance text-fill so that various style attributes can be on the pane
rather than on the character, and set pane attributes for markdown to
notice the starts of various paragraph types, particularly the various
list entries.

Signed-off-by: NeilBrown <neil@brown.name>
python/config.py
python/lib-textfill.py

index e42c4f3457dc499fe244dfd7b92c9b6c41561142..7deefc44f7e30ffdfa7e704e392eb92d57d4d2a8 100644 (file)
@@ -27,6 +27,14 @@ def config_appeared(key, focus, **a):
         else:
             focus.call("doc:set:view-default", "textfill,whitespace,autospell")
         focus.call("doc:set:fill-width", "72")
+
+        focus.call("doc:set:fill:start-re",
+                   "^([^a-zA-Z0-9\\n]*$| *-| *- *\\[[ X]]| *#+| *\\*+| *[0-9]*\\.)"
+                   )
+        focus.call("doc:set:fill:end-re",
+                   "^([^a-zA-Z0-9\\n]*$| *-| *- *\\[[ X]]| *#+| *\\*+| *[0-9]*\\.)"
+                   )
+
     return edlib.Efallthrough
 
 editor.call("global-set-command", "doc:appeared-config", config_appeared)
index 41bb59ac34b9f5e353ed7192016744a8f48df7e3..4c55c4ac62a2ef81ee91a1635314646cc49971b3 100644 (file)
@@ -128,6 +128,8 @@ def find_start(focus, mark):
     mark = mark.dup()
     m = mark.dup()
     re = focus.call("doc:get-attr", mark, "fill:start-re", ret='str')
+    if not re:
+        re = focus['fill:start-re']
     if not re:
         re = "^[^a-zA-Z0-9\n]*$"
     focus.call("doc:EOL", -100, m)
@@ -154,6 +156,8 @@ def find_end(focus, mark):
     m = mark.dup()
     focus.call("doc:EOL", 100, m)
     re = focus.call("doc:get-attr", mark, "fill:end-re", ret='str')
+    if not re:
+        re = focus['fill:end-re']
     if not re:
         re = "^[^a-zA-Z0-9\n]*$"
     try:
@@ -181,6 +185,8 @@ def get_prefixes(focus, mark, lines):
         # only one line, so prefix is all spaces but based on first line
         prefix = focus.call("doc:get-attr", "fill:default-prefix",
                             m, ret='str')
+        if not prefix:
+            prefix = focus['fill:default-prefix']
         if not prefix:
             prefix = ""
             # When a single line is being wrapped, all of these
@@ -188,6 +194,8 @@ def get_prefixes(focus, mark, lines):
             # other lines.
             repeating_prefix = focus.call("doc:get-attr", "fill:repeating-prefix",
                                           m, ret='str')
+            if not repeating_prefix:
+                repeating_prefix = focus['fill:repeating-prefix']
             if not repeating_prefix:
                 repeating_prefix=''
             repeating_prefix += ' \t'