From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74509: Feature request - smerge-mode Date: Sat, 30 Nov 2024 12:28:35 +0200 Message-ID: <86bjxx817w.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19764"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74509@debbugs.gnu.org To: Branislav =?UTF-8?Q?Zahradn=C3=ADk?= , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 30 11:29:14 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tHKiw-0004zO-1Z for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Nov 2024 11:29:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHKil-0007ud-BC; Sat, 30 Nov 2024 05:29:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tHKik-0007uQ-4M for bug-gnu-emacs@gnu.org; Sat, 30 Nov 2024 05:29:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHKij-0002YG-S4 for bug-gnu-emacs@gnu.org; Sat, 30 Nov 2024 05:29:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-version:References:In-Reply-To:From:Date:To:Subject; bh=IF4X4ISezkkZir1MBzyywNhYHxITcJiPb02uOzRkGeA=; b=hk9GHh2CfGZgfcMmrw1qtyYTOq4/bV291i/6olkduBv74h0IDERd6nWHNgI3tle3d0iZ8c9XR7G6z+xsQnn2uJZiYhgVteSA+Yp7RoT+qHo63j7ublId5PBzsCCXfbdKHKhKkaYlqS5V6AF18DueSQLro4+j9+/cJoYD2x1gsZDIsekfNBYP06MFbw6XHx3JV0G6TmoGux941B9j5EIpL4rzZKs9AryA8JWj3yvt0iRUrqMl1xQ348oZazj2Gz/k37Sv93O5f07nha1DJszohdkOrg32oDVOR3Xcw9QtJcBW5xr57uJpNFrDINhCDQHXq6JPJF27ArhZMBkK1+T9vQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tHKij-0000BN-Mz for bug-gnu-emacs@gnu.org; Sat, 30 Nov 2024 05:29:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Nov 2024 10:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74509 X-GNU-PR-Package: emacs Original-Received: via spool by 74509-submit@debbugs.gnu.org id=B74509.1732962526668 (code B ref 74509); Sat, 30 Nov 2024 10:29:01 +0000 Original-Received: (at 74509) by debbugs.gnu.org; 30 Nov 2024 10:28:46 +0000 Original-Received: from localhost ([127.0.0.1]:45592 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tHKiU-0000Ai-4B for submit@debbugs.gnu.org; Sat, 30 Nov 2024 05:28:46 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36500) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tHKiS-0000AP-7w for 74509@debbugs.gnu.org; Sat, 30 Nov 2024 05:28:44 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tHKiN-0002R4-0p; Sat, 30 Nov 2024 05:28:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=IF4X4ISezkkZir1MBzyywNhYHxITcJiPb02uOzRkGeA=; b=VqpWV/FehiUcdD/A35AZ aV2fxLRLojwV91SWjuY/z6c5wNy0hyt+dzmtlB8Q3O/Nl8TArU1SX/7l+yBHvjrj5K5YVZw+Q6uKX 4QNjX+xITV41au63DczfZjl0gCiB/tkYXiM/Wyf5Jl6nKj4EYgqYhOoydbadocR7kF2ineTUOPJAV vKLQENpNKgtrghsTILztNFEdB0bHG6piHqIV8yqEVPABvk/2+eI1N09yvU4mP3MCo1ng11CapcKAA PnQZd8UzCsAqI6P0EpTqIcNmdh/hISRmWYYbGznjF6m9xazvCfJCdeiImTILFOg2+G82EFSV0Pf5k RXn5toHpKtbN7w==; In-Reply-To: (message from Branislav =?UTF-8?Q?Zahradn=C3=ADk?= on Sun, 24 Nov 2024 09:17:56 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:296146 Archived-At: > From: Branislav ZahradnĂ­k > 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?