GNU bug report logs - #65605
[PATCH] Command and option to make Edmacro better for long sequences

Previous Next

Package: emacs;

Reported by: Okamsn <okamsn <at> protonmail.com>

Date: Wed, 30 Aug 2023 01:19:02 UTC

Severity: wishlist

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 65605 in the body.
You can then email your comments to 65605 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#65605; Package emacs. (Wed, 30 Aug 2023 01:19:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Okamsn <okamsn <at> protonmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 30 Aug 2023 01:19:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Okamsn <okamsn <at> protonmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Command and option to make Edmacro better for long sequences
Date: Wed, 30 Aug 2023 01:17:51 +0000
[Message part 1 (text/plain, inline)]
Hello,

The attached patch adds the command `edmacro-set-macro-to-region-lines` 
for quickly reducing the presented keys to those in the region, and adds 
the user option `edmacro-reverse-key-order` for showing the most recent 
keys first.

These two changes are useful for `kmacro-edit-lossage`.  My use case is 
that I would like to quickly create a keyboard macro from some of my 
recent key presses, but Edmacro is slow to use when the lossage size is 
large.  When it is large, I must jump to the bottom of the buffer, then 
cut the desired lines, then jump back up, then delete the remaining 
lines, then paste the cut lines, then press `C-c C-c`. If I use 
`delete-selection-mode`, I can combine two of the steps.  With this new 
change from the patch, I can move down a few lines, select a few lines, 
then press `C-c C-r`, then press `C-c C-c`.

