all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to bind isearch-repeat-forward to F3 in a certain mode only?
@ 2015-07-23 22:01 Marcin Borkowski
  2015-07-24 12:53 ` Michael Heerdegen
  0 siblings, 1 reply; 25+ messages in thread
From: Marcin Borkowski @ 2015-07-23 22:01 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi everyone,

I have this:

(define-key my-mode-map "/" #'isearch-forward)

(my-mode is derived from special-mode, and - inspired by Firefox -
I wanted to make searching easy, requiring just one key ("/") instead of
two ("C-s").  Note that buffers in my-mode are read-only, so
self-insert-command doesn't make any sense anyway.)

However, inside isearch I still have to press C-s to go to the next
occurrence.

How to make F3 go to the next occurrence?  For obvious reasons, I don't
want to make such a change globally to isearch-mode-map.  Is it
possible?  I tried this (in a function which creates a buffer and sets
my-mode in it):

,----
| (my-mode)
| (make-local-variable 'isearch-mode-map)
| (define-key isearch-mode-map (kbd "<F3>") #'isearch-repeat-forward)
`----

but to no avail.  Inspecting `isearch-mode-map' implies that it was in
fact changed globally.  Pressing F3 while in isearch, though, starts
recording a keyboard macro anyway (both in my-mode and outside it).

Any hints?

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
       [not found] <mailman.7323.1437688903.904.help-gnu-emacs@gnu.org>
@ 2015-07-23 22:53 ` Javier
  2015-07-23 23:09   ` Marcin Borkowski
  0 siblings, 1 reply; 25+ messages in thread
From: Javier @ 2015-07-23 22:53 UTC (permalink / raw)
  To: help-gnu-emacs

> ,----
> | (my-mode)
> | (make-local-variable 'isearch-mode-map)
> | (define-key isearch-mode-map (kbd "<F3>") #'isearch-repeat-forward)
> `----
> 
> but to no avail.  Inspecting `isearch-mode-map' implies that it was in
> fact changed globally.  Pressing F3 while in isearch, though, starts
> recording a keyboard macro anyway (both in my-mode and outside it).


(defun my-mode-keys ()
  "Keybindings for my-mode.  To be used as a hook."
  (local-set-key (kbd "<F3>") 'isearch-repeat-forward)
  )
(add-hook 'my-mode-hook 'my-mode-keys)

Would this work?  Is 'my-mode-hook defined in your case?



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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-23 22:53 ` How to bind isearch-repeat-forward to F3 in a certain mode only? Javier
@ 2015-07-23 23:09   ` Marcin Borkowski
  0 siblings, 0 replies; 25+ messages in thread
From: Marcin Borkowski @ 2015-07-23 23:09 UTC (permalink / raw)
  To: help-gnu-emacs


On 2015-07-24, at 00:53, Javier <nospam@nospam.com> wrote:

>> ,----
>> | (my-mode)
>> | (make-local-variable 'isearch-mode-map)
>> | (define-key isearch-mode-map (kbd "<F3>") #'isearch-repeat-forward)
>> `----
>> 
>> but to no avail.  Inspecting `isearch-mode-map' implies that it was in
>> fact changed globally.  Pressing F3 while in isearch, though, starts
>> recording a keyboard macro anyway (both in my-mode and outside it).
>
>
> (defun my-mode-keys ()
>   "Keybindings for my-mode.  To be used as a hook."
>   (local-set-key (kbd "<F3>") 'isearch-repeat-forward)
>   )
> (add-hook 'my-mode-hook 'my-mode-keys)
>
> Would this work?  Is 'my-mode-hook defined in your case?

Yes and no.  I mean, it probably would - but then F3 would be bound to
isearch-repeat-forward also outside isearch.  (Not a big deal, but I'm
just curious whether it's at all possible to "do it right".)

Thanks,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-23 22:01 Marcin Borkowski
@ 2015-07-24 12:53 ` Michael Heerdegen
  2015-07-27 21:13   ` Marcin Borkowski
  0 siblings, 1 reply; 25+ messages in thread
From: Michael Heerdegen @ 2015-07-24 12:53 UTC (permalink / raw)
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:

> ,----
> | (my-mode)
> | (make-local-variable 'isearch-mode-map)
> | (define-key isearch-mode-map (kbd "<F3>") #'isearch-repeat-forward)
> `----
>
> but to no avail.  Inspecting `isearch-mode-map' implies that it was in
> fact changed globally.  Pressing F3 while in isearch, though, starts
> recording a keyboard macro anyway (both in my-mode and outside it).

Your approach seems reasonable.  There are two errors in your code
however:

1. (kbd "<F3>") obviously doesn't return the key sequence you want.  I
don't use `kbd'; I would just use [f3] instead.

