unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to change keys for uncomment (C-u C-c C-c)?
@ 2005-04-21 15:03 JS
  2005-04-21 15:30 ` David Hansen
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: JS @ 2005-04-21 15:03 UTC (permalink / raw)


When I want to uncomment someting I first need to press C-u followed by C-c
C-c but that is not very handy. Is it possible to reconfigure C-u C-c C-c
into ie.:

C-c C-c C-v instead?

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 15:03 How to change keys for uncomment (C-u C-c C-c)? JS
@ 2005-04-21 15:30 ` David Hansen
  2005-04-21 18:45   ` JS
  2005-04-21 15:58 ` Kevin Rodgers
       [not found] ` <mailman.2427.1114099287.2895.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 18+ messages in thread
From: David Hansen @ 2005-04-21 15:30 UTC (permalink / raw)


On Thu, 21 Apr 2005 17:03:02 +0200 JS wrote:

> When I want to uncomment someting I first need to press C-u followed by C-c
> C-c but that is not very handy. Is it possible to reconfigure C-u C-c C-c
> into ie.:
>
> C-c C-c C-v instead?

Which major mode are you talking about?  For me M-; works fine in
all major modes i use.  See C-h k M-;

David

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 15:03 How to change keys for uncomment (C-u C-c C-c)? JS
  2005-04-21 15:30 ` David Hansen
@ 2005-04-21 15:58 ` Kevin Rodgers
       [not found] ` <mailman.2427.1114099287.2895.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 18+ messages in thread
From: Kevin Rodgers @ 2005-04-21 15:58 UTC (permalink / raw)


JS wrote:
 > When I want to uncomment someting I first need to press C-u followed 
by C-c
 > C-c but that is not very handy. Is it possible to reconfigure C-u C-c C-c
 > into ie.:
 >
 > C-c C-c C-v instead?

All things are possible.  But `C-c C-c C-v' is not necessarily a good
choice, because its prefix key `C-c C-c' is already bound to
comment-region (as you know) and all `C-c C-LETTER' keys are reserved
for major modes.  But since all of the `C-c LETTER' keys are reserved
for users, how about `C-c c' or `C-c u':

