From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#46538: Patch: wrap around smerge-vc-next-conflict if current file still has conflicts Date: Tue, 16 Feb 2021 01:00:49 +0300 Message-ID: <34d88602bcc902d9e0e3f03817bdc105c81172a1.camel@yandex.ru> References: <5d10180be5f6a5a23c91b0ed150c111a225d79ff.camel@yandex.ru> <87wnv9ta5i.fsf@tcd.ie> 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="25732"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.38.4 Cc: 46538@debbugs.gnu.org To: "Basil L. Contovounesios" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 15 23:02:31 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 1lBlwt-0006cs-EL for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Feb 2021 23:02:31 +0100 Original-Received: from localhost ([::1]:42766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBlws-00027q-Ee for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Feb 2021 17:02:30 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBlwQ-00026w-R2 for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2021 17:02:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55533) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBlwP-0000Y4-PK for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2021 17:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lBlwP-0006wR-MZ for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2021 17:02:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Feb 2021 22:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46538 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46538-submit@debbugs.gnu.org id=B46538.161342646226586 (code B ref 46538); Mon, 15 Feb 2021 22:02:01 +0000 Original-Received: (at 46538) by debbugs.gnu.org; 15 Feb 2021 22:01:02 +0000 Original-Received: from localhost ([127.0.0.1]:38844 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lBlvR-0006uX-MX for submit@debbugs.gnu.org; Mon, 15 Feb 2021 17:01:02 -0500 Original-Received: from forward102j.mail.yandex.net ([5.45.198.243]:51924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lBlvO-0006u0-Dr for 46538@debbugs.gnu.org; Mon, 15 Feb 2021 17:01:00 -0500 Original-Received: from myt5-6c0659e8c6cb.qloud-c.yandex.net (myt5-6c0659e8c6cb.qloud-c.yandex.net [IPv6:2a02:6b8:c12:271e:0:640:6c06:59e8]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 4A09DF21914; Tue, 16 Feb 2021 01:00:51 +0300 (MSK) Original-Received: from myt4-1dda227af9a8.qloud-c.yandex.net (myt4-1dda227af9a8.qloud-c.yandex.net [2a02:6b8:c00:3c83:0:640:1dda:227a]) by myt5-6c0659e8c6cb.qloud-c.yandex.net (mxback/Yandex) with ESMTP id NB8Pa9jLV0-0pI0qLVe; Tue, 16 Feb 2021 01:00:51 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1613426451; bh=D3MLwfP4mRvya3y/FCpIV5FGPYM5OR1oz1WTT5k+Ei8=; h=In-Reply-To:Cc:To:From:Subject:Message-ID:References:Date; b=Bdz28otwV8yhV1qqqbmKylrsL+S5xmlafAZqmR38CLYw7dYvr4lJqRyHApjky4CfH 6FwPDymoLVtYNuOP9OMz/i/vACgCB1bSwN/GlqgVyC94fky0NWmL1urVoQAdOXbkMg bCVmFRN+vNMhu8ZX/gPwWkFImoOuI0I0WCwMjTN4= Authentication-Results: myt5-6c0659e8c6cb.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by myt4-1dda227af9a8.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id ZNjIhU8ZnY-0oKOwNl5; Tue, 16 Feb 2021 01:00:50 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) In-Reply-To: <87wnv9ta5i.fsf@tcd.ie> 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:200088 Archived-At: Thank you! I will fix it up. Nice hint on the `ignore-errors` macro, I didn't know about it On Mon, 2021-02-15 at 19:15 +0000, Basil L. Contovounesios wrote: > 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))))))))) >