unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#74509: Feature request - smerge-mode
@ 2024-11-24  8:17 Branislav Zahradník
  0 siblings, 0 replies; only message 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] only message in thread

only message in thread, other threads:[~2024-11-24  8:17 UTC | newest]

Thread overview: (only message) (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

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