(add-hook 'this-major-mode-hook         ; e.g. 'c-mode-common-hook
	  (lambda ()
	    (local-set-key "\C-cc" 'uncomment-region))) ; or "\C-cu"

-- 
Kevin Rodgers

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 15:30 ` David Hansen
@ 2005-04-21 18:45   ` JS
  2005-04-21 19:01     ` David Hansen
  0 siblings, 1 reply; 18+ messages in thread
From: JS @ 2005-04-21 18:45 UTC (permalink / raw)


David Hansen wrote:

> On Thu, 21 Apr 2005 17:03:02 +0200 JS wrote:
> 
>> When I want to uncomment someting I first need to press C-u followed by
>> C-c C-c but that is not very handy. Is it possible to reconfigure C-u C-c
>> C-c into ie.:
>>
>> C-c C-c C-v instead?
> 
> Which major mode are you talking about?  For me M-; works fine in
> all major modes i use.  See C-h k M-;
> 
> David


hm nothing happens if I select some code and press M-. The selected area
disappears and in the tiny buffer in the buttom there is only this text:

M---

any idea?

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
       [not found] ` <mailman.2427.1114099287.2895.help-gnu-emacs@gnu.org>
@ 2005-04-21 18:51   ` JS
  2005-04-21 20:09     ` rgb
                       ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: JS @ 2005-04-21 18:51 UTC (permalink / raw)


Kevin Rodgers wrote:

> JS wrote:
>  > When I want to uncomment someting I first need to press C-u followed
> by C-c
>  > C-c but that is not very handy. Is it possible to reconfigure C-u C-c
>  > C-c into ie.:
>  >
>  > C-c C-c C-v instead?
> 
> All things are possible.  But `C-c C-c C-v' is not necessarily a good
> choice, because its prefix key `C-c C-c' is already bound to
> comment-region (as you know) and all `C-c C-LETTER' keys are reserved
> for major modes.  But since all of the `C-c LETTER' keys are reserved
> for users, how about `C-c c' or `C-c u':
> 
> (add-hook 'this-major-mode-hook         ; e.g. 'c-mode-common-hook
> (lambda ()
> (local-set-key "\C-cc" 'uncomment-region))) ; or "\C-cu"
> 

I just wrote this in my .emacs file:


(add-hook 'this-major-mode-hook
          (lambda ()
            (local-set-key "\C-cc" 'uncomment-region)))




But when I restart emacs the program is split in two and I get this error:



An error has occurred while loading `/home/johs/.emacs':

Symbol's value as variable is void:           

To ensure normal operation, you should investigate the cause
of the error in your initialization file and remove it.  Start
Emacs with the `--debug-init' option to view a complete error
backtrace
Loading view...done

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 18:45   ` JS
@ 2005-04-21 19:01     ` David Hansen
  2005-04-21 19:17       ` JS
  0 siblings, 1 reply; 18+ messages in thread
From: David Hansen @ 2005-04-21 19:01 UTC (permalink / raw)


On Thu, 21 Apr 2005 20:45:13 +0200 JS wrote:

>> Which major mode are you talking about?  For me M-; works fine in
>> all major modes i use.  See C-h k M-;
>
> hm nothing happens if I select some code and press M-. The selected area
> disappears and in the tiny buffer in the buttom there is only this text:
>
> M---

>From the tutorial:

,----
|  M-<chr>  means hold the META or EDIT or ALT key down while typing <chr>.
| 	  If there is no META, EDIT or ALT key, instead press and release the
| 	  ESC key and then type <chr>.  We write <ESC> for the ESC key.
`----

so "M-;" means: press Meta key, hold it and press ";".

David

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 19:01     ` David Hansen
@ 2005-04-21 19:17       ` JS
  2005-04-21 19:26         ` David Hansen
  0 siblings, 1 reply; 18+ messages in thread
From: JS @ 2005-04-21 19:17 UTC (permalink / raw)


David Hansen wrote:

> On Thu, 21 Apr 2005 20:45:13 +0200 JS wrote:
> 
>>> Which major mode are you talking about?  For me M-; works fine in
>>> all major modes i use.  See C-h k M-;
>>
>> hm nothing happens if I select some code and press M-. The selected area
>> disappears and in the tiny buffer in the buttom there is only this text:
>>
>> M---
> 
> From the tutorial:
> 
> ,----
> |  M-<chr>  means hold the META or EDIT or ALT key down while typing
> |  <chr>.
> | If there is no META, EDIT or ALT key, instead press and release the
> | ESC key and then type <chr>.  We write <ESC> for the ESC key.
> `----
> 
> so "M-;" means: press Meta key, hold it and press ";".
> 
> David


Ok I have this in my code:

/*   if (f != NULL){ */

When I select that line with the mouse and press:

M-; (Holding down my Alt key and ";")

I get this error:

No M-x tags-search or M-x tags-query-replace in progress

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 19:17       ` JS
@ 2005-04-21 19:26         ` David Hansen
  2005-04-21 19:55           ` JS
  0 siblings, 1 reply; 18+ messages in thread
From: David Hansen @ 2005-04-21 19:26 UTC (permalink / raw)


On Thu, 21 Apr 2005 21:17:10 +0200 JS wrote:

> M-; (Holding down my Alt key and ";")
>
> I get this error:
>
> No M-x tags-search or M-x tags-query-replace in progress

Hmm... What says C-h k M-; ?

David

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 19:26         ` David Hansen
@ 2005-04-21 19:55           ` JS
  2005-04-21 20:17             ` David Hansen
  0 siblings, 1 reply; 18+ messages in thread
From: JS @ 2005-04-21 19:55 UTC (permalink / raw)


David Hansen wrote:

> On Thu, 21 Apr 2005 21:17:10 +0200 JS wrote:
> 
>> M-; (Holding down my Alt key and ";")
>>
>> I get this error:
>>
>> No M-x tags-search or M-x tags-query-replace in progress
> 
> Hmm... What says C-h k M-; ?
> 
> David


I have just tried C-h k M-; and it gives me:


M-, runs the command tags-loop-continue
   which is an interactive compiled Lisp function in `etags'.
(tags-loop-continue &optional FIRST-TIME)

Continue last M-x tags-search or M-x tags-query-replace command.
Used noninteractively with non-nil argument to begin such a command (the
argument is passed to `next-file', which see).

Two variables control the processing we do on each file: the value of
`tags-loop-scan' is a form to be executed on each file to see if it is
interesting (it returns non-nil if so) and `tags-loop-operate' is a form to
evaluate to operate on an interesting file.  If the latter evaluates to
nil, we exit; otherwise we scan the next file.

--------------------
On my keyboard I get ";" by pressing Shift-,

If I try to press M-shift-,  nothing happens.

So I guess the problem is that I can only get ";" if I press Shift at the
same time.

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 18:51   ` JS
@ 2005-04-21 20:09     ` rgb
  2005-04-21 20:32     ` Kevin Rodgers
  2005-04-22 14:53     ` Mathias Dahl
  2 siblings, 0 replies; 18+ messages in thread
From: rgb @ 2005-04-21 20:09 UTC (permalink / raw)



JS wrote:
> Kevin Rodgers wrote:
>
> > JS wrote:
> >  > When I want to uncomment someting I first need to press C-u
followed
> > by C-c
> >  > C-c but that is not very handy. Is it possible to reconfigure
C-u C-c
> >  > C-c into ie.:
> >  >
> >  > C-c C-c C-v instead?
> >
> > All things are possible.  But `C-c C-c C-v' is not necessarily a
good
> > choice, because its prefix key `C-c C-c' is already bound to
> > comment-region (as you know) and all `C-c C-LETTER' keys are
reserved
> > for major modes.  But since all of the `C-c LETTER' keys are
reserved
> > for users, how about `C-c c' or `C-c u':
> >
> > (add-hook 'this-major-mode-hook         ; e.g. 'c-mode-common-hook
> > (lambda ()
> > (local-set-key "\C-cc" 'uncomment-region))) ; or "\C-cu"
> >
>
> I just wrote this in my .emacs file:
>
>
> (add-hook 'this-major-mode-hook
>           (lambda ()
>             (local-set-key "\C-cc" 'uncomment-region)))

'this-major-mode-hook is supposed to be replace by the name of the
mode hook whose mode you actually want the key defined within.

Perhaps if you just use this.

(global-set-key "\C-cc" 'uncomment-region)

And move to something more complicated (such as the prior suggestion)
if this causes you problems.

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 19:55           ` JS
@ 2005-04-21 20:17             ` David Hansen
  2005-04-21 20:35               ` David Hansen
  2005-04-22  8:22               ` JS
  0 siblings, 2 replies; 18+ messages in thread
From: David Hansen @ 2005-04-21 20:17 UTC (permalink / raw)


On Thu, 21 Apr 2005 21:55:27 +0200 JS wrote:

> I have just tried C-h k M-; and it gives me:
>
>
> M-, runs the command tags-loop-continue

[...]

> On my keyboard I get ";" by pressing Shift-,
>
> If I try to press M-shift-,  nothing happens.

And with C-h k before "M-shift-," (Holding down Alt *and* shift
and then ",")?

Anyway, that's probably not a convenient key binding. You may as
well try:

        (global-set-key "\M-," 'comment-region)

or get an US Keyboard ;)

David

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 18:51   ` JS
  2005-04-21 20:09     ` rgb
@ 2005-04-21 20:32     ` Kevin Rodgers
  2005-04-22 14:53     ` Mathias Dahl
  2 siblings, 0 replies; 18+ messages in thread
From: Kevin Rodgers @ 2005-04-21 20:32 UTC (permalink / raw)


JS wrote:
 > I just wrote this in my .emacs file:
 >
 > (add-hook 'this-major-mode-hook
 >           (lambda ()
 >             (local-set-key "\C-cc" 'uncomment-region)))
 >
 > But when I restart emacs the program is split in two and I get this 
error:
 >
 > An error has occurred while loading `/home/johs/.emacs':
 >
 > Symbol's value as variable is void:

That form would not (in fact, cannot) cause that error.  Either you
mistyped it or there is another error in your .emacs file.

 > To ensure normal operation, you should investigate the cause
 > of the error in your initialization file and remove it.  Start
 > Emacs with the `--debug-init' option to view a complete error
 > backtrace
 > Loading view...done

So why don't you try that?  It will bring up a *Backtrace* buffer
showing the stack of function calls that led to the error.

-- 
Kevin Rodgers

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 20:17             ` David Hansen
@ 2005-04-21 20:35               ` David Hansen
  2005-04-22  8:34                 ` JS
  2005-04-22  8:22               ` JS
  1 sibling, 1 reply; 18+ messages in thread
From: David Hansen @ 2005-04-21 20:35 UTC (permalink / raw)


On Thu, 21 Apr 2005 22:17:11 +0200 David Hansen wrote:

>         (global-set-key "\M-," 'comment-region)

Stupid me... should be

          (global-set-key "\M-," 'comment-dwim)

David

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 20:17             ` David Hansen
  2005-04-21 20:35               ` David Hansen
@ 2005-04-22  8:22               ` JS
  1 sibling, 0 replies; 18+ messages in thread
From: JS @ 2005-04-22  8:22 UTC (permalink / raw)


David Hansen wrote:

> On Thu, 21 Apr 2005 21:55:27 +0200 JS wrote:
> 
>> I have just tried C-h k M-; and it gives me:
>>
>>
>> M-, runs the command tags-loop-continue
> 
> [...]
> 
>> On my keyboard I get ";" by pressing Shift-,
>>
>> If I try to press M-shift-,  nothing happens.
> 
> And with C-h k before "M-shift-," (Holding down Alt *and* shift
> and then ",")?
> 
> Anyway, that's probably not a convenient key binding. You may as
> well try:
> 
>         (global-set-key "\M-," 'comment-region)
> 
> or get an US Keyboard ;)
> 
> David

When I do C-h k followed by "M-shift-," I get this:


M-; runs the command comment-dwim
   which 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'.


So I guess it should work. I have some commented text that I select with the
mouse. The I press "M-Shift-," but nothing happens.

I have then changed the value for transistent-mark-mode to "on" and now it
seems to work, but now everything gets painted in yellow when I use
-space...but I guess it ok.

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 20:35               ` David Hansen
@ 2005-04-22  8:34                 ` JS
  2005-04-22 14:48                   ` Mathias Dahl
  0 siblings, 1 reply; 18+ messages in thread
From: JS @ 2005-04-22  8:34 UTC (permalink / raw)


David Hansen wrote:

> On Thu, 21 Apr 2005 22:17:11 +0200 David Hansen wrote:
> 
>>         (global-set-key "\M-," 'comment-region)
> 
> Stupid me... should be
> 
>           (global-set-key "\M-," 'comment-dwim)
> 
> David


I have just entered this in my .emacs fil:

(global-set-key "\M-," 'comment-dwim)

When I start up emacs I get this error:




An error has occurred while loading `/home/johs/.emacs':

Symbol's function definition is void: global-set-key 

To ensure normal operation, you should investigate the cause
of the error in your initialization file and remove it.  Start
Emacs with the `--debug-init' option to view a complete error
backtrace
Loading view...done

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

I have then tried to start emacs like this: emacs --debug-init and then I
get this:

Debugger entered--Lisp error: (void-function global-set-key )
  (global-set-key  "¬"   (quote comment-dwim))
  eval-buffer(#<buffer  *load*> nil "~/.emacs" nil t)
  load-with-code-conversion("/home/johs/.emacs" "~/.emacs" t t)
  load("~/.emacs" t t)
  #[nil " …—

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-22  8:34                 ` JS
@ 2005-04-22 14:48                   ` Mathias Dahl
  0 siblings, 0 replies; 18+ messages in thread
From: Mathias Dahl @ 2005-04-22 14:48 UTC (permalink / raw)


JS <d44sf@44ada.com> writes:

>
> I have just entered this in my .emacs fil:
>
> (global-set-key "\M-," 'comment-dwim)
>
> When I start up emacs I get this error:

> An error has occurred while loading `/home/johs/.emacs':
>
> Symbol's function definition is void: global-set-key 

Seems like your newreader put some extra magic characters in the
parent post. Try this:

 (global-set-key "\M-," 'comment-dwim)

/Mathias

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-21 18:51   ` JS
  2005-04-21 20:09     ` rgb
  2005-04-21 20:32     ` Kevin Rodgers
@ 2005-04-22 14:53     ` Mathias Dahl
  2005-04-22 18:07       ` Alan Mackenzie
  2 siblings, 1 reply; 18+ messages in thread
From: Mathias Dahl @ 2005-04-22 14:53 UTC (permalink / raw)


JS <d44sf@44ada.com> writes:

>
> I just wrote this in my .emacs file:
>
>
> (add-hook 'this-major-mode-hook
>           (lambda ()
>             (local-set-key "\C-cc" 'uncomment-region)))
>
> But when I restart emacs the program is split in two and I get this error:
>
>
>
> An error has occurred while loading `/home/johs/.emacs':
>
> Symbol's value as variable is void:           

I don't know about you other guys, but something seems fishy with JS'
.emacs file. When I read the post above, each supposed-to-be space
character has a magenta coloured backlshash in front of it, suggestion
some special or control-character.

I won't paste his text here again (it is above), but if you do not see
what I see, this is how it looks (drawn in normal ascii):

  (add-hook 'this-major-mode-hook
  \ \ \ \ \ \ \ \ \ \ (lambda\ ()
  \ \ \ \ \ \ \ \ \ \ \ \ (local-set-key\ "\C-cc"\ 'uncomment-region)))

When I put the cursor on one of those and used C-x =, this is what I
got:

Char: \  (04240, 2208, 0x8a0, file 0xA0) point=961 of 1442 (67%) column 0 

Note: I had to use normal ascii to be sure that the "backslash-space"
char above was displayed correctly. It is indeed only one character.

Anyway, just a thought.

/Mathias

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

* Re: How to change keys for uncomment (C-u C-c C-c)?
  2005-04-22 14:53     ` Mathias Dahl
@ 2005-04-22 18:07       ` Alan Mackenzie
  0 siblings, 0 replies; 18+ messages in thread
From: Alan Mackenzie @ 2005-04-22 18:07 UTC (permalink / raw)


Mathias Dahl <brakjoller.rem0veth1s@gmail.com> wrote on Fri, 22 Apr 2005
16:53:56 +0200:

> I don't know about you other guys, but something seems fishy with JS'
> .emacs file. When I read the post above, each supposed-to-be space
> character has a magenta coloured backlshash in front of it, suggestion
> some special or control-character.

> I won't paste his text here again (it is above), but if you do not see
> what I see, this is how it looks (drawn in normal ascii):

>   (add-hook 'this-major-mode-hook
>   \ \ \ \ \ \ \ \ \ \ (lambda\ ()
>   \ \ \ \ \ \ \ \ \ \ \ \ (local-set-key\ "\C-cc"\ 'uncomment-region)))

> When I put the cursor on one of those and used C-x =, this is what I
> got:

> Char: \  (04240, 2208, 0x8a0, file 0xA0) point=961 of 1442 (67%) column
> 0 

iso-8995-1 0xA0 is "non-break space".  Perhaps JS's newsreader (Knode) is
"trying to be helpful" in pre-empting the possibility of the line being
broken up by filling.

> Note: I had to use normal ascii to be sure that the "backslash-space"
> char above was displayed correctly. It is indeed only one character.

> Anyway, just a thought.

> /Mathias

-- 
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] 18+ messages in thread

end of thread, other threads:[~2005-04-22 18:07 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-21 15:03 How to change keys for uncomment (C-u C-c C-c)? JS
2005-04-21 15:30 ` David Hansen
2005-04-21 18:45   ` JS
2005-04-21 19:01     ` David Hansen
2005-04-21 19:17       ` JS
2005-04-21 19:26         ` David Hansen
2005-04-21 19:55           ` JS
2005-04-21 20:17             ` David Hansen
2005-04-21 20:35               ` David Hansen
2005-04-22  8:34                 ` JS
2005-04-22 14:48                   ` Mathias Dahl
2005-04-22  8:22               ` JS
2005-04-21 15:58 ` Kevin Rodgers
     [not found] ` <mailman.2427.1114099287.2895.help-gnu-emacs@gnu.org>
2005-04-21 18:51   ` JS
2005-04-21 20:09     ` rgb
2005-04-21 20:32     ` Kevin Rodgers
2005-04-22 14:53     ` Mathias Dahl
2005-04-22 18:07       ` Alan Mackenzie

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