unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Teemu Likonen <tlikonen@iki.fi>, 1756@emacsbugs.donarmstrong.com
Cc: bug-cc-mode@gnu.org, bug-gnu-emacs@gnu.org
Subject: Re: bug#1756: awk-mode: An empty line is not a paragraph separator (should be)
Date: Mon, 5 Jan 2009 16:12:09 +0000	[thread overview]
Message-ID: <20090105161209.GB2501@muc.de> (raw)
In-Reply-To: <87sko35t3u.fsf@iki.fi>

Hi, Teemu!

On Thu, Jan 01, 2009 at 10:27:17AM +0200, Teemu Likonen wrote:
> In awk-mode an empty line is not considered a paragraph separator, only
> lines containing whitespace and "#" character(s) are. After running the
> command "M-x awk-mode" the value of both paragraph-start and
> paragraph-separate are set as follows:

>     "[ \t]*\\(#+\\)[ \t]*$\\|^\f"
>               ^^

> See, at least one # is required. I think better default would be #* so
> that empty lines or lines with only whitespace would be paragraph
> separators too.

Agreed.  Thanks for the report.

> I suggest doing the following change: 
> [ Tweaking the definition of c-comment-prefix-regexp. ]

I'd rather not do it this way, because although c-comment-prefix-regexp
isn't currently used anywhere else, it might be in the future.  A blank
line cannot be a comment prefix in AWK.

> (pike-mode and "other" have a comment prefix regexp which matches a zero
> number of comment prefix characters: \**)

Can you please try the following patch (it might be a few lines offset
from the given line numbers).  It checks whether the comment prefix
matches a blank line, and fixes paragraph-s{tart,eparate} if it doesn't.

#########################################################################

*** orig/cc-styles.el	2009-01-05 11:49:10.753657960 +0000
--- cc-styles.el	2009-01-05 15:29:34.569332408 +0000
***************
*** 512,525 ****
  			  (assoc 'other c-comment-prefix-regexp)))
  	  c-comment-prefix-regexp))
  
!   (let ((comment-line-prefix
! 	 (concat "[ \t]*\\(" c-current-comment-prefix "\\)[ \t]*")))
  
!     (setq paragraph-start (concat comment-line-prefix
  				  c-paragraph-start
  				  "\\|"
  				  page-delimiter)
! 	  paragraph-separate (concat comment-line-prefix
  				     c-paragraph-separate
  				     "\\|"
  				     page-delimiter)
--- 512,532 ----
  			  (assoc 'other c-comment-prefix-regexp)))
  	  c-comment-prefix-regexp))
  
!   (let* ((empty-is-prefix (string-match c-current-comment-prefix ""))
! 	 (nonws-comment-line-prefix
! 	  (concat "\\(" c-current-comment-prefix "\\)[ \t]*"))
! 	 (comment-line-prefix (concat "[ \t]*" nonws-comment-line-prefix))
! 	 (blank-or-comment-line-prefix
! 	  (concat "[ \t]*"
! 		  (if empty-is-prefix "" "\\(")
! 		  nonws-comment-line-prefix
! 		  (if empty-is-prefix "" "\\)?"))))
  
!     (setq paragraph-start (concat blank-or-comment-line-prefix
  				  c-paragraph-start
  				  "\\|"
  				  page-delimiter)
! 	  paragraph-separate (concat blank-or-comment-line-prefix
  				     c-paragraph-separate
  				     "\\|"
  				     page-delimiter)

#########################################################################

> There is another and related bug. It is possible to configure the
> comment prefix regexp with the option c-comment-prefix-regexp. But the
> problem is that the option only takes effect when awk-mode is turned on.
> If user later changes indentation style with the command c-set-style
> (bound to C-c .) then it seems that the hard-coded default (#+) takes
> preference over user's c-comment-prefix-regexp settings.

I'll get back to you on this one.

Thanks again for the bug report.

-- 
Alan Mackenzie (Nuremberg, Germany).

------------------------------------------------------------------------------


  reply	other threads:[~2009-01-05 16:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-01  8:27 bug#1756: awk-mode: An empty line is not a paragraph separator (should be) Teemu Likonen
2009-01-05 16:12 ` Alan Mackenzie [this message]
2009-01-05 17:53   ` Teemu Likonen
2009-01-05 18:35 ` Alan Mackenzie
2009-01-05 18:38   ` Teemu Likonen
2009-01-06 16:15     ` Alan Mackenzie
2009-01-07 16:32       ` Teemu Likonen
2009-01-08 16:25         ` Alan Mackenzie

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=20090105161209.GB2501@muc.de \
    --to=acm@muc.de \
    --cc=1756@emacsbugs.donarmstrong.com \
    --cc=bug-cc-mode@gnu.org \
    --cc=bug-gnu-emacs@gnu.org \
    --cc=tlikonen@iki.fi \
    /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).