emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-30 292fcd20099: Fix c-ts-common filling function (bug#71760)


From: Yuan Fu
Subject: emacs-30 292fcd20099: Fix c-ts-common filling function (bug#71760)
Date: Sat, 3 Aug 2024 23:04:11 -0400 (EDT)

branch: emacs-30
commit 292fcd2009918a3e4f15b6451ad521a0a92188ad
Author: Damien Cassou <damien@cassou.me>
Commit: Yuan Fu <casouri@gmail.com>

    Fix c-ts-common filling function (bug#71760)
    
    * lisp/progmodes/c-ts-common.el (c-ts-common--fill-block-comment): If
    masking hasn't been done, don't unmask.
---
 lisp/progmodes/c-ts-common.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el
index 3882a697c48..14dd29e07e2 100644
--- a/lisp/progmodes/c-ts-common.el
+++ b/lisp/progmodes/c-ts-common.el
@@ -151,7 +151,9 @@ comment."
          (orig-point (point-marker))
          (start-marker (point-marker))
          (end-marker nil)
-         (end-len 0))
+         (end-len 0)
+         (start-mask-done nil)
+         (end-mask-done nil))
     (move-marker start-marker start)
     ;; We mask "/*" and the space before "*/" like
     ;; `c-fill-paragraph' does.
@@ -162,6 +164,7 @@ comment."
                             (group "/") "*"))
         (goto-char (match-beginning 1))
         (move-marker start-marker (point))
+        (setq start-mask-done t)
         (replace-match " " nil nil nil 1))
 
       ;; Include whitespaces before /*.
@@ -179,6 +182,7 @@ comment."
         (goto-char (match-beginning 1))
         (setq end-marker (point-marker))
         (setq end-len (- (match-end 1) (match-beginning 1)))
+        (setq end-mask-done t)
         (replace-match (make-string end-len ?x)
                        nil nil nil 1))
 
@@ -206,11 +210,11 @@ comment."
         (fill-region (max start-marker para-start) (min end para-end) arg))
 
       ;; Unmask.
-      (when start-marker
+      (when (and start-mask-done start-marker)
         (goto-char start-marker)
         (delete-char 1)
         (insert "/"))
-      (when end-marker
+      (when (and end-mask-done start-marker)
         (goto-char end-marker)
         (delete-region (point) (+ end-len (point)))
         (insert (make-string end-len ?\s)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]