Thank you.
[0001-Make-using-Edmacro-better-for-long-sequences-of-keys.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65605; Package emacs. (Wed, 30 Aug 2023 01:22:03 GMT) Full text and rfc822 format available.

Message #8 received at 65605 <at> debbugs.gnu.org (full text, mbox):

From: Okamsn <okamsn <at> protonmail.com>
To: 65605 <at> debbugs.gnu.org
Subject: Re: bug#65605: [PATCH] Command and option to make Edmacro better for
 long sequences
Date: Wed, 30 Aug 2023 01:21:25 +0000
[Message part 1 (text/plain, inline)]
There was a typo in the commit message of the previous attached file. 
This new attached file fixes the typo.
[v2-0001-Make-using-Edmacro-better-for-long-sequences-of-k.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65605; Package emacs. (Wed, 30 Aug 2023 11:39:01 GMT) Full text and rfc822 format available.

Message #11 received at 65605 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Okamsn <okamsn <at> protonmail.com>
Cc: 65605 <at> debbugs.gnu.org
Subject: Re: bug#65605: [PATCH] Command and option to make Edmacro better for
 long sequences
Date: Wed, 30 Aug 2023 14:37:48 +0300
> Date: Wed, 30 Aug 2023 01:17:51 +0000
> From:  Okamsn via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> The attached patch adds the command `edmacro-set-macro-to-region-lines` 
> for quickly reducing the presented keys to those in the region, and adds 
> the user option `edmacro-reverse-key-order` for showing the most recent 
> keys first.

Thanks.

> These two changes are useful for `kmacro-edit-lossage`.  My use case is 
> that I would like to quickly create a keyboard macro from some of my 
> recent key presses, but Edmacro is slow to use when the lossage size is 
> large.  When it is large, I must jump to the bottom of the buffer, then 
> cut the desired lines, then jump back up, then delete the remaining 
> lines, then paste the cut lines, then press `C-c C-c`. If I use 
> `delete-selection-mode`, I can combine two of the steps.  With this new 
> change from the patch, I can move down a few lines, select a few lines, 
> then press `C-c C-r`, then press `C-c C-c`.

If these commands are indeed important conveniences, they should be in
the manual, I think.

> +(defcustom edmacro-reverse-key-order nil
> +  "Non-nil if `edit-kbd-macro' should show the most recent keys first.
> +
> +This is useful when dealing with long lists of key sequences, such as
> +from `kmacro-edit-lossage'."
> +  :type 'boolean
> +  :group 'kmacro)

Defcustoms should have the :version tag.

> +(defun edmacro-set-macro-to-region-lines (beg end)
> +  "Set the Macro text to the lines of the region.

We prefer to have the mandatory arguments mentioned in the first line
of a function's doc string.

> +If BEG is not at the beginning of a line, it is moved to the
> +beginning of the line.  If END is at the beginning of a line,
> +that line is excluded.  Otherwise, if END is not at the
> +end of a line, it is moved to the end of the line."

This describes the implementation, whereas this is a command, so the
doc string should have users, not programmer's in mind.  Try to
describe BEG and END in user-level terms, for example:

  Macro text will start and the beginning of line containing buffer
  position BEG.

Also, the doc string should tell how BEG and END are determined in
interactive invocations.





Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 03 Sep 2023 11:02:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65605; Package emacs. (Sun, 03 Sep 2023 17:23:01 GMT) Full text and rfc822 format available.

Message #16 received at 65605 <at> debbugs.gnu.org (full text, mbox):

From: Okamsn <okamsn <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 65605 <at> debbugs.gnu.org
Subject: Re: bug#65605: [PATCH] Command and option to make Edmacro better for
 long sequences
Date: Sun, 03 Sep 2023 16:05:03 +0000
[Message part 1 (text/plain, inline)]
Eli Zaretskii wrote:
> If these commands are indeed important conveniences, they should be in
> the manual, I think.

I have described the new command and `edmacro-insert-key` in the manual.

> Defcustoms should have the :version tag.

I have given it as "30.1".

> 
>> +(defun edmacro-set-macro-to-region-lines (beg end)
>> +  "Set the Macro text to the lines of the region.
> 
> We prefer to have the mandatory arguments mentioned in the first line
> of a function's doc string.
> 
>> +If BEG is not at the beginning of a line, it is moved to the
>> +beginning of the line.  If END is at the beginning of a line,
>> +that line is excluded.  Otherwise, if END is not at the
>> +end of a line, it is moved to the end of the line."
> 
> This describes the implementation, whereas this is a command, so the
> doc string should have users, not programmer's in mind.  Try to
> describe BEG and END in user-level terms, for example:
> 
>    Macro text will start and the beginning of line containing buffer
>    position BEG.
> 
> Also, the doc string should tell how BEG and END are determined in
> interactive invocations.
> 

I have changed it. How does it look now?
[v3-0001-Make-using-Edmacro-better-for-long-sequences-of-k.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65605; Package emacs. (Sun, 03 Sep 2023 18:37:02 GMT) Full text and rfc822 format available.

Message #19 received at 65605 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Okamsn <okamsn <at> protonmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 65605 <at> debbugs.gnu.org
Subject: Re: bug#65605: [PATCH] Command and option to make Edmacro better for
 long sequences
Date: Sun, 3 Sep 2023 11:36:36 -0700
Okamsn via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <bug-gnu-emacs <at> gnu.org> writes:

> From f1365193df83f7a765abc95507bbddb0d5d5a929 Mon Sep 17 00:00:00 2001
> From: Earl Hyatt <okamsn <at> protonmail.com>
> Date: Sat, 19 Aug 2023 18:26:45 -0400
> Subject: [PATCH v3] Make using Edmacro better for long sequences of keys.
>
> * lisp/edmacro.el (edmacro-set-macro-to-region-lines,
> edmacro-reverse-key-order): New command and user option to
> make working with longer lists of keys (such as from
> 'kmacro-edit-lossage') easier.
> (edit-kbd-macro): Move regexps used to identify parts of buffer
> to internal variables.
> (edmacro--macro-lines-regexp, edmacro-mode-font-lock-keywords): Allow
> noting whether the most recent line of keys is displayed first.
> (edmacro-mode-map): Bind the new command to 'C-c C-r'.
> (edmacro-mode): Describe the new command in the mode documentation
> string.

Thanks, this looks like a useful feature.

Your patch LGTM, but I think it deserves to be called out in NEWS.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65605; Package emacs. (Mon, 04 Sep 2023 11:07:01 GMT) Full text and rfc822 format available.

Message #22 received at 65605 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Okamsn <okamsn <at> protonmail.com>
Cc: 65605 <at> debbugs.gnu.org
Subject: Re: bug#65605: [PATCH] Command and option to make Edmacro better for
 long sequences
Date: Mon, 04 Sep 2023 14:05:38 +0300
> Date: Sun, 03 Sep 2023 16:05:03 +0000
> From: Okamsn <okamsn <at> protonmail.com>
> Cc: 65605 <at> debbugs.gnu.org
> 
> >> +If BEG is not at the beginning of a line, it is moved to the
> >> +beginning of the line.  If END is at the beginning of a line,
> >> +that line is excluded.  Otherwise, if END is not at the
> >> +end of a line, it is moved to the end of the line."
> > 
> > This describes the implementation, whereas this is a command, so the
> > doc string should have users, not programmer's in mind.  Try to
> > describe BEG and END in user-level terms, for example:
> > 
> >    Macro text will start and the beginning of line containing buffer
> >    position BEG.
> > 
> > Also, the doc string should tell how BEG and END are determined in
> > interactive invocations.
> > 
> 
> I have changed it. How does it look now?

See some comments below.

> +@findex edmacro-insert-key
> +@findex edmacro-set-macro-to-region-lines
> +  The mode provides commands for more easily editing the formatted

You say "The mode", but it is not clear what is "the mode" to which
you allude.

> +macro.  Use @kbd{C-c C-q} (@code{edmacro-insert-key}) to insert the
> +next key sequence that you type into the buffer using the correct
> +format, similar to @kbd{C-q} (@code{quoted-insert}).  Use @kbd{C-c
> +C-r} (@code{edmacro-set-macro-to-region-lines}) to replace the macro's
> +formatted text with the lines overlapping the region of text between
> +point and mark.

Here, "the lines overlapping the region of text between point and
mark" is IMO not clear enough.  I think you mean to say "text in the
region", and the "overlapping" part is just to allude to the fact that
the region might begin and/or end in the middle of a line?  If so, I
would suggest

  Use @kbd{C-c C-r} (@code{edmacro-set-macro-to-region-lines}) to
  replace the macro's formatted text with the text in the region.  If
  the region begins not and beginning of a line or ends not at end of
  line, it is extended to include complete lines.

Also, is the "formatted" in "macro's formatted text" really needed?
What does "formatted" signify?

> +(defcustom edmacro-reverse-key-order nil
> +  "Non-nil if `edit-kbd-macro' should show the most recent line of keys first.
                                                                      ^^^^
"Keys" or "key sequence"?

> +(defun edmacro-set-macro-to-region-lines (beg end)
> +  "Set the macro text to the lines overlapping the buffer text from BEG to END.

I would suggest

  Set macro text to lines of text in current buffer between BEG and END.

> +When called interactively, this command uses the beginning and
> +end of the selected region as the buffer positions.

  Interactively, BEG and END are the beginning and end of the region.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#65605; Package emacs. (Sat, 09 Sep 2023 00:46:01 GMT) Full text and rfc822 format available.

Message #25 received at 65605 <at> debbugs.gnu.org (full text, mbox):

From: Okamsn <okamsn <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 65605 <at> debbugs.gnu.org, stefankangas <at> gmail.com
Subject: Re: bug#65605: [PATCH] Command and option to make Edmacro better for
 long sequences
Date: Sat, 09 Sep 2023 00:45:05 +0000
[Message part 1 (text/plain, inline)]
Eli Zaretskii wrote:
>> Date: Sun, 03 Sep 2023 16:05:03 +0000
>> From: Okamsn <okamsn <at> protonmail.com>
>> Cc: 65605 <at> debbugs.gnu.org
>>
>>>> +If BEG is not at the beginning of a line, it is moved to the
>>>> +beginning of the line.  If END is at the beginning of a line,
>>>> +that line is excluded.  Otherwise, if END is not at the
>>>> +end of a line, it is moved to the end of the line."
>>>
>>> This describes the implementation, whereas this is a command, so the
>>> doc string should have users, not programmer's in mind.  Try to
>>> describe BEG and END in user-level terms, for example:
>>>
>>>     Macro text will start and the beginning of line containing buffer
>>>     position BEG.
>>>
>>> Also, the doc string should tell how BEG and END are determined in
>>> interactive invocations.
>>>
>>
>> I have changed it. How does it look now?
> 
> See some comments below.
> 
>> +@findex edmacro-insert-key
>> +@findex edmacro-set-macro-to-region-lines
>> +  The mode provides commands for more easily editing the formatted
> 
> You say "The mode", but it is not clear what is "the mode" to which
> you allude.
> 
>> +macro.  Use @kbd{C-c C-q} (@code{edmacro-insert-key}) to insert the
>> +next key sequence that you type into the buffer using the correct
>> +format, similar to @kbd{C-q} (@code{quoted-insert}).  Use @kbd{C-c
>> +C-r} (@code{edmacro-set-macro-to-region-lines}) to replace the macro's
>> +formatted text with the lines overlapping the region of text between
>> +point and mark.
> 
> Here, "the lines overlapping the region of text between point and
> mark" is IMO not clear enough.  I think you mean to say "text in the
> region", and the "overlapping" part is just to allude to the fact that
> the region might begin and/or end in the middle of a line?  If so, I
> would suggest
> 
>    Use @kbd{C-c C-r} (@code{edmacro-set-macro-to-region-lines}) to
>    replace the macro's formatted text with the text in the region.  If
>    the region begins not and beginning of a line or ends not at end of
>    line, it is extended to include complete lines.
> 
> Also, is the "formatted" in "macro's formatted text" really needed?
> What does "formatted" signify?

I wasn't sure what to call the lines of formatted text showing the 
macro's contents. I have changed it to just "text".

>> +(defcustom edmacro-reverse-key-order nil
>> +  "Non-nil if `edit-kbd-macro' should show the most recent line of keys first.
>                                                                        ^^^^
> "Keys" or "key sequence"?

I have changed it to "key sequences".

>> +(defun edmacro-set-macro-to-region-lines (beg end)
>> +  "Set the macro text to the lines overlapping the buffer text from BEG to END.
> 
> I would suggest
> 
>    Set macro text to lines of text in current buffer between BEG and END.
> 
>> +When called interactively, this command uses the beginning and
>> +end of the selected region as the buffer positions.
> 
>    Interactively, BEG and END are the beginning and end of the region.
> 

I have changed it to:

"Set the macro text to lines of text in the buffer between BEG and END.

Interactively, BEG and END are the beginning and end of the
region.  If the region does not begin at the start of a line or
if it does not end at the end of a line, the region is extended
to include complete lines.  If the region ends at the beginning
of a line, that final line is excluded."

I have also added the new command and user option to "NEWS" as requested 
by Stefan Kangas, and have described the new user option in the manual.

I have also changed the name of the user option to 
"edmacro-reverse-macro-lines", which is a bit clearer.
[v4-0001-Make-using-Edmacro-better-for-long-sequences-of-k.patch (text/x-patch, attachment)]

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 16 Sep 2023 09:56:01 GMT) Full text and rfc822 format available.

Notification sent to Okamsn <okamsn <at> protonmail.com>:
bug acknowledged by developer. (Sat, 16 Sep 2023 09:56:02 GMT) Full text and rfc822 format available.

Message #30 received at 65605-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Okamsn <okamsn <at> protonmail.com>
Cc: 65605-done <at> debbugs.gnu.org, stefankangas <at> gmail.com
Subject: Re: bug#65605: [PATCH] Command and option to make Edmacro better for
 long sequences
Date: Sat, 16 Sep 2023 12:55:05 +0300
> Date: Sat, 09 Sep 2023 00:45:05 +0000
> From: Okamsn <okamsn <at> protonmail.com>
> Cc: 65605 <at> debbugs.gnu.org, stefankangas <at> gmail.com
> 
> Eli Zaretskii wrote:
> >> Date: Sun, 03 Sep 2023 16:05:03 +0000
> >> From: Okamsn <okamsn <at> protonmail.com>
> >> Cc: 65605 <at> debbugs.gnu.org
> >>
> >>>> +If BEG is not at the beginning of a line, it is moved to the
> >>>> +beginning of the line.  If END is at the beginning of a line,
> >>>> +that line is excluded.  Otherwise, if END is not at the
> >>>> +end of a line, it is moved to the end of the line."
> >>>
> >>> This describes the implementation, whereas this is a command, so the
> >>> doc string should have users, not programmer's in mind.  Try to
> >>> describe BEG and END in user-level terms, for example:
> >>>
> >>>     Macro text will start and the beginning of line containing buffer
> >>>     position BEG.
> >>>
> >>> Also, the doc string should tell how BEG and END are determined in
> >>> interactive invocations.
> >>>
> >>
> >> I have changed it. How does it look now?
> > 
> > See some comments below.
> > 
> >> +@findex edmacro-insert-key
> >> +@findex edmacro-set-macro-to-region-lines
> >> +  The mode provides commands for more easily editing the formatted
> > 
> > You say "The mode", but it is not clear what is "the mode" to which
> > you allude.
> > 
> >> +macro.  Use @kbd{C-c C-q} (@code{edmacro-insert-key}) to insert the
> >> +next key sequence that you type into the buffer using the correct
> >> +format, similar to @kbd{C-q} (@code{quoted-insert}).  Use @kbd{C-c
> >> +C-r} (@code{edmacro-set-macro-to-region-lines}) to replace the macro's
> >> +formatted text with the lines overlapping the region of text between
> >> +point and mark.
> > 
> > Here, "the lines overlapping the region of text between point and
> > mark" is IMO not clear enough.  I think you mean to say "text in the
> > region", and the "overlapping" part is just to allude to the fact that
> > the region might begin and/or end in the middle of a line?  If so, I
> > would suggest
> > 
> >    Use @kbd{C-c C-r} (@code{edmacro-set-macro-to-region-lines}) to
> >    replace the macro's formatted text with the text in the region.  If
> >    the region begins not and beginning of a line or ends not at end of
> >    line, it is extended to include complete lines.
> > 
> > Also, is the "formatted" in "macro's formatted text" really needed?
> > What does "formatted" signify?
> 
> I wasn't sure what to call the lines of formatted text showing the 
> macro's contents. I have changed it to just "text".
> 
> >> +(defcustom edmacro-reverse-key-order nil
> >> +  "Non-nil if `edit-kbd-macro' should show the most recent line of keys first.
> >                                                                        ^^^^
> > "Keys" or "key sequence"?
> 
> I have changed it to "key sequences".
> 
> >> +(defun edmacro-set-macro-to-region-lines (beg end)
> >> +  "Set the macro text to the lines overlapping the buffer text from BEG to END.
> > 
> > I would suggest
> > 
> >    Set macro text to lines of text in current buffer between BEG and END.
> > 
> >> +When called interactively, this command uses the beginning and
> >> +end of the selected region as the buffer positions.
> > 
> >    Interactively, BEG and END are the beginning and end of the region.
> > 
> 
> I have changed it to:
> 
> "Set the macro text to lines of text in the buffer between BEG and END.
> 
> Interactively, BEG and END are the beginning and end of the
> region.  If the region does not begin at the start of a line or
> if it does not end at the end of a line, the region is extended
> to include complete lines.  If the region ends at the beginning
> of a line, that final line is excluded."
> 
> I have also added the new command and user option to "NEWS" as requested 
> by Stefan Kangas, and have described the new user option in the manual.
> 
> I have also changed the name of the user option to 
> "edmacro-reverse-macro-lines", which is a bit clearer.

Thanks, installed on the master branch, and closing the bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 14 Oct 2023 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 249 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.