all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#74509: Feature request - smerge-mode
@ 2024-11-24  8:17 Branislav Zahradník
  2024-11-30 10:28 ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Branislav Zahradník @ 2024-11-24  8:17 UTC (permalink / raw)
  To: 74509

[-- Attachment #1: Type: text/plain, Size: 1548 bytes --]

Hi,

first thank you all for your work.

I didn't find better way how to request features so reporting it as bug.

Recently I'm using smerge-mode little bit more than usually and I come with
missing features

# keybinding

would be nice to provide default keybinding for smerge-swap: C-c ^ s

# smerge-extend

Helpful when user intent to keep both.
Simple extend "current" with one line following conflict.
In my work such line is usually:
- empty line separating documentation sections
- `}` line ending block / function

default keybinding: C-c ^ x

Here is my attempt to solve this problem. It works for me, but I'm not very
skillful in elisp so it may not fit your standards.

Best regards,
Brano

(defun smerge-extend ()
  "Copy the line directly following the conflict into both upper and lower
sections.
This is useful when both versions need to share some common code that
follows the conflict."
  (interactive)

  (smerge-match-conflict)
  (let ((beg (match-beginning 0))
        (end (match-end 0))
        (next-line ""))

    (save-excursion
      (goto-char end)
      (when (and (not (eobp))
                 (looking-at ".*$"))
        (setq next-line (concat (match-string 0) "\n"))
(delete-region end (min (1+ (line-end-position)) (point-max)))
))

    (when (not (string= next-line ""))
      (save-excursion
        (smerge-match-conflict)
        (goto-char (match-end 3))
        (insert next-line)
 )

      (save-excursion
        (smerge-match-conflict)
        (goto-char (match-end 1))
        (insert next-line)
 )
 )
))

[-- Attachment #2: Type: text/html, Size: 2192 bytes --]

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

* bug#74509: Feature request - smerge-mode
  2024-11-24  8:17 bug#74509: Feature request - smerge-mode Branislav Zahradník
@ 2024-11-30 10:28 ` Eli Zaretskii
  2024-12-01 23:51   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2024-11-30 10:28 UTC (permalink / raw)
  To: Branislav Zahradník, Stefan Monnier; +Cc: 74509

> From: Branislav Zahradník <happy.barney@gmail.com>
> Date: Sun, 24 Nov 2024 09:17:56 +0100
> 
> Hi,
> 
> first thank you all for your work.
> 
> I didn't find better way how to request features so reporting it as bug.
> 
> Recently I'm using smerge-mode little bit more than usually and I come with
> missing features
> 
> # keybinding
> 
> would be nice to provide default keybinding for smerge-swap: C-c ^ s
> 
> # smerge-extend
> 
> Helpful when user intent to keep both.
> Simple extend "current" with one line following conflict.
> In my work such line is usually:
> - empty line separating documentation sections
> - `}` line ending block / function
> 
> default keybinding: C-c ^ x
> 
> Here is my attempt to solve this problem. It works for me, but I'm not very skillful in elisp so it may not fit your
> standards.
> 
> Best regards,
> Brano
> 
> (defun smerge-extend ()
>   "Copy the line directly following the conflict into both upper and lower sections.
> This is useful when both versions need to share some common code that follows the conflict."
>   (interactive)
> 
>   (smerge-match-conflict)
>   (let ((beg (match-beginning 0))
>         (end (match-end 0))
>         (next-line ""))
> 
>     (save-excursion
>       (goto-char end)
>       (when (and (not (eobp))
>                  (looking-at ".*$"))
>         (setq next-line (concat (match-string 0) "\n"))
> (delete-region end (min (1+ (line-end-position)) (point-max)))
> ))
> 
>     (when (not (string= next-line ""))
>       (save-excursion
>         (smerge-match-conflict)
>         (goto-char (match-end 3))
>         (insert next-line)
>  )
> 
>       (save-excursion
>         (smerge-match-conflict)
>         (goto-char (match-end 1))
>         (insert next-line)
>  )
>  )
> ))

Stefan, any comments or suggestions?





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

* bug#74509: Feature request - smerge-mode
  2024-11-30 10:28 ` Eli Zaretskii
@ 2024-12-01 23:51   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-02  7:59     ` Branislav Zahradník
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-01 23:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Branislav Zahradník, 74509

>> # keybinding
>> would be nice to provide default keybinding for smerge-swap: C-c ^ s

Interesting.  I've never found a use for that command, personally.
Could you give some hint for the situations where you found it handy?

>> # smerge-extend
>> Helpful when user intent to keep both.

Sorry: to keep both what?

>> (defun smerge-extend ()
>>   "Copy the line directly following the conflict into both upper and lower sections.

Hmm... Why just one line and why only from the end?
[ IOW, here as well, I'm curious what is the kind of scenario where you
  use that command.  ]

>> This is useful when both versions need to share some common code that follows the conflict."

Hmm... my conflicts have usually 3 sections, so "both" isn't right.

[ Unless you specifically chose 2-way conflicts, I recommend you
  investigate how to get 3-way conflicts, because they give a lot more
  information and allow for example `smerge-resolve` to "just work" in
  more cases.  YMMV, but personally whenever I'm faced with a 2-way
  conflict, I'm frustrated.  ]


        Stefan






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

* bug#74509: Feature request - smerge-mode
  2024-12-01 23:51   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-02  7:59     ` Branislav Zahradník
  2024-12-03  3:26       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Branislav Zahradník @ 2024-12-02  7:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 74509, Eli Zaretskii

[-- Attachment #1: Type: text/plain, Size: 2043 bytes --]

On Mon, 2 Dec 2024 at 00:51, Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> >> # keybinding
> >> would be nice to provide default keybinding for smerge-swap: C-c ^ s
>
> Interesting.  I've never found a use for that command, personally.
> Could you give some hint for the situations where you found it handy?
>

Example:
I keep my functions alphabetically ordered.
When I merge two changes which added function in same alphabetical place,
I often need to change their order.

same goes for if/else if sequence


> >> # smerge-extend
> >> Helpful when user intent to keep both.
>
> Sorry: to keep both what?
>

Both = lower + upper.

Using above example:
when I intent to keep both functions, end of block (eg: C, Java, Perl, ...)
will currently not appear twice,
should be manually added. Same for empty line separating functions.

On my current WIP such functions often shares more than one tailing line


>
> >> (defun smerge-extend ()
> >>   "Copy the line directly following the conflict into both upper and
> lower sections.
>
> Hmm... Why just one line and why only from the end?
>

One line - one can use it multiple times to add more.

And yes, you are right, it should accept numeric argument (negative for
preceding line).
Though I still believe common use case will be to extend with following.



> [ IOW, here as well, I'm curious what is the kind of scenario where you
>   use that command.  ]
>

Scenario described above.



>
> >> This is useful when both versions need to share some common code that
> follows the conflict."
>
> Hmm... my conflicts have usually 3 sections, so "both" isn't right.
>
> [ Unless you specifically chose 2-way conflicts, I recommend you
>   investigate how to get 3-way conflicts, because they give a lot more
>   information and allow for example `smerge-resolve` to "just work" in
>   more cases.  YMMV, but personally whenever I'm faced with a 2-way
>   conflict, I'm frustrated.  ]
>

Different experiences - I for example run mostly into 2-way conflicts


>
>
>         Stefan
>
>
Brano

[-- Attachment #2: Type: text/html, Size: 3653 bytes --]

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

* bug#74509: Feature request - smerge-mode
  2024-12-02  7:59     ` Branislav Zahradník
@ 2024-12-03  3:26       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-03  6:39         ` Branislav Zahradník
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-03  3:26 UTC (permalink / raw)
  To: Branislav Zahradník; +Cc: 74509, Eli Zaretskii

>> >> # keybinding
>> >> would be nice to provide default keybinding for smerge-swap: C-c ^ s
>> Interesting.  I've never found a use for that command, personally.
>> Could you give some hint for the situations where you found it handy?
> Example:
> I keep my functions alphabetically ordered.
> When I merge two changes which added function in same alphabetical place,
> I often need to change their order.

I see; makes sense!

>> >> # smerge-extend
>> >> Helpful when user intent to keep both.
>> Sorry: to keep both what?
>
> Both = lower + upper.
>
> Using above example:
> when I intent to keep both functions, end of block (eg: C, Java, Perl, ...)
> will currently not appear twice,

Really?  Here, when I merge two changes which both add a function at the
same place I get a conflict with the complete functions (with their
respective closing brace and trailing space if applicable).

>> Hmm... Why just one line and why only from the end?
> One line - one can use it multiple times to add more.
> And yes, you are right, it should accept numeric argument (negative for
> preceding line).
> Though I still believe common use case will be to extend with following.

I guess a numeric argument could be handy (e.g. to handle the case of
extending from the front rather than from the end).
I had in mind a different UI where you move point to the "end" of the
extension (i.e. to right after the one-or-two lines you want to add to
the ends), but I guess that would be more clunky than what you have.

>> [ Unless you specifically chose 2-way conflicts, I recommend you
>>   investigate how to get 3-way conflicts, because they give a lot more
>>   information and allow for example `smerge-resolve` to "just work" in
>>   more cases.  YMMV, but personally whenever I'm faced with a 2-way
>>   conflict, I'm frustrated.  ]
> Different experiences - I for example run mostly into 2-way conflicts

Maybe it's because of

    % grep -B1 diff3  ~/.gitconfig
    [merge]
            conflictstyle = diff3
    %

🙂


        Stefan






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

* bug#74509: Feature request - smerge-mode
  2024-12-03  3:26       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-03  6:39         ` Branislav Zahradník
  2024-12-21  8:47           ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Branislav Zahradník @ 2024-12-03  6:39 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 74509, Eli Zaretskii

[-- Attachment #1: Type: text/plain, Size: 2693 bytes --]

On Tue, 3 Dec 2024 at 04:26, Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> >> >> # keybinding
> >> >> would be nice to provide default keybinding for smerge-swap: C-c ^ s
> >> Interesting.  I've never found a use for that command, personally.
> >> Could you give some hint for the situations where you found it handy?
> > Example:
> > I keep my functions alphabetically ordered.
> > When I merge two changes which added function in same alphabetical place,
> > I often need to change their order.
>
> I see; makes sense!
>
> >> >> # smerge-extend
> >> >> Helpful when user intent to keep both.
> >> Sorry: to keep both what?
> >
> > Both = lower + upper.
> >
> > Using above example:
> > when I intent to keep both functions, end of block (eg: C, Java, Perl,
> ...)
> > will currently not appear twice,
>
> Really?  Here, when I merge two changes which both add a function at the
> same place I get a conflict with the complete functions (with their
> respective closing brace and trailing space if applicable).
>

> >> Hmm... Why just one line and why only from the end?
> > One line - one can use it multiple times to add more.
> > And yes, you are right, it should accept numeric argument (negative for
> > preceding line).
> > Though I still believe common use case will be to extend with following.
>
> I guess a numeric argument could be handy (e.g. to handle the case of
> extending from the front rather than from the end).
> I had in mind a different UI where you move point to the "end" of the
> extension (i.e. to right after the one-or-two lines you want to add to
> the ends), but I guess that would be more clunky than what you have.
>
> >> [ Unless you specifically chose 2-way conflicts, I recommend you
> >>   investigate how to get 3-way conflicts, because they give a lot more
> >>   information and allow for example `smerge-resolve` to "just work" in
> >>   more cases.  YMMV, but personally whenever I'm faced with a 2-way
> >>   conflict, I'm frustrated.  ]
> > Different experiences - I for example run mostly into 2-way conflicts
>
> Maybe it's because of
>
>     % grep -B1 diff3  ~/.gitconfig
>     [merge]
>             conflictstyle = diff3
>     %
>
> 🙂
>

As I said, everyone has different preferences and experiences.
I'm trying to organize my code (diff-friendly programming) that way
so only minimum number of lines / informations is changed so conflicts
are usually easier to solve, including punctuation characters used by
given programming language. That leads to small diffs, easy to solve,
but with necessity of having this extend functionality.


>
>
>         Stefan
>
>

[-- Attachment #2: Type: text/html, Size: 3697 bytes --]

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

* bug#74509: Feature request - smerge-mode
  2024-12-03  6:39         ` Branislav Zahradník
@ 2024-12-21  8:47           ` Eli Zaretskii
  2024-12-21 15:11             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2024-12-21  8:47 UTC (permalink / raw)
  To: monnier, Branislav Zahradník; +Cc: 74509

> From: Branislav Zahradník <happy.barney@gmail.com>
> Date: Tue, 3 Dec 2024 07:39:30 +0100
> Cc: Eli Zaretskii <eliz@gnu.org>, 74509@debbugs.gnu.org
> 
> On Tue, 3 Dec 2024 at 04:26, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> 
>  >> >> # keybinding
>  >> >> would be nice to provide default keybinding for smerge-swap: C-c ^ s
>  >> Interesting.  I've never found a use for that command, personally.
>  >> Could you give some hint for the situations where you found it handy?
>  > Example:
>  > I keep my functions alphabetically ordered.
>  > When I merge two changes which added function in same alphabetical place,
>  > I often need to change their order.
> 
>  I see; makes sense!
> 
>  >> >> # smerge-extend
>  >> >> Helpful when user intent to keep both.
>  >> Sorry: to keep both what?
>  >
>  > Both = lower + upper.
>  >
>  > Using above example:
>  > when I intent to keep both functions, end of block (eg: C, Java, Perl, ...)
>  > will currently not appear twice,
> 
>  Really?  Here, when I merge two changes which both add a function at the
>  same place I get a conflict with the complete functions (with their
>  respective closing brace and trailing space if applicable). 
> 
>  >> Hmm... Why just one line and why only from the end?
>  > One line - one can use it multiple times to add more.
>  > And yes, you are right, it should accept numeric argument (negative for
>  > preceding line).
>  > Though I still believe common use case will be to extend with following.
> 
>  I guess a numeric argument could be handy (e.g. to handle the case of
>  extending from the front rather than from the end).
>  I had in mind a different UI where you move point to the "end" of the
>  extension (i.e. to right after the one-or-two lines you want to add to
>  the ends), but I guess that would be more clunky than what you have.
> 
>  >> [ Unless you specifically chose 2-way conflicts, I recommend you
>  >>   investigate how to get 3-way conflicts, because they give a lot more
>  >>   information and allow for example `smerge-resolve` to "just work" in
>  >>   more cases.  YMMV, but personally whenever I'm faced with a 2-way
>  >>   conflict, I'm frustrated.  ]
>  > Different experiences - I for example run mostly into 2-way conflicts
> 
>  Maybe it's because of
> 
>      % grep -B1 diff3  ~/.gitconfig
>      [merge]
>              conflictstyle = diff3
>      %
> 
>  🙂
> 
> As I said, everyone has different preferences and experiences.
> I'm trying to organize my code (diff-friendly programming) that way
> so only minimum number of lines / informations is changed so conflicts
> are usually easier to solve, including punctuation characters used by
> given programming language. That leads to small diffs, easy to solve,
> but with necessity of having this extend functionality.

How should we go about this bug report?  Can we make some progress
here?  Or should we close it as wontfix?





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

* bug#74509: Feature request - smerge-mode
  2024-12-21  8:47           ` Eli Zaretskii
@ 2024-12-21 15:11             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-22  2:54               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-21 15:11 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Branislav Zahradník, 74509

> How should we go about this bug report?
> Can we make some progress here?  Or should we close it as wontfix?

No, I think his commands make sense.  We just need to improve them so
they also work with 3-part conflicts.


        Stefan






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

* bug#74509: Feature request - smerge-mode
  2024-12-21 15:11             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-22  2:54               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-22  9:46                 ` Branislav Zahradník
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-22  2:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Branislav Zahradník, 74509

>> How should we go about this bug report?
>> Can we make some progress here?  Or should we close it as wontfix?
> No, I think his commands make sense.  We just need to improve them so
> they also work with 3-part conflicts.

I just pushed to `master` a version of `smerge-extend` which can
incorporate both following and preceding lines, and works with both
diff2 and diff3 style conflicts.

The OP also suggested binding this new command as well as `smerge-swap`
in the SMerge minor mode map (to `C-c ^ x` and `C-c ^ s` respectively).
That would shadow `M-x` and `M-s` (when `smerge-mode` is active) for
users who configured `smerge-command-prefix` to be ESC, so I think that
could be problematic.  For that reason, I did not include that part.


        Stefan






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

* bug#74509: Feature request - smerge-mode
  2024-12-22  2:54               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-22  9:46                 ` Branislav Zahradník
  0 siblings, 0 replies; 10+ messages in thread
From: Branislav Zahradník @ 2024-12-22  9:46 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 74509, Eli Zaretskii

[-- Attachment #1: Type: text/plain, Size: 1234 bytes --]

On Sun, 22 Dec 2024 at 03:54, Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> >> How should we go about this bug report?
> >> Can we make some progress here?  Or should we close it as wontfix?
> > No, I think his commands make sense.  We just need to improve them so
> > they also work with 3-part conflicts.
>
> I just pushed to `master` a version of `smerge-extend` which can
> incorporate both following and preceding lines, and works with both
> diff2 and diff3 style conflicts.
>
> The OP also suggested binding this new command as well as `smerge-swap`
> in the SMerge minor mode map (to `C-c ^ x` and `C-c ^ s` respectively).
> That would shadow `M-x` and `M-s` (when `smerge-mode` is active) for
> users who configured `smerge-command-prefix` to be ESC, so I think that
> could be problematic.  For that reason, I did not include that part.
>

Thank you very much. Such code is at the moment beyond my elisp
capabilities :-)

Key bindings were "nice to have", it's not a problem to configure it
manually.
With current implementation I'd probably have two bindings anyway.

I will think about bindings and will come with suggestion later (if/when I
will have something usable)

Best regards,
Brano


>
>         Stefan
>
>

[-- Attachment #2: Type: text/html, Size: 1943 bytes --]

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

end of thread, other threads:[~2024-12-22  9:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-24  8:17 bug#74509: Feature request - smerge-mode Branislav Zahradník
2024-11-30 10:28 ` Eli Zaretskii
2024-12-01 23:51   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-02  7:59     ` Branislav Zahradník
2024-12-03  3:26       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-03  6:39         ` Branislav Zahradník
2024-12-21  8:47           ` Eli Zaretskii
2024-12-21 15:11             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-22  2:54               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-22  9:46                 ` Branislav Zahradník

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.