unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How make comment-region NOT ignore blank lines but comment out those too?
@ 2003-08-14 17:12 Christian Seberino
  2003-08-14 22:06 ` Jesper Harder
  0 siblings, 1 reply; 11+ messages in thread
From: Christian Seberino @ 2003-08-14 17:12 UTC (permalink / raw)


I thought I could make comment-region comment out blank lines with this:

(setq comment-empty-lines t  )

but it did not work.

Anyone else know how to make comment-region NOT ignore blank lines?

Chris

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How make comment-region NOT ignore blank lines but comment out those too?
  2003-08-14 17:12 How make comment-region NOT ignore blank lines but comment out those too? Christian Seberino
@ 2003-08-14 22:06 ` Jesper Harder
  2003-08-15 20:39   ` Christian Seberino
  0 siblings, 1 reply; 11+ messages in thread
From: Jesper Harder @ 2003-08-14 22:06 UTC (permalink / raw)


seberino@spawar.navy.mil (Christian Seberino) writes:

> I thought I could make comment-region comment out blank lines with
> this:
>
> (setq comment-empty-lines t  )
>
> but it did not work.

Which version of Emacs are you using?

The option `comment-empty-lines' only exists in the development
version of Emacs.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How make comment-region NOT ignore blank lines but comment out those too?
  2003-08-14 22:06 ` Jesper Harder
@ 2003-08-15 20:39   ` Christian Seberino
  2003-08-15 23:36     ` Jesper Harder
  0 siblings, 1 reply; 11+ messages in thread
From: Christian Seberino @ 2003-08-15 20:39 UTC (permalink / raw)


Jesper

Thanks.  Are you saying that before the new bleeding edge version of Emacs
people never were able to comment empty lines???

I have ver. 21.2 and 21.3 from Emacs CVS server about a month ago.

I thought I was on 21.3 but my path was pointing to 21.2.  Should it
work with 21.3?

Chris

Jesper Harder <harder@myrealbox.com> wrote in message news:<m365kz99nb.fsf@defun.localdomain>...
> seberino@spawar.navy.mil (Christian Seberino) writes:
> 
> > I thought I could make comment-region comment out blank lines with
> > this:
> >
> > (setq comment-empty-lines t  )
> >
> > but it did not work.
> 
> Which version of Emacs are you using?
> 
> The option `comment-empty-lines' only exists in the development
> version of Emacs.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How make comment-region NOT ignore blank lines but comment out those too?
  2003-08-15 20:39   ` Christian Seberino
@ 2003-08-15 23:36     ` Jesper Harder
  2003-08-26  0:04       ` Christian Seberino
  2003-08-26  0:37       ` Christian Seberino
  0 siblings, 2 replies; 11+ messages in thread
From: Jesper Harder @ 2003-08-15 23:36 UTC (permalink / raw)


seberino@spawar.navy.mil (Christian Seberino) writes:

