From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: Multiple bugs in lisp-mode M-q on paragraphs within #|..|# comments Date: Sun, 25 Mar 2007 12:18:17 +0200 Message-ID: <46064C69.1010807@gmx.at> References: <17925.31957.782297.513252@rgrjr.dyndns.org> <87lkhmflwk.fsf@stupidchicken.com> <17925.37199.346999.399423@rgrjr.dyndns.org> <4605A120.6030400@gmx.at> <17925.49428.760951.346087@rgrjr.dyndns.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070902050302060206040603" X-Trace: sea.gmane.org 1174818197 2605 80.91.229.12 (25 Mar 2007 10:23:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 25 Mar 2007 10:23:17 +0000 (UTC) Cc: emacs-devel To: Bob Rogers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 25 12:23:10 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HVPsT-0006qU-Ou for ged-emacs-devel@m.gmane.org; Sun, 25 Mar 2007 12:23:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVPua-0005DV-KF for ged-emacs-devel@m.gmane.org; Sun, 25 Mar 2007 05:25:20 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HVPuX-0005Ay-T2 for emacs-devel@gnu.org; Sun, 25 Mar 2007 06:25:17 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HVPuW-00058K-Q5 for emacs-devel@gnu.org; Sun, 25 Mar 2007 06:25:17 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVPuW-00058D-NZ for emacs-devel@gnu.org; Sun, 25 Mar 2007 05:25:16 -0500 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1HVPsO-0003C5-KA for emacs-devel@gnu.org; Sun, 25 Mar 2007 06:23:05 -0400 Original-Received: (qmail invoked by alias); 25 Mar 2007 10:23:02 -0000 Original-Received: from N742P022.adsl.highway.telekom.at (EHLO [62.47.36.182]) [62.47.36.182] by mail.gmx.net (mp044) with SMTP; 25 Mar 2007 12:23:02 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/VgCd/nV/VpLnLdr7bLjjp79OgwUuHVm7MFqbsAP hvij4GOrjSEWb/ User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en In-Reply-To: <17925.49428.760951.346087@rgrjr.dyndns.org> X-Y-GMX-Trusted: 0 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:68524 Archived-At: This is a multi-part message in MIME format. --------------070902050302060206040603 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > Then the problem is with the following stretch of code in > `fill-paragraph': > > (and fill-paragraph-handle-comment > ;; Our code only handles \n-terminated comments right now. > comment-start (equal comment-end "") > (let ((fill-paragraph-handle-comment nil)) > (fill-comment-paragraph arg))) > > We have to find something more intelligent here. > > Is this really the place? If I add a call to error just before the > fill-comment-paragraph call, none of the four bugs cause it to be > called. Correct. But what I wanted to express was that `fill-comment-paragraph' will get it wrong for a block comment. The following part is used to find the end of the region to fill by searching for `comment-re' at the begin of every line which fails for block comments. ;; Find the beginning of the first line past the region to fill. (save-excursion (while (progn (forward-line 1) (looking-at comment-re))) > It might be better to recognize Lisp "#|...|#" comments explicitly at > a point where we know we're dealing with Lisp. The attached patch is a > total hack, but it seems to relieve the symptoms of the first three bugs > (and changes that of the fourth). This style of comment can be nested, > so the hack will get confused if still inside a comment but after an > inner comment. The changed symptoms of the fourth bug suggest that the > bounds passed to the fill-region-as-paragraph call are wrong. But I'll > bet someone else can do better. I'm afraid this problem is not restricted to the Lisp case. I think we should modify `fill-comment-paragraph' to (1) check whether the current major mode allows comments that are not terminated by a newline, (2) if (1) applies parse whether we are in such a comment or a nested comment, and (3) call `fill-comment-paragraph' iff (2) doesn't apply. Anyway please try the attached patch. I'm confident Stefan will find a better solution soon. --------------070902050302060206040603 Content-Type: text/plain; name="lisp-mode.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="lisp-mode.patch" *** lisp-mode.el Fri Mar 9 06:48:38 2007 --- lisp-mode.el Sun Mar 25 12:12:38 2007 *************** *** 1246,1252 **** paragraph of it that point is in, preserving the comment's indentation and initial semicolons." (interactive "P") ! (or (fill-comment-paragraph justify) ;; Since fill-comment-paragraph returned nil, that means we're not in ;; a comment: Point is on a program line; we are interested ;; particularly in docstring lines. --- 1246,1258 ---- paragraph of it that point is in, preserving the comment's indentation and initial semicolons." (interactive "P") ! (or (and (equal major-mode 'lisp-mode) ! (let ((state (syntax-ppss (point)))) ! (and (nth 4 state) (eq (nth 7 state) t))) ! (let ((comment-end "|#")) ! (fill-paragraph justify) ! t)) ! (fill-comment-paragraph justify) ;; Since fill-comment-paragraph returned nil, that means we're not in ;; a comment: Point is on a program line; we are interested ;; particularly in docstring lines. --------------070902050302060206040603 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --------------070902050302060206040603--