strange behaviour in keyboard macro

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

strange behaviour in keyboard macro

Héctor Lahoz
I saved a keyboard macro like this:

<<search-forward>> ;; search-forward
Priority: ;; self-insert-command * 9
SPC ;; self-insert-command
required ;; self-insert-command * 8
RET ;; newline
<<backward-paragraph>> ;; backward-paragraph
C-n ;; next-line
<<search-forward>> ;; search-forward
: ;; self-insert-command
SPC ;; self-insert-command
RET ;; newline

When I execute it sometimes it does what I mean and the cursor ends on the right line.
But sometimes it ends (erroneously) on the following line. For example (I added numbers
for reference):

1: Package: mypkg
2: xxxxxxxxxxxxxx
3:  xxxxxxxxxxxxxx
4: Priority: normal
5:
6: Package: mypkg2
7: xxxxxxxxxxxxxx
8: Priority: required

backward-paragraph should set the cursor at line 5 (blank line) so
cursor should end up at line 6.

At first it seemed random. Then I tried to find a pattern and found
out that it has something to do with text scrolling. When I repeat the
macro starting at a distant point (like half the window size) I manage
to get alternating results, that is, with one execution it ends at
line 6 and with the next execution (reseting the start position) it
ends at line 7.

Emacs version 24.4.1. Fundamental mode.
Is this a bug? I think with emacs 23 it worked fine.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: strange behaviour in keyboard macro

Emanuel Berg-4
Héctor Lahoz wrote:

> I saved a keyboard macro [...]

Rewrite it an Elisp function and voilà probably
you can work out debugging without us :)

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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: strange behaviour in keyboard macro

Héctor Lahoz
Emanuel Berg wrote:
> Héctor Lahoz wrote:
>
> > I saved a keyboard macro [...]
>
> Rewrite it an Elisp function and voilà probably
> you can work out debugging without us :)

Yes, it's not very long. But I wanted to do it
quickly without programming. Then, what's the
point of having keyboard macros?

For the time being I came through by using

<<search-backward>>     ;; search-backward
C-q                     ;; quoted-insert
LFD                     ;; nroff-electric-newline
C-q                     ;; quoted-insert
LFD                     ;; nroff-electric-newline
RET                     ;; newline

instead of "backward-paragraph".

I hate when programs don't behave as I expect.
Especially with Emacs :-) Although most of the
time it is because I don't understand them.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: strange behaviour in keyboard macro

Emanuel Berg-4
Héctor Lahoz wrote:

>> Rewrite it an Elisp function and voilà
>> probably you can work out debugging without
>> us :)
>
> Yes, it's not very long. But I wanted to do
> it quickly without programming. Then, what's
> the point of having keyboard macros?

None whatsoever for people like you who know
how to program.

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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: strange behaviour in keyboard macro

Emanuel Berg-4
In reply to this post by Héctor Lahoz
Héctor Lahoz wrote:

> I hate when programs don't behave as
> I expect.

Agree 100%

> Although most of the time it is because
> I don't understand them.

*All* of the time!

Some people say the whole universe is
deterministic. And at least they are correct
with respect to computers! That's the
whole foundation.

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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: strange behaviour in keyboard macro

Marcin Borkowski-3
In reply to this post by Emanuel Berg-4

On 2017-07-30, at 15:46, Emanuel Berg <[hidden email]> wrote:

> Héctor Lahoz wrote:
>
>>> Rewrite it an Elisp function and voilà
>>> probably you can work out debugging without
>>> us :)
>>
>> Yes, it's not very long. But I wanted to do
>> it quickly without programming. Then, what's
>> the point of having keyboard macros?
>
> None whatsoever for people like you who know
> how to program.

Speed.

Best,

--
Marcin Borkowski

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: strange behaviour in keyboard macro

Emanuel Berg-4
Marcin Borkowski wrote:

>>> Yes, it's not very long. But I wanted to do
>>> it quickly without programming. Then,
>>> what's the point of having keyboard macros?
>>
>> None whatsoever for people like you who know
>> how to program.
>
> Speed.

