Discussion:
Macro suddenly broken
Peter Davis
2015-08-14 14:47:13 UTC
Permalink
I've been using gnus for months on Aquamacs on a Mac OS X 10.10 system,
but suddenly, the 'd' macro that I've designed to mark a message as
expirable and move to the next one is failing with:

After 0 kbd macro iterations: undefined: Keyboard macro terminated by a command ringing the bell

I'm not aware of anything that's changed in my emacs or gnus setup. I
have defined a macro that use 'd' for delete/next:

D runs the command [77 77 101 101 down 103], which is a keyboard macro.

It is bound to D.


Macro: 2*M 2*e <down> g

Keyboard macro.

Any clues what might be going wrong here?

Thank you.

-pd
Peter Davis
2015-08-14 15:01:18 UTC
Permalink
Post by Peter Davis
I've been using gnus for months on Aquamacs on a Mac OS X 10.10 system,
but suddenly, the 'd' macro that I've designed to mark a message as
After 0 kbd macro iterations: undefined: Keyboard macro terminated by a command ringing the bell
I'm not aware of anything that's changed in my emacs or gnus setup. I
D runs the command [77 77 101 101 down 103], which is a keyboard macro.
It is bound to D.
Macro: 2*M 2*e <down> g
Keyboard macro.
Interestingly, the same macro is working on another Mac.

Thanks,
-pd
Tassilo Horn
2015-08-14 15:49:20 UTC
Permalink
Post by Peter Davis
I've been using gnus for months on Aquamacs on a Mac OS X 10.10
system, but suddenly, the 'd' macro that I've designed to mark a
After 0 kbd macro iterations: undefined: Keyboard macro terminated by a
command ringing the bell
I'm not aware of anything that's changed in my emacs or gnus setup. I
D runs the command [77 77 101 101 down 103], which is a keyboard macro.
It is bound to D.
Macro: 2*M 2*e <down> g
Keyboard macro.
Any clues what might be going wrong here?
Not really but what happens when you run the keyboard macro manually,
i.e., just press the sequence of keys defining it?

The "ringing the bell" means that some error during movement occurred,
e.g., like pressing <down> when you are already on the last line of the
buffer.

Bye,
Tassilo
Peter Davis
2015-08-14 16:17:19 UTC
Permalink
Post by Tassilo Horn
Post by Peter Davis
I've been using gnus for months on Aquamacs on a Mac OS X 10.10
system, but suddenly, the 'd' macro that I've designed to mark a
After 0 kbd macro iterations: undefined: Keyboard macro terminated by a
command ringing the bell
I'm not aware of anything that's changed in my emacs or gnus setup. I
D runs the command [77 77 101 101 down 103], which is a keyboard macro.
It is bound to D.
Macro: 2*M 2*e <down> g
Keyboard macro.
Any clues what might be going wrong here?
Not really but what happens when you run the keyboard macro manually,
i.e., just press the sequence of keys defining it?
The "ringing the bell" means that some error during movement occurred,
e.g., like pressing <down> when you are already on the last line of the
buffer.
Thank you. On the non-working system, I type:

M M e, but Emacs displays:

^M ^M E is undefined

(I used '^' for shift arrows)

The next 'e' puts the article in edit mode.

The definitions (and the .gnus.el files) are the same on the two systems:

(defun pm/alter-summary-map ()
(local-set-key "d" [?M ?M ?e ?e down ?g]))

(defun pm/alter-article-map ()
(local-set-key "d" "MMeen"))

