unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* bug in comment-region
@ 2004-06-09 13:36 Werner LEMBERG
  2004-06-09 14:01 ` Karl Chen
  0 siblings, 1 reply; 9+ messages in thread
From: Werner LEMBERG @ 2004-06-09 13:36 UTC (permalink / raw)



[CVS 2004-05-30]

Assume this:

  foo

  bar

After calling comment-region I get this:

  ;; foo

  ;; bar

(the actual comment prefix doesn't matter).

The doc string of comment-region says this:

  Comment or uncomment each line in the region.
                       ^^^^^^^^^
This is not how command-region currently works.  I really would like
to have this:

  ;; foo
  ;;
  ;; bar

In case the current behaviour is intentional, please change the
prefix arg to make the function work on all lines.

Or even better, make comment-region work as advertised:

  . A normal call comments all lines of a region.

  . A call prefixed with C-u comments only non-empty lines.  I
    strongly suggest to abandon the current behaviour of the C-u
    prefix (i.e., uncommenting a region), given that we have a
    separate `uncomment-region' function.


      Werner

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

* Re: bug in comment-region
  2004-06-09 13:36 bug in comment-region Werner LEMBERG
@ 2004-06-09 14:01 ` Karl Chen
  2004-06-09 14:08   ` Werner LEMBERG
  0 siblings, 1 reply; 9+ messages in thread
From: Karl Chen @ 2004-06-09 14:01 UTC (permalink / raw)



>>>>> "Werner" == Werner LEMBERG <wl@gnu.org> writes:
    Werner> This is not how command-region currently works.  I
    Werner> really would like to have this:
    Werner> 
    Werner>   ;; foo
    Werner>   ;;
    Werner>   ;; bar

Try:
    (setq comment-empty-lines t)

