* Q1 - the keys' bindings to work more widely
@ 2024-12-14 23:46 Tatsu Takamaro
2024-12-15 2:15 ` [External] : " Drew Adams
2024-12-15 10:05 ` Alain.Cochard
0 siblings, 2 replies; 8+ messages in thread
From: Tatsu Takamaro @ 2024-12-14 23:46 UTC (permalink / raw)
To: help-gnu-emacs
Hi there, sirs!
I'm new to Emacs, just a month from the beginning. I've managed to do
all the major settings, wrote through the Tutorial. But for now there
are 4 residual questions. I'll ask them one by one, one per letter to
get more precise.
So, here is the first one. I would like to have my keys (my bindings)
working more widely so that I could trust them more. But for now some of
them don't work. E. g. in a Help buffer C-c doesn't work as a copy
action (though it works globally as I set). And this is not surprising.
I understand that major modes have priority over the global one. What is
the best idea to make my keys more reliable? One way is to change all
the major and minor modes, but it's a big load of work and code. Another
way is to create my own minor mode key bindings and make it be turned on
by default, and I managed to find how it should be done ("init-value"
and "global" should be non-nil, in the "define-minor-mode" call). So I
hope I'm somewhere close to the solution. Here is my function call with
an example of C-c rebinding:
(define-minor-mode ttkeys-mode "My key bindings"
:init-value 1 :lighter " TT" :global 1
:keymap
'(
("C-c" . #'kill-ring-save)
("C-a" . #'mark-whole-buffer)
)
)
The TT mode is being shown normally, I can switch in on and off, but the
C-c and C-a don't work as I told them to. I tried to vary signs like #
and ', but no result. What am I doing wrong?
And, maybe there is some other advice that you could give to make my
keys more reliable (make them work everywhere in Emacs)? Don't offer a
CUA mode, I know about it, but it doesn't meet my needs.
Tony.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [External] : Q1 - the keys' bindings to work more widely
2024-12-14 23:46 Q1 - the keys' bindings to work more widely Tatsu Takamaro
@ 2024-12-15 2:15 ` Drew Adams
2024-12-16 23:11 ` Tatsu Takamaro
2024-12-15 10:05 ` Alain.Cochard
1 sibling, 1 reply; 8+ messages in thread
From: Drew Adams @ 2024-12-15 2:15 UTC (permalink / raw)
To: Tatsu Takamaro, help-gnu-emacs@gnu.org
> I would like to have my keys (my bindings)
> working more widely so that I could trust them more. But for now some of
> them don't work. E. g. in a Help buffer C-c doesn't work as a copy
> action (though it works globally as I set). And this is not surprising.
> I understand that major modes have priority over the global one. What is
> the best idea to make my keys more reliable? One way is to change all
> the major and minor modes, but it's a big load of work and code. Another
> way is to create my own minor mode key bindings and make it be turned on
> by default, and I managed to find how it should be done ("init-value"
> and "global" should be non-nil, in the "define-minor-mode" call). So I
> hope I'm somewhere close to the solution. Here is my function call with
> an example of C-c rebinding:
>
> (define-minor-mode ttkeys-mode "My key bindings"
> :init-value 1 :lighter " TT" :global 1
> :keymap
> '(
> ("C-c" . #'kill-ring-save)
> ("C-a" . #'mark-whole-buffer)
> )
> )
>
> The TT mode is being shown normally, I can switch in on and off, but the
> C-c and C-a don't work as I told them to. I tried to vary signs like #
> and ', but no result. What am I doing wrong?
>
> And, maybe there is some other advice that you could give to make my
> keys more reliable (make them work everywhere in Emacs)? Don't offer a
> CUA mode, I know about it, but it doesn't meet my needs.
See node `Key Binding Conventions' in the Elisp manual:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html
That's `C-h i m elisp RET', then `g key binding conventions RET'.
See also the Emacs manual (`C-h r'), node `CUA Bindings'.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Q1 - the keys' bindings to work more widely
2024-12-14 23:46 Q1 - the keys' bindings to work more widely Tatsu Takamaro
2024-12-15 2:15 ` [External] : " Drew Adams
@ 2024-12-15 10:05 ` Alain.Cochard
1 sibling, 0 replies; 8+ messages in thread
From: Alain.Cochard @ 2024-12-15 10:05 UTC (permalink / raw)
To: Tatsu Takamaro; +Cc: help-gnu-emacs
Tatsu Takamaro writes on Sun 15 Dec 2024 02:46:
> I would like to have my keys (my bindings) working more widely so that I
> could trust them more. But for now some of them don't work. E. g. in a
> Help buffer C-c doesn't work as a copy action (though it works globally
> as I set). And this is not surprising. I understand that major modes
> have priority over the global one. What is the best idea to make my keys
> more reliable? One way is to change all the major and minor modes, but
> it's a big load of work and code. Another way is to create my own minor
> mode key bindings and make it be turned on by default, and I managed to
> find how it should be done ("init-value" and "global" should be non-nil,
> in the "define-minor-mode" call). So I hope I'm somewhere close to the
> solution. Here is my function call with an example of C-c rebinding:
>
> (define-minor-mode ttkeys-mode "My key bindings"
> :init-value 1 :lighter " TT" :global 1
> :keymap
> '(
> ("C-c" . #'kill-ring-save)
> ("C-a" . #'mark-whole-buffer)
> )
> )
>
> The TT mode is being shown normally, I can switch in on and off, but the
> C-c and C-a don't work as I told them to. I tried to vary signs like #
> and ', but no result. What am I doing wrong?
>
> And, maybe there is some other advice that you could give to make my
> keys more reliable (make them work everywhere in Emacs)? Don't offer a
> CUA mode, I know about it, but it doesn't meet my needs.
I am not sure it addresses your question (in particular, I do not redefine
C-c), and I have read that this way is frowned upon, but here is what I do:
;; First:
(defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
;; Then all my keys like that:
(define-key my-keys-minor-mode-map "\M-." 'scroll-up)
--
EOST (École et Observatoire des Sciences de la Terre)
ITE (Institut Terre & Environnement) | alain.cochard@unistra.fr
5 rue René Descartes | Phone: +33 (0)3 68 85 50 44
F-67084 Strasbourg Cedex, France | bureau 110, ancien bât.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [External] : Q1 - the keys' bindings to work more widely
2024-12-15 2:15 ` [External] : " Drew Adams
@ 2024-12-16 23:11 ` Tatsu Takamaro
2024-12-16 23:55 ` Drew Adams via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 8+ messages in thread
From: Tatsu Takamaro @ 2024-12-16 23:11 UTC (permalink / raw)
To: Drew Adams, help-gnu-emacs@gnu.org
>>See also the Emacs manual (`C-h r'), node `CUA Bindings'.
As I told: "Don't offer a CUA mode, I know about it, but it doesn't meet
my needs."
I've read conventions, but did not find any answer to my questions. The
only thing that may be close to it is about "Sequences consisting
ofC-cfollowed by...", but it is irrelevant because 1) My "C-c" is not
followed by anything, 2) I don't make any plugin for other users, I just
try to set Emacs _for myself_. All the World uses Ctrl + c for copy, so
the whole world would not sag under one program.
Anyway, my question here is why the key bindings in my minor mode don't
work. Is there some syntax mistake? Lets' for example change them to others:
(define-minor-mode ttkeys-mode "Normal key bindings"
:init-value 1 :lighter " TT" :global 1
:keymap
'(
("a" . #'kill-ring-save)
)
)
Well, this variant doesn't work either. I get the message: "Wrong type
argument: commandp, #'kill-ring-save"
вс, 15.12.2024 5:15, Drew Adams пишет:
>> I would like to have my keys (my bindings)
>> working more widely so that I could trust them more. But for now some of
>> them don't work. E. g. in a Help buffer C-c doesn't work as a copy
>> action (though it works globally as I set). And this is not surprising.
>> I understand that major modes have priority over the global one. What is
>> the best idea to make my keys more reliable? One way is to change all
>> the major and minor modes, but it's a big load of work and code. Another
>> way is to create my own minor mode key bindings and make it be turned on
>> by default, and I managed to find how it should be done ("init-value"
>> and "global" should be non-nil, in the "define-minor-mode" call). So I
>> hope I'm somewhere close to the solution. Here is my function call with
>> an example of C-c rebinding:
>>
>> (define-minor-mode ttkeys-mode "My key bindings"
>> :init-value 1 :lighter " TT" :global 1
>> :keymap
>> '(
>> ("C-c" . #'kill-ring-save)
>> ("C-a" . #'mark-whole-buffer)
>> )
>> )
>>
>> The TT mode is being shown normally, I can switch in on and off, but the
>> C-c and C-a don't work as I told them to. I tried to vary signs like #
>> and ', but no result. What am I doing wrong?
>>
>> And, maybe there is some other advice that you could give to make my
>> keys more reliable (make them work everywhere in Emacs)? Don't offer a
>> CUA mode, I know about it, but it doesn't meet my needs.
> See node `Key Binding Conventions' in the Elisp manual:
>
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html
>
> That's `C-h i m elisp RET', then `g key binding conventions RET'.
>
> See also the Emacs manual (`C-h r'), node `CUA Bindings'.
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [External] : Q1 - the keys' bindings to work more widely
2024-12-16 23:11 ` Tatsu Takamaro
@ 2024-12-16 23:55 ` Drew Adams via Users list for the GNU Emacs text editor
2024-12-17 0:05 ` Drew Adams
0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams via Users list for the GNU Emacs text editor @ 2024-12-16 23:55 UTC (permalink / raw)
To: Tatsu Takamaro, help-gnu-emacs@gnu.org
Below.
I've read conventions, but did not find any answer to my questions. The only thing that may be close to it is about "Sequences consisting of C-c followed by...", but it is irrelevant because 1) My "C-c" is not followed by anything, 2) I don't make any plugin for other users, I just try to set Emacs for myself. All the World uses Ctrl + c for copy, so the whole world would not sag under one program.
A user can use any keys s?he likes. That Elisp convention tells you which keys are reserved for users. Other keys (not reserved for users) are likely to have bindings provided by Emacs or packages, so if you bind them to different keys you might change some behavior. That's all - just useful to know, for users too.
Anyway, my question here is why the key bindings in my minor mode don't work. Is there some syntax mistake? Lets' for example change them to others:
(define-minor-mode ttkeys-mode "Normal key bindings"
:init-value 1 :lighter " TT" :global 1
:keymap
'(
("a" . #'kill-ring-save)
)
)
This isn't a keymap: '(("a" . #'kill-ring-save)))
(keymapp '(("a" . #'kill-ring-save))) ; returns nil
This is a keymap: '(keymap ("a" . #'kill-ring-save)))
(keymapp '(keymap ("a" . #'kill-ring-save))) ; returns t
Well, this variant doesn't work either. I get the message: "Wrong type argument: commandp, #'kill-ring-save"
Yes, that too. You can't bind non-interactive functions to keys.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [External] : Q1 - the keys' bindings to work more widely
2024-12-16 23:55 ` Drew Adams via Users list for the GNU Emacs text editor
@ 2024-12-17 0:05 ` Drew Adams
2024-12-17 0:16 ` Tatsu Takamaro
0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2024-12-17 0:05 UTC (permalink / raw)
To: Drew Adams, Tatsu Takamaro, help-gnu-emacs@gnu.org
Reformatting...
___
Below.
> I've read conventions, but did not find any answer to my questions. The
> only thing that may be close to it is about "Sequences consisting of C-c
> followed by...", but it is irrelevant because 1) My "C-c" is not followed
> by anything, 2) I don't make any plugin for other users, I just try to
> set Emacs for myself. All the World uses Ctrl + c for copy, so the whole
> world would not sag under one program.
A user can use any keys s?he likes. That Elisp convention tells you which
keys are reserved for users. Other keys (not reserved for users) are
likely to have bindings provided by Emacs or packages, so if you bind
them to different keys you might change some behavior. That's all - just
useful to know, for users too.
> Anyway, my question here is why the key bindings in my minor mode don't
> work. Is there some syntax mistake? Lets' for example change them to
> others:
>
> (define-minor-mode ttkeys-mode "Normal key bindings"
> :init-value 1 :lighter " TT" :global 1
> :keymap
> '(
> ("a" . #'kill-ring-save)
> )
> )
This isn't a keymap: '(("a" . #'kill-ring-save)))
(keymapp '(("a" . #'kill-ring-save))) ; returns nil
This is a keymap: '(keymap ("a" . #'kill-ring-save)))
(keymapp '(keymap ("a" . #'kill-ring-save))) ; returns t
> Well, this variant doesn't work either. I get the message: "Wrong type
> argument: commandp, #'kill-ring-save"
Yes, that too. You can't bind non-interactive functions to keys.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [External] : Q1 - the keys' bindings to work more widely
2024-12-17 0:05 ` Drew Adams
@ 2024-12-17 0:16 ` Tatsu Takamaro
2024-12-17 2:17 ` Drew Adams
0 siblings, 1 reply; 8+ messages in thread
From: Tatsu Takamaro @ 2024-12-17 0:16 UTC (permalink / raw)
To: Drew Adams, help-gnu-emacs@gnu.org
>> You can't bind non-interactive functions to keys.
But I rebound globally and this works:
*(keymap-global-unset "C-c")**
**(keymap-global-set "C-c" #'kill-ring-save)*
*
*
*
*
>> This is a keymap: '(keymap ("a" . #'kill-ring-save)))
Do you mean this:
*(define-minor-mode ttkeys-mode "Normal key bindings"**
**:init-value 1 :lighter " TT" :global 1**
**:keymap**
**'(keymap ("a" . #'kill-ring-save)))*
Doesn't work either.
вт, 17.12.2024 3:05, Drew Adams пишет:
> Reformatting...
> ___
>
> Below.
>
>> I've read conventions, but did not find any answer to my questions. The
>> only thing that may be close to it is about "Sequences consisting of C-c
>> followed by...", but it is irrelevant because 1) My "C-c" is not followed
>> by anything, 2) I don't make any plugin for other users, I just try to
>> set Emacs for myself. All the World uses Ctrl + c for copy, so the whole
>> world would not sag under one program.
> A user can use any keys s?he likes. That Elisp convention tells you which
> keys are reserved for users. Other keys (not reserved for users) are
> likely to have bindings provided by Emacs or packages, so if you bind
> them to different keys you might change some behavior. That's all - just
> useful to know, for users too.
>
>> Anyway, my question here is why the key bindings in my minor mode don't
>> work. Is there some syntax mistake? Lets' for example change them to
>> others:
>>
>> (define-minor-mode ttkeys-mode "Normal key bindings"
>> :init-value 1 :lighter " TT" :global 1
>> :keymap
>> '(
>> ("a" . #'kill-ring-save)
>> )
>> )
> This isn't a keymap: '(("a" . #'kill-ring-save)))
>
> (keymapp '(("a" . #'kill-ring-save))) ; returns nil
>
> This is a keymap: '(keymap ("a" . #'kill-ring-save)))
>
> (keymapp '(keymap ("a" . #'kill-ring-save))) ; returns t
>
>> Well, this variant doesn't work either. I get the message: "Wrong type
>> argument: commandp, #'kill-ring-save"
> Yes, that too. You can't bind non-interactive functions to keys.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [External] : Q1 - the keys' bindings to work more widely
2024-12-17 0:16 ` Tatsu Takamaro
@ 2024-12-17 2:17 ` Drew Adams
0 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2024-12-17 2:17 UTC (permalink / raw)
To: Tatsu Takamaro, help-gnu-emacs@gnu.org
>> This is a keymap: '(keymap ("a" . #'kill-ring-save)))
It satisfies `keymapp', at least. ;-) But unfortunately,
`keymapp' doesn't guarantee a keymap. The Elisp manual
says it allows any list whose car is `keymap':
More precisely, this function tests for a list whose CAR is
‘keymap’, or for a symbol whose function definition satisfies
‘keymapp’.
> Do you mean this:
>
> (define-minor-mode ttkeys-mode "Normal key bindings"
>:init-value 1 :lighter " TT" :global 1
>:keymap '(keymap ("a" . #'kill-ring-save)))
>
> Doesn't work either.
Try this:
:keymap '(keymap (?a . kill-ring-save)))
or this:
:keymap '(keymap (97 . kill-ring-save)))
https://www.gnu.org/software/emacs/manual/html_node/elisp/Format-of-Keymaps.html
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-12-17 2:17 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-14 23:46 Q1 - the keys' bindings to work more widely Tatsu Takamaro
2024-12-15 2:15 ` [External] : " Drew Adams
2024-12-16 23:11 ` Tatsu Takamaro
2024-12-16 23:55 ` Drew Adams via Users list for the GNU Emacs text editor
2024-12-17 0:05 ` Drew Adams
2024-12-17 0:16 ` Tatsu Takamaro
2024-12-17 2:17 ` Drew Adams
2024-12-15 10:05 ` Alain.Cochard
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).