Thanks,
-pd
Peter Davis
2015-08-15 13:06:37 UTC
Permalink
Post by Peter Davis
Post by Tassilo Horn
Post by Peter Davis
I've been using gnus for months on Aquamacs on a Mac OS X 10.10
system, but suddenly, the 'd' macro that I've designed to mark a
After 0 kbd macro iterations: undefined: Keyboard macro terminated by a
command ringing the bell
I'm not aware of anything that's changed in my emacs or gnus setup. I
D runs the command [77 77 101 101 down 103], which is a keyboard macro.
It is bound to D.
Macro: 2*M 2*e <down> g
Keyboard macro.
Any clues what might be going wrong here?
Not really but what happens when you run the keyboard macro manually,
i.e., just press the sequence of keys defining it?
The "ringing the bell" means that some error during movement occurred,
e.g., like pressing <down> when you are already on the last line of the
buffer.
^M ^M E is undefined
(I used '^' for shift arrows)
The next 'e' puts the article in edit mode.
(defun pm/alter-summary-map ()
(local-set-key "d" [?M ?M ?e ?e down ?g]))
(defun pm/alter-article-map ()
(local-set-key "d" "MMeen"))
Does anyone even have a suggestion for how to trouble-shoot this? I'm not lisp-savvy, but I know that same code running on two
identical Macs should behave the same way. I'm using the same .gnus.el file, and it works correctly on one, and used to work on the
other, but now suddenly started failing. I've restarted emacs and rebooted the system several times, but no joy.

Any clues?

Thank you,
-pd
Tassilo Horn
2015-08-17 07:19:15 UTC
Permalink
Post by Peter Davis
Post by Tassilo Horn
Not really but what happens when you run the keyboard macro manually,
i.e., just press the sequence of keys defining it?
The "ringing the bell" means that some error during movement
occurred, e.g., like pressing <down> when you are already on the last
line of the buffer.
^M ^M E is undefined
Same here: M M e is undefined

I guess, that's already the reason. The keyboard macro fails because
the start of the macro's key sequence doesn't invoke any command.
Post by Peter Davis
(defun pm/alter-summary-map ()
(local-set-key "d" [?M ?M ?e ?e down ?g]))
(defun pm/alter-article-map ()
(local-set-key "d" "MMeen"))
Is is possible that you are running two different Gnus versions on the
two computers, i.e., in one version M M e is bound to something and in
one it is not? (I use the latest Gnus version from Git, and there M M
e is not bound neither in the summary nor in the article buffer.)

Anyway, what does `C-h k M M e' show in a summary/article buffer on the
computer where your macro still works?

Bye,
Tassilo
Peter Davis
2015-08-17 12:18:56 UTC
Permalink
Post by Tassilo Horn
Post by Peter Davis
Post by Tassilo Horn
Not really but what happens when you run the keyboard macro manually,
i.e., just press the sequence of keys defining it?
The "ringing the bell" means that some error during movement
occurred, e.g., like pressing <down> when you are already on the last
line of the buffer.
^M ^M E is undefined
Same here: M M e is undefined
I guess, that's already the reason. The keyboard macro fails because
the start of the macro's key sequence doesn't invoke any command.
On the working system, 'M M e' is nothing, but 'M M e e' is:

⇧M ⇧M E E runs the command gnus-summary-put-mark-as-expirable, which
is an interactive Lisp function in `gnus-sum.el'.

It is bound to ⇧M ⇧M E E.

(gnus-summary-put-mark-as-expirable N)


Mark the current article as expirable.
If N, the prefix, then repeat N times.
If N is negative, move in reverse order.
The difference between N and the actual number of articles marked is
returned.
Post by Tassilo Horn
Post by Peter Davis
(defun pm/alter-summary-map ()
(local-set-key "d" [?M ?M ?e ?e down ?g]))
(defun pm/alter-article-map ()
(local-set-key "d" "MMeen"))
Is is possible that you are running two different Gnus versions on the
two computers, i.e., in one version M M e is bound to something and in
one it is not? (I use the latest Gnus version from Git, and there M M
e is not bound neither in the summary nor in the article buffer.)
Anyway, what does `C-h k M M e' show in a summary/article buffer on the
computer where your macro still works?
As above, 'M M e e' is (gnus-summary-put-mark-as-expirable N)

So it appears something is causing the failing emacs to think 'M M e' is the whole sequence, and it's undefined. That gets me a
little closer.

Thank you, Tassilo!

-pd
Tassilo Horn
2015-08-18 07:46:20 UTC
Permalink
Post by Peter Davis
Post by Tassilo Horn
Post by Peter Davis
Post by Tassilo Horn
Not really but what happens when you run the keyboard macro
manually, i.e., just press the sequence of keys defining it?
The "ringing the bell" means that some error during movement
occurred, e.g., like pressing <down> when you are already on the last
line of the buffer.
^M ^M E is undefined
Same here: M M e is undefined
I guess, that's already the reason. The keyboard macro fails because
the start of the macro's key sequence doesn't invoke any command.
What does "nothing" mean? I guess "the key sequence is not finished",
right?
Post by Peter Davis
⇧M ⇧M E E runs the command gnus-summary-put-mark-as-expirable, which
is an interactive Lisp function in `gnus-sum.el'.
Anyway. By default, `gnus-summary-put-mark-as-expirable' is not bound
to a key, at least not in the current Gnus version. Is it possible that
you've bound it, e.g., in ~/.gnus.el, on the machine where the macro
works?

Well, what you can do of course is define your keyboard macro in such a
way that it doesn't depend on key bindings, that is, the keyboard macro
would do

M-x gnus-summary-put-mark-as-expirable RET...

instead of

M M e e...

Bye,
Tassilo
Peter Davis
2015-08-18 12:28:06 UTC
Permalink
Post by Tassilo Horn
Post by Peter Davis
Post by Tassilo Horn
Post by Peter Davis
Post by Tassilo Horn
Not really but what happens when you run the keyboard macro
manually, i.e., just press the sequence of keys defining it?
The "ringing the bell" means that some error during movement
occurred, e.g., like pressing <down> when you are already on the last
line of the buffer.
^M ^M E is undefined
Same here: M M e is undefined
I guess, that's already the reason. The keyboard macro fails because
the start of the macro's key sequence doesn't invoke any command.
What does "nothing" mean? I guess "the key sequence is not finished",
right?
Nothing means that if I type 'M M e', emacs immediately responds that this is undefined, without waiting for any further keystrokes.
Post by Tassilo Horn
Post by Peter Davis
⇧M ⇧M E E runs the command gnus-summary-put-mark-as-expirable, which
is an interactive Lisp function in `gnus-sum.el'.
Anyway. By default, `gnus-summary-put-mark-as-expirable' is not bound
to a key, at least not in the current Gnus version. Is it possible that
you've bound it, e.g., in ~/.gnus.el, on the machine where the macro
works?
It's not defined anywhere in my .emacs or .gnus.el file. In fact, the sequence originally came from an example Peter Münster posted
to this list, so it evidently worked for him.
Post by Tassilo Horn
Well, what you can do of course is define your keyboard macro in such a
way that it doesn't depend on key bindings, that is, the keyboard macro
would do
M-x gnus-summary-put-mark-as-expirable RET...
instead of
M M e e...
Yes, I'd have to figure out how to do the rest of the behavior (moving to and showing the next message in the group). As I
mentioned, I'm not lisp-savvy, but I could figure this out in time.

I'm still puzzled about why it suddenly stopped working, after being in use for months.

Thanks,
-pd
Tassilo Horn
2015-08-18 14:10:05 UTC
Permalink
Post by Peter Davis
Post by Tassilo Horn
What does "nothing" mean? I guess "the key sequence is not finished",
right?
Nothing means that if I type 'M M e', emacs immediately responds that
this is undefined, without waiting for any further keystrokes.
Wow, this is really strange. If `M M e' is described as undefined, then
actually `e' should be bound to `gnus-summary-put-mark-as-expirable'.
Post by Peter Davis
Post by Tassilo Horn
Post by Peter Davis
⇧M ⇧M E E runs the command gnus-summary-put-mark-as-expirable,
which is an interactive Lisp function in `gnus-sum.el'.
Is that the literal output? I've never seen this key notation in emacs.
Here, it would say `M M e e'. Is that something inherent to Aquamacs?
Post by Peter Davis
Post by Tassilo Horn
Anyway. By default, `gnus-summary-put-mark-as-expirable' is not bound
to a key, at least not in the current Gnus version. Is it possible that
you've bound it, e.g., in ~/.gnus.el, on the machine where the macro
works?
It's not defined anywhere in my .emacs or .gnus.el file. In fact, the
sequence originally came from an example Peter Münster posted to this
list, so it evidently worked for him.
Ok, I see.
Post by Peter Davis
Post by Tassilo Horn
Well, what you can do of course is define your keyboard macro in such
a way that it doesn't depend on key bindings, that is, the keyboard
macro would do
M-x gnus-summary-put-mark-as-expirable RET...
instead of
M M e e...
Yes, I'd have to figure out how to do the rest of the behavior (moving
to and showing the next message in the group). As I mentioned, I'm not
lisp-savvy, but I could figure this out in time.
Binding keys to vectors of keys is not the best way to persist keyboard
macros. Basically, I'd recommend you re-record your macro using

1. Start recording with <f3>.

2. Perform the actions you want to record, e.g., expire the current
message and move on to the next one. You can use key bindings for
that but also the menu or tool bar or M-x ...

3. Finish recording of the macro with <f4>.

4. Give the last recently recorded keyboard macro a name, e.g.,
`pd/gnus-expire-and-move-on' using `C-x C-k n'

5. Open your ~/.emacs, move point to some empty line and do ` M-x
insert-kbd-macro RET pd/gnus-expire-and-move-on RET'. This will
insert a command definition for the given keyboard macro. Then you
can bind that command rather than a plain key sequence in your
`pm/alter-*-map' functions which I guess are run in
`gnus-summary-mode-hook' and `gnus-article-mode-hook'.
Post by Peter Davis
I'm still puzzled about why it suddenly stopped working, after being in use for months.
Yes, me too. Is it possible that you are using different Aquamacs
versions on the two computers? AFAIK, the current Aquamacs release is
based on emacs 24.x whereas the previos version was based on emacs 23.x.
It is possible that something in the handling of keyboard macros has
changed between versions (although I cannot find a corresponding NEWS
entry).

Concretely, from what you are telling it seems as if the current version
errors when a keyboard macro invokes an undefined key binding whereas
the older version just ignores it and continues with the rest of the
macro's keys.

Bye,
Tassilo
Peter Davis
2015-08-19 23:23:36 UTC
Permalink
Post by Tassilo Horn
Binding keys to vectors of keys is not the best way to persist keyboard
macros. Basically, I'd recommend you re-record your macro using
1. Start recording with <f3>.
2. Perform the actions you want to record, e.g., expire the current
message and move on to the next one. You can use key bindings for
that but also the menu or tool bar or M-x ...
3. Finish recording of the macro with <f4>.
4. Give the last recently recorded keyboard macro a name, e.g.,
`pd/gnus-expire-and-move-on' using `C-x C-k n'
5. Open your ~/.emacs, move point to some empty line and do ` M-x
insert-kbd-macro RET pd/gnus-expire-and-move-on RET'. This will
insert a command definition for the given keyboard macro. Then you
can bind that command rather than a plain key sequence in your
`pm/alter-*-map' functions which I guess are run in
`gnus-summary-mode-hook' and `gnus-article-mode-hook'.
Thanks very much for the detailed instructions. This will certainly be useful in the future. However, ...

I did this, resulting in:

(fset 'pd/gnus-expire-and-show-next
(lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("E " 0 "%d")) arg)))

