all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* global-set-key, error: Invalid modifier in string
@ 2007-08-17  5:08 John
  2007-08-17  8:17 ` Peter Dyballa
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: John @ 2007-08-17  5:08 UTC (permalink / raw)
  To: help-gnu-emacs

I'm trying to remap just a few keys around, but Emacs is telling me
"error: Invalid modifier in string". Here's what I'm dropping into the
middle of my ~/.emacs file:

;; To scroll the window up/down by one line. Stealing M-<
;; and M->. I'll use some other keys for beginning- and
;; end-of-buffer (see below).
(global-set-key "\M-<" '"\C-u1\C-v")
(global-set-key "\M->" '"\C-u1\M-v")

;; Used to be M-< and M->
(global-set-key "\M-," 'beginning-of-buffer)
(global-set-key "\M-." 'end-of-buffer)

;; Used to be M-, and M-.
(global-set-key "\C-<" 'tags-loop-continue)
(global-set-key "\C->" 'find-tag)

;; Used to be M-{ and M-}
(global-set-key "\M-{" nil)
(global-set-key "\M-}" nil)
(global-set-key "\M-p" 'backward-paragraph)
(global-set-key "\M-n" 'forward-paragraph)

;; Used to be M-v and C-v
(global-set-key "\C-v" nil)
(global-set-key "\M-v" nil)
(global-set-key "\C-," 'scroll-down)
(global-set-key "\C-." 'scroll-up)

Seems like some of the Alt keys are working, but the ones with "\C-"
in them are causing the error. I think I'm correctly following the
example in the manual ("57.4.6 Rebinding Keys in Your Init File"). Are
there rules about the order in which you set the bindings?

I'm setting some of those to nil just because I'd guess it would be
easier to acclimate to the new ones without the old ones still
working.

Starting Emacs with --debug-init gives me:


Debugger entered--Lisp error: (error "Invalid modifier in string")
  eval-buffer(#<buffer  *load*> nil "/home/john/.emacs" nil t)  ;
Reading at buffer position 2007
  load-with-code-conversion("/home/john/.emacs" "/home/john/.emacs" t
t)
  load("~/.emacs" t t)
  #[ nil "<snip lots of escaped hexy-looking backslash-ridden
stuff>" [init-file-user system-type user-init-file-1 user-init-file
otherfile source ms-dos "~" "/_emacs" windows-nt directory-files nil "^
\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" "~/
_emacs" vax-vms "sys$login:.emacs" "/.emacs" t load expand-file-name
"init" file-name-as-directory "/.emacs.d" file-name-extension "elc"
file-name-sans-extension ".el" file-exists-p file-newer-than-file-p
message "Warning: %s is newer than %s" sit-for 1 "default" alt inhibit-
default-init inhibit-startup-message] 7]()
  command-line()
  normal-top-level()


Any corrections would be much appreciated.

This is GNU Emacs 22.0.91.1 on Ubuntu (the emacs-snapshot-gtk package).

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

* Re: global-set-key, error: Invalid modifier in string
  2007-08-17  5:08 global-set-key, error: Invalid modifier in string John
@ 2007-08-17  8:17 ` Peter Dyballa
  2007-08-17 10:13 ` Johan Bockgård
       [not found] ` <mailman.4897.1187338712.32220.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 9+ messages in thread
From: Peter Dyballa @ 2007-08-17  8:17 UTC (permalink / raw)
  To: John; +Cc: help-gnu-emacs


Am 17.08.2007 um 07:08 schrieb John:

> (global-set-key "\M-{" nil)

What do you think of global-unset-key?

--
Greetings

   Pete

"Don't just do something, sit there."

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

* Re: global-set-key, error: Invalid modifier in string
  2007-08-17  5:08 global-set-key, error: Invalid modifier in string John
  2007-08-17  8:17 ` Peter Dyballa
@ 2007-08-17 10:13 ` Johan Bockgård
  2007-08-17 15:20   ` John
       [not found] ` <mailman.4897.1187338712.32220.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 9+ messages in thread
From: Johan Bockgård @ 2007-08-17 10:13 UTC (permalink / raw)
  To: help-gnu-emacs

John <jmg3000@gmail.com> writes:

> Seems like some of the Alt keys are working, but the ones with "\C-"
> in them are causing the error.

Strings can't contain non-ASCII control characters. Use (kbd "C-.") or
[?\C-.] etc instead.

-- 
Johan Bockgård

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

* Re: global-set-key, error: Invalid modifier in string
       [not found] ` <mailman.4897.1187338712.32220.help-gnu-emacs@gnu.org>
@ 2007-08-17 15:08   ` John
  0 siblings, 0 replies; 9+ messages in thread
From: John @ 2007-08-17 15:08 UTC (permalink / raw)
  To: help-gnu-emacs

On Aug 17, 4:17 am, Peter Dyballa <Peter_Dyba...@Web.DE> wrote:
> Am 17.08.2007 um 07:08 schrieb John:
>
> > (global-set-key "\M-{" nil)
>
> What do you think of global-unset-key?
>

Thanks Peter. Interestingly enough, since the C-v key was used above
for

(global-set-key "\M-<" '"\C-u1\C-v")

if I try to later unset it, that global-set-key fails. That is, even
though I'm unsetting C-v *after* that global-set-key call.

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

* Re: global-set-key, error: Invalid modifier in string
  2007-08-17 10:13 ` Johan Bockgård
@ 2007-08-17 15:20   ` John
  2007-08-17 15:40     ` John
  2007-08-17 18:16     ` Emilio Lopes
  0 siblings, 2 replies; 9+ messages in thread
From: John @ 2007-08-17 15:20 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 781 bytes --]

