unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
@ 2022-05-19  1:59 Lars Ingebrigtsen
  2022-05-19  7:08 ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-19  1:59 UTC (permalink / raw)
  To: 55514


visual-line-mode is nice, but it has one major drawback -- it makes
<down> not "reliable" when recording macros.

That is, if you record

C-x ( C-SPC <down> <down> C-k C-x )

(i.e., "kill two lines"), you can't really use `C-x e' to do much of
anything, because the buffer may have too-long lines that makes <down>
move down into the middle of a logical line.

So perhaps we should have a user option that remaps
next-line/previous-line to next-logical-line/previous-logical-line while
inside a `C-x ('?

(Or something to that effect -- perhaps the user option should make `C-x
(' switch visual-line-mode off and exiting recording switches it on
again (and the recorded macro would also contain those commands).


In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0)
 of 2022-05-17 built on xo
Repository revision: 803041e01474f2a522170c9f388068e8460be2ae
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Debian GNU/Linux bookworm/sid


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no






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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-19  1:59 bug#55514: 29.0.50; Keyboard macros and visual-line-mode Lars Ingebrigtsen
@ 2022-05-19  7:08 ` Eli Zaretskii
  2022-05-19 23:41   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-05-19  7:08 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55514

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Thu, 19 May 2022 03:59:01 +0200
> 
> visual-line-mode is nice, but it has one major drawback -- it makes
> <down> not "reliable" when recording macros.
> 
> That is, if you record
> 
> C-x ( C-SPC <down> <down> C-k C-x )
> 
> (i.e., "kill two lines"), you can't really use `C-x e' to do much of
> anything, because the buffer may have too-long lines that makes <down>
> move down into the middle of a logical line.
> 
> So perhaps we should have a user option that remaps
> next-line/previous-line to next-logical-line/previous-logical-line while
> inside a `C-x ('?
> 
> (Or something to that effect -- perhaps the user option should make `C-x
> (' switch visual-line-mode off and exiting recording switches it on
> again (and the recorded macro would also contain those commands).

Maybe all we need is to add a hook that will be called by
kmacro-call-macro before running the macro.  Then users can do
whatever they like in that hook, including turning off
line-move-visual (which I'm guessing is what you meant, not
visual-line-mode).

We could also have a new user option to turn that off automatically
while running a macro, but that sounds too specific to some uses of
macros in some use cases, not something many users will want in many
cases.





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-19  7:08 ` Eli Zaretskii
@ 2022-05-19 23:41   ` Lars Ingebrigtsen
  2022-05-20  7:01     ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-19 23:41 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 55514

Eli Zaretskii <eliz@gnu.org> writes:

> Maybe all we need is to add a hook that will be called by
> kmacro-call-macro before running the macro.  Then users can do
> whatever they like in that hook, including turning off
> line-move-visual (which I'm guessing is what you meant, not
> visual-line-mode).

But that doesn't really fix the issue -- the non-visual-line-moving
commands have to be replicated when we execute the macro.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-19 23:41   ` Lars Ingebrigtsen
@ 2022-05-20  7:01     ` Eli Zaretskii
  2022-05-20  7:14       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-05-20  7:01 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55514

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: 55514@debbugs.gnu.org
> Date: Fri, 20 May 2022 01:41:30 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Maybe all we need is to add a hook that will be called by
> > kmacro-call-macro before running the macro.  Then users can do
> > whatever they like in that hook, including turning off
> > line-move-visual (which I'm guessing is what you meant, not
> > visual-line-mode).
> 
> But that doesn't really fix the issue -- the non-visual-line-moving
> commands have to be replicated when we execute the macro.

No, you need just turn off line-move-visual in that hook, then C-n
will follow physical lines instead of visual lines, which is AFAIU
what you wanted.





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-20  7:01     ` Eli Zaretskii
@ 2022-05-20  7:14       ` Lars Ingebrigtsen
  2022-05-20  7:22         ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-20  7:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 55514

Eli Zaretskii <eliz@gnu.org> writes:

> No, you need just turn off line-move-visual in that hook, then C-n
> will follow physical lines instead of visual lines, which is AFAIU
> what you wanted.

I don't understand what you mean here.  Of course `C-n' will move
logically when you switch line-move-visual off.  But when you switch it
back on again after recording the macro, `C-x e' will move visually
again, which is what you don't want.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-20  7:14       ` Lars Ingebrigtsen
@ 2022-05-20  7:22         ` Eli Zaretskii
  2022-05-20  7:26           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-05-20  7:22 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55514

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: 55514@debbugs.gnu.org
> Date: Fri, 20 May 2022 09:14:23 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > No, you need just turn off line-move-visual in that hook, then C-n
> > will follow physical lines instead of visual lines, which is AFAIU
> > what you wanted.
> 
> I don't understand what you mean here.  Of course `C-n' will move
> logically when you switch line-move-visual off.  But when you switch it
> back on again after recording the macro, `C-x e' will move visually
> again, which is what you don't want.

Then maybe I didn't understand the original report.  I thought you
wanted a way to make sure the macro runs with C-n/C-p working by
physical lines?





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-20  7:22         ` Eli Zaretskii
@ 2022-05-20  7:26           ` Lars Ingebrigtsen
  2022-05-20 10:46             ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-20  7:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 55514

Eli Zaretskii <eliz@gnu.org> writes:

> Then maybe I didn't understand the original report.  I thought you
> wanted a way to make sure the macro runs with C-n/C-p working by
> physical lines?

I want people to be able to create usable keyboard macros -- that's the
major regression line-move-visual led to, so I never understood why this
wasn't fixed when it was introduced.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-20  7:26           ` Lars Ingebrigtsen
@ 2022-05-20 10:46             ` Eli Zaretskii
  2022-05-21 11:40               ` Lars Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-05-20 10:46 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55514

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: 55514@debbugs.gnu.org
> Date: Fri, 20 May 2022 09:26:50 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Then maybe I didn't understand the original report.  I thought you
> > wanted a way to make sure the macro runs with C-n/C-p working by
> > physical lines?
> 
> I want people to be able to create usable keyboard macros -- that's the
> major regression line-move-visual led to, so I never understood why this
> wasn't fixed when it was introduced.

I don't agree that using visual-line movement in a macro makes the
macro "unusable".  But I don't mind supporting your use case.  As I
said earlier, we could add a special value of line-move-visual, which
would mean "move by visual lines, except when executing macros", which
would I think solve your problem.  I just thought that adding a hook
could cater to a more general class of use cases, that's all.





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-20 10:46             ` Eli Zaretskii
@ 2022-05-21 11:40               ` Lars Ingebrigtsen
  2022-05-21 12:41                 ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-21 11:40 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 55514

Eli Zaretskii <eliz@gnu.org> writes:

> As I said earlier, we could add a special value of line-move-visual,
> which would mean "move by visual lines, except when executing macros",
> which would I think solve your problem. 

That seems like a heavier solution than I had envisioned (without
looking at the code).  You can bind keyboard macros to keys and have
them executed, and the point is that they should execute the same way as
they were recorded.  That's the fantastic utility of recording keyboard
macros, after all.

I don't think a setting that affects line-move-visual in this way would
be all that sturdy.  You can, for instance, record a macro, save it to a
file, and use it later.  It would be awkward if flipping a setting then
affects how the macro executes.

I think having <down> recorded as `M-x next-logical-line' (etc), or
something to that effect, is the way to go here.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-21 11:40               ` Lars Ingebrigtsen
@ 2022-05-21 12:41                 ` Eli Zaretskii
  2022-05-21 13:38                   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-05-21 12:41 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55514

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: 55514@debbugs.gnu.org
> Date: Sat, 21 May 2022 13:40:38 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > As I said earlier, we could add a special value of line-move-visual,
> > which would mean "move by visual lines, except when executing macros",
> > which would I think solve your problem. 
> 
> That seems like a heavier solution than I had envisioned (without
> looking at the code).  You can bind keyboard macros to keys and have
> them executed, and the point is that they should execute the same way as
> they were recorded.  That's the fantastic utility of recording keyboard
> macros, after all.

I don't think I understand.  Emacs always knows when it is executing a
keyboard macro.

And what do you mean by "execute the same as they were recorded"?
With C-n, it can only be exactly "the same" if you move across exactly
the same text.  Once the text is different, the partition into
physical and screen lines is different, and the effect is different.

To my mind, keyboard macros are about repeating the _commands_; the
effect of those commands is not guaranteed to be exactly the same in
each case.

> I don't think a setting that affects line-move-visual in this way would
> be all that sturdy.  You can, for instance, record a macro, save it to a
> file, and use it later.  It would be awkward if flipping a setting then
> affects how the macro executes.

The idea was that you won't flip the value, but set it once to that
value, assuming that you always (or frequently) want C-n/C-p go by
physical lines when invoked from a macro.  Wasn't that your original
request?

> I think having <down> recorded as `M-x next-logical-line' (etc), or
> something to that effect, is the way to go here.

That's trivial to program, so I'm not sure I understand why would we
need that in core.





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-21 12:41                 ` Eli Zaretskii
@ 2022-05-21 13:38                   ` Lars Ingebrigtsen
  2022-05-21 13:59                     ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-21 13:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 55514

Eli Zaretskii <eliz@gnu.org> writes:

> And what do you mean by "execute the same as they were recorded"?

Moving logically versus visually.

>> I think having <down> recorded as `M-x next-logical-line' (etc), or
>> something to that effect, is the way to go here.
>
> That's trivial to program, so I'm not sure I understand why would we
> need that in core.

Trivial how?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-21 13:38                   ` Lars Ingebrigtsen
@ 2022-05-21 13:59                     ` Eli Zaretskii
  2022-05-22 11:14                       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-05-21 13:59 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55514

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: 55514@debbugs.gnu.org
> Date: Sat, 21 May 2022 15:38:37 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > And what do you mean by "execute the same as they were recorded"?
> 
> Moving logically versus visually.

Not sure I follow.  When you recorded the macro, was C-n moving by
logical lines or by screen lines?  If the former, how did you get it
to move by logical lines, when the default is to move by screen lines?

> >> I think having <down> recorded as `M-x next-logical-line' (etc), or
> >> something to that effect, is the way to go here.
> >
> > That's trivial to program, so I'm not sure I understand why would we
> > need that in core.
> 
> Trivial how?

Write a command that binds line-move-visual to nil and invokes
next-line, then bind it to some key, and use that key when you record
the macro.

But maybe your answer to my first questions above will explain to me
that I misunderstood you all the way.





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-21 13:59                     ` Eli Zaretskii
@ 2022-05-22 11:14                       ` Lars Ingebrigtsen
  2022-05-22 13:00                         ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-22 11:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 55514

Eli Zaretskii <eliz@gnu.org> writes:

> Not sure I follow.  When you recorded the macro, was C-n moving by
> logical lines or by screen lines?  If the former, how did you get it
> to move by logical lines, when the default is to move by screen lines?

That is what this bug report is about -- recording and executing macros.

> Write a command that binds line-move-visual to nil and invokes
> next-line, then bind it to some key, and use that key when you record
> the macro.

I think we'll just have to let this rest for a while, because we've been
over this too many times.  The original bug report really has all the
details.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#55514: 29.0.50; Keyboard macros and visual-line-mode
  2022-05-22 11:14                       ` Lars Ingebrigtsen
@ 2022-05-22 13:00                         ` Eli Zaretskii
  0 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2022-05-22 13:00 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55514

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: 55514@debbugs.gnu.org
> Date: Sun, 22 May 2022 13:14:37 +0200
> 
> I think we'll just have to let this rest for a while, because we've been
> over this too many times.  The original bug report really has all the
> details.

FWIW, I think my proposal -- to have an optional feature whereby
C-n/C-p move by logical lines inside a macro -- would solve the issue
presented in the original report.





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

end of thread, other threads:[~2022-05-22 13:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19  1:59 bug#55514: 29.0.50; Keyboard macros and visual-line-mode Lars Ingebrigtsen
2022-05-19  7:08 ` Eli Zaretskii
2022-05-19 23:41   ` Lars Ingebrigtsen
2022-05-20  7:01     ` Eli Zaretskii
2022-05-20  7:14       ` Lars Ingebrigtsen
2022-05-20  7:22         ` Eli Zaretskii
2022-05-20  7:26           ` Lars Ingebrigtsen
2022-05-20 10:46             ` Eli Zaretskii
2022-05-21 11:40               ` Lars Ingebrigtsen
2022-05-21 12:41                 ` Eli Zaretskii
2022-05-21 13:38                   ` Lars Ingebrigtsen
2022-05-21 13:59                     ` Eli Zaretskii
2022-05-22 11:14                       ` Lars Ingebrigtsen
2022-05-22 13:00                         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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