(`comment-empty-lines' should be documented and referenced in
`comment-region' et al)

-- 
Karl 2004-06-09 06:59

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

* Re: bug in comment-region
  2004-06-09 14:01 ` Karl Chen
@ 2004-06-09 14:08   ` Werner LEMBERG
  2004-06-09 14:14     ` David Kastrup
  2004-06-09 21:09     ` Miles Bader
  0 siblings, 2 replies; 9+ messages in thread
From: Werner LEMBERG @ 2004-06-09 14:08 UTC (permalink / raw)
  Cc: emacs-devel

> Try:
>     (setq comment-empty-lines t)

Thanks.  Anyway, my suggestion w.r.t. C-u still holds -- IMHO it is
quite inconvenient to control the behaviour of such a versatile
function with a global variable.  For example, I might prefer to
comment empty lines in C mode but not in TeX mode.


    Werner

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

* Re: bug in comment-region
  2004-06-09 14:08   ` Werner LEMBERG
@ 2004-06-09 14:14     ` David Kastrup
  2004-06-09 14:42       ` Werner LEMBERG
  2004-06-09 21:09     ` Miles Bader
  1 sibling, 1 reply; 9+ messages in thread
From: David Kastrup @ 2004-06-09 14:14 UTC (permalink / raw)
  Cc: quarl+dated+1087221580.02c4f1, quarl, emacs-devel

Werner LEMBERG <wl@gnu.org> writes:

> > Try:
> >     (setq comment-empty-lines t)
> 
> Thanks.  Anyway, my suggestion w.r.t. C-u still holds -- IMHO it is
> quite inconvenient to control the behaviour of such a versatile
> function with a global variable.  For example, I might prefer to
> comment empty lines in C mode but not in TeX mode.

(add-hook 'c-mode-hook (lambda ()
        (set (make-local-variable 'comment-empty-lines) t)))

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: bug in comment-region
  2004-06-09 14:14     ` David Kastrup
@ 2004-06-09 14:42       ` Werner LEMBERG
  0 siblings, 0 replies; 9+ messages in thread
From: Werner LEMBERG @ 2004-06-09 14:42 UTC (permalink / raw)
  Cc: quarl+dated+1087221580.02c4f1, quarl, emacs-devel


> (add-hook 'c-mode-hook (lambda ()
>         (set (make-local-variable 'comment-empty-lines) t)))

Thanks.  I still think that comment-region's behaviour can be
improved...


    Werner

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

* Re: bug in comment-region
  2004-06-09 14:08   ` Werner LEMBERG
  2004-06-09 14:14     ` David Kastrup
@ 2004-06-09 21:09     ` Miles Bader
  2004-06-09 23:06       ` Werner LEMBERG
  1 sibling, 1 reply; 9+ messages in thread
From: Miles Bader @ 2004-06-09 21:09 UTC (permalink / raw)
  Cc: quarl+dated+1087221580.02c4f1, quarl, emacs-devel

On Wed, Jun 09, 2004 at 04:08:02PM +0200, Werner LEMBERG wrote:
> Thanks.  Anyway, my suggestion w.r.t. C-u still holds -- IMHO it is
> quite inconvenient to control the behaviour of such a versatile
> function with a global variable.

`comment-region' and `comment-dwim' already have a (much more useful) meaning
for C-u (in fact, comment-region has several).

-Miles
-- 
We have met the enemy, and he is us.  -- Pogo

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

* Re: bug in comment-region
  2004-06-09 21:09     ` Miles Bader
@ 2004-06-09 23:06       ` Werner LEMBERG
  2004-06-10  1:36         ` Miles Bader
  2004-06-10  9:11         ` Karl Chen
  0 siblings, 2 replies; 9+ messages in thread
From: Werner LEMBERG @ 2004-06-09 23:06 UTC (permalink / raw)
  Cc: quarl+dated+1087221580.02c4f1, quarl, emacs-devel

> > Thanks.  Anyway, my suggestion w.r.t. C-u still holds -- IMHO it
> > is quite inconvenient to control the behaviour of such a versatile
> > function with a global variable.
> 
> `comment-region' and `comment-dwim' already have a (much more
> useful) meaning for C-u (in fact, comment-region has several).

I haven't yet used comment-dwim, so I won't say something about this
function.  But IMHO it is a strange idea to have `C-u something' do
exactly the opposite of `something'.  Until now I've considered the
C-u prefix as a means to get an extended or slightly modified
functionality of a function.

Are there other commands which do the opposite if prefixed with C-u?

And I don't agree with your conclusion that the several meanings of
C-u for `comment-region' are `much more useful'.  For me, they are
useful for `uncomment-region' only.


    Werner

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

* Re: bug in comment-region
  2004-06-09 23:06       ` Werner LEMBERG
@ 2004-06-10  1:36         ` Miles Bader
  2004-06-10  9:11         ` Karl Chen
  1 sibling, 0 replies; 9+ messages in thread
From: Miles Bader @ 2004-06-10  1:36 UTC (permalink / raw)
  Cc: quarl+dated+1087221580.02c4f1, quarl, emacs-devel

Werner LEMBERG <wl@gnu.org> writes:
> I haven't yet used comment-dwim, so I won't say something about this
> function.  But IMHO it is a strange idea to have `C-u something' do
> exactly the opposite of `something'.

Not at all.  Indeed, it's stunningly natural.

> And I don't agree with your conclusion that the several meanings of
> C-u for `comment-region' are `much more useful'.  For me, they are
> useful for `uncomment-region' only.

Clearly a matter of opinion; I've made mine clear (I really like the
way the comment-foo functions work currently).

-Miles
-- 
自らを空にして、心を開く時、道は開かれる

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

* Re: bug in comment-region
  2004-06-09 23:06       ` Werner LEMBERG
  2004-06-10  1:36         ` Miles Bader
@ 2004-06-10  9:11         ` Karl Chen
  1 sibling, 0 replies; 9+ messages in thread
From: Karl Chen @ 2004-06-10  9:11 UTC (permalink / raw)
  Cc: emacs-devel, miles



I use C-u comment-region / comment-dwim all the time.  Perhaps
that functionality could be moved to M-- (negative-argument)
instead of C-u though.

(BTW: I actually use my own function `comment-line-or-region'
which is much more useful when transient-mark-mode is on)

>>> "Werner" == Werner LEMBERG <wl@gnu.org> writes:
    Werner> 
    >> Thanks.  Anyway, my suggestion w.r.t. C-u still holds --
    >> IMHO it is quite inconvenient to control the behaviour of
    >> such a versatile function with a global variable.
    >> 
    >> `comment-region' and `comment-dwim' already have a (much
    >> more useful) meaning for C-u (in fact, comment-region has
    >> several).
    Werner> 
    Werner> I haven't yet used comment-dwim, so I won't say
    Werner> something about this function.  But IMHO it is a
    Werner> strange idea to have `C-u something' do exactly the
    Werner> opposite of `something'.  Until now I've considered
    Werner> the C-u prefix as a means to get an extended or
    Werner> slightly modified functionality of a function.
    Werner> 
    Werner> Are there other commands which do the opposite if
    Werner> prefixed with C-u?
    Werner> 
    Werner> And I don't agree with your conclusion that the
    Werner> several meanings of C-u for `comment-region' are `much
    Werner> more useful'.  For me, they are useful for
    Werner> `uncomment-region' only.
    Werner> 
    Werner> 
    Werner>     Werner
    Werner> 
-- 
Karl 2004-06-10 02:07

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

end of thread, other threads:[~2004-06-10  9:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-09 13:36 bug in comment-region Werner LEMBERG
2004-06-09 14:01 ` Karl Chen
2004-06-09 14:08   ` Werner LEMBERG
2004-06-09 14:14     ` David Kastrup
2004-06-09 14:42       ` Werner LEMBERG
2004-06-09 21:09     ` Miles Bader
2004-06-09 23:06       ` Werner LEMBERG
2004-06-10  1:36         ` Miles Bader
2004-06-10  9:11         ` Karl Chen

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