On Aug 17, 6:13 am, bojohan+n...@dd.chalmers.se (Johan Bockgård)
wrote:
> John <jmg3...@gmail.com> writes:
> > Seems like some of the Alt keys are working, but the ones with "\C-"
> > in them are causing the error.
>
> Strings can't contain non-ASCII control characters. Use (kbd "C-.") or
> [?\C-.] etc instead.
>

I'm not familiar with the differences between ascii and non-ascii ctrl
characters, but using kbd fixed the problem. :)

(Note: I swapped around the C-<> and M-<> keys from what's shown
above.) I'm giving these new key combos a try for a little while.
Using M-v for page up has always seemed out of place wrt the rest of
the Emacs key bindings. And M-n / M-p seems to make perfect sense for
backward-/forward-paragraph.

Thanks Johan!

---John

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

* Re: global-set-key, error: Invalid modifier in string
  2007-08-17 15:20   ` John
@ 2007-08-17 15:40     ` John
  2007-08-19 15:56       ` Johan Bockgård
  2007-08-17 18:16     ` Emilio Lopes
  1 sibling, 1 reply; 9+ messages in thread
From: John @ 2007-08-17 15:40 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 644 bytes --]

On Aug 17, 11:20 am, John <jmg3...@gmail.com> wrote:
> On Aug 17, 6:13 am, bojohan+n...@dd.chalmers.se (Johan Bockgård)
> wrote:
>
> > John <jmg3...@gmail.com> writes:
> > > Seems like some of the Alt keys are working, but the ones with "\C-"
> > > in them are causing the error.
>
> > Strings can't contain non-ASCII control characters. Use (kbd "C-.") or
> > [?\C-.] etc instead.
>
> I'm not familiar with the differences between ascii and non-ascii ctrl
> characters, but using kbd fixed the problem. :)

... but I'm beginning to *get* familiar, since they don't seem to work
when using Emacs in my terminal window over ssh.

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

* Re: global-set-key, error: Invalid modifier in string
  2007-08-17 15:20   ` John
  2007-08-17 15:40     ` John
@ 2007-08-17 18:16     ` Emilio Lopes
  2007-08-20  6:12       ` Stefan Monnier
  1 sibling, 1 reply; 9+ messages in thread
From: Emilio Lopes @ 2007-08-17 18:16 UTC (permalink / raw)
  To: help-gnu-emacs

John  writes:

> On Aug 17, 6:13 am, bojohan+n...@dd.chalmers.se (Johan Bockgård)
> wrote:
>> Strings can't contain non-ASCII control characters. Use (kbd "C-.") or
>> [?\C-.] etc instead.

> I'm not familiar with the differences between ascii and non-ascii ctrl
> characters, but using kbd fixed the problem. :)

I have this macro at the top of my ~/.emacs so that I don't have to
think about this mess anymore:

    (defmacro global-defkey (key def)
      "*Bind KEY globally to DEF.
    KEY should be a string constant in the format used for
    saving keyboard macros (cf. `insert-kbd-macro')."
      `(global-set-key (kbd ,key) ,def))

Use it as in:

    (global-defkey "C-M-<backspace>" 'backward-kill-sexp)

-- 
Emílio C. Lopes
Munich, Germany

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

* Re: global-set-key, error: Invalid modifier in string
  2007-08-17 15:40     ` John
@ 2007-08-19 15:56       ` Johan Bockgård
  0 siblings, 0 replies; 9+ messages in thread
From: Johan Bockgård @ 2007-08-19 15:56 UTC (permalink / raw)
  To: help-gnu-emacs

John <jmg3000@gmail.com> writes:

> On Aug 17, 11:20 am, John <jmg3...@gmail.com> wrote:
>>
>> I'm not familiar with the differences between ascii and non-ascii ctrl
>> characters, but using kbd fixed the problem. :)
>
> ... but I'm beginning to *get* familiar, since they don't seem to work
> when using Emacs in my terminal window over ssh.

Yes, normally terminals don't know about non-ASCII control characters.

You can make xterm recognize these keys by using

   XTerm*modifyOtherKeys:  1

in ~/.Xdefaults.

(If you have a recent CVS version of Emacs, it will try to turn this
feature on automatically.)

-- 
Johan Bockgård

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

* Re: global-set-key, error: Invalid modifier in string
  2007-08-17 18:16     ` Emilio Lopes
@ 2007-08-20  6:12       ` Stefan Monnier
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2007-08-20  6:12 UTC (permalink / raw)
  To: help-gnu-emacs

> I have this macro at the top of my ~/.emacs so that I don't have to
> think about this mess anymore:

>     (defmacro global-defkey (key def)
>       "*Bind KEY globally to DEF.
>     KEY should be a string constant in the format used for
>     saving keyboard macros (cf. `insert-kbd-macro')."
>       `(global-set-key (kbd ,key) ,def))

> Use it as in:

>     (global-defkey "C-M-<backspace>" 'backward-kill-sexp)

I prefer to solve this issue by saying that key combos are not characters and
hence key sequences are not strings.
So I recommend to use the array notation instead, which also happens to be
the "native" notation.


        Stefan

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

end of thread, other threads:[~2007-08-20  6:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-17  5:08 global-set-key, error: Invalid modifier in string John
2007-08-17  8:17 ` Peter Dyballa
2007-08-17 10:13 ` Johan Bockgård
2007-08-17 15:20   ` John
2007-08-17 15:40     ` John
2007-08-19 15:56       ` Johan Bockgård
2007-08-17 18:16     ` Emilio Lopes
2007-08-20  6:12       ` Stefan Monnier
     [not found] ` <mailman.4897.1187338712.32220.help-gnu-emacs@gnu.org>
2007-08-17 15:08   ` John

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.