]> git.neil.brown.name Git - edlib.git/commitdiff
textfill: default fill:end-re to fill:start-re
authorNeilBrown <neil@brown.name>
Fri, 26 May 2023 03:22:26 +0000 (13:22 +1000)
committerNeilBrown <neil@brown.name>
Fri, 26 May 2023 22:18:43 +0000 (08:18 +1000)
The regexp for start and end of para are usually the same, so if end-re
isn't given, use the same as start-re.

Use this to simplify md config, and enhance it a bit.

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

index 129313a8282b19d0d855fa1083f58f7e18b6d640..af34fec18a2b8777ab7db9d2f6d7c110862542ab 100644 (file)
@@ -59,7 +59,7 @@ Bugs to be fixed
 - [X] transparent images appear in email with horiz lines
 - [ ] Replying to w3m/html mail results in unsightly markup in reply
 - [ ] converting email parts with external code should be async
-- [ ] fill:end-re should default to fill:start-re
+- [X] fill:end-re should default to fill:start-re
 - [ ] md-mode should set the fill re-s don't rely on config
 - [ ] config.py should load from $HOME/.config/edlib/config.py
         exec(read())
index c5f9e0c20c6606e048e1c0df82680c6e8b0ba001..de0e723f63386403851abb7cf7fb6baeb24a38ae 100644 (file)
@@ -22,18 +22,18 @@ def config_appeared(key, focus, **a):
             focus.call("doc:set:whitespace-width", "60")
 
     if p and p[-3:] == ".md":
+        # Until I have a real markdown module, I need this at least.
         if os.getenv("EDLIB_TESTING"):
             focus.call("doc:set:view-default", "textfill,whitespace")
         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]*\\.)"
-                   )
+        focus["fill-width"] = "72"
+        focus["fill:start-re"] = ("^("
+                                  "[^a-zA-Z0-9\\n]*$|" # empty/puctuation line
+                                  " *-|"               # list item
+                                  " *- *\\[[ X]]|"     # todo list item
+                                  " *#+|"              # section head
+                                  " *[0-9]*\\.)")      # Numbered list
 
     return edlib.Efallthrough
 
index 7bc77d388e80fa3cbc5cc893bbb9247631face21..41bfdcec8f646422ec0627cd092da190cdf767eb 100644 (file)
@@ -154,6 +154,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.call("doc:get-attr", mark, "fill:start-re", ret='str')
     if not re:
         re = "^[^a-zA-Z0-9\n]*$"
     try: