all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to uncomment Perl program in emacs?
@ 2005-08-18 21:23 Andy
  2005-08-18 22:13 ` David Hansen
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Andy @ 2005-08-18 21:23 UTC (permalink / raw)


I am right now using GNU emacs 20.3.1 on solaris. I can comment and
uncomment C codes by first simply highlighting the codes, and then
Control-c Control-c for comment or Control-u Control-c Control-c for
uncomment.

But I can't apply the above method to comment or uncomment Perl codes.
Alternatively, I can comment Perl codes by first highlighting the codes
then "M-x comment-region". But I don't know how to uncomment Perl
codes; at least, "M-x uncomment-region" doesn't work.

Can anyone please help me to find a better way to comment/uncomment
Perl codes, just like what can be done for C codes? Thanks a lot for
your help!

Andy

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

* Re: How to uncomment Perl program in emacs?
  2005-08-18 21:23 How to uncomment Perl program in emacs? Andy
@ 2005-08-18 22:13 ` David Hansen
  2005-08-19  2:45   ` Andy
  2005-08-18 22:37 ` Edward O'Connor
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: David Hansen @ 2005-08-18 22:13 UTC (permalink / raw)


On 18 Aug 2005 14:23:59 -0700 Andy wrote:

> I am right now using GNU emacs 20.3.1 on solaris.

At least in more recent versions of emacs M-; should work for
commenting and uncommenting the region.

David

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

* Re: How to uncomment Perl program in emacs?
  2005-08-18 21:23 How to uncomment Perl program in emacs? Andy
  2005-08-18 22:13 ` David Hansen
@ 2005-08-18 22:37 ` Edward O'Connor
       [not found] ` <mailman.4248.1124405039.20277.help-gnu-emacs@gnu.org>
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Edward O'Connor @ 2005-08-18 22:37 UTC (permalink / raw)


> Can anyone please help me to find a better way to comment/uncomment
> Perl codes, just like what can be done for C codes? Thanks a lot for
> your help!

The command `comment-dwim' might do what you want, but note that its
dwimmish behavior depends on `transient-mark-mode' being enabled.

,----[ C-h f comment-dwim RET ]
| comment-dwim is an interactive compiled Lisp function in `newcomment'.
| (comment-dwim ARG)
| 
| Call the comment command you want (Do What I Mean).
| If the region is active and `transient-mark-mode' is on, call
|   `comment-region' (unless it only consists of comments, in which
|   case it calls `uncomment-region').
| Else, if the current line is empty, insert a comment and indent it.
| Else if a prefix ARG is specified, call `comment-kill'.
| Else, call `comment-indent'.
`----


Ted

-- 
Edward O'Connor
hober0@gmail.com

Ense petit placidam sub libertate quietem.

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

* Re: How to uncomment Perl program in emacs?
  2005-08-18 22:13 ` David Hansen
@ 2005-08-19  2:45   ` Andy
  2005-08-19  3:32     ` Henrik Enberg
  0 siblings, 1 reply; 11+ messages in thread
From: Andy @ 2005-08-19  2:45 UTC (permalink / raw)



David Hansen 写道:

> At least in more recent versions of emacs M-; should work for
> commenting and uncommenting the region.
>
> David

I believe my GNU emacs (20.3.1) should be pretty recent, and I can use
"M-x comment-region" to comment out Perl code. BUT my problem is that I
don't know how to uncomment the region. Unfortunately, it seems that
there is no command as "uncomment-region" as one will naturally think
to complement to command of "comment-region".

Therefore, I really get stucked without knowing a good way to uncomment
a block of Perl code other than having to deleting those comment
symbols, "#" in Perl case, line by line, which is of course a painfully
inconvenient way to do the work. 

Andy

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

* Re: How to uncomment Perl program in emacs?
       [not found] ` <mailman.4248.1124405039.20277.help-gnu-emacs@gnu.org>
@ 2005-08-19  2:49   ` Andy
  0 siblings, 0 replies; 11+ messages in thread
From: Andy @ 2005-08-19  2:49 UTC (permalink / raw)



Edward O'Connor 写道:

> The command `comment-dwim' might do what you want, but note that its
> dwimmish behavior depends on `transient-mark-mode' being enabled.
>
> Ted

There is no command as `comment-dwim' for my emacs. Actually, there is
ONLY one command starting with "comment" for my emacs, that is,
`comment-region'.

And `comment-region' works for me for the purpose of commenting out
Perl codes, that is, it will precede every line of perl code with
comment symbol of "#". However, when it comes to uncomment the Perl
codes, then I don't know the trick for the job. Any help for UNcomment
a block of Perl codes?

Thanks,

Andy

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

* Re: How to uncomment Perl program in emacs?
  2005-08-19  2:45   ` Andy
@ 2005-08-19  3:32     ` Henrik Enberg
  0 siblings, 0 replies; 11+ messages in thread
From: Henrik Enberg @ 2005-08-19  3:32 UTC (permalink / raw)


> From: "Andy" <gngandy@gmail.com>
> Date: 18 Aug 2005 19:45:12 -0700
> 
> David Hansen 写道:
> 
> > At least in more recent versions of emacs M-; should work for
> > commenting and uncommenting the region.
> 
> I believe my GNU emacs (20.3.1) should be pretty recent, and I can use

It was released 6 years and 364 days ago.  the current version of Emacs
is 21.4.

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

* RE: How to uncomment Perl program in emacs?
@ 2005-08-19  4:09 Dave Humphries
  0 siblings, 0 replies; 11+ messages in thread
From: Dave Humphries @ 2005-08-19  4:09 UTC (permalink / raw)


M-x uncomment-region ?

Dave

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

* Re: How to uncomment Perl program in emacs?
  2005-08-18 21:23 How to uncomment Perl program in emacs? Andy
                   ` (2 preceding siblings ...)
       [not found] ` <mailman.4248.1124405039.20277.help-gnu-emacs@gnu.org>
@ 2005-08-19  7:16 ` ht000
  2005-08-19  8:44 ` Alan Mackenzie
  2005-08-19 10:53 ` Michael Cadilhac
  5 siblings, 0 replies; 11+ messages in thread
From: ht000 @ 2005-08-19  7:16 UTC (permalink / raw)


"Andy" <gngandy@gmail.com> writes:

> Can anyone please help me to find a better way to comment/uncomment
> Perl codes, just like what can be done for C codes? Thanks a lot for
> your help!
>
If you use cperl-mode there is a comment/uncomment-region command in
the menu.

--
Henrik Tougaard

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

* Re: How to uncomment Perl program in emacs?
  2005-08-18 21:23 How to uncomment Perl program in emacs? Andy
                   ` (3 preceding siblings ...)
  2005-08-19  7:16 ` ht000
@ 2005-08-19  8:44 ` Alan Mackenzie
  2005-08-19 16:06   ` Andy
  2005-08-19 10:53 ` Michael Cadilhac
  5 siblings, 1 reply; 11+ messages in thread
From: Alan Mackenzie @ 2005-08-19  8:44 UTC (permalink / raw)


Andy <gngandy@gmail.com> wrote on 18 Aug 2005 14:23:59 -0700:
> I am right now using GNU emacs 20.3.1 on solaris.

First comment: that release is many years old; if you upgraded to a more
recent release (currently, that's 21.4), you might well like the new
features; there's little to dislike, and few, if any, compatibility
problems.  Also, if you have any more problems, the people who'll be
helping you will know the current release much better than older ones.

> I can comment and uncomment C codes by first simply highlighting the
> codes, and then Control-c Control-c for comment or Control-u Control-c
> Control-c for uncomment.

> But I can't apply the above method to comment or uncomment Perl codes.
> Alternatively, I can comment Perl codes by first highlighting the codes
> then "M-x comment-region".

OK, just a first check: You're using "Perl Mode", right?  That is, on the
mode line you see "(Perl)" just to the left of the line number?  The
thing is, there is at least one other mode ("CPerl Mode", I think) which
can be used instead.

> But I don't know how to uncomment Perl codes; at least, "M-x
> uncomment-region" doesn't work.

C-u M-x comment-region  ;-)

> Can anyone please help me to find a better way to comment/uncomment
> Perl codes, just like what can be done for C codes? Thanks a lot for
> your help!

Put this in your .emacs:

  (eval-after-load "perl-mode"
    '(define-key perl-mode-map "\C-c\C-c"  'comment-region))

(DON'T miss out the tick at the beginning of the second line.  It's
important.)

That should set up your mode so that you can use C-c C-c for perl.

Just one proviso: I've tried all this in Emacs 21.3, not 20.3.  It should
probably work in the older version, though.

> Andy

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

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

* Re: How to uncomment Perl program in emacs?
  2005-08-18 21:23 How to uncomment Perl program in emacs? Andy
                   ` (4 preceding siblings ...)
  2005-08-19  8:44 ` Alan Mackenzie
@ 2005-08-19 10:53 ` Michael Cadilhac
  5 siblings, 0 replies; 11+ messages in thread
From: Michael Cadilhac @ 2005-08-19 10:53 UTC (permalink / raw)
  Cc: help-gnu-emacs

"Andy" <gngandy@gmail.com> writes:

> But I can't apply the above method to comment or uncomment Perl codes.
> Alternatively, I can comment Perl codes by first highlighting the codes
> then "M-x comment-region". But I don't know how to uncomment Perl
> codes; at least, "M-x uncomment-region" doesn't work.

  C-u M-x comment-region

  
,----[ C-h f comment-region ]
| comment-region is an interactive autoloaded Lisp function in `newcomment'.
| It is bound to M-;.
| (comment-region BEG END &optional ARG)
| 
| Comment or uncomment each line in the region.
| With just C-u prefix arg, uncomment each line in region BEG .. END.
| Numeric prefix ARG means use ARG comment characters.
| If ARG is negative, delete that many comment characters instead.
| By default, comments start at the left margin, are terminated on each line,
| even for syntax in which newline does not end the comment and blank lines
| do not get comments.  This can be changed with `comment-style'.
| 
| The strings used as comment starts are built from
| `comment-start' without trailing spaces and `comment-padding'.
| 
`----


-- 
    Michael Cadilhac, a.k.a. Micha [mika] |
                    Epita/LRDE promo 2007 |  Please note that you should
  2 rue de la Convention | 01.46.70.90.75 |  s/-@t-/@/ my mail address.
94270 Le Kremlin Bicetre | 06.23.20.31.30 |

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

* Re: How to uncomment Perl program in emacs?
  2005-08-19  8:44 ` Alan Mackenzie
@ 2005-08-19 16:06   ` Andy
  0 siblings, 0 replies; 11+ messages in thread
From: Andy @ 2005-08-19 16:06 UTC (permalink / raw)


Alan Mackenzie 写道:

> C-u M-x comment-region  ;-)

"C-u M-x comment-region" works perfectly on my Emacs (which I igorantly
thought to be recent version, sorry about it) to uncomment Perl codes.
Thanks a lot!

> Put this in your .emacs:
>
>   (eval-after-load "perl-mode"
>     '(define-key perl-mode-map "\C-c\C-c"  'comment-region))
>
> (DON'T miss out the tick at the beginning of the second line.  It's
> important.)

> That should set up your mode so that you can use C-c C-c for perl.

I can achieve both commenting Perl code with "\C-c\C-c" and
uncommenting with "C-u\C-c\C-c" after I put in those macros as you
suggested to .emacs. Again, Thanks tremendously!

> Alan Mackenzie (Munich, Germany)


Andy

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

end of thread, other threads:[~2005-08-19 16:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-18 21:23 How to uncomment Perl program in emacs? Andy
2005-08-18 22:13 ` David Hansen
2005-08-19  2:45   ` Andy
2005-08-19  3:32     ` Henrik Enberg
2005-08-18 22:37 ` Edward O'Connor
     [not found] ` <mailman.4248.1124405039.20277.help-gnu-emacs@gnu.org>
2005-08-19  2:49   ` Andy
2005-08-19  7:16 ` ht000
2005-08-19  8:44 ` Alan Mackenzie
2005-08-19 16:06   ` Andy
2005-08-19 10:53 ` Michael Cadilhac
  -- strict thread matches above, loose matches on Subject: below --
2005-08-19  4:09 Dave Humphries

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.