From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Newsgroups: gmane.emacs.bugs Subject: bug#20256: 25.0.50; css-mode: filling multi-line comments Date: Fri, 10 Apr 2015 20:45:50 +0200 Message-ID: <1428691550.2286.0@smtp.gmail.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=-oWsiO2CZl4fX8PnoNX73" X-Trace: ger.gmane.org 1428691672 22700 80.91.229.3 (10 Apr 2015 18:47:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 Apr 2015 18:47:52 +0000 (UTC) Cc: 20256@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 10 20:47:40 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YgdxQ-0004we-Du for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Apr 2015 20:47:12 +0200 Original-Received: from localhost ([::1]:40747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgdxP-000737-Nq for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Apr 2015 14:47:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgdxL-000731-Fv for bug-gnu-emacs@gnu.org; Fri, 10 Apr 2015 14:47:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YgdxG-0006Bm-Dv for bug-gnu-emacs@gnu.org; Fri, 10 Apr 2015 14:47:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34657) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgdxG-0006Bi-A9 for bug-gnu-emacs@gnu.org; Fri, 10 Apr 2015 14:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YgdxG-0008Ny-1v for bug-gnu-emacs@gnu.org; Fri, 10 Apr 2015 14:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Apr 2015 18:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20256 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20256-submit@debbugs.gnu.org id=B20256.142869156332153 (code B ref 20256); Fri, 10 Apr 2015 18:47:01 +0000 Original-Received: (at 20256) by debbugs.gnu.org; 10 Apr 2015 18:46:03 +0000 Original-Received: from localhost ([127.0.0.1]:52666 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YgdwI-0008MU-D8 for submit@debbugs.gnu.org; Fri, 10 Apr 2015 14:46:03 -0400 Original-Received: from mail-lb0-f177.google.com ([209.85.217.177]:36072) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YgdwG-0008Lv-2O for 20256@debbugs.gnu.org; Fri, 10 Apr 2015 14:46:00 -0400 Original-Received: by lbbqq2 with SMTP id qq2so20069519lbb.3 for <20256@debbugs.gnu.org>; Fri, 10 Apr 2015 11:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version:content-type; bh=vAhHYIcunvYviTEvTpxzDKEMwUPoxwbXyO2t8944Lqc=; b=dzVsa3Tq0KHYg/kG3M+GRodk+FJQAxNfIAqYrVaP+47kAnKDIKhVYpZ/XIlCpF8NWw QH0LFuUFCSMyP0N5dhkrCk6yamRHM9+Bm3wgEMj8kCDKmCpJaNTa3NSAWf41q06o+Dm3 nGKOnUC2iI2mJMvNyfVzybYYh/WdaLI6Lk4ESVlKq9loHrTejKrkXRgvdCawCzrXhzbX tyCdS3uc9vppoX+wrxrjGWCRpuNVInnLqNhlG7JDrARqE3UxhXcqoOoE+1KvH7gZ9rCa RKEIBc8DH4NC9DB1ggXL03yEZw1NnhUMp2bVr/3q7gmy3h6kv8XxSwLWQzXDCHhgfv5F nXcg== X-Received: by 10.112.162.232 with SMTP id yd8mr2570793lbb.41.1428691553974; Fri, 10 Apr 2015 11:45:53 -0700 (PDT) Original-Received: from [192.168.1.114] (cm-84.215.44.110.getinternet.no. [84.215.44.110]) by mx.google.com with ESMTPSA id pq1sm620099lbb.41.2015.04.10.11.45.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Apr 2015 11:45:52 -0700 (PDT) In-Reply-To: X-Mailer: geary/0.8.2 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:101395 Archived-At: --=-oWsiO2CZl4fX8PnoNX73 Content-Type: text/plain; charset=utf-8; format=flowed > As mentioned, I think this had better be a buffer-local setting, > rather > than a let-binding. After all, it would be good if it also works for > auto-fill-mode. Ah, thanks, I missed that. An updated patch follows. It defines `css-adaptive-fill' buffer-locally, which makes `auto-fill-mode' behave nice. `css-fill-paragraph' should now be general again. From 4e46637ceeab0a0a266cac035204f6db798fbd38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Thu, 9 Apr 2015 19:09:04 +0200 Subject: [PATCH] css-mode.el: Support multi-line comment filling Fixes: debbugs:20256 * lisp/textmodes/css-mode.el (css-fill-paragraph): Support multi-line comment filling. (css-adaptive-fill): New function. (css-mode): Set `adaptive-fill-function'. (scss-fill-paragraph): New function. (scss-mode): Set `fill-paragraph-function'. --- lisp/textmodes/css-mode.el | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index d1893a3..b4de1a5 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -381,7 +381,8 @@ 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 adaptive-fill-function #'css-adaptive-fill) (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 @@ -395,6 +396,12 @@ pseudo-classes, and at-rules." (defun css-fill-paragraph (&optional justify) (save-excursion + ;; Fill succeeding comment when invoked right before a multi-line + ;; comment. + (when (save-excursion + (back-to-indentation) + (looking-at (regexp-quote comment-start))) + (goto-char (match-end 0))) (let ((ppss (syntax-ppss)) (eol (line-end-position))) (cond @@ -414,7 +421,10 @@ pseudo-classes, and at-rules." (paragraph-separate (if (and comment-continue (string-match "[^ \t]" comment-continue)) - (concat "\\(?:[ \t]*" (regexp-quote comment-continue) + (concat "\\(?:[ \t]*" + (regexp-opt + (list comment-continue comment-start + comment-end)) "\\)?\\(?:" paragraph-separate "\\)") paragraph-separate)) (paragraph-start @@ -468,6 +478,12 @@ pseudo-classes, and at-rules." ;; Don't use the default filling code. t))))))) +(defun css-adaptive-fill () + (when (looking-at "[ \t]*/\\*[ \t]*") + (let ((str (match-string 0))) + (and (string-match "/\\*" str) + (replace-match " *" t t str))))) + (defun css-current-defun-name () "Return the name of the CSS section at point, or nil." (save-excursion @@ -506,7 +522,17 @@ pseudo-classes, and at-rules." (setq-local comment-end "") (setq-local comment-start-skip "/[*/]+[ \t]*") (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*+/\\)") + (setq-local fill-paragraph-function #'scss-fill-paragraph) (setq-local font-lock-defaults '(scss-font-lock-keywords nil t))) +(defun scss-fill-paragraph (&optional justify) + "Call `css-fill-paragraph', but ensure that the multi-line + variants of `comment-start' and `comment-end' are in use, in + order to support multi-line comment filling in SCSS mode as + well." + (let ((comment-start "/*") + (comment-end "*/")) + (css-fill-paragraph justify))) + (provide 'css-mode) ;;; css-mode.el ends here -- 2.1.4 --=-oWsiO2CZl4fX8PnoNX73 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
As mentioned, I think this had better be a buffer-local setting, r= ather than a let-binding. After all, it would be good if it also works for auto-fill-mode.

