From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#20256: 25.0.50; css-mode: filling multi-line comments Date: Sat, 18 Apr 2015 10:06:04 -0400 Message-ID: References: <1429351350.28233.1@smtp.gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1429366050 20578 80.91.229.3 (18 Apr 2015 14:07:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 18 Apr 2015 14:07:30 +0000 (UTC) Cc: 20256@debbugs.gnu.org To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 18 16:07:19 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 1YjTOw-0001um-Qb for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Apr 2015 16:07:19 +0200 Original-Received: from localhost ([::1]:45802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjTOw-0001Rt-4r for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Apr 2015 10:07:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjTOs-0001Ro-Qz for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2015 10:07:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YjTOp-0004ta-Ld for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2015 10:07:14 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42078) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjTOg-0004sc-TY for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2015 10:07:11 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YjTOg-0005Mg-JG for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2015 10:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Apr 2015 14:07: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.142936597020563 (code B ref 20256); Sat, 18 Apr 2015 14:07:02 +0000 Original-Received: (at 20256) by debbugs.gnu.org; 18 Apr 2015 14:06:10 +0000 Original-Received: from localhost ([127.0.0.1]:60087 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YjTNp-0005Lb-TB for submit@debbugs.gnu.org; Sat, 18 Apr 2015 10:06:10 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:35346) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YjTNm-0005LQ-NP for 20256@debbugs.gnu.org; Sat, 18 Apr 2015 10:06:07 -0400 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id t3IE64PL008946; Sat, 18 Apr 2015 10:06:04 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 6D2D42174; Sat, 18 Apr 2015 10:06:04 -0400 (EDT) In-Reply-To: <1429351350.28233.1@smtp.gmail.com> ("Simen =?UTF-8?Q?Heggest=C3=B8yl?="'s message of "Sat, 18 Apr 2015 12:02:30 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Level: X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0.2 X-NAI-Spam-Rules: 2 Rules triggered NOFROM_SGMAIL=0.2, RV5280=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5280> : inlines <2752> : streams <1424544> : uri <1909891> 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:101679 Archived-At: > Thanks again for the feedback, Stefan! An updated patch follows. Thank you. Looks good to me. Maybe we should even try to move this fill function to prog-mode.el. Stefan > 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