From 854950a148087a8e33098d543d1fabcb252762d2 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sat, 10 Dec 2022 09:35:41 +0200 Subject: [PATCH] * (sweeprolog-mode): Improve interaction with auto-fill-mode --- sweeprolog-tests.el | 23 +++++++++++++++++++++++ sweeprolog.el | 2 ++ 2 files changed, 25 insertions(+) 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 -- 2.39.2