Ah, thanks, I missed that. = An updated patch follows. It defines
`css-adaptive-fill' buffer-l= ocally, which makes `auto-fill-mode'
behave nice. `css-fill-parag= raph' should now be general again.


= >From 4e46637ceeab0a0a266cac035204f6db798fbd38 Mon Sep 17 00:00:00 2001
From: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D <simenheg@gmai= l.com>
Date: Thu, 9 Apr 2015 19:09:04 +0200
Subject:= [PATCH] css-mode.el: Support multi-line comment filling

Fixes: debbugs:20256

* lisp/textmodes/css-m= ode.el (css-fill-paragraph): Support multi-line
comment filling.<= /div>
(css-adaptive-fill): New function.
(css-mode): Set `ada= ptive-fill-function'.
(scss-fill-paragraph): New function.
<= div>(scss-mode): Set `fill-paragraph-function'.
---
&nb= sp;lisp/textmodes/css-mode.el | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el<= /div>
index d1893a3..b4de1a5 100644
--- a/lisp/textmodes/css-= mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -381,7 +381= ,8 @@ pseudo-classes, and at-rules."
   (setq-local com= ment-start-skip "/\\*+[ \t]*")
   (setq-local comment-e= nd "*/")
   (setq-local comment-end-skip "[ \t]*\\*+/")=
-  (setq-local fill-paragraph-function 'css-fill-paragraph)=
+  (setq-local fill-paragraph-function #'css-fill-paragraph= )
+  (setq-local adaptive-fill-function #'css-adaptive-fill)=
   (setq-local add-log-current-defun-function #'css-cu= rrent-defun-name)
   (smie-setup css-smie-grammar #'css= -smie-rules
              &nbs= p;:forward-token #'css-smie--forward-token
@@ -395,6 +396,12 @@ p= seudo-classes, and at-rules."
 
 (defun css-f= ill-paragraph (&optional justify)
   (save-excursio= n
+    ;; Fill succeeding comment when invoked right be= fore a multi-line
+    ;; comment.
+   &= nbsp;(when (save-excursion
+           &= nbsp;(back-to-indentation)
+           &= nbsp;(looking-at (regexp-quote comment-start)))
+     &= nbsp;(goto-char (match-end 0)))
     (let ((ppss (= syntax-ppss))
           (eol (line= -end-position)))
       (cond
@@ -4= 14,7 +421,10 @@ pseudo-classes, and at-rules."
    &nbs= p;            (paragraph-separate
&= nbsp;                 (if (and comm= ent-continue
              &nb= sp;            (string-match "[^ \t]" comment= -continue))
-               &n= bsp;     (concat "\\(?:[ \t]*" (regexp-quote comment-continue)
+                   &n= bsp; (concat "\\(?:[ \t]*"
+           &= nbsp;                 (regexp-opt
+                   &= nbsp;          (list comment-continue comment-star= t
+                  = ;                  comment-end= ))
                 =             "\\)?\\(?:" paragraph-separate "= \\)")
                &nb= sp;   paragraph-separate))
         = ;        (paragraph-start
@@ -468,6 +478,12 @= @ pseudo-classes, and at-rules."
        &nbs= p;    ;; Don't use the default filling code.
  &nb= sp;          t)))))))
 
+= (defun css-adaptive-fill ()
+  (when (looking-at "[ \t]*/\\*= [ \t]*")
+    (let ((str (match-string 0)))
+=      (and (string-match "/\\*" str)
+   &nbs= p;       (replace-match " *" t t str)))))
+
<= div> (defun css-current-defun-name ()
   "Return t= he name of the CSS section at point, or nil."
   (save-= excursion
@@ -506,7 +522,17 @@ pseudo-classes, and at-rules."
   (setq-local comment-end "")
   (set= q-local comment-start-skip "/[*/]+[ \t]*")
   (setq-loc= al comment-end-skip "[ \t]*\\(?:\n\\|\\*+/\\)")
+  (setq-loc= al fill-paragraph-function #'scss-fill-paragraph)
   (s= etq-local font-lock-defaults '(scss-font-lock-keywords nil t)))
&= nbsp;
+(defun scss-fill-paragraph (&optional justify)
+  "Call `css-fill-paragraph', but ensure that the multi-line
=
+   variants of `comment-start' and `comment-end' are in use, in<= /div>
+   order to support multi-line comment filling in SCSS mode= as
+   well."
+  (let ((comment-start "/*")<= /div>
+        (comment-end "*/"))
+ &nbs= p;  (css-fill-paragraph justify)))
+
 (provid= e 'css-mode)
 ;;; css-mode.el ends here
-- 
2.1.4

= --=-oWsiO2CZl4fX8PnoNX73--