unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Remapping keys and creating my own keymap \\ too complicated\\
@ 2024-12-03 16:59 Tatsu Takamaro
  2024-12-04  7:43 ` Jean Louis
  2024-12-04 16:25 ` Jean Louis
  0 siblings, 2 replies; 18+ messages in thread
From: Tatsu Takamaro @ 2024-12-03 16:59 UTC (permalink / raw)
  To: help-gnu-emacs

Good afternoon, I'm trying to reassign keys but have run into a number 
of difficulties and questions about the best way to do it and how to do 
it correctly.
1. Do I understand correctly that if I want to change hotkeys, the most 
logical, sensible and ‘beautiful’ way to do it is to create my own key 
map? That is, I create key mappings to commands, save it all in a file, 
and then just plug that map in instead of the default one (via the 
appropriate command in the ‘.emacs’ file). This seems like a more proper 
way, better than making changes to the default key map. Right?

2. Your original manual has a lot of complicated text on this topic. I 
honestly tried to figure it out on my own, though. However, I eventually 
found an article that explains in simple words how to do it. Here is 
that article: 
https://emacspal.com/extending-emacs-functionally-with-user-defined-keymaps/
However, I saw a large number of differences between the article and 
your official documentation. I already wrote to Emacs Pal (the authors 
of the article), but they haven't replied for a week now. On the one 
hand, the article is clear, but the syntax of the commands does not 
match your documentation on many points.

For example, here they describe the define-keymap command:
*
**(define-keymap my-map**
**  "Binding description."**
**  :bind (("C-c C-a" . select-all)**
**         ("C-c C-f" . find-file)))*

And here's an example from the official docs:
*
**         (define-keymap :full t**
**  "g" #'eww-reload**
**  :menu '("Eww"**
**          ["Exit" quit-window t]**
**          ["Reload" eww-reload t]))*

Huge difference. For example: 1) you don't specify the name of the 
keymap right after define-keymap. How do you plan to call it later, if 
not by name? And Emacs itself does not provide the name of the map in 
the command description either. 2) they probably have a description 
after the map name (line ‘Binding description.’), but official syntax 
does not provide any description in this place. 3) further they have the 
:bind key, which is also not officially provided. And other things, as 
you can see from the examples.
Thus, I am even more confused.

3. So how do I create my key map correctly (in simple words)? I need a 
global map to replace the default one. But I don't want to prescribe all 
combinations at all, but only those that I want to set my own. The rest 
of the combinations should remain as in the default one.


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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-03 16:59 Remapping keys and creating my own keymap \\ too complicated\\ Tatsu Takamaro
@ 2024-12-04  7:43 ` Jean Louis
  2024-12-04 15:49   ` Tatsu Takamaro
  2024-12-04 15:55   ` Tatsu Takamaro
  2024-12-04 16:25 ` Jean Louis
  1 sibling, 2 replies; 18+ messages in thread
From: Jean Louis @ 2024-12-04  7:43 UTC (permalink / raw)
  To: Tatsu Takamaro; +Cc: help-gnu-emacs

Here is example how I have defined some global keys:

(defvar cf-map)
(define-prefix-command 'cf-map)
(keymap-global-set "C-c p" 'cf-map)
(keymap-set cf-map "l" #'cf-people-last-few)
(keymap-set cf-map "N" #'cf-people-add)
(keymap-set cf-map "P" #'cf-people-search-ts-query)
(keymap-set cf-map "a" #'cf-people-list-by-name)
(keymap-set cf-map "c" #'cf-people-by-country)
(keymap-set cf-map "d" #'cf-people-by-description)
(keymap-set cf-map "f" #'cf-find-files-of-person)
(keymap-set cf-map "i" #'cf-people-by-interactions)
(keymap-set cf-map "j" #'cf-people-by-phone)
(keymap-set cf-map "m" #'cf-messages-repeat-to-last-person-sent)
(keymap-set cf-map "n" #'cf-people-by-name)
(keymap-set cf-map "p" #'cf-people)
(keymap-set cf-map "r" #'cf-people-by-rank)
(keymap-set cf-map "w" #'cf-people-not-in-any-list)

And here is example how I have defined some menus:

(defvar cf-people-menu-find-people
  (list "Find people"
	["Find people" cf-people t]
	["Find people by name" cf-people-by-name t]
	["Find people by query" cf-people-search-ts-query t]
	["Find files of person" cf-find-files-of-person t]
	["Find people by description" cf-people-by-description t]))

(defvar cf-people-menu-list-of-people
  (list "List of people"
	["Find people by rank" cf-people-by-rank t]
	["Latest contacts" cf-people-last-few t]
	["List contacts by interactions" cf-people-by-interactions t]
	["People by country" cf-people-by-country t]
	["People without account" cf-people-not-in-any-list t]
	["People from last 60 days without valid email" cf-people-recent-with-failed-email-addresses t]))

where above functions are used in the following:

(easy-menu-define cf-people-menu  global-map "People menu"
  (list "People"
	cf-people-menu-find-people
	cf-people-menu-list-of-people
	cf-people-menu-collaborate
	cf-people-menu-add-new-people
	cf-people-menu-edit-people
	cf-mailing-list-menu
	cf-central-files-menu
	rcd-db-database-maintenance-menu
	;;hyperscope-menu-module-for-other-menu
	))

-- 
Jean Louis



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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-04  7:43 ` Jean Louis
@ 2024-12-04 15:49   ` Tatsu Takamaro
  2024-12-04 15:55   ` Tatsu Takamaro
  1 sibling, 0 replies; 18+ messages in thread
From: Tatsu Takamaro @ 2024-12-04 15:49 UTC (permalink / raw)
  To: help-gnu-emacs

Well, though this it interesting, it is still far from what I asked. 
There were 3 points which I want to understand. Not an example, but an 
explaination according to my exact questions.

You know, the answers that I find in the Internet are too easy and 
irrelevant, but the official docs info is too difficult and 
irrelevant... So I need someting in between, maybe.

ср, 04.12.2024 10:43, Jean Louis пишет:
> Here is example how I have defined some global keys:
>
> (defvar cf-map)
> (define-prefix-command 'cf-map)
> (keymap-global-set "C-c p" 'cf-map)
> (keymap-set cf-map "l" #'cf-people-last-few)
> (keymap-set cf-map "N" #'cf-people-add)
> (keymap-set cf-map "P" #'cf-people-search-ts-query)
> (keymap-set cf-map "a" #'cf-people-list-by-name)
> (keymap-set cf-map "c" #'cf-people-by-country)
> (keymap-set cf-map "d" #'cf-people-by-description)
> (keymap-set cf-map "f" #'cf-find-files-of-person)
> (keymap-set cf-map "i" #'cf-people-by-interactions)
> (keymap-set cf-map "j" #'cf-people-by-phone)
> (keymap-set cf-map "m" #'cf-messages-repeat-to-last-person-sent)
> (keymap-set cf-map "n" #'cf-people-by-name)
> (keymap-set cf-map "p" #'cf-people)
> (keymap-set cf-map "r" #'cf-people-by-rank)
> (keymap-set cf-map "w" #'cf-people-not-in-any-list)
>
> And here is example how I have defined some menus:
>
> (defvar cf-people-menu-find-people
>    (list "Find people"
> 	["Find people" cf-people t]
> 	["Find people by name" cf-people-by-name t]
> 	["Find people by query" cf-people-search-ts-query t]
> 	["Find files of person" cf-find-files-of-person t]
> 	["Find people by description" cf-people-by-description t]))
>
> (defvar cf-people-menu-list-of-people
>    (list "List of people"
> 	["Find people by rank" cf-people-by-rank t]
> 	["Latest contacts" cf-people-last-few t]
> 	["List contacts by interactions" cf-people-by-interactions t]
> 	["People by country" cf-people-by-country t]
> 	["People without account" cf-people-not-in-any-list t]
> 	["People from last 60 days without valid email" cf-people-recent-with-failed-email-addresses t]))
>
> where above functions are used in the following:
>
> (easy-menu-define cf-people-menu  global-map "People menu"
>    (list "People"
> 	cf-people-menu-find-people
> 	cf-people-menu-list-of-people
> 	cf-people-menu-collaborate
> 	cf-people-menu-add-new-people
> 	cf-people-menu-edit-people
> 	cf-mailing-list-menu
> 	cf-central-files-menu
> 	rcd-db-database-maintenance-menu
> 	;;hyperscope-menu-module-for-other-menu
> 	))
>


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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-04  7:43 ` Jean Louis
  2024-12-04 15:49   ` Tatsu Takamaro
@ 2024-12-04 15:55   ` Tatsu Takamaro
  2024-12-04 16:06     ` Robert Pluim
  1 sibling, 1 reply; 18+ messages in thread
From: Tatsu Takamaro @ 2024-12-04 15:55 UTC (permalink / raw)
  To: help-gnu-emacs

So, the concrete questions that bother me are as they were in the 
original question. Like 1) Is my idea to create an own keymap the best 
(or is it OK just to change the defaults)?, 2) What about the 
differenced in the approach and the syntax matters, 3) What is the 
correct way of creating my keymap. Sould it be inside of the ".emacs" 
file or a separate one? What commands should I use?

And yes, I read the manual, but it's too difficult... Maybe it's just OK 
to change the defaults? No?

ср, 04.12.2024 10:43, Jean Louis пишет:
> Here is example how I have defined some global keys:
>
> (defvar cf-map)
> (define-prefix-command 'cf-map)
> (keymap-global-set "C-c p" 'cf-map)
> (keymap-set cf-map "l" #'cf-people-last-few)
> (keymap-set cf-map "N" #'cf-people-add)
> (keymap-set cf-map "P" #'cf-people-search-ts-query)
> (keymap-set cf-map "a" #'cf-people-list-by-name)
> (keymap-set cf-map "c" #'cf-people-by-country)
> (keymap-set cf-map "d" #'cf-people-by-description)
> (keymap-set cf-map "f" #'cf-find-files-of-person)
> (keymap-set cf-map "i" #'cf-people-by-interactions)
> (keymap-set cf-map "j" #'cf-people-by-phone)
> (keymap-set cf-map "m" #'cf-messages-repeat-to-last-person-sent)
> (keymap-set cf-map "n" #'cf-people-by-name)
> (keymap-set cf-map "p" #'cf-people)
> (keymap-set cf-map "r" #'cf-people-by-rank)
> (keymap-set cf-map "w" #'cf-people-not-in-any-list)
>
> And here is example how I have defined some menus:
>
> (defvar cf-people-menu-find-people
>    (list "Find people"
> 	["Find people" cf-people t]
> 	["Find people by name" cf-people-by-name t]
> 	["Find people by query" cf-people-search-ts-query t]
> 	["Find files of person" cf-find-files-of-person t]
> 	["Find people by description" cf-people-by-description t]))
>
> (defvar cf-people-menu-list-of-people
>    (list "List of people"
> 	["Find people by rank" cf-people-by-rank t]
> 	["Latest contacts" cf-people-last-few t]
> 	["List contacts by interactions" cf-people-by-interactions t]
> 	["People by country" cf-people-by-country t]
> 	["People without account" cf-people-not-in-any-list t]
> 	["People from last 60 days without valid email" cf-people-recent-with-failed-email-addresses t]))
>
> where above functions are used in the following:
>
> (easy-menu-define cf-people-menu  global-map "People menu"
>    (list "People"
> 	cf-people-menu-find-people
> 	cf-people-menu-list-of-people
> 	cf-people-menu-collaborate
> 	cf-people-menu-add-new-people
> 	cf-people-menu-edit-people
> 	cf-mailing-list-menu
> 	cf-central-files-menu
> 	rcd-db-database-maintenance-menu
> 	;;hyperscope-menu-module-for-other-menu
> 	))
>


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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-04 15:55   ` Tatsu Takamaro
@ 2024-12-04 16:06     ` Robert Pluim
  2024-12-04 16:37       ` Tatsu Takamaro
  0 siblings, 1 reply; 18+ messages in thread
From: Robert Pluim @ 2024-12-04 16:06 UTC (permalink / raw)
  To: Tatsu Takamaro; +Cc: help-gnu-emacs

>>>>> On Wed, 4 Dec 2024 18:55:00 +0300, Tatsu Takamaro <tatsu.takamaro@gmail.com> said:

    Tatsu> So, the concrete questions that bother me are as they were in the
    Tatsu> original question. Like 1) Is my idea to create an own keymap the best
    Tatsu> (or is it OK just to change the defaults)?, 2) What about the
    Tatsu> differenced in the approach and the syntax matters, 3) What is the
    Tatsu> correct way of creating my keymap. Sould it be inside of the ".emacs"
    Tatsu> file or a separate one? What commands should I use?

If you want to change global bindings, you can do that in the global
map with eg `global-set-key' or `keymap-global-set' in more recent
emacs. Iʼd use the latter, if possible, as the syntax of key sequences
it uses is easier to write.

Remember: your .emacs is yours, and changing defaults to suit you
(including default bindings) is encouraged.

Robert
-- 



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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-03 16:59 Remapping keys and creating my own keymap \\ too complicated\\ Tatsu Takamaro
  2024-12-04  7:43 ` Jean Louis
@ 2024-12-04 16:25 ` Jean Louis
  2024-12-04 16:57   ` Tatsu Takamaro
  1 sibling, 1 reply; 18+ messages in thread
From: Jean Louis @ 2024-12-04 16:25 UTC (permalink / raw)
  To: Tatsu Takamaro; +Cc: help-gnu-emacs

I suggest that you say which key bindings you would like to set, as
that way it will be possible to understand what you wish to achieve,
and then answer will come easier.

-- 
Jean Louis



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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-04 16:06     ` Robert Pluim
@ 2024-12-04 16:37       ` Tatsu Takamaro
  2024-12-04 16:40         ` Robert Pluim
  0 siblings, 1 reply; 18+ messages in thread
From: Tatsu Takamaro @ 2024-12-04 16:37 UTC (permalink / raw)
  To: Robert Pluim; +Cc: help-gnu-emacs

Thank you! OK, so once again, am I right that if I just want to set my 
own key bindings (not changing all of them, but just some), then it's 
better to just use keymap-global-set (anticipated by 
keymap-global-unset)? And I may don't care about touching and changing 
the default settings?

And can I be sure that everything is all right when I change the global 
keymap, won't I be necessarily have to reinstall Emacs everytime I do 
something wrong (if I do...) with the global key assignment?

Is it just a matter of the ".emacs" file, and all wiil turn right if I 
just zeroize the ".emacs" settings?

And if so, I can just have my own settings inside of the ".emacs" file, 
and if I go to another computer I can just bring my ".emacs" file with 
me and it will work the way I want? And so it means I don't need a 
separate keymap file, do I?

ср, 04.12.2024 19:06, Robert Pluim пишет:
>>>>>> On Wed, 4 Dec 2024 18:55:00 +0300, Tatsu Takamaro<tatsu.takamaro@gmail.com>  said:
>      Tatsu> So, the concrete questions that bother me are as they were in the
>      Tatsu> original question. Like 1) Is my idea to create an own keymap the best
>      Tatsu> (or is it OK just to change the defaults)?, 2) What about the
>      Tatsu> differenced in the approach and the syntax matters, 3) What is the
>      Tatsu> correct way of creating my keymap. Sould it be inside of the ".emacs"
>      Tatsu> file or a separate one? What commands should I use?
>
> If you want to change global bindings, you can do that in the global
> map with eg `global-set-key' or `keymap-global-set' in more recent
> emacs. Iʼd use the latter, if possible, as the syntax of key sequences
> it uses is easier to write.
>
> Remember: your .emacs is yours, and changing defaults to suit you
> (including default bindings) is encouraged.
>
> Robert


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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-04 16:37       ` Tatsu Takamaro
@ 2024-12-04 16:40         ` Robert Pluim
  2024-12-04 17:05           ` Tatsu Takamaro
  0 siblings, 1 reply; 18+ messages in thread
From: Robert Pluim @ 2024-12-04 16:40 UTC (permalink / raw)
  To: Tatsu Takamaro; +Cc: help-gnu-emacs

>>>>> On Wed, 4 Dec 2024 19:37:11 +0300, Tatsu Takamaro <tatsu.takamaro@gmail.com> said:

    Tatsu> Thank you! OK, so once again, am I right that if I just want to set my
    Tatsu> own key bindings (not changing all of them, but just some), then it's
    Tatsu> better to just use keymap-global-set (anticipated by
    Tatsu> keymap-global-unset)? And I may don't care about touching and changing
    Tatsu> the default settings?

Yes.

    Tatsu> And can I be sure that everything is all right when I change the
    Tatsu> global keymap, won't I be necessarily have to reinstall Emacs
    Tatsu> everytime I do something wrong (if I do...) with the global key
    Tatsu> assignment?

    Tatsu> Is it just a matter of the ".emacs" file, and all wiil turn right if I
    Tatsu> just zeroize the ".emacs" settings?

Right. You can always move the .emacs file out of the way, or start
emacs with the "-Q" flag, which will prevent it from loading .emacs

    Tatsu> And if so, I can just have my own settings inside of the ".emacs"
    Tatsu> file, and if I go to another computer I can just bring my ".emacs"
    Tatsu> file with me and it will work the way I want? And so it means I don't
    Tatsu> need a separate keymap file, do I?

Exactly. Iʼve been carrying my .emacs around for decades over dozens
of machines.

Robert
-- 



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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-04 16:25 ` Jean Louis
@ 2024-12-04 16:57   ` Tatsu Takamaro
  0 siblings, 0 replies; 18+ messages in thread
From: Tatsu Takamaro @ 2024-12-04 16:57 UTC (permalink / raw)
  To: help-gnu-emacs

Answering that question, I just wanna set the keys I got accustomed to:

1/ С-a to extract all

2/ C-c to copy

3/ C-v to paste

4/ C-x to cut

5/ C-o to open

6/ C-s to save

7/ C-f to find something in the text

8/ C-z to cancle

9/ C-q to quit Emacs (C-x-c)

And! I would also like to set new binding on the commands that were (or 
would have been) set free (like C-a to move-beginning-of-line).

I respect the "development history" that lead to your default key 
bindings, but I'm 40 y.o. and I just don't want to change my fundamental 
habits. And btw, I know about your CUA mode. But it doesn't fit my needs 
for two main reasons: it offers not all of the hotkeys I mentioned above 
and it doen't work everywhere. But the CUA mode is a good idea, apparently.

ср, 04.12.2024 19:25, Jean Louis пишет:
> I suggest that you say which key bindings you would like to set, as
> that way it will be possible to understand what you wish to achieve,
> and then answer will come easier.
>


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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-04 16:40         ` Robert Pluim
@ 2024-12-04 17:05           ` Tatsu Takamaro
  2024-12-05 10:25             ` Robert Pluim
  0 siblings, 1 reply; 18+ messages in thread
From: Tatsu Takamaro @ 2024-12-04 17:05 UTC (permalink / raw)
  To: Robert Pluim; +Cc: help-gnu-emacs

Thank you, Robert, it is a complete answer to my first question. And 
thus maybe to all the others, logically.

So, I'll set my new key bindings in .emacs file and I'll be happy with it.

P. S. But it's still interestin though why is there such a difference in 
the description of the *define-keymap* command in the official docs and 
in the Emacs Pal article. I suppose there must be an exact description 
for the command in the manual, which is the only true. So are they in 
Emacs Pal wrong?

ср, 04.12.2024 19:40, Robert Pluim пишет:
>>>>>> On Wed, 4 Dec 2024 19:37:11 +0300, Tatsu Takamaro<tatsu.takamaro@gmail.com>  said:
>      Tatsu> Thank you! OK, so once again, am I right that if I just want to set my
>      Tatsu> own key bindings (not changing all of them, but just some), then it's
>      Tatsu> better to just use keymap-global-set (anticipated by
>      Tatsu> keymap-global-unset)? And I may don't care about touching and changing
>      Tatsu> the default settings?
>
> Yes.
>
>      Tatsu> And can I be sure that everything is all right when I change the
>      Tatsu> global keymap, won't I be necessarily have to reinstall Emacs
>      Tatsu> everytime I do something wrong (if I do...) with the global key
>      Tatsu> assignment?
>
>      Tatsu> Is it just a matter of the ".emacs" file, and all wiil turn right if I
>      Tatsu> just zeroize the ".emacs" settings?
>
> Right. You can always move the .emacs file out of the way, or start
> emacs with the "-Q" flag, which will prevent it from loading .emacs
>
>      Tatsu> And if so, I can just have my own settings inside of the ".emacs"
>      Tatsu> file, and if I go to another computer I can just bring my ".emacs"
>      Tatsu> file with me and it will work the way I want? And so it means I don't
>      Tatsu> need a separate keymap file, do I?
>
> Exactly. Iʼve been carrying my .emacs around for decades over dozens
> of machines.
>
> Robert


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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-04 17:05           ` Tatsu Takamaro
@ 2024-12-05 10:25             ` Robert Pluim
  2024-12-05 18:08               ` Tatsu Takamaro
  0 siblings, 1 reply; 18+ messages in thread
From: Robert Pluim @ 2024-12-05 10:25 UTC (permalink / raw)
  To: Tatsu Takamaro; +Cc: help-gnu-emacs

>>>>> On Wed, 4 Dec 2024 20:05:28 +0300, Tatsu Takamaro <tatsu.takamaro@gmail.com> said:

    Tatsu> P. S. But it's still interestin though why is there such a difference
    Tatsu> in the description of the *define-keymap* command in the official docs
    Tatsu> and in the Emacs Pal article. I suppose there must be an exact
    Tatsu> description for the command in the manual, which is the only true. So
    Tatsu> are they in Emacs Pal wrong?

What is 'Emacs Pal'? Can you provide a link?

Robert
-- 



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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-05 10:25             ` Robert Pluim
@ 2024-12-05 18:08               ` Tatsu Takamaro
  2024-12-06  9:57                 ` Robert Pluim
  0 siblings, 1 reply; 18+ messages in thread
From: Tatsu Takamaro @ 2024-12-05 18:08 UTC (permalink / raw)
  To: Robert Pluim; +Cc: help-gnu-emacs

I gave a link to an article in my original message. Here it is: 
https://emacspal.com/extending-emacs-functionally-with-user-defined-keymaps/

чт, 05.12.2024 13:25, Robert Pluim пишет:
>>>>>> On Wed, 4 Dec 2024 20:05:28 +0300, Tatsu Takamaro<tatsu.takamaro@gmail.com>  said:
>      Tatsu> P. S. But it's still interestin though why is there such a difference
>      Tatsu> in the description of the *define-keymap* command in the official docs
>      Tatsu> and in the Emacs Pal article. I suppose there must be an exact
>      Tatsu> description for the command in the manual, which is the only true. So
>      Tatsu> are they in Emacs Pal wrong?
>
> What is 'Emacs Pal'? Can you provide a link?
>
> Robert


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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-05 18:08               ` Tatsu Takamaro
@ 2024-12-06  9:57                 ` Robert Pluim
  2024-12-06 10:38                   ` Jean Louis
  0 siblings, 1 reply; 18+ messages in thread
From: Robert Pluim @ 2024-12-06  9:57 UTC (permalink / raw)
  To: Tatsu Takamaro; +Cc: help-gnu-emacs

>>>>> On Thu, 5 Dec 2024 21:08:41 +0300, Tatsu Takamaro <tatsu.takamaro@gmail.com> said:

    Tatsu> I gave a link to an article in my original message. Here it is:
    Tatsu> https://emacspal.com/extending-emacs-functionally-with-user-defined-keymaps/

Ah, Iʼd missed that.

I object to a lot of the advice given in that article (and the other
articles on that site are equally objectionable or inaccurate), so Iʼd
recommend you avoid it.

Robert
-- 



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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-06  9:57                 ` Robert Pluim
@ 2024-12-06 10:38                   ` Jean Louis
  2024-12-06 13:18                     ` Robert Pluim
  0 siblings, 1 reply; 18+ messages in thread
From: Jean Louis @ 2024-12-06 10:38 UTC (permalink / raw)
  To: help-gnu-emacs, Robert Pluim, Tatsu Takamaro

On December 6, 2024 12:57:36 PM GMT+03:00, Robert Pluim <rpluim@gmail.com> wrote:
>>>>>> On Thu, 5 Dec 2024 21:08:41 +0300, Tatsu Takamaro <tatsu.takamaro@gmail.com> said:
>
>    Tatsu> I gave a link to an article in my original message. Here it is:
>    Tatsu> https://emacspal.com/extending-emacs-functionally-with-user-defined-keymaps/
>
>Ah, Iʼd missed that.
>
>I object to a lot of the advice given in that article (and the other
>articles on that site are equally objectionable or inaccurate), so Iʼd
>recommend you avoid it.
>
>Robert

There is page about the global visual line mode which speaks about the global editing over all files at once which is factually totally incorrect. Visual line mode is used for the word wrap and not global editing over files.

That page was generated by neglectful artificial intelligence. 


Jean



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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-06 10:38                   ` Jean Louis
@ 2024-12-06 13:18                     ` Robert Pluim
  2024-12-08 16:16                       ` Tatsu Takamaro
  0 siblings, 1 reply; 18+ messages in thread
From: Robert Pluim @ 2024-12-06 13:18 UTC (permalink / raw)
  To: Jean Louis; +Cc: help-gnu-emacs, Tatsu Takamaro

>>>>> On Fri, 06 Dec 2024 13:38:17 +0300, Jean Louis <bugs@gnu.support> said:
    Jean> That page was generated by neglectful artificial intelligence. 

I suspected as much, but didnʼt want to spend any effort on confirming
it. 😀

Robert
-- 



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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-06 13:18                     ` Robert Pluim
@ 2024-12-08 16:16                       ` Tatsu Takamaro
  2024-12-08 23:07                         ` Stephen Berman
  0 siblings, 1 reply; 18+ messages in thread
From: Tatsu Takamaro @ 2024-12-08 16:16 UTC (permalink / raw)
  To: Robert Pluim, Jean Louis; +Cc: help-gnu-emacs

I did as you said and just added some commands to an .emacs file. And 
everything worked untill I tried to change the C-x binding. Here is my 
exact code:

(keymap-global-unset "C-x")
(keymap-global-set "C-x" #'kill-region)
(keymap-set global-map "<apps>" 'ctl-x-map)

It seems logical, but it doesn't work properly. The Ctrl + x works just 
fine and cuts the selected fragment. Pressing Ctrl + x also doesn't have 
an effect as a C-x prefix (for example, keys C-x-s don't work to save). 
But then there is an unexpected behaviour. Pressing the Menu button 
(<apps>) doesn't act as C-x, and I can't use it to run commands that 
start with C-x. For example, I can't do save-buffer by pressing 
<apps>-s. Why is it so? What am I missing?


пт, 06.12.2024 16:18, Robert Pluim пишет:
>>>>>> On Fri, 06 Dec 2024 13:38:17 +0300, Jean Louis<bugs@gnu.support>  said:
>      Jean> That page was generated by neglectful artificial intelligence.
>
> I suspected as much, but didnʼt want to spend any effort on confirming
> it. 😀
>
> Robert


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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-08 16:16                       ` Tatsu Takamaro
@ 2024-12-08 23:07                         ` Stephen Berman
  2024-12-09 22:34                           ` Tatsu Takamaro
  0 siblings, 1 reply; 18+ messages in thread
From: Stephen Berman @ 2024-12-08 23:07 UTC (permalink / raw)
  To: Tatsu Takamaro; +Cc: Robert Pluim, Jean Louis, help-gnu-emacs

On Sun, 8 Dec 2024 19:16:02 +0300 Tatsu Takamaro <tatsu.takamaro@gmail.com> wrote:

> I did as you said and just added some commands to an .emacs file. And
> everything worked untill I tried to change the C-x binding. Here is my exact
> code:
>
> (keymap-global-unset "C-x")
> (keymap-global-set "C-x" #'kill-region)
> (keymap-set global-map "<apps>" 'ctl-x-map)
>
> It seems logical, but it doesn't work properly. The Ctrl + x works just fine
> and cuts the selected fragment. Pressing Ctrl + x also doesn't have an effect
> as a C-x prefix (for example, keys C-x-s don't work to save). But then there
> is an unexpected behaviour. Pressing the Menu button (<apps>) doesn't act as
> C-x, and I can't use it to run commands that start with C-x. For example, I
> can't do save-buffer by pressing <apps>-s. Why is it so? What am I missing?

`ctl-x-map' is a variable whose value is a keymap, and you want to bind
that value, so don't quote the name:

(keymap-set global-map "<apps>" ctl-x-map)

Steve Berman



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

* Re: Remapping keys and creating my own keymap \\ too complicated\\
  2024-12-08 23:07                         ` Stephen Berman
@ 2024-12-09 22:34                           ` Tatsu Takamaro
  0 siblings, 0 replies; 18+ messages in thread
From: Tatsu Takamaro @ 2024-12-09 22:34 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Robert Pluim, Jean Louis, help-gnu-emacs

Yes, true. Thanks, now it works. Well, that's what I have now:

(keymap-global-unset "C-q")
(keymap-global-set "C-q" #'save-buffers-kill-terminal)
(keymap-global-unset "<pause>")
(keymap-global-set "<pause>" #'quoted-insert)
(keymap-global-unset "C-a")
(keymap-global-set "C-a" #'mark-whole-buffer)
(keymap-global-unset "C-z")
(keymap-global-set "C-z" #'undo)
(keymap-global-unset "C-/")
(keymap-global-set "C-/" #'suspend-frame)
(keymap-global-unset "C-s")
(keymap-global-unset "C-f")
(keymap-global-set "C-s" #'save-buffer)
(keymap-global-set "C-f" #'isearch-forward)
(keymap-global-unset "C-x")
(keymap-global-set "C-x" #'kill-region)
(keymap-global-unset "<apps>")
(keymap-set global-map "<apps>" ctl-x-map)
(keymap-global-unset "C-c")
(keymap-global-set "C-c" #'kill-ring-save)
(keymap-global-unset "C-v")
(keymap-global-set "C-v" #'yank)
(keymap-global-unset "C-o")
(keymap-global-set "C-o" #'find-file)
(keymap-global-unset "M-o")
(keymap-global-set "M-o" #'open-line)

(keymap-global-unset "C-<left>")
(keymap-global-set "C-<left>" #'backward-sentence)
(keymap-global-unset "C-<right>")
(keymap-global-set "C-<right>" #'forward-sentence)
(keymap-global-unset "M-<up>")
(keymap-global-set "M-<up>" #'backward-paragraph)
(keymap-global-unset "M-<down>")
(keymap-global-set "M-<down>" #'forward-paragraph)
(keymap-global-unset "C-<up>")
(keymap-global-set "C-<up>" #'scroll-down-command)
(keymap-global-unset "C-<down>")
(keymap-global-set "C-<down>" #'scroll-up-command)
(keymap-global-unset "C-S-<left>")
(keymap-global-set "C-S-<left>" #'backward-kill-word)
(keymap-global-unset "C-S-<right>")
(keymap-global-set "C-S-<right>" #'kill-word)

The keys work. Not as ideal but work. The main problem is resolved. But 
if I may continue, there are some details that still bother me.

1. What if I want not to cut (or how you call it - kill) a word with 
"backward-kill-word" and "kill-word", but delete it (so as not to put 
the words into the exchange buffer)?

2. Commands "forward-sentence" and "backward-sentence" do not move by 
sentences actually. I tried in both Text and Fundamental modes. If there 
are two sentences in a line, they ignore the dot in the middle. I guess 
it is somehow connected with an internal mode's settings (what is 
considered to be a sentence). But it seems logical that when I'm in a 
Text mode, I await to treat literary sentences as sentences, where a dot 
sign is a delimiter.

3. I would like to have my keys working more widely so that I could 
trust them more. But for now (see my bindings above - they are all 
global) some of them don't work. Eg in a Help buffer C-c doesn't work as 
a copy action. 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, but I will have to turn it on in every buffer 
manually, which is also not very comfortable. What would you advice?

With respect.

Tony.

пн, 09.12.2024 2:07, Stephen Berman пишет:
> On Sun, 8 Dec 2024 19:16:02 +0300 Tatsu Takamaro<tatsu.takamaro@gmail.com>  wrote:
>
>> I did as you said and just added some commands to an .emacs file. And
>> everything worked untill I tried to change the C-x binding. Here is my exact
>> code:
>>
>> (keymap-global-unset "C-x")
>> (keymap-global-set "C-x" #'kill-region)
>> (keymap-set global-map "<apps>" 'ctl-x-map)
>>
>> It seems logical, but it doesn't work properly. The Ctrl + x works just fine
>> and cuts the selected fragment. Pressing Ctrl + x also doesn't have an effect
>> as a C-x prefix (for example, keys C-x-s don't work to save). But then there
>> is an unexpected behaviour. Pressing the Menu button (<apps>) doesn't act as
>> C-x, and I can't use it to run commands that start with C-x. For example, I
>> can't do save-buffer by pressing <apps>-s. Why is it so? What am I missing?
> `ctl-x-map' is a variable whose value is a keymap, and you want to bind
> that value, so don't quote the name:
>
> (keymap-set global-map "<apps>" ctl-x-map)
>
> Steve Berman


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

end of thread, other threads:[~2024-12-09 22:34 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 16:59 Remapping keys and creating my own keymap \\ too complicated\\ Tatsu Takamaro
2024-12-04  7:43 ` Jean Louis
2024-12-04 15:49   ` Tatsu Takamaro
2024-12-04 15:55   ` Tatsu Takamaro
2024-12-04 16:06     ` Robert Pluim
2024-12-04 16:37       ` Tatsu Takamaro
2024-12-04 16:40         ` Robert Pluim
2024-12-04 17:05           ` Tatsu Takamaro
2024-12-05 10:25             ` Robert Pluim
2024-12-05 18:08               ` Tatsu Takamaro
2024-12-06  9:57                 ` Robert Pluim
2024-12-06 10:38                   ` Jean Louis
2024-12-06 13:18                     ` Robert Pluim
2024-12-08 16:16                       ` Tatsu Takamaro
2024-12-08 23:07                         ` Stephen Berman
2024-12-09 22:34                           ` Tatsu Takamaro
2024-12-04 16:25 ` Jean Louis
2024-12-04 16:57   ` Tatsu Takamaro

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