unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Disabling M-q
@ 2013-05-15 15:31 Cecil Westerhof
  2013-05-16  2:59 ` Yuri Khan
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Cecil Westerhof @ 2013-05-15 15:31 UTC (permalink / raw)
  To: help-gnu-emacs

A friend asked how to disable M-q. My first thought was:
    (local-unset-key (kbd "\M-q"))
or
    (local-set-key (kbd "M-q") nil)

But both did not work. I am now using:
    (local-set-key (kbd "M-q") "")

and this works. Is this the best way, or is there a better way?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


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

* Re: Disabling M-q
  2013-05-15 15:31 Disabling M-q Cecil Westerhof
@ 2013-05-16  2:59 ` Yuri Khan
  2013-05-18  4:43 ` B. T. Raven
       [not found] ` <mailman.25881.1368673172.855.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 13+ messages in thread
From: Yuri Khan @ 2013-05-16  2:59 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: help-gnu-emacs

On Wed, May 15, 2013 at 10:31 PM, Cecil Westerhof <Cecil@decebal.nl> wrote:
> A friend asked how to disable M-q. My first thought was:
>     (local-unset-key (kbd "\M-q"))
> or
>     (local-set-key (kbd "M-q") nil)

You need to unset the key in the map that sets it, or override it with
another function in a higher-priority map (as you do below with the
empty string, which is not a proper function).

> But both did not work. I am now using:
>     (local-set-key (kbd "M-q") "")
>
> and this works. Is this the best way, or is there a better way?

You could bind the `ignore' function discussed recently on this list.



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

* Re: Disabling M-q
  2013-05-15 15:31 Disabling M-q Cecil Westerhof
  2013-05-16  2:59 ` Yuri Khan
@ 2013-05-18  4:43 ` B. T. Raven
  2013-05-18 10:26   ` Emanuel Berg
       [not found] ` <mailman.25881.1368673172.855.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 13+ messages in thread
From: B. T. Raven @ 2013-05-18  4:43 UTC (permalink / raw)
  To: help-gnu-emacs


> A friend asked how to disable M-q. My first thought was:
>     (local-unset-key (kbd "\M-q"))
> or
>     (local-set-key (kbd "M-q") nil)
> 
> But both did not work. I am now using:
>     (local-set-key (kbd "M-q") "")
> 
> and this works. Is this the best way, or is there a better way?
> 

How about either

(global-unset-key [(meta q)]

or

(local-unset-key [(meta q)]

??



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

* Re: Disabling M-q
  2013-05-18  4:43 ` B. T. Raven
@ 2013-05-18 10:26   ` Emanuel Berg
  2013-05-18 17:44     ` B. T. Raven
  0 siblings, 1 reply; 13+ messages in thread
From: Emanuel Berg @ 2013-05-18 10:26 UTC (permalink / raw)
  To: help-gnu-emacs

"B. T. Raven" <btraven@nihilo.net> writes:

>> A friend asked how to disable M-q. My first thought was:
>>     (local-unset-key (kbd "\M-q"))
>> or
>>     (local-set-key (kbd "M-q") nil)
>> 
>> But both did not work. I am now using:
>>     (local-set-key (kbd "M-q") "")
>> 
>> and this works. Is this the best way, or is there a better way?
>
> How about either
>
> (global-unset-key [(meta q)]
>
> or
>
> (local-unset-key [(meta q)]

I wrote a couple of lines you can experiment with. Use `C-h w' for the
functions and `C-x C-e' to change keybinding.

The local binding will shadow the global. If the global is shadowed,
it won't report any key on `C-h w'. But, as soon as you unset the
local, or set it to the nils, the global is back on. When the local is
set to the empty string, the shadow is on (i.e., the global is off)
only this "shadow" doesn't do anything.

Like I said, play around with it.

(defun test-message-local  () (interactive) (message "local check"))
(defun test-message-global () (interactive) (message "global check"))
(global-unset-key (kbd "C-M-w")) ; either unset both
(local-unset-key  (kbd "C-M-w"))
(global-set-key   (kbd "C-M-w") 'test-message-global) ; test C-h w here
(local-set-key    (kbd "C-M-w") 'test-message-local)  ; shadows global
(local-set-key    (kbd "C-M-w")  nil) ; these four - global *on*
(local-set-key    (kbd "C-M-w") 'nil)
(local-set-key    (kbd "C-M-w")  ())
(local-set-key    (kbd "C-M-w") '())
(local-set-key    (kbd "C-M-w") "")   ; this - local "nothing" shadow

-- 
Emanuel Berg - programmer (hire me! CV below)
computer projects: http://user.it.uu.se/~embe8573
internet activity: http://home.student.uu.se/embe8573


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

* Re: Disabling M-q
  2013-05-18 10:26   ` Emanuel Berg
@ 2013-05-18 17:44     ` B. T. Raven
  2013-05-21  8:21       ` Cecil Westerhof
  0 siblings, 1 reply; 13+ messages in thread
From: B. T. Raven @ 2013-05-18 17:44 UTC (permalink / raw)
  To: help-gnu-emacs



> "B. T. Raven" <btraven@nihilo.net> writes:
> 
>>> A friend asked how to disable M-q. My first thought was:
>>>     (local-unset-key (kbd "\M-q"))

This was the original question. Should M be escaped in a string here?
Did you try the vector description of "M-q"? I notice that (kbd <key>...
returns a specific vector but the vector [(meta q)] just evaluates to
itself. Have you tried:

(define-key (current-local-map) [(meta q)] nil)

??


>>> or
>>>     (local-set-key (kbd "M-q") nil)
>>>
>>> But both did not work. I am now using:
>>>     (local-set-key (kbd "M-q") "")
>>>
>>> and this works. Is this the best way, or is there a better way?
>>
>> How about either
>>
>> (global-unset-key [(meta q)]
>>
>> or
>>
>> (local-unset-key [(meta q)]
> 
> I wrote a couple of lines you can experiment with. Use `C-h w' for the
> functions and `C-x C-e' to change keybinding.
> 
> The local binding will shadow the global. If the global is shadowed,
> it won't report any key on `C-h w'. But, as soon as you unset the
> local, or set it to the nils, the global is back on. When the local is
> set to the empty string, the shadow is on (i.e., the global is off)
> only this "shadow" doesn't do anything.
> 
> Like I said, play around with it.
> 
> (defun test-message-local  () (interactive) (message "local check"))
> (defun test-message-global () (interactive) (message "global check"))
> (global-unset-key (kbd "C-M-w")) ; either unset both
> (local-unset-key  (kbd "C-M-w"))
> (global-set-key   (kbd "C-M-w") 'test-message-global) ; test C-h w here
> (local-set-key    (kbd "C-M-w") 'test-message-local)  ; shadows global
> (local-set-key    (kbd "C-M-w")  nil) ; these four - global *on*
> (local-set-key    (kbd "C-M-w") 'nil)
> (local-set-key    (kbd "C-M-w")  ())
> (local-set-key    (kbd "C-M-w") '())
> (local-set-key    (kbd "C-M-w") "")   ; this - local "nothing" shadow
> 



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

* Re: Disabling M-q
       [not found] ` <mailman.25881.1368673172.855.help-gnu-emacs@gnu.org>
@ 2013-05-21  8:13   ` Cecil Westerhof
  0 siblings, 0 replies; 13+ messages in thread
From: Cecil Westerhof @ 2013-05-21  8:13 UTC (permalink / raw)
  To: help-gnu-emacs

Op donderdag 16 mei 2013 04:59 CEST schreef Yuri Khan:

> On Wed, May 15, 2013 at 10:31 PM, Cecil Westerhof <Cecil@decebal.nl> wrote:
>> A friend asked how to disable M-q. My first thought was:
>> (local-unset-key (kbd "\M-q"))
>> or
>> (local-set-key (kbd "M-q") nil)
>
> You need to unset the key in the map that sets it, or override it
> with another function in a higher-priority map (as you do below with
> the empty string, which is not a proper function).
>
>> But both did not work. I am now using:
>> (local-set-key (kbd "M-q") "")
>>
>> and this works. Is this the best way, or is there a better way?
>
> You could bind the `ignore' function discussed recently on this
> list.

I have tried (I am not using it):
    (local-set-key (kbd "M-q") 'ignore)

and it works. I send the improved solution to my friend.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


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

* Re: Disabling M-q
  2013-05-18 17:44     ` B. T. Raven
@ 2013-05-21  8:21       ` Cecil Westerhof
  2013-05-21 16:44         ` Drew Adams
                           ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Cecil Westerhof @ 2013-05-21  8:21 UTC (permalink / raw)
  To: help-gnu-emacs

Op zaterdag 18 mei 2013 19:44 CEST schreef B. T. Raven:

> This was the original question. Should M be escaped in a string
> here? Did you try the vector description of "M-q"? I notice that
> (kbd <key>... returns a specific vector but the vector [(meta q)]
> just evaluates to itself. Have you tried:
>
> (define-key (current-local-map) [(meta q)] nil)

Does not work either, but
    (local-set-key (kbd "M-q") 'ignore)
does.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


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

* RE: Disabling M-q
  2013-05-21  8:21       ` Cecil Westerhof
@ 2013-05-21 16:44         ` Drew Adams
  2013-05-21 16:57         ` B. T. Raven
       [not found]         ` <mailman.131.1369154672.22516.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 13+ messages in thread
From: Drew Adams @ 2013-05-21 16:44 UTC (permalink / raw)
  To: Cecil Westerhof, help-gnu-emacs

> (define-key (current-local-map) [(meta q)] nil) Does not work either

You must use [(meta ?q)], not [(meta q)].



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

* Re: Disabling M-q
  2013-05-21  8:21       ` Cecil Westerhof
  2013-05-21 16:44         ` Drew Adams
@ 2013-05-21 16:57         ` B. T. Raven
       [not found]         ` <mailman.131.1369154672.22516.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 13+ messages in thread
From: B. T. Raven @ 2013-05-21 16:57 UTC (permalink / raw)
  To: help-gnu-emacs


> Op zaterdag 18 mei 2013 19:44 CEST schreef B. T. Raven:
> 
>> This was the original question. Should M be escaped in a string
>> here? Did you try the vector description of "M-q"? I notice that
>> (kbd <key>... returns a specific vector but the vector [(meta q)]
>> just evaluates to itself. Have you tried:
>>
>> (define-key (current-local-map) [(meta q)] nil)
> 
> Does not work either, but
>     (local-set-key (kbd "M-q") 'ignore)
> does.
> 

It's weird that both you and the third party are having the same
problem. If one of you tries the same experiments on an emacs -Q
invocation, does the problem disappear?

Ed




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

* Re: Disabling M-q
       [not found]         ` <mailman.131.1369154672.22516.help-gnu-emacs@gnu.org>
@ 2013-05-21 18:35           ` Cecil Westerhof
  2013-05-21 20:29             ` Drew Adams
  2013-05-21 20:44           ` B. T. Raven
  1 sibling, 1 reply; 13+ messages in thread
From: Cecil Westerhof @ 2013-05-21 18:35 UTC (permalink / raw)
  To: help-gnu-emacs

Op dinsdag 21 mei 2013 18:44 CEST schreef Drew Adams:

>> (define-key (current-local-map) [(meta q)] nil) Does not work
>> either
>
> You must use [(meta ?q)], not [(meta q)].

Does not work either. I'll try with -Q as in the other post.
On the other hand I do not find
    (local-set-key (kbd "M-q") 'ignore)

less clear. I even think it is more clear. Or is there a reason to
prefer this solution above the ignore solution?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


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

* RE: Disabling M-q
  2013-05-21 18:35           ` Cecil Westerhof
@ 2013-05-21 20:29             ` Drew Adams
  0 siblings, 0 replies; 13+ messages in thread
From: Drew Adams @ 2013-05-21 20:29 UTC (permalink / raw)
  To: Cecil Westerhof, help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

> >> (define-key (current-local-map) [(meta q)] nil) Does not work
> >> either
> >
> > You must use [(meta ?q)], not [(meta q)].
> 
> Does not work either. I'll try with -Q as in the other post.
> On the other hand I do not find (local-set-key (kbd "M-q") 'ignore)
> less clear. I even think it is more clear.  Or is there a reason to
> prefer this solution above the ignore solution?

You are confusing a lot of things.  I merely wanted to say that [(meta q)] should be [(meta ?q)]: ?q is the character; q is not.  Other people have mentioned other, orthogonal corrections.

Yes, (kbd "M-q") is perfectly clear.  No, there is no advantage in one's init file to using [(meta ?q)] instead.  No one suggested otherwise.

[-- Attachment #2: maker.ini --]
[-- Type: application/octet-stream, Size: 31745 bytes --]

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

* Re: Disabling M-q
       [not found]         ` <mailman.131.1369154672.22516.help-gnu-emacs@gnu.org>
  2013-05-21 18:35           ` Cecil Westerhof
@ 2013-05-21 20:44           ` B. T. Raven
  2013-05-22 14:59             ` Drew Adams
  1 sibling, 1 reply; 13+ messages in thread
From: B. T. Raven @ 2013-05-21 20:44 UTC (permalink / raw)
  To: help-gnu-emacs


>> (define-key (current-local-map) [(meta q)] nil) Does not work either
> 
> You must use [(meta ?q)], not [(meta q)].
> 


I've seen that in the docs but it doesn't seem to matter (with ver.
23.3). In my .emacs (together with a couple of dozen other similar
forms) I have:

(global-set-key [(meta super s)] 'search-forward-regexp)

This works and C-hf search-forward-regexp shows this:

"
search-forward-regexp is an interactive built-in function in
`subr.el'.

It is bound to M-s-s.

(search-forward-regexp REGEXP &optional BOUND NOERROR COUNT)
"

But maybe I've just been lucky not to have something masking the ?q
interpretation of q. Anyway it seems to work without specifying that q
is a char.


Ed


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

* RE: Disabling M-q
  2013-05-21 20:44           ` B. T. Raven
@ 2013-05-22 14:59             ` Drew Adams
  0 siblings, 0 replies; 13+ messages in thread
From: Drew Adams @ 2013-05-22 14:59 UTC (permalink / raw)
  To: B. T. Raven, help-gnu-emacs

> > You must use [(meta ?q)], not [(meta q)].
> 
> I've seen that in the docs but it doesn't seem to matter (with ver. 23.3).

I guess you're right.  That seems to be the case from at least Emacs 22 on (perhaps earlier too).  I wasn't aware of that (or forgot it).



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

end of thread, other threads:[~2013-05-22 14:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-15 15:31 Disabling M-q Cecil Westerhof
2013-05-16  2:59 ` Yuri Khan
2013-05-18  4:43 ` B. T. Raven
2013-05-18 10:26   ` Emanuel Berg
2013-05-18 17:44     ` B. T. Raven
2013-05-21  8:21       ` Cecil Westerhof
2013-05-21 16:44         ` Drew Adams
2013-05-21 16:57         ` B. T. Raven
     [not found]         ` <mailman.131.1369154672.22516.help-gnu-emacs@gnu.org>
2013-05-21 18:35           ` Cecil Westerhof
2013-05-21 20:29             ` Drew Adams
2013-05-21 20:44           ` B. T. Raven
2013-05-22 14:59             ` Drew Adams
     [not found] ` <mailman.25881.1368673172.855.help-gnu-emacs@gnu.org>
2013-05-21  8:13   ` Cecil Westerhof

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