From 69858ae4eabbd56fe9840cd149ba006dea509660 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Sun, 4 Aug 2024 20:46:45 -0700 Subject: [PATCH] Fix c-ts-common filling * lisp/progmodes/c-ts-common.el: (c-ts-common--fill-block-comment): Exclude the last line from filling if it only has non-word characters like *=-. * test/lisp/progmodes/c-ts-mode-resources/filling.erts: Fir the multi-line test and add a single line test. (cherry picked from commit 5ecd35555e9e20de9717f0184f58a15d8a2e68a3) --- lisp/progmodes/c-ts-common.el | 6 +++--- .../progmodes/c-ts-mode-resources/filling.erts | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el index 022d21e11a1..674623a5e61 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -186,9 +186,9 @@ comment." ;; filling region. (when (not end-marker) (goto-char end) - (when (looking-back (rx "*/") 2) - (backward-char 2) - (skip-syntax-backward "-") + (forward-line 0) + (when (looking-at (rx (* (or (syntax whitespace) "*" "=" "-")) + "*/" eol)) (setq end (point)))) ;; Let `fill-paragraph' do its thing. diff --git a/test/lisp/progmodes/c-ts-mode-resources/filling.erts b/test/lisp/progmodes/c-ts-mode-resources/filling.erts index e58b8e91c90..5425519b3d7 100644 --- a/test/lisp/progmodes/c-ts-mode-resources/filling.erts +++ b/test/lisp/progmodes/c-ts-mode-resources/filling.erts @@ -101,7 +101,7 @@ Name: Type 4 =-= /*================================================================ * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy - woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy * ================================================================*/ =-= @@ -112,6 +112,20 @@ Name: Type 4 * ================================================================*/ =-=-= +Name: Type 4 Single-line + +=-= +/*================================================================ + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * ================================================================*/ +=-= +/*================================================================ + * woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy + * woooomy woooomy + * ================================================================*/ +=-=-= + + Name: Type 5 /* woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy woooomy -- 2.39.2