unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to bind the keyboard 'C-;'
@ 2007-03-13 23:12 Vols
  2007-03-14  0:49 ` John Paul Wallington
  0 siblings, 1 reply; 4+ messages in thread
From: Vols @ 2007-03-13 23:12 UTC (permalink / raw)
  To: help-gnu-emacs

Hi, group

I want the keyboard binding 'Control  ;' , for example, I tried:
(global-set-key  "\C-;" 'kill-this-buffe)
It doesn't work and comes with a "invalid modifier in string" error.

Actually i want to use 'C-;' to comment current line. (M-; add comment
at the end of the line). I used :

(global-set-key  "\C-;" 'my-comment-current-line)
(defun my-comment-current-line ()
  (interactive)
  (comment-region (line-beginning-position) (line-end-position)))

Thanks.
Vol.

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

* Re: How to bind the keyboard 'C-;'
  2007-03-13 23:12 How to bind the keyboard 'C-;' Vols
@ 2007-03-14  0:49 ` John Paul Wallington
  2007-03-16  7:00   ` Kevin Rodgers
       [not found]   ` <mailman.994.1174028547.7795.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: John Paul Wallington @ 2007-03-14  0:49 UTC (permalink / raw)
  To: help-gnu-emacs

"Vols" <volunteers@gmail.com> writes:

> I want the keyboard binding 'Control  ;' , for example, I tried:
> (global-set-key  "\C-;" 'kill-this-buffe)

You must avoid the string syntax when binding non-ASCII characters.
(kbd "C-;") and [(control \;)] should work.

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

* Re: How to bind the keyboard 'C-;'
  2007-03-14  0:49 ` John Paul Wallington
@ 2007-03-16  7:00   ` Kevin Rodgers
       [not found]   ` <mailman.994.1174028547.7795.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2007-03-16  7:00 UTC (permalink / raw)
  To: help-gnu-emacs

John Paul Wallington wrote:
> "Vols" <volunteers@gmail.com> writes:
> 
>> I want the keyboard binding 'Control  ;' , for example, I tried:
>> (global-set-key  "\C-;" 'kill-this-buffe)
> 
> You must avoid the string syntax when binding non-ASCII characters.
> (kbd "C-;") and [(control \;)] should work.

and [?\C-;]

Can anyone explain why the semicolon does not need to be backslashed
there?

-- 
Kevin Rodgers
Denver, Colorado, USA

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

* Re: How to bind the keyboard 'C-;'
       [not found]   ` <mailman.994.1174028547.7795.help-gnu-emacs@gnu.org>
@ 2007-03-16 14:06     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2007-03-16 14:06 UTC (permalink / raw)
  To: help-gnu-emacs

> and [?\C-;]
> Can anyone explain why the semicolon does not need to be backslashed
> there?

Well, it kind of does: the `read' function will not need a backslash because
when it sees "?\C-" is knows that what follows can't be a comment (because
"?\C-" on its own is not a valid lexeme).

But emacs-lisp-mode doesn't understand this (because it doesn't use the full
builtin lisp parser), so font-lock and syntax-based navigation (e.g. C-M-f)
will not treat it correctly if the ; is not escaped.


        Stefan

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

end of thread, other threads:[~2007-03-16 14:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-13 23:12 How to bind the keyboard 'C-;' Vols
2007-03-14  0:49 ` John Paul Wallington
2007-03-16  7:00   ` Kevin Rodgers
     [not found]   ` <mailman.994.1174028547.7795.help-gnu-emacs@gnu.org>
2007-03-16 14:06     ` Stefan Monnier

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