From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Simen Heggestøyl" <simenheg@gmail.com>
Cc: 20256@debbugs.gnu.org
Subject: bug#20256: 25.0.50; css-mode: filling multi-line comments
Date: Tue, 07 Apr 2015 14:26:51 -0400 [thread overview]
Message-ID: <jwvr3rvresl.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <1428153151.17305.0@smtp.gmail.com> ("Simen Heggestøyl"'s message of "Sat, 04 Apr 2015 15:12:31 +0200")
> From this comment in `css-fill-paragraph', it sounds like it is
> supposed to work, or has been working some time before:
> ;; Filling inside a comment whose comment-end marker is not \n.
> ;; This code is meant to be generic, so that it works not only for
> ;; css-mode but for all modes.
> Could someone fill me in?
It is "work in progress", so it does work in some cases (e.g. if you
add a "*" line as in:
/*
*
* Multi-line comment here.
* This comment spans
* multiple
* lines.
* Better fill it!
*/
). The patch below seems to fix one half of the problem (tho it's
probably better to set adaptive-fill-function buffer-locally rather
than let-bind it, this was just a quick-hack). Tweaking the
paragraph-separate regexp (so as to recognize the "/*" line as
a paragraph separator) should let you fix the second.
Stefan
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 7280080..c09245d 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -377,7 +377,7 @@ pseudo-classes, and at-rules."
(setq-local comment-start-skip "/\\*+[ \t]*")
(setq-local comment-end "*/")
(setq-local comment-end-skip "[ \t]*\\*+/")
- (setq-local fill-paragraph-function 'css-fill-paragraph)
+ (setq-local fill-paragraph-function #'css-fill-paragraph)
(setq-local add-log-current-defun-function #'css-current-defun-name)
(smie-setup css-smie-grammar #'css-smie-rules
:forward-token #'css-smie--forward-token
@@ -418,7 +418,13 @@ pseudo-classes, and at-rules."
(string-match "[^ \t]" comment-continue))
(concat "\\(?:[ \t]*" (regexp-quote comment-continue)
"\\)?\\(?:" paragraph-start "\\)")
- paragraph-start)))
+ paragraph-start))
+ (adaptive-fill-function
+ (lambda ()
+ (when (looking-at "[ \t]*/\\*[ \t]*")
+ (let ((str (match-string 0)))
+ (and (string-match "/\\*" str)
+ (replace-match " *" t t str)))))))
(fill-paragraph justify)
;; Don't try filling again.
t)))
next prev parent reply other threads:[~2015-04-07 18:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-04 13:12 bug#20256: 25.0.50; css-mode: filling multi-line comments Simen Heggestøyl
2015-04-07 18:26 ` Stefan Monnier [this message]
2015-04-09 18:51 ` Simen Heggestøyl
2015-04-10 1:25 ` Stefan Monnier
2015-04-10 18:45 ` Simen Heggestøyl
2015-04-13 14:28 ` Stefan Monnier
2015-04-18 10:02 ` Simen Heggestøyl
2015-04-18 14:06 ` Stefan Monnier
2015-04-18 18:33 ` Simen Heggestøyl
2015-04-20 16:09 ` Stefan Monnier
2015-04-21 19:08 ` Simen Heggestøyl
2015-04-21 20:26 ` Stefan Monnier
2015-04-26 20:56 ` Simen Heggestøyl
2015-04-27 4:11 ` Stefan Monnier
2015-04-27 20:32 ` Simen Heggestøyl
2015-04-27 22:46 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvr3rvresl.fsf-monnier+emacsbugs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=20256@debbugs.gnu.org \
--cc=simenheg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).