From: NeilBrown Date: Fri, 26 May 2023 03:22:26 +0000 (+1000) Subject: textfill: default fill:end-re to fill:start-re X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=897009a2d260e34a1198cfdfbafd9ce0ff457e39;p=edlib.git textfill: default fill:end-re to fill:start-re 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 --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 129313a8..af34fec1 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -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()) diff --git a/python/config.py b/python/config.py index c5f9e0c2..de0e723f 100644 --- a/python/config.py +++ b/python/config.py @@ -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 diff --git a/python/lib-textfill.py b/python/lib-textfill.py index 7bc77d38..41bfdcec 100644 --- a/python/lib-textfill.py +++ b/python/lib-textfill.py @@ -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: