unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59763: 29.0.60; Filling for c-ts-mode
@ 2022-12-02  5:33 Yuan Fu
  2022-12-02 14:58 ` Eli Zaretskii
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Yuan Fu @ 2022-12-02  5:33 UTC (permalink / raw)
  To: 59763


IMO For c-ts-mode to be usable we need to have at least a basic filling
function. Below is the function I have in my init.el, could someone have
a look and see if it’s good? Alternatively we could copy out the comment
and fill it in a temp buffer with c-mode, but I didn’t have the time to try
it out and see how well it works.

(defun ts-c-fill-paragraph (&optional arg)
  (interactive)
  (let* ((node (treesit-node-at (point)))
         (start (treesit-node-start node))
         (end (treesit-node-end node))
         (pstart (save-excursion
                   (forward-paragraph -1)
                   (skip-syntax-forward "-")
                   (point)))
         (pend (save-excursion
                 (forward-paragraph 1)
                 (point))))
    (when (equal (treesit-node-type node) "comment")
      (fill-region (max start pstart) (min end pend)))
    t))

Yuan





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-01-07 23:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-02  5:33 bug#59763: 29.0.60; Filling for c-ts-mode Yuan Fu
2022-12-02 14:58 ` Eli Zaretskii
2022-12-03  0:54   ` Yuan Fu
2022-12-05 11:47     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-24  8:36 ` Yuan Fu
2022-12-24  8:42   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-25  1:30 ` Yuan Fu
2022-12-25  7:33   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-26 21:31 ` Yuan Fu
2022-12-26 22:03   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-26 22:51     ` Yuan Fu
2022-12-26 23:00       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-07 23:11 ` Yuan Fu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).