(defun pm/alter-summary-map ()
; (local-set-key "d" [?M ?M ?e ?e down ?g])
(local-set-key "d" 'pd/gnus-expire-and-show-next)
(local-set-key "vj" "BmINBOX.Junk Mail")
)

Unfortunately, I'm *still* getting:

After 0 kbd macro iterations: undefined: Keyboard macro terminated by a command ringing the bell

Ah, well.

Thank you!
-pd
--
----
Peter Davis
The Tech Curmudgeon
www.techcurmudgeon.com
Tassilo Horn
2015-08-20 05:01:30 UTC
Permalink
Peter Davis <***@pfdstudio.com> writes:

Hi Peter,
Post by Peter Davis
Thanks very much for the detailed instructions. This will certainly be
useful in the future. However, ...
(fset 'pd/gnus-expire-and-show-next
(lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("E " 0 "%d")) arg)))
(defun pm/alter-summary-map ()
; (local-set-key "d" [?M ?M ?e ?e down ?g])
(local-set-key "d" 'pd/gnus-expire-and-show-next)
(local-set-key "vj" "BmINBOX.Junk Mail")
)
After 0 kbd macro iterations: undefined: Keyboard macro terminated by
a command ringing the bell
Strange. I can use that here and it works, i.e., it marks the current
article as expirable and then selects the next one if there's any. No
errors.

Sorry, now I'm running out of ideas...

Bye,
Tassilo
Peter Davis
2015-08-20 12:11:06 UTC
Permalink
Post by Tassilo Horn
Hi Peter,
Post by Peter Davis
Thanks very much for the detailed instructions. This will certainly be
useful in the future. However, ...
(fset 'pd/gnus-expire-and-show-next
(lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("E " 0 "%d")) arg)))
(defun pm/alter-summary-map ()
; (local-set-key "d" [?M ?M ?e ?e down ?g])
(local-set-key "d" 'pd/gnus-expire-and-show-next)
(local-set-key "vj" "BmINBOX.Junk Mail")
)
After 0 kbd macro iterations: undefined: Keyboard macro terminated by
a command ringing the bell
Strange. I can use that here and it works, i.e., it marks the current
article as expirable and then selects the next one if there's any. No
errors.
So that suggests that the problem is not in the macro definition at all, but in some function that's getting invoked by it. Maybe I
need to completely remove and re-install gnus or Aquamacs or both.

I notice, though, from my limited understanding of lisp, it appears the recorded macro still depends on the definition of the "E"
key, rather than invoking a lisp function directly. I can try re-recording it just using function calls.
Post by Tassilo Horn
Sorry, now I'm running out of ideas...
I was out of ideas when I started this thread, so thank you for keeping this alive, and for the wealth of information you've provided
along the way.

Cheers,
-pd
Tassilo Horn
2015-08-20 12:31:49 UTC
Permalink
Post by Peter Davis
Post by Tassilo Horn
Strange. I can use that here and it works, i.e., it marks the
current article as expirable and then selects the next one if there's
any. No errors.
So that suggests that the problem is not in the macro definition at
all, but in some function that's getting invoked by it.
It means that `E' is not bound to a command when the macro is executed,
and I have no clue how that can happen because you said that `E' works
when you do it manually, i.e., press just `E' in the summary buffer.
Post by Peter Davis
Maybe I need to completely remove and re-install gnus or Aquamacs or
both.
I don't think this is or can be caused by a broken Gnus install but of
course try. And let us know if you could fix the issue.
Post by Peter Davis
I notice, though, from my limited understanding of lisp, it appears
the recorded macro still depends on the definition of the "E" key,
rather than invoking a lisp function directly. I can try re-recording
it just using function calls.
Yes, it does. A keyboard macro just does exactly what you have been
recording, so when you press `E', it'll record that. When you do `M-x
gnus-summary-mark-as-expirable RET', it'll record that. Both macros
have the same effect but the former will break if the binding changes
(unlikely), and the second one will break if the command name changes
(even more unlikely).
Post by Peter Davis
Post by Tassilo Horn
Sorry, now I'm running out of ideas...
I was out of ideas when I started this thread, so thank you for
keeping this alive, and for the wealth of information you've provided
along the way.
You're welcome!

Bye,
Tassilo
Peter Davis
2015-08-20 12:57:34 UTC
Permalink
Post by Tassilo Horn
Post by Peter Davis
Post by Tassilo Horn
Strange. I can use that here and it works, i.e., it marks the
current article as expirable and then selects the next one if there's
any. No errors.
So that suggests that the problem is not in the macro definition at
all, but in some function that's getting invoked by it.
It means that `E' is not bound to a command when the macro is executed,
and I have no clue how that can happen because you said that `E' works
when you do it manually, i.e., press just `E' in the summary buffer.
I pressed 'E' when I was recording the macro, and it did expire the message.
Post by Tassilo Horn
Post by Peter Davis
Maybe I need to completely remove and re-install gnus or Aquamacs or
both.
I don't think this is or can be caused by a broken Gnus install but of
course try. And let us know if you could fix the issue.
I'll try re-recording the macro using the gnus-summary-mark-as-expirable function and see if that helps.
Post by Tassilo Horn
You're welcome!
And thank you again!

-pd

Loading...