2. Your change is "globally visible" because you missed that in Lisp,
variables reference lists by reference, not by value.  Keymaps are lists
in Elisp.

So, in your code, you create a new (local) binding, but that binding
still refers to the same object.  Use `copy-keymap' to fix that.  So at
the end you would have something like

(setq-local isearch-mode-map (copy-keymap isearch-mode-map))
(define-key isearch-mode-map [f3] #'isearch-repeat-forward)

You can do that in your `my-mode-hook' of course.


Regards,

Michael.




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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-24 12:53 ` Michael Heerdegen
@ 2015-07-27 21:13   ` Marcin Borkowski
  2015-07-27 21:43     ` Michael Heerdegen
  2015-07-27 23:45     ` Emanuel Berg
  0 siblings, 2 replies; 25+ messages in thread
From: Marcin Borkowski @ 2015-07-27 21:13 UTC (permalink / raw)
  To: help-gnu-emacs


On 2015-07-24, at 14:53, Michael Heerdegen <michael_heerdegen@web.de> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> ,----
>> | (my-mode)
>> | (make-local-variable 'isearch-mode-map)
>> | (define-key isearch-mode-map (kbd "<F3>") #'isearch-repeat-forward)
>> `----
>>
>> but to no avail.  Inspecting `isearch-mode-map' implies that it was in
>> fact changed globally.  Pressing F3 while in isearch, though, starts
>> recording a keyboard macro anyway (both in my-mode and outside it).
>
> Your approach seems reasonable.  There are two errors in your code
> however:

Thanks for your response!

> 1. (kbd "<F3>") obviously doesn't return the key sequence you want.  I
> don't use `kbd'; I would just use [f3] instead.

Something is strange here.

(equal [f3] [f3]) => t
(equal [f3] [F3]) => nil
(equal (kbd "<f3>") [f3]) => t
(equal (kbd "<f3>") (kbd "<F3>")) => nil
(equal (kbd "<F3>") [F3]) => t
(kbd "<f3>") => [f3]
(kbd "<F3>") => [F3]
(kbd "<S-f3>") => [S-f3]
(kbd "<S-F3>") => [S-F3]
(equal [S-f3] [F3]) => nil

So, what is [F3] exactly and how it differs from [f3]?

> 2. Your change is "globally visible" because you missed that in Lisp,
> variables reference lists by reference, not by value.  Keymaps are lists
> in Elisp.
>
> So, in your code, you create a new (local) binding, but that binding
> still refers to the same object.  Use `copy-keymap' to fix that.  So at
> the end you would have something like
>
> (setq-local isearch-mode-map (copy-keymap isearch-mode-map))
> (define-key isearch-mode-map [f3] #'isearch-repeat-forward)
>
> You can do that in your `my-mode-hook' of course.

Do I get it right that I should be careful to execute those lines
exactly once per each buffer in my-mode?  Is there any reason to put in
in the hook and not in the command which will create that buffer and
enter that mode?

> Regards,
>
> Michael.

TIA,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-27 21:13   ` Marcin Borkowski
@ 2015-07-27 21:43     ` Michael Heerdegen
  2015-07-27 23:45     ` Emanuel Berg
  1 sibling, 0 replies; 25+ messages in thread
From: Michael Heerdegen @ 2015-07-27 21:43 UTC (permalink / raw)
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:

> So, what is [F3] exactly and how it differs from [f3]?

The key <F3> is represented by the symbol `f3' in Emacs, that's it.  I
think it's by convention because all event basic types are represented
by lower case symbols.  Unlike in Common Lisp, in Emacs Lisp symbol
names are case sensitive.

That (kbd "<F3>") doesn't return what could be expected is not nice,
OTOH it's just consistent.

> > (setq-local isearch-mode-map (copy-keymap isearch-mode-map))
> > (define-key isearch-mode-map [f3] #'isearch-repeat-forward)
> >
> > You can do that in your `my-mode-hook' of course.
>
> Do I get it right that I should be careful to execute those lines
> exactly once per each buffer in my-mode?

That would not harm (would it?), though avoiding it would be cleaner.


> Is there any reason to put in in the hook and not in the command which
> will create that buffer and enter that mode?

No.

If the bindings are not directly related to your mode, you should not
put it into its hook.

But be careful: changing the major mode in any buffer kills all buffer
local variable bindings.


Regards,

Michael.




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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-27 21:13   ` Marcin Borkowski
  2015-07-27 21:43     ` Michael Heerdegen
@ 2015-07-27 23:45     ` Emanuel Berg
  2015-07-28  0:26       ` Ian Zimmerman
  2015-07-28  1:02       ` Marcin Borkowski
  1 sibling, 2 replies; 25+ messages in thread
From: Emanuel Berg @ 2015-07-27 23:45 UTC (permalink / raw)
  To: help-gnu-emacs

Don't use the F* keys:

    1. They are lousy keys that are too far away
       (reaching + resetting hand necessary) - they
       don't even have their own designations.
       People seldom use them and never remember what
       they do. They are like the Siberia of the
       keyboard; only real Siberia is much more
       interesting (tho equally remote, wide, and
       foggily unclear).

    2. They don't work everywhere.

Conclusion: keep out!

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-27 23:45     ` Emanuel Berg
@ 2015-07-28  0:26       ` Ian Zimmerman
  2015-07-28  1:07         ` Emanuel Berg
                           ` (2 more replies)
  2015-07-28  1:02       ` Marcin Borkowski
  1 sibling, 3 replies; 25+ messages in thread
From: Ian Zimmerman @ 2015-07-28  0:26 UTC (permalink / raw)
  To: help-gnu-emacs

On 2015-07-28 01:45 +0200, Emanuel Berg wrote:

> They are lousy keys that are too far away (reaching + resetting hand
> necessary) - they don't even have their own designations.  People
> seldom use them and never remember what they do. They are like the
> Siberia of the keyboard; only real Siberia is much more interesting
> (tho equally remote, wide, and foggily unclear).

LOL

> They don't work everywhere.

F3 should work an any ANSI terminal, unlike C-=.

Sorry, couldn't resist ;-)

A bit more seriously, I mostly agree with Emanuel.  F3 in particular may
be problematic because of [1] (unfortunately hidden away and so often
overlooked).  The exceptions are F10 for menu and F1 for help, which are
well established hard to replace with single-keystroke bindings.

[1]
https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html#Key-Binding-Conventions

-- 
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.




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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-27 23:45     ` Emanuel Berg
  2015-07-28  0:26       ` Ian Zimmerman
@ 2015-07-28  1:02       ` Marcin Borkowski
  1 sibling, 0 replies; 25+ messages in thread
From: Marcin Borkowski @ 2015-07-28  1:02 UTC (permalink / raw)
  To: help-gnu-emacs


On 2015-07-28, at 01:45, Emanuel Berg <embe8573@student.uu.se> wrote:

> Don't use the F* keys:
>
>     1. They are lousy keys that are too far away
>        (reaching + resetting hand necessary) - they
>        don't even have their own designations.
>        People seldom use them and never remember what
>        they do. They are like the Siberia of the
>        keyboard; only real Siberia is much more
>        interesting (tho equally remote, wide, and
>        foggily unclear).

Love this quote.  Even though it's not true.

Many people are quite accustomed to hitting F3 for "find the next
occurrence".  (Also, many people are quite accustomed to hitting F5 to
copy, F6 to move files, F7 to create directories and F8 to delete
files...)

>     2. They don't work everywhere.

True.  OTOH, what I want to bind to F3 is fully accessible on plain old C-s.

> Conclusion: keep out!

I see no reason!

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-28  0:26       ` Ian Zimmerman
@ 2015-07-28  1:07         ` Emanuel Berg
  2015-07-28  8:30         ` Marcin Borkowski
       [not found]         ` <mailman.7513.1438072243.904.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 25+ messages in thread
From: Emanuel Berg @ 2015-07-28  1:07 UTC (permalink / raw)
  To: help-gnu-emacs

Ian Zimmerman <itz@buug.org> writes:

> F3 should work an any ANSI terminal, unlike C-=.

What is an ANSI terminal? Is there a list of those
who passed?

F3 doesn't work for me here in Emacs in /dev/tty1 -
but in the terminal, showkey gets it (keycode 61) so
the old console key hack can let me have it, only
I don't want it.

Still, why it doesn't work in Emacs is another
question to which I don't have an answer...

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-28  0:26       ` Ian Zimmerman
  2015-07-28  1:07         ` Emanuel Berg
@ 2015-07-28  8:30         ` Marcin Borkowski
  2015-07-28 16:15           ` Yuri Khan
       [not found]         ` <mailman.7513.1438072243.904.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 25+ messages in thread
From: Marcin Borkowski @ 2015-07-28  8:30 UTC (permalink / raw)
  To: help-gnu-emacs


On 2015-07-28, at 02:26, Ian Zimmerman <itz@buug.org> wrote:

> A bit more seriously, I mostly agree with Emanuel.  F3 in particular may
> be problematic because of [1] (unfortunately hidden away and so often
> overlooked).  The exceptions are F10 for menu and F1 for help, which are
> well established hard to replace with single-keystroke bindings.

Funnily, of a few Fn bindings present in (my) Emacs, F1 and F10 are
among those I *never* use...  Help is C-h for me, and I haven't used the
menu for more than decade.  And I explained the rationale behind my idea
of binding F3 in an earlier post.

BTW, how do you guys use keyboard macros?  "C-x (", "C-x )" and "C-x e"
are so inconvenient compared to F3 and F4...

(OK, this Emanuel doesn't have to answer this last question - he doesn't
use kbd macros, and doesn't even know what he misses;-);-);-).)

> [1]
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html#Key-Binding-Conventions

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
       [not found]         ` <mailman.7513.1438072243.904.help-gnu-emacs@gnu.org>
@ 2015-07-28  8:42           ` Rusi
  2015-07-28  8:50             ` Marcin Borkowski
                               ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Rusi @ 2015-07-28  8:42 UTC (permalink / raw)
  To: help-gnu-emacs

On Tuesday, July 28, 2015 at 2:00:45 PM UTC+5:30, Marcin Borkowski wrote:
> On 2015-07-28, at 02:26, Ian Zimmerman  wrote:
> 
> > A bit more seriously, I mostly agree with Emanuel.  F3 in particular may
> > be problematic because of [1] (unfortunately hidden away and so often
> > overlooked).  The exceptions are F10 for menu and F1 for help, which are
> > well established hard to replace with single-keystroke bindings.
> 
> Funnily, of a few Fn bindings present in (my) Emacs, F1 and F10 are
> among those I *never* use...  Help is C-h for me, and I haven't used the
> menu for more than decade.  And I explained the rationale behind my idea
> of binding F3 in an earlier post.
> 
> BTW, how do you guys use keyboard macros?  "C-x (", "C-x )" and "C-x e"
> are so inconvenient compared to F3 and F4...
> 
> (OK, this Emanuel doesn't have to answer this last question - he doesn't
> use kbd macros, and doesn't even know what he misses;-);-);-).)
> 
> > [1]
> > https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html#Key-Binding-Conventions

I am actually a bit surprised by Ian's quoting the above page.
AIUI that is for *elisp library developers* to keep some order in keybindings
If an *individual user* is prevented (even suggested) to not use da-da
to do de-de, then what's the point of emacs really and its famed customizability?



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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-28  8:42           ` Rusi
@ 2015-07-28  8:50             ` Marcin Borkowski
  2015-07-28 15:01             ` Ian Zimmerman
       [not found]             ` <mailman.7551.1438095703.904.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 25+ messages in thread
From: Marcin Borkowski @ 2015-07-28  8:50 UTC (permalink / raw)
  To: help-gnu-emacs


On 2015-07-28, at 10:42, Rusi <rustompmody@gmail.com> wrote:

> On Tuesday, July 28, 2015 at 2:00:45 PM UTC+5:30, Marcin Borkowski wrote:
>> On 2015-07-28, at 02:26, Ian Zimmerman  wrote:
>> 
>> > A bit more seriously, I mostly agree with Emanuel.  F3 in particular may
>> > be problematic because of [1] (unfortunately hidden away and so often
>> > overlooked).  The exceptions are F10 for menu and F1 for help, which are
>> > well established hard to replace with single-keystroke bindings.
>> 
>> Funnily, of a few Fn bindings present in (my) Emacs, F1 and F10 are
>> among those I *never* use...  Help is C-h for me, and I haven't used the
>> menu for more than decade.  And I explained the rationale behind my idea
>> of binding F3 in an earlier post.
>> 
>> BTW, how do you guys use keyboard macros?  "C-x (", "C-x )" and "C-x e"
>> are so inconvenient compared to F3 and F4...
>> 
>> (OK, this Emanuel doesn't have to answer this last question - he doesn't
>> use kbd macros, and doesn't even know what he misses;-);-);-).)
>> 
>> > [1]
>> > https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html#Key-Binding-Conventions
>
> I am actually a bit surprised by Ian's quoting the above page.
> AIUI that is for *elisp library developers* to keep some order in keybindings
> If an *individual user* is prevented (even suggested) to not use da-da
> to do de-de, then what's the point of emacs really and its famed customizability?

To be fair, I intend to publish my code.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-28  8:42           ` Rusi
  2015-07-28  8:50             ` Marcin Borkowski
@ 2015-07-28 15:01             ` Ian Zimmerman
  2015-07-28 15:28               ` Marcin Borkowski
       [not found]               ` <mailman.7552.1438097346.904.help-gnu-emacs@gnu.org>
       [not found]             ` <mailman.7551.1438095703.904.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 25+ messages in thread
From: Ian Zimmerman @ 2015-07-28 15:01 UTC (permalink / raw)
  To: help-gnu-emacs

On 2015-07-28 01:42 -0700, Rusi wrote:

> I am actually a bit surprised by Ian's quoting the above page.  AIUI
> that is for *elisp library developers* to keep some order in
> keybindings If an *individual user* is prevented (even suggested) to
> not use da-da to do de-de, then what's the point of emacs really and
> its famed customizability?

Nothing prevents you as user from binding any key to any command, of
course.  But you shouldn't be too surprised when the next version of
Emacs will globally bind F3 to .. let's follow Marcin's cue
.. kmacro-start-macro.

This has happened to me a few times with keys like M-o.

-- 
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.




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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-28 15:01             ` Ian Zimmerman
@ 2015-07-28 15:28               ` Marcin Borkowski
       [not found]               ` <mailman.7552.1438097346.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 25+ messages in thread
From: Marcin Borkowski @ 2015-07-28 15:28 UTC (permalink / raw)
  To: help-gnu-emacs


On 2015-07-28, at 17:01, Ian Zimmerman <itz@buug.org> wrote:

> On 2015-07-28 01:42 -0700, Rusi wrote:
>
>> I am actually a bit surprised by Ian's quoting the above page.  AIUI
>> that is for *elisp library developers* to keep some order in
>> keybindings If an *individual user* is prevented (even suggested) to
>> not use da-da to do de-de, then what's the point of emacs really and
>> its famed customizability?
>
> Nothing prevents you as user from binding any key to any command, of
> course.  But you shouldn't be too surprised when the next version of
> Emacs will globally bind F3 to .. let's follow Marcin's cue
> .. kmacro-start-macro.

:-)

Note that starting a kbd macro within isearch is rather improbable, so
my idea seems safe.  (Although after this discussion I'm going to change
it anyway.)

> This has happened to me a few times with keys like M-o.

That's why many of my private bindings start with C-z.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-28  8:30         ` Marcin Borkowski
@ 2015-07-28 16:15           ` Yuri Khan
  0 siblings, 0 replies; 25+ messages in thread
From: Yuri Khan @ 2015-07-28 16:15 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: help-gnu-emacs@gnu.org

On Tue, Jul 28, 2015 at 2:30 PM, Marcin Borkowski <mbork@mbork.pl> wrote:

> BTW, how do you guys use keyboard macros?  "C-x (", "C-x )" and "C-x e"
> are so inconvenient compared to F3 and F4...

I am a recent (≈8 years) migrant from a different be-all-end-all tool
on a different OS, and I’ve kept some habits.

So if I could figure out how to make the same C-. key start and end
macro recording, and immediately after stopping recording ask for a
key binding… hm, in fact I can.

===
(define-minor-mode yk-kmacro-mode
  "Record a keyboard macro and bind it to a key."
  :global t
  :init-value nil
  :lighter " ●"
  (if yk-kmacro-mode
      (kmacro-start-macro nil)
    ;; KLUDGE
    (let ((yk-kmacro-ring (cdr kmacro-ring)))
      (kmacro-end-macro nil)
      (when (eq yk-kmacro-ring kmacro-ring)
        (kmacro-push-ring)
        (setq last-kbd-macro "")))
    (kmacro-bind-to-key nil)))
(global-set-key (kbd "C-.") 'yk-kmacro-mode)
===

The kludge is there in order to remove macros when they are no longer
needed. It would be even better to restore the original binding (if
any) but that would basically require reimplementing
kmacro-bind-to-key.



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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
       [not found]             ` <mailman.7551.1438095703.904.help-gnu-emacs@gnu.org>
@ 2015-07-28 17:00               ` Rusi
  0 siblings, 0 replies; 25+ messages in thread
From: Rusi @ 2015-07-28 17:00 UTC (permalink / raw)
  To: help-gnu-emacs

On Tuesday, July 28, 2015 at 8:31:45 PM UTC+5:30, Ian Zimmerman wrote:
> On 2015-07-28 01:42 -0700, Rusi wrote:
> 
> > I am actually a bit surprised by Ian's quoting the above page.  AIUI
> > that is for *elisp library developers* to keep some order in
> > keybindings If an *individual user* is prevented (even suggested) to
> > not use da-da to do de-de, then what's the point of emacs really and
> > its famed customizability?
> 
> Nothing prevents you as user from binding any key to any command, of
> course.

Easier said than done...
Try rebinding C-x, C-c, C-v to what 99% of the computer users on this planet
expect of them. [Yeah C-v is easier]


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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
       [not found]               ` <mailman.7552.1438097346.904.help-gnu-emacs@gnu.org>
@ 2015-07-30  0:23                 ` Hikaru Ichijyo
  2015-07-30  1:17                   ` Ian Zimmerman
       [not found]                   ` <mailman.7637.1438219082.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 25+ messages in thread
From: Hikaru Ichijyo @ 2015-07-30  0:23 UTC (permalink / raw)
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:

> On 2015-07-28, at 17:01, Ian Zimmerman <itz@buug.org> wrote:
>
>> Nothing prevents you as user from binding any key to any command, of
>> course.  But you shouldn't be too surprised when the next version of
>> Emacs will globally bind F3 to .. let's follow Marcin's cue
>> .. kmacro-start-macro.
>
> :-)
>
> Note that starting a kbd macro within isearch is rather improbable, so
> my idea seems safe.  (Although after this discussion I'm going to change
> it anyway.)
>
>> This has happened to me a few times with keys like M-o.
>
> That's why many of my private bindings start with C-z.

Most of my private key bindings are setup on the "super" key, which is
the Windows key in X11 on Linux (on an x86 keyboard).  I never use the
Windows key for anything else, and Emacs seems to have done nothing with
it but make it the "super" from the days of space cadet keyboards, so
it's been pretty safe.  I've never seen anything else use an "s-"
binding but me.

The only disadvantage for me has been that it only seems to work in X.
On a Linux VTY, or on a text terminal over SSH, the mapping seems to not
work, but thanks to Tramp mode, I almost never use Emacs outside of X.

-- 
He that would make his own liberty secure must guard even his enemy from
oppression; for if he violates this duty, he establishes a precedent
that will reach to himself.
					--Thomas Paine


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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-30  0:23                 ` Hikaru Ichijyo
@ 2015-07-30  1:17                   ` Ian Zimmerman
  2015-07-30  3:15                     ` Emanuel Berg
       [not found]                   ` <mailman.7637.1438219082.904.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 25+ messages in thread
From: Ian Zimmerman @ 2015-07-30  1:17 UTC (permalink / raw)
  To: help-gnu-emacs

On 2015-07-29 19:23 -0500, Hikaru Ichijyo wrote:

> > That's why many of my private bindings start with C-z.
> 
> Most of my private key bindings are setup on the "super" key, which is
> the Windows key in X11 on Linux (on an x86 keyboard).  I never use the
> Windows key for anything else, and Emacs seems to have done nothing with
> it but make it the "super" from the days of space cadet keyboards, so
> it's been pretty safe.  I've never seen anything else use an "s-"
> binding but me.

But the Super key is a modifier.  Key combinations involving a modifier
(sometimes called "chords") are appreciably harder to perform, and more
likely to lead to RSI, than sequences of single keystrokes.  I would
rate even a 1-2 sequence starting with the dreaded function key as
easier to type than something like C-h (h is exactly midway between the
2 Control keys on my keyboard).

This also applies to C-z, alas.  But at least the components of that
chord are very close to each other on typical keyboards where I live.

Or have you managed to remove the modifier status from the Super key?  I
tried to do something like that a couple of times and I remember it was
close to impossible.  That was in the days of xmodmap, though.  I don't
really expect it to be easier with xkb, but maybe you know more about
this stuff?

-- 
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.




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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
       [not found]                   ` <mailman.7637.1438219082.904.help-gnu-emacs@gnu.org>
@ 2015-07-30  1:48                     ` Hikaru Ichijyo
  2015-07-30 12:56                     ` HASM
  1 sibling, 0 replies; 25+ messages in thread
From: Hikaru Ichijyo @ 2015-07-30  1:48 UTC (permalink / raw)
  To: help-gnu-emacs

Ian Zimmerman <itz@buug.org> writes:

> On 2015-07-29 19:23 -0500, Hikaru Ichijyo wrote:
>
>> > That's why many of my private bindings start with C-z.
>> 
>> Most of my private key bindings are setup on the "super" key, which is
>> the Windows key in X11 on Linux (on an x86 keyboard).  I never use the
>> Windows key for anything else, and Emacs seems to have done nothing with
>> it but make it the "super" from the days of space cadet keyboards, so
>> it's been pretty safe.  I've never seen anything else use an "s-"
>> binding but me.
>
> But the Super key is a modifier.  Key combinations involving a modifier
> (sometimes called "chords") are appreciably harder to perform, and more
> likely to lead to RSI, than sequences of single keystrokes.  I would
> rate even a 1-2 sequence starting with the dreaded function key as
> easier to type than something like C-h (h is exactly midway between the
> 2 Control keys on my keyboard).
>
> This also applies to C-z, alas.  But at least the components of that
> chord are very close to each other on typical keyboards where I live.

Oh, you want to be able to do it in one keystroke!

Well, for things that I want to make that easy, I just carefully choose
function keys that aren't already being used by something else that I
care about.  (Sorry if you were hoping for some solution other than
f-keys).  For example, I use 'other-window' way too much to be typing
'C-x o' all the time, so I have that bound to 'f6'.  As far as making it
only get mapped in a certain mode, you may have to do something like
I've done below to Gnus:

(add-hook 'gnus-summary-mode-hook (lambda ()
    (local-set-key "D" 'delete-then-read-next)
    (local-set-key "d" 'gnus-summary-put-mark-as-expirable-next)
    (local-set-key "u" 'gnus-summary-clear-mark-forward)
    (local-set-key "x" 'expunge-and-reload)
    (local-set-key "v" 'gnus-article-view-part)
    (local-set-key (kbd "C-a") 'gnus-summary-save-parts)))

I just got into Emacs last year, so I don't know how wise any of the
above is, but it's been working for me so far.  It attaches to the Gnus
summary screen and attaches local key bindings that only work there and
nowhere else.  You may be able to do something similar in your situation.

> Or have you managed to remove the modifier status from the Super key?  I
> tried to do something like that a couple of times and I remember it was
> close to impossible.  That was in the days of xmodmap, though.  I don't
> really expect it to be easier with xkb, but maybe you know more about
> this stuff?

Oh no, I wouldn't think trying to make any modifier key into an ordinary
one sounds like a very good idea.

-- 
He that would make his own liberty secure must guard even his enemy from
oppression; for if he violates this duty, he establishes a precedent
that will reach to himself.
					--Thomas Paine


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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-30  1:17                   ` Ian Zimmerman
@ 2015-07-30  3:15                     ` Emanuel Berg
  2015-07-30  5:10                       ` Ian Zimmerman
  0 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg @ 2015-07-30  3:15 UTC (permalink / raw)
  To: help-gnu-emacs

Ian Zimmerman <itz@buug.org> writes:

> Key combinations involving a modifier (sometimes
> called "chords") are appreciably harder to perform,
> and more likely to lead to RSI, than sequences of
> single keystrokes.

Not necessarily! It all depends.

For example, I have M-o to do

    (defun other-window-or-split ()
      (interactive)
      (when (= 1 (count-windows)) (split-window-vertically))
      (other-window 1) )

which I do all the time. If you put your fingers into
proper positions - real hackers don't have to do this,
because they always have them there anyway - and look
down, observe what minimal motion of the left thumb,
and right ring finger, in order to hit this shortcut,
and the *zero* hand motion.

Compared to some single keys - in particular:

    a s d f j k l ;

then yes, M-o is barely slower and less ergonomic, but
compared to many, many single keys M-o is much better.
And I don't only mean the F* keys; the numeric keypad;
the arrow keys; the Home, End, etc. keys; and all that
which are obviously incomparably worse to fingers,
hands, neck, and eyes. No, M-o is also better than the
digit keys, most keys below your left hand (i.e., z,
x, c, with the exception of v which is comparable to
M-o); and so on.

So if those prefix keys are placed wisely, they
shouldn't be thought of as unergonomic.

This file contains a lot, but if you search for
"prefix" you see how a new one can be setup easily and
thereafter used like the standard ones.

    http://user.it.uu.se/~embe8573/conf/emacs-init/global-keys.el

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-30  3:15                     ` Emanuel Berg
@ 2015-07-30  5:10                       ` Ian Zimmerman
  2015-07-30 22:36                         ` Emanuel Berg
  0 siblings, 1 reply; 25+ messages in thread
From: Ian Zimmerman @ 2015-07-30  5:10 UTC (permalink / raw)
  To: help-gnu-emacs

On 2015-07-30 05:15 +0200, Emanuel Berg wrote:

> > Key combinations involving a modifier (sometimes
> > called "chords") are appreciably harder to perform,
> > and more likely to lead to RSI, than sequences of
> > single keystrokes.
> 
> Not necessarily! It all depends.

Right.  On the actual keyboard, of course.  Also on your hands.  Mine
are girlish small, and I have a minor handicap in the right hand.

-- 
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.




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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
       [not found]                   ` <mailman.7637.1438219082.904.help-gnu-emacs@gnu.org>
  2015-07-30  1:48                     ` Hikaru Ichijyo
@ 2015-07-30 12:56                     ` HASM
  2015-07-30 22:37                       ` Emanuel Berg
  1 sibling, 1 reply; 25+ messages in thread
From: HASM @ 2015-07-30 12:56 UTC (permalink / raw)
  To: help-gnu-emacs

Ian Zimmerman <itz@buug.org> writes:

> That was in the days of xmodmap, though.

Interesting, I still use xmodmap these days.

> Or have you managed to remove the modifier status from the Super key?

Maybe something like this would work

% xmodmap -pm  | grep Super
mod4        Multi_key (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)

% echo remove mod4 Super_R | xmodmap -
% echo remove mod4 Super_L | xmodmap -

-- HASM


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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-30  5:10                       ` Ian Zimmerman
@ 2015-07-30 22:36                         ` Emanuel Berg
  0 siblings, 0 replies; 25+ messages in thread
From: Emanuel Berg @ 2015-07-30 22:36 UTC (permalink / raw)
  To: help-gnu-emacs

Ian Zimmerman <itz@buug.org> writes:

>>> Key combinations involving a modifier (sometimes
>>> called "chords") are appreciably harder to
>>> perform, and more likely to lead to RSI, than
>>> sequences of single keystrokes.
>>
>> Not necessarily! It all depends.
>
> Right. On the actual keyboard, of course. Also on
> your hands. Mine are girlish small, and I have
> a minor handicap in the right hand.

It depends on that as well.

Also, after some training with bad keys those will be
better for you than the good keys. As long as the bad
keys aren't terribly bad, it isn't a bad thing.

No one can get everything right from day one, but it
is something to aim for nonetheless. Some bad habits
can be corrected, some are perhaps better to be left
alone as long as, again, they aren't terribly bad.

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
  2015-07-30 12:56                     ` HASM
@ 2015-07-30 22:37                       ` Emanuel Berg
  0 siblings, 0 replies; 25+ messages in thread
From: Emanuel Berg @ 2015-07-30 22:37 UTC (permalink / raw)
  To: help-gnu-emacs

HASM <netnews@invalid.com> writes:

>> That was in the days of xmodmap, though.
>
> Interesting, I still use xmodmap these days.

So do I and so do a lot of people.

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

end of thread, other threads:[~2015-07-30 22:37 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.7323.1437688903.904.help-gnu-emacs@gnu.org>
2015-07-23 22:53 ` How to bind isearch-repeat-forward to F3 in a certain mode only? Javier
2015-07-23 23:09   ` Marcin Borkowski
2015-07-23 22:01 Marcin Borkowski
2015-07-24 12:53 ` Michael Heerdegen
2015-07-27 21:13   ` Marcin Borkowski
2015-07-27 21:43     ` Michael Heerdegen
2015-07-27 23:45     ` Emanuel Berg
2015-07-28  0:26       ` Ian Zimmerman
2015-07-28  1:07         ` Emanuel Berg
2015-07-28  8:30         ` Marcin Borkowski
2015-07-28 16:15           ` Yuri Khan
     [not found]         ` <mailman.7513.1438072243.904.help-gnu-emacs@gnu.org>
2015-07-28  8:42           ` Rusi
2015-07-28  8:50             ` Marcin Borkowski
2015-07-28 15:01             ` Ian Zimmerman
2015-07-28 15:28               ` Marcin Borkowski
     [not found]               ` <mailman.7552.1438097346.904.help-gnu-emacs@gnu.org>
2015-07-30  0:23                 ` Hikaru Ichijyo
2015-07-30  1:17                   ` Ian Zimmerman
2015-07-30  3:15                     ` Emanuel Berg
2015-07-30  5:10                       ` Ian Zimmerman
2015-07-30 22:36                         ` Emanuel Berg
     [not found]                   ` <mailman.7637.1438219082.904.help-gnu-emacs@gnu.org>
2015-07-30  1:48                     ` Hikaru Ichijyo
2015-07-30 12:56                     ` HASM
2015-07-30 22:37                       ` Emanuel Berg
     [not found]             ` <mailman.7551.1438095703.904.help-gnu-emacs@gnu.org>
2015-07-28 17:00               ` Rusi
2015-07-28  1:02       ` Marcin Borkowski

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.