[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 f02998939c 1/8: ; Fix c-ts-mode filling
From: |
Yuan Fu |
Subject: |
emacs-29 f02998939c 1/8: ; Fix c-ts-mode filling |
Date: |
Sun, 15 Jan 2023 04:17:43 -0500 (EST) |
branch: emacs-29
commit f02998939c6b7eaa5a63137573abe6fd85fc3de1
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
; Fix c-ts-mode filling
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--comment-regexp): New variable.
(c-ts-mode--fill-paragraph): Use the new variable, and make sure
start-marker is always initialized.
---
lisp/progmodes/c-ts-mode.el | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index ef5a9c2195..c1f354c7ba 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -671,6 +671,11 @@ the semicolon. This function skips the semicolon."
;;; Filling
+(defvar c-ts-mode--comment-regexp
+ ;; These covers C/C++, Java, JavaScript, TypeScript, Rust, C#.
+ (rx (or "comment" "line_comment" "block_comment"))
+ "Regexp pattern that matches a comment in C-like languages.")
+
(defun c-ts-mode--fill-paragraph (&optional arg)
"Fillling function for `c-ts-mode'.
ARG is passed to `fill-paragraph'."
@@ -683,12 +688,12 @@ ARG is passed to `fill-paragraph'."
;; Bind to nil to avoid infinite recursion.
(fill-paragraph-function nil)
(orig-point (point-marker))
- (start-marker nil)
+ (start-marker (point-marker))
(end-marker nil)
(end-len 0))
- ;; These covers C/C++, Java, JavaScript, TypeScript, Rust, C#.
- (when (member (treesit-node-type node)
- '("comment" "line_comment" "block_comment"))
+ (move-marker start-marker start)
+ (when (string-match-p c-ts-mode--comment-regexp
+ (treesit-node-type node))
;; We mask "/*" and the space before "*/" like
;; `c-fill-paragraph' does.
(atomic-change-group
@@ -697,7 +702,7 @@ ARG is passed to `fill-paragraph'."
(when (looking-at (rx (* (syntax whitespace))
(group "/") "*"))
(goto-char (match-beginning 1))
- (setq start-marker (point-marker))
+ (move-marker start-marker (point))
(replace-match " " nil nil nil 1))
;; Include whitespaces before /*.
(goto-char start)
- emacs-29 updated (b365a7cc32 -> 3fa10f6e54), Yuan Fu, 2023/01/15
- emacs-29 25a5575f16 7/8: Fix c-ts-mode block comment indentation (bug#60270), Yuan Fu, 2023/01/15
- emacs-29 3fa10f6e54 8/8: ; Add more c-ts-mode indent and filling tests, Yuan Fu, 2023/01/15
- emacs-29 252b2c01af 6/8: Fix c-ts-mode label indent, Yuan Fu, 2023/01/15
- emacs-29 f02998939c 1/8: ; Fix c-ts-mode filling,
Yuan Fu <=
- emacs-29 d13a329acf 3/8: ; Minor change in c-ts-mode--indent-styles, Yuan Fu, 2023/01/15
- emacs-29 c78e19d99c 4/8: Allow offset in tree-sitter indent rules to be functions, Yuan Fu, 2023/01/15
- emacs-29 189d976dba 5/8: Fix statement indent for c-ts-mode (bug#59686) (bug#60280), Yuan Fu, 2023/01/15
- emacs-29 d428d51066 2/8: Support filling line comments in c-ts-mode, Yuan Fu, 2023/01/15