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: Sat, 18 Apr 2015 12:02:30 +0200 Message-ID: <1429351350.28233.1@smtp.gmail.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=-GCOEcwW/74J6jh3JWE2X" X-Trace: ger.gmane.org 1429351405 3589 80.91.229.3 (18 Apr 2015 10:03:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 18 Apr 2015 10:03:25 +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 Sat Apr 18 12:03:14 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 1YjPaj-0000DI-Ji for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Apr 2015 12:03:13 +0200 Original-Received: from localhost ([::1]:45099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjPai-0004sM-ES for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Apr 2015 06:03:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjPad-0004sE-PE for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2015 06:03:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YjPaY-00038N-MX for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2015 06:03:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41586) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjPaY-00038I-Ie for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2015 06:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YjPaY-0005Jx-2p for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2015 06:03: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: Sat, 18 Apr 2015 10:03:02 +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.142935136320426 (code B ref 20256); Sat, 18 Apr 2015 10:03:02 +0000 Original-Received: (at 20256) by debbugs.gnu.org; 18 Apr 2015 10:02:43 +0000 Original-Received: from localhost ([127.0.0.1]:59595 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YjPaE-0005JM-IK for submit@debbugs.gnu.org; Sat, 18 Apr 2015 06:02:43 -0400 Original-Received: from mail-la0-f50.google.com ([209.85.215.50]:35637) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YjPaB-0005J7-MZ for 20256@debbugs.gnu.org; Sat, 18 Apr 2015 06:02:40 -0400 Original-Received: by labbd9 with SMTP id bd9so96496955lab.2 for <20256@debbugs.gnu.org>; Sat, 18 Apr 2015 03:02:33 -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=TiEtNz/oqGw7eT/6+Z3BCkusNXEWdkZfiEq/mj8j1QU=; b=I2D7Kr4WeK+oAQRIOaVh9R1NjGfk7EBY8lHb6qsluHFrEC13ZLJnk4eekokjPQut8q ouAoN1qMdH3qFn+9f2ZdMBgljNUkkONl3YjnYHMLmO7jfewXNd3KzwIJh34cdPp1hUkc +5wCTbvw8OpSFQN4X+rwaQT834ywQIA/EagDbcesJpeXXBkYPEpBCEwMXedbZsz0tLJq v2yCWGIEFgr2j+hoXWbb9CWpf8sWoK8lRSLITR02kQc4UT+0jM84DY1BcFz9CO7cAkUX JCb96hIoMbiXSrOiElj6ofgZM+gdinS6EwtNNIAlPGtdeoEMyBxpfE7kGaq7iVOl1ucz rfzQ== X-Received: by 10.152.203.162 with SMTP id kr2mr7866251lac.68.1429351353827; Sat, 18 Apr 2015 03:02:33 -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 ej5sm2957125lad.5.2015.04.18.03.02.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Apr 2015 03:02:33 -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:101678 Archived-At: --=-GCOEcwW/74J6jh3JWE2X Content-Type: text/plain; charset=utf-8; format=flowed Thanks again for the feedback, Stefan! An updated patch follows. -- Simen From 839810c2fc79d64634be2d27148df9f0759e1c8b 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-mode): Set `comment-continue'. --- lisp/textmodes/css-mode.el | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index d1893a3..424cdb7 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 + (beginning-of-line) + (comment-search-forward (point-at-eol) t)) + (goto-char (match-end 0))) (let ((ppss (syntax-ppss)) (eol (line-end-position))) (cond @@ -414,8 +421,11 @@ pseudo-classes, and at-rules." (paragraph-separate (if (and comment-continue (string-match "[^ \t]" comment-continue)) - (concat "\\(?:[ \t]*" (regexp-quote comment-continue) - "\\)?\\(?:" paragraph-separate "\\)") + (concat "\\(?:[ \t]*\\(?:" + (regexp-quote comment-continue) "\\|" + comment-start-skip "\\|" + comment-end-skip "\\)\\)?" + "\\(?:" paragraph-separate "\\)") paragraph-separate)) (paragraph-start (if (and comment-continue @@ -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 @@ -504,6 +520,7 @@ pseudo-classes, and at-rules." "Major mode to edit \"Sassy CSS\" files." (setq-local comment-start "// ") (setq-local comment-end "") + (setq-local comment-continue " *") (setq-local comment-start-skip "/[*/]+[ \t]*") (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*+/\\)") (setq-local font-lock-defaults '(scss-font-lock-keywords nil t))) -- 2.1.4 --=-GCOEcwW/74J6jh3JWE2X Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Thanks again for the feedback, Stefan! An updated patch follows.
=

-- Simen


From 8= 39810c2fc79d64634be2d27148df9f0759e1c8b Mon Sep 17 00:00:00 2001
= From: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D <simenheg@gmail.com&= gt;
Date: Thu, 9 Apr 2015 19:09:04 +0200
Subject: [PATC= H] css-mode.el: Support multi-line comment filling

Fixes: debbugs:20256

* lisp/textmodes/css-mode.el= (css-fill-paragraph): Support multi-line
comment filling.
<= div>(css-adaptive-fill): New function.
(css-mode): Set `adaptive-= fill-function'.
(scss-mode): Set `comment-continue'.
--= -
 lisp/textmodes/css-mode.el | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
<= br>
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-= mode.el
index d1893a3..424cdb7 100644
--- a/lisp/textmo= des/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -38= 1,7 +381,8 @@ pseudo-classes, and at-rules."
   (setq-l= ocal comment-start-skip "/\\*+[ \t]*")
   (setq-local c= omment-end "*/")
   (setq-local comment-end-skip "[ \t]= *\\*+/")
-  (setq-local fill-paragraph-function 'css-fill-pa= ragraph)
+  (setq-local fill-paragraph-function #'css-fill-p= aragraph)
+  (setq-local adaptive-fill-function #'css-adapti= ve-fill)
   (setq-local add-log-current-defun-function = #'css-current-defun-name)
   (smie-setup css-smie-gramm= ar #'css-smie-rules
            &nb= sp;  :forward-token #'css-smie--forward-token
@@ -395,6 +396= ,12 @@ pseudo-classes, and at-rules."
 
 (def= un css-fill-paragraph (&optional justify)
   (save-= excursion
+    ;; Fill succeeding comment when invoked = right before a multi-line
+    ;; comment.
+ =    (when (save-excursion
+         =    (beginning-of-line)
+         &n= bsp;  (comment-search-forward (point-at-eol) t))
+   &n= bsp;  (goto-char (match-end 0)))
     (let ((= ppss (syntax-ppss))
           (eol= (line-end-position)))
       (cond
@@ -414,8 +421,11 @@ pseudo-classes, and at-rules."
   = ;              (paragraph-separate
=
                  (if (an= d comment-continue
            &nbs= p;              (string-match "[^ \t]" c= omment-continue))
-             &nb= sp;       (concat "\\(?:[ \t]*" (regexp-quote comment-contin= ue)
-                 &nb= sp;           "\\)?\\(?:" paragraph-separate "\\)"= )
+                  = ;   (concat "\\(?:[ \t]*\\(?:"
+        =                     (reg= exp-quote comment-continue) "\\|"
+         &= nbsp;                   commen= t-start-skip "\\|"
+             &n= bsp;               comment-end-skip "\\)= \\)?"
+                 &= nbsp;           "\\(?:" paragraph-separate "\\)")<= /div>
                  &n= bsp; paragraph-separate))
          &nbs= p;      (paragraph-start
      &nbs= p;           (if (and comment-continue
@= @ -468,6 +478,12 @@ pseudo-classes, and at-rules."
    =          ;; Don't use the default filling code.
             t)))))))
=  
+(defun css-adaptive-fill ()
+  (when (look= ing-at "[ \t]*/\\*[ \t]*")
+    (let ((str (match-strin= g 0)))
+      (and (string-match "/\\*" str)
=
+           (replace-match " *" t t str)))))<= /div>
+
 (defun css-current-defun-name ()
&nbs= p;  "Return the name of the CSS section at point, or nil."
&= nbsp;  (save-excursion
@@ -504,6 +520,7 @@ pseudo-classes, a= nd at-rules."
   "Major mode to edit \"Sassy CSS\" file= s."
   (setq-local comment-start "// ")
 = ;  (setq-local comment-end "")
+  (setq-local comment-c= ontinue " *")
   (setq-local comment-start-skip "/[*/]+= [ \t]*")
   (setq-local comment-end-skip "[ \t]*\\(?:\n= \\|\\*+/\\)")
   (setq-local font-lock-defaults '(scss-= font-lock-keywords nil t)))
-- 
2.1.4
= --=-GCOEcwW/74J6jh3JWE2X--