From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#46538: Patch: wrap around smerge-vc-next-conflict if current file still has conflicts Date: Mon, 15 Feb 2021 19:15:37 +0000 Message-ID: <87wnv9ta5i.fsf@tcd.ie> References: <5d10180be5f6a5a23c91b0ed150c111a225d79ff.camel@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24053"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 46538@debbugs.gnu.org To: Konstantin Kharlamov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 15 20:18:35 2021 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 1lBjOE-00067a-Lc for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Feb 2021 20:18:34 +0100 Original-Received: from localhost ([::1]:45736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBjOD-00053X-K9 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Feb 2021 14:18:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBjLs-0003Fp-Hx for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2021 14:16:10 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBjLl-0001gl-Td for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2021 14:16:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lBjLl-0000Vy-NW for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2021 14:16:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Feb 2021 19:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46538 X-GNU-PR-Package: emacs Original-Received: via spool by 46538-submit@debbugs.gnu.org id=B46538.16134165481946 (code B ref 46538); Mon, 15 Feb 2021 19:16:01 +0000 Original-Received: (at 46538) by debbugs.gnu.org; 15 Feb 2021 19:15:48 +0000 Original-Received: from localhost ([127.0.0.1]:38711 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lBjLX-0000VJ-MQ for submit@debbugs.gnu.org; Mon, 15 Feb 2021 14:15:48 -0500 Original-Received: from mail-wm1-f49.google.com ([209.85.128.49]:51612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lBjLU-0000Uz-Q1 for 46538@debbugs.gnu.org; Mon, 15 Feb 2021 14:15:46 -0500 Original-Received: by mail-wm1-f49.google.com with SMTP id r5so3836264wmp.1 for <46538@debbugs.gnu.org>; Mon, 15 Feb 2021 11:15:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=A58wvKHBG+jvU0IboNRJsqO5S/Avt1EJOBdWWFR1F1A=; b=gOqab4gI2uYRoINAxFdvuuTuccFWMWX7EOTkEFejmm2u54YzBy0fvklXo+y3FSUEAz lkZj2zwy4SMoy2cAyCOxU1CqBU4VIZLmMElooaG4+K/k4BfY8XuwL5dZ0fo/JurHMg6p olyvJ/xyJeEfUA0ssiix8rW2LbtV2WP1T+4JPJMbyzeZ6ocV1fcMuyFADYEhjwZsfXnu 7JgTu6rItmdRqsOXv3LhJo0dV4fNzslvNcOvu7nkmKCqKSQ24OsMLNk8dzb+HDCJXZlu jst7xFqfiEuNAb0zgQg85MUyqv5wwGjNUuLEZMq7Dy9aNhcgoJzaFw6WB16dnyPPYMpw vgKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=A58wvKHBG+jvU0IboNRJsqO5S/Avt1EJOBdWWFR1F1A=; b=HPqKLEq0k/cUZ5+MsAsEGHdxynffcB98r+YxkStiPOrLDszezc8nAoFnr2XUSFxnT/ UJsY3/otjAFKmzf4IFrCn+8M1voGQdgnOQljO9M2HQ7++BDo0eZfQjJXXKMFD5ASyL41 0hu86VB271zvdw1CeGlcOJoNMnBzXpiQqzW1+UUDZO7EsQN9PzG0zcTQP1yUehNpE1iw VcLmv0LKKj9iNNwuQQ+ond2E9k8XIunh3Xg/GG65YKlW6okjoN5Kun5SqGj/ktlXNYYP g1dMGgtZA5fT6u4bd+CkGNLedk6O9hnum6I9veKfWkwvbklfq6OaMiqvMUai8L5PhXVP +7BQ== X-Gm-Message-State: AOAM533j/RRQq2eXbsclJjw/xBxtz/YrnyW/GDr95lvbFeIFLkr/GVhB wU3YR5g9Qvbj3uNaoso2NGtsLg== X-Google-Smtp-Source: ABdhPJyOalieSWWK18R4yOgVgK3h0jUn487guIgycRqTzoi66RV6csg31mD59HkwACvKTEVbKFZTNQ== X-Received: by 2002:a1c:610b:: with SMTP id v11mr286859wmb.188.1613416539043; Mon, 15 Feb 2021 11:15:39 -0800 (PST) Original-Received: from localhost ([2a02:8084:20e2:c380:d15:339e:aa10:60f1]) by smtp.gmail.com with ESMTPSA id y1sm15468902wrr.41.2021.02.15.11.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 11:15:38 -0800 (PST) In-Reply-To: <5d10180be5f6a5a23c91b0ed150c111a225d79ff.camel@yandex.ru> (Konstantin Kharlamov's message of "Mon, 15 Feb 2021 21:51:41 +0300") 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" Xref: news.gmane.io gmane.emacs.bugs:200078 Archived-At: tags 46538 + patch quit Konstantin Kharlamov writes: > Attached patch implements additional check for conflicts just for the case when > the buffer is the last conflicted file and all conflicts are above current > point. Thanks, just a few nits from me. > From f8d8f1cbdb94f75765165acacd089f1e3cc4a763 Mon Sep 17 00:00:00 2001 > From: Konstantin Kharlamov > Date: Mon, 15 Feb 2021 21:37:33 +0300 > Subject: [PATCH] vc: make smerge-vc-next-conflict wrap around > > lisp/vc/smerge-mode.el: > (smerge-next-safe): a wrapper around smerge-next that doesn't throw > an error. > (smerge-vc-next-conflict): make it wrap around a file if it's the last > conflicted file, and it still has conflicts Please use proper sentences starting with a capital letter and ending in a full stop. > --- > lisp/vc/smerge-mode.el | 20 ++++++++++++++------ > 1 file changed, 14 insertions(+), 6 deletions(-) > > diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el > index 3b09dfe5d2..0558240120 100644 > --- a/lisp/vc/smerge-mode.el > +++ b/lisp/vc/smerge-mode.el > @@ -1446,6 +1446,14 @@ smerge-change-buffer-confirm > "If non-nil, request confirmation before moving to another buffer." > :type 'boolean) > > +(defun smerge-next-safe () > + "Tries to move to next conflict, returns t on success, nil ^^^^ Excess indentation. > +otherwise" The first line should contain a whole sentence, usually in the imperative; see (info "(elisp) Documentation Tips"). E.g.: "Try moving to next conflict. Return non-nil on success; nil otherwise." > + (condition-case err ^^^ This variable is unused, so just pass nil instead. > + (not (smerge-next)) > + ('error ^^ Conditions are usually unquoted. > + nil))) You can reuse the macro ignore-errors for this: (ignore-errors (not (smerge-next))) > (defun smerge-vc-next-conflict () > "Go to next conflict, possibly in another file. > First tries to go to the next conflict in the current buffer, and if not > @@ -1469,12 +1477,12 @@ smerge-vc-next-conflict > (if (and (buffer-modified-p) buffer-file-name) > (save-buffer)) > (vc-find-conflicted-file) > - (if (eq buffer (current-buffer)) > - ;; Do nothing: presumably `vc-find-conflicted-file' already > - ;; emitted a message explaining there aren't any more conflicts. > - nil > - (goto-char (point-min)) > - (smerge-next))))))) > + (when (eq buffer (current-buffer)) > + ;; try to find a conflict marker in current file above the point > + (let ((prev-pos (point))) > + (goto-char (point-min)) > + (when (not (smerge-next-safe)) ^^^^^^^^^^ Nit: when + not = unless > + (goto-char prev-pos))))))))) -- Basil