From: Eshel Yaron Date: Sat, 10 Dec 2022 07:35:41 +0000 (+0200) Subject: * (sweeprolog-mode): Improve interaction with auto-fill-mode X-Git-Tag: V9.1.1-sweep-0.9.5~2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=854950a148087a8e33098d543d1fabcb252762d2;p=dict.git * (sweeprolog-mode): Improve interaction with auto-fill-mode --- diff --git a/sweeprolog-tests.el b/sweeprolog-tests.el index cf0d331..5ccbb03 100644 --- a/sweeprolog-tests.el +++ b/sweeprolog-tests.el @@ -1044,6 +1044,29 @@ scasp_and_show(Q, Model, Tree) :- % % ")))) +(ert-deftest auto-fill-pldoc-comments () + "Test writing PlDoc comments with `auto-fill-mode' enable." + (with-temp-buffer + (sweeprolog-mode) + (auto-fill-mode) + (seq-do (lambda (c) + (let ((last-command-event c)) + (call-interactively #'self-insert-command))) + " +%! foobar is det. +% +% Nam vestibulum accumsan nisl. Donec pretium posuere tellus. Aenean in sem ac leo mollis blandit. Nam a sapien. Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus. +" + ) + (should (string= (buffer-string) + " +%! foobar is det. +% +% Nam vestibulum accumsan nisl. Donec pretium posuere tellus. +% Aenean in sem ac leo mollis blandit. Nam a sapien. Proin quam +% nisl, tincidunt et, mattis eget, convallis nec, purus. +")))) + (ert-deftest electric-layout () "Test `sweeprolog-electric-layout-mode'." (with-temp-buffer diff --git a/sweeprolog.el b/sweeprolog.el index 9fabeb0..92c0bde 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -3545,6 +3545,8 @@ certain contexts to maintain conventional Prolog layout." (setq-local forward-sexp-function #'sweeprolog-forward-sexp-function) (setq-local syntax-propertize-function #'sweeprolog-syntax-propertize) (setq-local indent-line-function #'sweeprolog-indent-line) + (setq-local adaptive-fill-regexp "[ \t]*") + (setq-local fill-indent-according-to-mode t) (setq-local font-lock-defaults '(nil nil