Not in the medium or long run as you get better
with Elisp, and keyboard macros are much more
difficult to adapt/debug.

There is the ELPA and MELPA with readily
transferable Elisp for a reason. But where do
you guys get your keyboard macros?
The port block?

Learn to type really, really fast. Use Elisp
whenever it isn't fast enough. Speed kills.

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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: strange behaviour in keyboard macro

Marcin Borkowski-3

On 2017-07-30, at 23:47, Emanuel Berg <[hidden email]> wrote:

> Marcin Borkowski wrote:
>
>>>> Yes, it's not very long. But I wanted to do
>>>> it quickly without programming. Then,
>>>> what's the point of having keyboard macros?
>>>
>>> None whatsoever for people like you who know
>>> how to program.
>>
>> Speed.
>
> Not in the medium or long run as you get better
> with Elisp, and keyboard macros are much more
> difficult to adapt/debug.
>
> There is the ELPA and MELPA with readily
> transferable Elisp for a reason. But where do
> you guys get your keyboard macros?
> The port block?

A typical use case: I need to fix/edit/add something in a configuration
file, using the format VARIABLE=value, for 4-5 variables with similar
names (like PREFIX_SOMETHING=value, where value is somehow based on
SOMETHING).  I record a keybord macro, press F4 3-4 times, bam, done, in
10 seconds.  (Recently, I started to use multiple cursors for that kind
of stuff, too, but keyboard macros are a tad more powerful, I guess.)

> Learn to type really, really fast. Use Elisp
> whenever it isn't fast enough. Speed kills.

Typing fast would be fine, but keyboard macros don't make mistakes.

--
Marcin Borkowski

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: strange behaviour in keyboard macro

Emanuel Berg-4
Marcin Borkowski wrote:

> A typical use case: I need to fix/edit/add
> something in a configuration file, using the
> format VARIABLE=value, for 4-5 variables with
> similar names (like PREFIX_SOMETHING=value,
> where value is somehow based on SOMETHING).
> I record a keybord macro, press F4 3-4 times,
> bam, done, in 10 seconds. (Recently,
> I started to use multiple cursors for that
> kind of stuff, too, but keyboard macros are
> a tad more powerful, I guess.)

4-5 variables?! :O

I think I'd do *40-50* with typing only before
I even considered anything else. And it takes
less time than drinking a 33 cl 2.8% beer.
Ba ba ba ba ba ba ba. Done.

For configuration files absolutely unnecessary
both keyboard macros and Elisp. Perhaps for
huge batch data files, but then I'd use some
shell processing tool to clean that up, rather.

Here, I say "Elisp" as in Elisp to do the
specific case. But Santa has a few helpers that
works in general, and can be applied to many
situations, e.g.:

    http://user.it.uu.se/~embe8573/emacs-init/align.el

>> Learn to type really, really fast. Use Elisp
>> whenever it isn't fast enough. Speed kills.
>
> Typing fast would be fine, but keyboard
> macros don't make mistakes.

They do which is one of their problems.
Doing Elisp also has errors (bugs) but 1) they
are much easier to fix, and 2) the solution is
transferable and transformable. Keyboard macros
are poor-man's programming by definition.

Will be inferior, always. And they don't lead
anywhere. Elisp on the contrary leads to more
Elisp, to the destruction of many young men's
careers and so on. But what do you need
a career for when you have Elisp?

TEHO, of course.

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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: strange behaviour in keyboard macro

Stefan Huchler
Emanuel Berg <[hidden email]> writes:

> Will be inferior, always. And they don't lead
> anywhere. Elisp on the contrary leads to more
> Elisp, to the destruction of many young men's
> careers and so on. But what do you need
> a career for when you have Elisp?
>
> TEHO, of course.

Ahh lol, so I am not the only one :D with no career :)

Well had none before I learned elisp, but I feel like elisp makes shure
that I never will have one :D


Loading...