unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* function keys in macro
@ 2013-11-23 15:10 Emanuel Berg
  2013-11-25 12:38 ` Michael Heerdegen
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Emanuel Berg @ 2013-11-23 15:10 UTC (permalink / raw)
  To: help-gnu-emacs

I tried so many ways to include one of the function
keys in a macro, like:

(fset 'F2 (kbd "M-<f2>"))
(fset 'F2 (kbd "<M-f2>"))
(fset 'F2 [(meta f2)])
(fset 'F2 [M-f2])
;; and more...

and then (after either of the above)

(execute-kbd-macro (symbol-function 'F2))

But then I always get:

"Keyboard macro terminated by a command ringing the bell"

But it works for the non-F* keys so there has to be
something with those that breaks it.

Thanks!

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


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

* Re: function keys in macro
  2013-11-23 15:10 function keys in macro Emanuel Berg
@ 2013-11-25 12:38 ` Michael Heerdegen
  2013-11-25 12:44 ` Jambunathan K
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Michael Heerdegen @ 2013-11-25 12:38 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> I tried so many ways to include one of the function
> keys in a macro, like:
>
> (fset 'F2 (kbd "M-<f2>"))
> (fset 'F2 (kbd "<M-f2>"))
> (fset 'F2 [(meta f2)])
> (fset 'F2 [M-f2])
> ;; and more...
>
> and then (after either of the above)
>
> (execute-kbd-macro (symbol-function 'F2))

Have you bound M-f2 to any command?

Michael.




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

* Re: function keys in macro
  2013-11-23 15:10 function keys in macro Emanuel Berg
  2013-11-25 12:38 ` Michael Heerdegen
@ 2013-11-25 12:44 ` Jambunathan K
  2013-11-25 12:50 ` Jambunathan K
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Jambunathan K @ 2013-11-25 12:44 UTC (permalink / raw)
  To: help-gnu-emacs


M-x global-set-key (do whatever Emacs asks you to do)

M-x list-command-history

I see this:

    (global-set-key [27 f2] (quote ignore))

I am using ESC and not Alt (as seen on my keyboard).  Alt-F2 opens a
"Run Program" for me here.

Emanuel Berg <embe8573@student.uu.se> writes:

> I tried so many ways to include one of the function
> keys in a macro, like:
>
> (fset 'F2 (kbd "M-<f2>"))
> (fset 'F2 (kbd "<M-f2>"))
> (fset 'F2 [(meta f2)])
> (fset 'F2 [M-f2])
> ;; and more...
>
> and then (after either of the above)
>
> (execute-kbd-macro (symbol-function 'F2))
>
> But then I always get:
>
> "Keyboard macro terminated by a command ringing the bell"
>
> But it works for the non-F* keys so there has to be
> something with those that breaks it.
>
> Thanks!



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

* Re: function keys in macro
  2013-11-23 15:10 function keys in macro Emanuel Berg
  2013-11-25 12:38 ` Michael Heerdegen
  2013-11-25 12:44 ` Jambunathan K
@ 2013-11-25 12:50 ` Jambunathan K
       [not found] ` <mailman.7060.1385383126.10748.help-gnu-emacs@gnu.org>
       [not found] ` <mailman.7064.1385384049.10748.help-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 14+ messages in thread
From: Jambunathan K @ 2013-11-25 12:50 UTC (permalink / raw)
  To: help-gnu-emacs


F2 is a prefix key.

\f
Global Bindings Starting With <f2>:
key             binding
---             -------

<f2> 2		2C-two-columns
<f2> b		2C-associate-buffer
<f2> s		2C-split
<f2> <f2>	2C-two-columns

So once you press f2 whatever that follows "completes" the prefix.

Emanuel Berg <embe8573@student.uu.se> writes:

> I tried so many ways to include one of the function
> keys in a macro, like:
>
> (fset 'F2 (kbd "M-<f2>"))
> (fset 'F2 (kbd "<M-f2>"))
> (fset 'F2 [(meta f2)])
> (fset 'F2 [M-f2])
> ;; and more...
>
> and then (after either of the above)
>
> (execute-kbd-macro (symbol-function 'F2))
>
> But then I always get:
>
> "Keyboard macro terminated by a command ringing the bell"
>
> But it works for the non-F* keys so there has to be
> something with those that breaks it.
>
> Thanks!



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

* Re: function keys in macro
       [not found] ` <mailman.7060.1385383126.10748.help-gnu-emacs@gnu.org>
@ 2013-11-25 20:34   ` Emanuel Berg
  2013-11-25 21:40     ` Emanuel Berg
  2014-01-14  1:47     ` Emanuel Berg
  0 siblings, 2 replies; 14+ messages in thread
From: Emanuel Berg @ 2013-11-25 20:34 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Have you bound M-f2 to any command?

Well, I use Emacs in a Linux VT (tty1 to be precise)
and M-F2 (or Alt-F2) will switch to tty2. In
/etc/console-setup/remap.inc, with

# J - Emacs to the left...
alt keycode 36       = Decr_Console
ctrll alt keycode 36 = Decr_Console
# L - ... Linux VTs with tmux to the right
alt keycode 38       = Incr_Console
ctrll alt keycode 38 = Incr_Console

I have bound those functions to Alt-J and Alt-K
instead, but I haven't unset those old "short"cuts
because I'd never use them for anything else.

That's why, in Emacs (in tty1), I can't hit M-F2 and
have Emacs process it, because the tty1 will intercept
it and jump to tty2.

But, I just tried Emacs in X and no: M-F2 is unbound.

So, for everything to fall into place like the blocks
of Tetris, if I put those keys in a macro, could I jump
between the ttys programmatically with Elisp?

I have tried the following shell/X tools to accomplish
the same task:

* chvt (doesn't work from Emacs, tmux, or X, but from
  an "empty" Linux VT, it works to everywhere including
  X)
* xdotool (works from everywhere, but you cannot get
  from the "VT world" to X)
* xmacroplay (works just like xdotool, which makes sense)

So the best solution I found so far, which is 99%
satisfactory, is remap from the VT world, and xdotool
from X.

In fact, I just got a new idea writing this, remap to
some unused shortcut (or even Unicode char, if those
could be put in macros), and then have a macro "type"
that... stay tuned!

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


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

* Re: function keys in macro
       [not found] ` <mailman.7064.1385384049.10748.help-gnu-emacs@gnu.org>
@ 2013-11-25 20:40   ` Emanuel Berg
  2013-11-25 20:42     ` Emanuel Berg
  0 siblings, 1 reply; 14+ messages in thread
From: Emanuel Berg @ 2013-11-25 20:40 UTC (permalink / raw)
  To: help-gnu-emacs

Jambunathan K <kjambunathan@gmail.com> writes:

> F2 is a prefix key.

Interesting, are you saying that breaks the macro on a
definition (or even "notation") level?

By the way, how did you do that "Next/Previous Page"?
It looked like ^ L (without the whitespace) when I
replied to your post.

I'm trying it myself right now:

This is page 1.
^L
Is this page 2?

I can't say that's anything I would ever use because I
prefer scrolling, at least when setup so it scrolls one
line at a time. But, without bragging, I'm always
impressed when I see something I didn't see before :)

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


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

* Re: function keys in macro
  2013-11-25 20:40   ` Emanuel Berg
@ 2013-11-25 20:42     ` Emanuel Berg
  2013-11-27 12:38       ` Tassilo Horn
       [not found]       ` <mailman.7252.1385555936.10748.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 14+ messages in thread
From: Emanuel Berg @ 2013-11-25 20:42 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> By the way, how did you do that "Next/Previous Page"?
> It looked like ^ L (without the whitespace) when I
> replied to your post.
>
> I'm trying it myself right now:
>
> This is page 1.
> ^L
> Is this page 2?

No, that didn't work.

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


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

* Re: function keys in macro
  2013-11-25 20:34   ` Emanuel Berg
@ 2013-11-25 21:40     ` Emanuel Berg
  2013-11-26  7:35       ` Michael Heerdegen
  2014-01-14  1:47     ` Emanuel Berg
  1 sibling, 1 reply; 14+ messages in thread
From: Emanuel Berg @ 2013-11-25 21:40 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> In fact, I just got a new idea writing this, remap to
> some unused shortcut (or even Unicode char, if those
> could be put in macros), and then have a macro "type"
> that... stay tuned!

Keyboard macros are *not* intercepted by the tty:

(fset 'Ml (kbd "M-l"))
(execute-kbd-macro (symbol-function 'Ml))

This will *not* take me to tty2 (if in tty1/Emacs), but
will instead run `downcase-word', i.e., normal Emacs
behaviour!

Amazing! That means this whole idea must be dropped!

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


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

* Re: function keys in macro
  2013-11-25 21:40     ` Emanuel Berg
@ 2013-11-26  7:35       ` Michael Heerdegen
  0 siblings, 0 replies; 14+ messages in thread
From: Michael Heerdegen @ 2013-11-26  7:35 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> Keyboard macros are *not* intercepted by the tty:
>
> (fset 'Ml (kbd "M-l"))
> (execute-kbd-macro (symbol-function 'Ml))
>
> This will *not* take me to tty2 (if in tty1/Emacs), but
> will instead run `downcase-word', i.e., normal Emacs
> behaviour!
>
> Amazing! That means this whole idea must be dropped!

Indeed.  `execute-kbd-macro' just calls commands bound to the given
keys.  It's internal to Emacs, and something different from hitting that
key on your keyboard.  It is the same only when that key event is
received by Emacs.


Regards,

Michael.




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

* Re: function keys in macro
  2013-11-25 20:42     ` Emanuel Berg
@ 2013-11-27 12:38       ` Tassilo Horn
       [not found]       ` <mailman.7252.1385555936.10748.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 14+ messages in thread
From: Tassilo Horn @ 2013-11-27 12:38 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

>> I'm trying it myself right now:
>>
>> This is page 1.
>> ^L
>> Is this page 2?
>
> No, that didn't work.

It's the control character ^L.
\f
You know, PAGE BREAK.

Bye,
Tassilo



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

* Re: function keys in macro
       [not found]       ` <mailman.7252.1385555936.10748.help-gnu-emacs@gnu.org>
@ 2013-11-27 20:10         ` Emanuel Berg
  2013-11-28 10:06           ` Jambunathan K
       [not found]           ` <mailman.7323.1385633250.10748.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 14+ messages in thread
From: Emanuel Berg @ 2013-11-27 20:10 UTC (permalink / raw)
  To: help-gnu-emacs

Tassilo Horn <tsdh@gnu.org> writes:

>>> I'm trying it myself right now:
>>>
>>> This is page 1.
>>> ^L
>>> Is this page 2?
>>
>> No, that didn't work.
>
> It's the control character ^L.
> You know, PAGE BREAK.

*laughter* That's so cute! No, I don't know. Do you
insert it as a Unicode char? Or do you have to quote
it? Or is it the representation of a keystroke?

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


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

* Re: function keys in macro
  2013-11-27 20:10         ` Emanuel Berg
@ 2013-11-28 10:06           ` Jambunathan K
       [not found]           ` <mailman.7323.1385633250.10748.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 14+ messages in thread
From: Jambunathan K @ 2013-11-28 10:06 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

>> It's the control character ^L.
>> You know, PAGE BREAK.
>
> *laughter* That's so cute! No, I don't know. Do you
> insert it as a Unicode char? Or do you have to quote
> it? Or is it the representation of a keystroke?

C-q C-l will get you ^L.

If you are editing a large text or source file you can "create pages"
and navigate using C-x [ and C-x ].



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

* Re: function keys in macro
       [not found]           ` <mailman.7323.1385633250.10748.help-gnu-emacs@gnu.org>
@ 2013-11-28 15:25             ` Emanuel Berg
  0 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg @ 2013-11-28 15:25 UTC (permalink / raw)
  To: help-gnu-emacs

Jambunathan K <kjambunathan@gmail.com> writes:

> C-q C-l will get you ^L.
>
> If you are editing a large text or source file you
> can "create pages" and navigate

I see. In mails, one has to wonder though how they turn
out in other clients? But it was a fun thing for sure.

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


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

* Re: function keys in macro
  2013-11-25 20:34   ` Emanuel Berg
  2013-11-25 21:40     ` Emanuel Berg
@ 2014-01-14  1:47     ` Emanuel Berg
  1 sibling, 0 replies; 14+ messages in thread
From: Emanuel Berg @ 2014-01-14  1:47 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> * chvt (doesn't work from Emacs, tmux, or X, but from
> an "empty" Linux VT, it works to everywhere including
> X)

I found a way to make chvt work from everywhere
(including Emacs and tmux, in- and outside of X). The
console remap is perhaps better (safer) for keypresses
(at least there is no reason not to use it, as that's
what you do), but if you really want it as a *command*
(to be invoked from Emacs and/or shell functions) this
makes it work:

sudo chmod u+s /bin/chvt

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


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

end of thread, other threads:[~2014-01-14  1:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-23 15:10 function keys in macro Emanuel Berg
2013-11-25 12:38 ` Michael Heerdegen
2013-11-25 12:44 ` Jambunathan K
2013-11-25 12:50 ` Jambunathan K
     [not found] ` <mailman.7060.1385383126.10748.help-gnu-emacs@gnu.org>
2013-11-25 20:34   ` Emanuel Berg
2013-11-25 21:40     ` Emanuel Berg
2013-11-26  7:35       ` Michael Heerdegen
2014-01-14  1:47     ` Emanuel Berg
     [not found] ` <mailman.7064.1385384049.10748.help-gnu-emacs@gnu.org>
2013-11-25 20:40   ` Emanuel Berg
2013-11-25 20:42     ` Emanuel Berg
2013-11-27 12:38       ` Tassilo Horn
     [not found]       ` <mailman.7252.1385555936.10748.help-gnu-emacs@gnu.org>
2013-11-27 20:10         ` Emanuel Berg
2013-11-28 10:06           ` Jambunathan K
     [not found]           ` <mailman.7323.1385633250.10748.help-gnu-emacs@gnu.org>
2013-11-28 15:25             ` Emanuel Berg

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