> Jesper Harder <harder@myrealbox.com> wrote...
>
>> The option `comment-empty-lines' only exists in the development
>> version of Emacs.
>
> Thanks.  Are you saying that before the new bleeding edge version of Emacs
> people never were able to comment empty lines???

Yes, as far as I know.

> I have ver. 21.2 and 21.3 from Emacs CVS server about a month ago.

Setting `comment-empty-lines' to t works for me with a current version
from CVS.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How make comment-region NOT ignore blank lines but comment out those too?
  2003-08-15 23:36     ` Jesper Harder
@ 2003-08-26  0:04       ` Christian Seberino
  2003-08-26  0:37       ` Christian Seberino
  1 sibling, 0 replies; 11+ messages in thread
From: Christian Seberino @ 2003-08-26  0:04 UTC (permalink / raw)


Jesper

I very much want to get the CVS version of Emacs to try
setting comment-empty-lines there....

I went to Savannah site for Emacs and couldn't find docs
on how to check out current CVS copy.

How did you do this or find docs on how to do this?

Chris

Jesper Harder <harder@myrealbox.com> wrote in message news:<m33cg24ho9.fsf@defun.localdomain>...
> seberino@spawar.navy.mil (Christian Seberino) writes:
> 
> > Jesper Harder <harder@myrealbox.com> wrote...
> >
> >> The option `comment-empty-lines' only exists in the development
> >> version of Emacs.
> >
> > Thanks.  Are you saying that before the new bleeding edge version of Emacs
> > people never were able to comment empty lines???
> 
> Yes, as far as I know.
> 
> > I have ver. 21.2 and 21.3 from Emacs CVS server about a month ago.
> 
> Setting `comment-empty-lines' to t works for me with a current version
> from CVS.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How make comment-region NOT ignore blank lines but comment out those too?
  2003-08-15 23:36     ` Jesper Harder
  2003-08-26  0:04       ` Christian Seberino
@ 2003-08-26  0:37       ` Christian Seberino
  2003-08-26 14:04         ` Jesper Harder
  1 sibling, 1 reply; 11+ messages in thread
From: Christian Seberino @ 2003-08-26  0:37 UTC (permalink / raw)


Jesper

I figured out how to get Emacs from CVS but when I do M-x help
and type in comment-empty-lines it says there is no such thing?!?!?!

Are you using Xemacs or am I doing something else wrong?

Chris


Jesper Harder <harder@myrealbox.com> wrote in message news:<m33cg24ho9.fsf@defun.localdomain>...
> seberino@spawar.navy.mil (Christian Seberino) writes:
> 
> > Jesper Harder <harder@myrealbox.com> wrote...
> >
> >> The option `comment-empty-lines' only exists in the development
> >> version of Emacs.
> >
> > Thanks.  Are you saying that before the new bleeding edge version of Emacs
> > people never were able to comment empty lines???
> 
> Yes, as far as I know.
> 
> > I have ver. 21.2 and 21.3 from Emacs CVS server about a month ago.
> 
> Setting `comment-empty-lines' to t works for me with a current version
> from CVS.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How make comment-region NOT ignore blank lines but comment out those too?
  2003-08-26  0:37       ` Christian Seberino
@ 2003-08-26 14:04         ` Jesper Harder
  2003-08-27 21:57           ` Christian Seberino
  0 siblings, 1 reply; 11+ messages in thread
From: Jesper Harder @ 2003-08-26 14:04 UTC (permalink / raw)


seberino@spawar.navy.mil (Christian Seberino) writes:

> I figured out how to get Emacs from CVS but when I do M-x help and
> type in comment-empty-lines it says there is no such thing?!?!?!

It's only defined after the comment code is loaded, e.g. after the
first time you do `M-;'.  Just put 

      (setq comment-empty-lines t)

in you ~/.emacs and it should work fine.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How make comment-region NOT ignore blank lines but comment out those too?
  2003-08-26 14:04         ` Jesper Harder
@ 2003-08-27 21:57           ` Christian Seberino
  2003-08-28  1:38             ` Jesper Harder
  0 siblings, 1 reply; 11+ messages in thread
From: Christian Seberino @ 2003-08-27 21:57 UTC (permalink / raw)


Jesper

You were right! It worked!!! Now Emacs (CVS version) comments out empty lines!
It's great! Thanks for all the help.

Can I ask you one more question about this?....

I noticed that the empty lines when they get commented have whitespace
after the comment character.....

e.g. a blank line ---> "#  \n"
instead of                 "#\n"

Is it too much to ask to try to make comment-region change blanks to "#\n" instead
of "#  \n"????

Chris



Jesper Harder <harder@myrealbox.com> wrote in message news:<m37k50ms5y.fsf@defun.localdomain>...
> seberino@spawar.navy.mil (Christian Seberino) writes:
> 
> > I figured out how to get Emacs from CVS but when I do M-x help and
> > type in comment-empty-lines it says there is no such thing?!?!?!
> 
> It's only defined after the comment code is loaded, e.g. after the
> first time you do `M-;'.  Just put 
> 
>       (setq comment-empty-lines t)
> 
> in you ~/.emacs and it should work fine.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How make comment-region NOT ignore blank lines but comment out those too?
  2003-08-27 21:57           ` Christian Seberino
@ 2003-08-28  1:38             ` Jesper Harder
  2003-08-28  7:37               ` Christian Seberino
  0 siblings, 1 reply; 11+ messages in thread
