[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 398ed75c27 4/5: ; * lisp/progmodes/c-ts-mode.el (c-ts-mode--fil
From: |
Yuan Fu |
Subject: |
emacs-29 398ed75c27 4/5: ; * lisp/progmodes/c-ts-mode.el (c-ts-mode--fill-paragraph): Fix. |
Date: |
Wed, 28 Dec 2022 18:57:48 -0500 (EST) |
branch: emacs-29
commit 398ed75c276d7e4de583a9de750a777173252e77
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
; * lisp/progmodes/c-ts-mode.el (c-ts-mode--fill-paragraph): Fix.
---
lisp/progmodes/c-ts-mode.el | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 83b0459c23..8ba6cdee42 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -590,6 +590,10 @@ ARG is passed to `fill-paragraph'."
(goto-char (match-beginning 1))
(setq start-marker (point-marker))
(replace-match " " nil nil nil 1))
+ ;; Include whitespaces before /*.
+ (goto-char start)
+ (beginning-of-line)
+ (setq start (point))
;; Mask spaces before "*/" if it is attached at the end
;; of a sentence rather than on its own line.
(goto-char end)
@@ -661,11 +665,18 @@ Set up:
(concat (rx (* (syntax whitespace))
(group (or (seq "/" (+ "/")) (* "*"))))
adaptive-fill-regexp))
- ;; Same as `adaptive-fill-regexp'.
+ ;; Note the missing * comparing to `adaptive-fill-regexp'. The
+ ;; reason for its absence is a bit convoluted to explain. Suffice
+ ;; to say that without it, filling a single line paragraph that
+ ;; starts with /* doesn't insert * at the beginning of each
+ ;; following line, and filling a multi-line paragraph whose first
+ ;; two lines start with * does insert * at the beginning of each
+ ;; following line. If you know how does adaptive filling works, you
+ ;; know what I mean.
(setq-local adaptive-fill-first-line-regexp
(rx bos
(seq (* (syntax whitespace))
- (group (or (seq "/" (+ "/")) (* "*")))
+ (group (seq "/" (+ "/")))
(* (syntax whitespace)))
eos))
;; Same as `adaptive-fill-regexp'.