From: Jesper Harder @ 2003-08-28  1:38 UTC (permalink / raw)


seberino@spawar.navy.mil (Christian Seberino) writes:

> I noticed that the empty lines when they get commented have whitespace
> after the comment character.....
>
> e.g. a blank line ---> "#  \n"
> instead of                 "#\n"
>
> Is it too much to ask to try to make comment-region change blanks to
> "#\n" instead of "# \n"????

I don't think that's currently possible (you could send a bug report
and suggest it).

You can get rid of the padding after the comment character with (setq
comment-padding nil), but that also removes it from non-empty lines.

There might be one small advantage with padding of empty lines -- if
you later decide to write something on it, then the text will already
be aligned.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How make comment-region NOT ignore blank lines but comment out those too?
  2003-08-28  1:38             ` Jesper Harder
@ 2003-08-28  7:37               ` Christian Seberino
  2003-08-28 16:49                 ` Kevin Rodgers
  0 siblings, 1 reply; 11+ messages in thread
From: Christian Seberino @ 2003-08-28  7:37 UTC (permalink / raw)


Thanks.

Is it possible to do a search and replace automatically as a "hook" to
comment-region????

The file will have this problem as "\n#  \n".
I just have to replace that with "\n#\n".

I believe this is called a regular expression??

Can they be run every time we do a comment-region?

Chris


Jesper Harder <harder@myrealbox.com> wrote in message news:<m3n0dud0ia.fsf@defun.localdomain>...
> seberino@spawar.navy.mil (Christian Seberino) writes:
> 
> > I noticed that the empty lines when they get commented have whitespace
> > after the comment character.....
> >
> > e.g. a blank line ---> "#  \n"
> > instead of                 "#\n"
> >
> > Is it too much to ask to try to make comment-region change blanks to
> > "#\n" instead of "# \n"????
> 
> I don't think that's currently possible (you could send a bug report
> and suggest it).
> 
> You can get rid of the padding after the comment character with (setq
> comment-padding nil), but that also removes it from non-empty lines.
> 
> There might be one small advantage with padding of empty lines -- if
> you later decide to write something on it, then the text will already
> be aligned.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How make comment-region NOT ignore blank lines but comment out those too?
  2003-08-28  7:37               ` Christian Seberino
@ 2003-08-28 16:49                 ` Kevin Rodgers
  0 siblings, 0 replies; 11+ messages in thread
From: Kevin Rodgers @ 2003-08-28 16:49 UTC (permalink / raw)


Christian Seberino wrote:

> Thanks.
> 
> Is it possible to do a search and replace automatically as a "hook" to
> comment-region????
> 
> The file will have this problem as "\n#  \n".
> I just have to replace that with "\n#\n".
> 
> I believe this is called a regular expression??
> 
> Can they be run every time we do a comment-region?

You can always try (this is completely untested):

(defadvice comment-region (after unpad-blank-line-comments)
   "If blank lines are commented, delete `comment-padding' on those lines."
   (if (and (null (ad-get-arg 2))	; (null ARG), (null current-prefix-arg)
	   comment-empty-lines)
       ;; We are commenting, not uncommenting.
       (let ((empty-comment-regexp (format "^[ \t]*\\(%s\\)\\(%s\\)$"
					  comment-start
					  comment-padding)))
	(save-restriction
	  (narrow-to-region (ad-get-arg 0) (ad-get-arg 1)) ; (... BEG END)
	  (goto-char (point-min))
	  (while (re-search-forward empty-comment-regexp nil t)
	    (replace-match "" nil nil nil 2))))))

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-08-28 16:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-14 17:12 How make comment-region NOT ignore blank lines but comment out those too? Christian Seberino
2003-08-14 22:06 ` Jesper Harder
2003-08-15 20:39   ` Christian Seberino
2003-08-15 23:36     ` Jesper Harder
2003-08-26  0:04       ` Christian Seberino
2003-08-26  0:37       ` Christian Seberino
2003-08-26 14:04         ` Jesper Harder
2003-08-27 21:57           ` Christian Seberino
2003-08-28  1:38             ` Jesper Harder
2003-08-28  7:37               ` Christian Seberino
2003-08-28 16:49                 ` Kevin Rodgers

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).