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#46876: [PATCH] Find conflict markers in opened buffers as well Date: Tue, 2 Mar 2021 22:40:19 +0300 Message-ID: <20210302194019.714751-1-Hi-Angel@yandex.ru> References: <20210302162349.709999-1-Hi-Angel@yandex.ru> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15038"; mail-complaints-to="usenet@ciao.gmane.io" To: 46876@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 02 20:41:16 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 1lHAtQ-0003km-D1 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Mar 2021 20:41:16 +0100 Original-Received: from localhost ([::1]:56168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHAtP-0000kt-DW for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Mar 2021 14:41:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHAtC-0000iD-AG for bug-gnu-emacs@gnu.org; Tue, 02 Mar 2021 14:41:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHAtC-0006N0-32 for bug-gnu-emacs@gnu.org; Tue, 02 Mar 2021 14:41:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lHAtC-0003Cw-0m for bug-gnu-emacs@gnu.org; Tue, 02 Mar 2021 14:41:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <20210302162349.709999-1-Hi-Angel@yandex.ru> Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Mar 2021 19:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46876 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46876-submit@debbugs.gnu.org id=B46876.161471403512280 (code B ref 46876); Tue, 02 Mar 2021 19:41:01 +0000 Original-Received: (at 46876) by debbugs.gnu.org; 2 Mar 2021 19:40:35 +0000 Original-Received: from localhost ([127.0.0.1]:54253 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHAsl-0003By-EA for submit@debbugs.gnu.org; Tue, 02 Mar 2021 14:40:35 -0500 Original-Received: from forward102o.mail.yandex.net ([37.140.190.182]:45288) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHAsj-0003Bf-PR for 46876@debbugs.gnu.org; Tue, 02 Mar 2021 14:40:34 -0500 Original-Received: from forward103q.mail.yandex.net (forward103q.mail.yandex.net [IPv6:2a02:6b8:c0e:50:0:640:b21c:d009]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 722736681526 for <46876@debbugs.gnu.org>; Tue, 2 Mar 2021 22:40:26 +0300 (MSK) Original-Received: from vla5-7026d7bc498f.qloud-c.yandex.net (vla5-7026d7bc498f.qloud-c.yandex.net [IPv6:2a02:6b8:c18:351e:0:640:7026:d7bc]) by forward103q.mail.yandex.net (Yandex) with ESMTP id 6E06061E0004 for <46876@debbugs.gnu.org>; Tue, 2 Mar 2021 22:40:26 +0300 (MSK) Original-Received: from vla1-1bc5b51c612f.qloud-c.yandex.net (vla1-1bc5b51c612f.qloud-c.yandex.net [2a02:6b8:c0d:89c:0:640:1bc5:b51c]) by vla5-7026d7bc498f.qloud-c.yandex.net (mxback/Yandex) with ESMTP id TAZYy9Ya2p-eQH8JHUf; Tue, 02 Mar 2021 22:40:26 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1614714026; bh=QrK0oecLtrnyYoixS3i98fQaJ+qOhXxCgEhMDiSDKvU=; h=Date:Subject:To:From:Message-Id; b=QAf1rsrePrLBlyWzzICftjoHEpGdL0GTBFn+D4eQOvWJTd0wQRGbKuznnrTnOMFhY 2Ob/RnlBZB+BCcyOBUbms4tgJBcWOO4u00ewwZXppJbjWgW64eWKzAiJluYA3GDdTl AJRNsylFAjRm6hGB0LxzB6pLL+/YZdFKQP/qtwNc= Authentication-Results: vla5-7026d7bc498f.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by vla1-1bc5b51c612f.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id 9JQQrzgECI-ePn4j6ao; Tue, 02 Mar 2021 22:40:25 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) X-Mailer: git-send-email 2.30.1 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:201234 Archived-At: Call to (vc-find-conflicted-file) will only result in jump to a conflict marker when file is a newly opened one. When a file is already open in Emacs, (vc-find-conflicted-file) only switches to that buffer, so we need to explicitly jump to a conflict marker. * lisp/vc/smerge-mode.el (smerge-vc-next-conflict): Search for a conflict marker if call to (vc-find-conflicted-file) haven't resulted in a jump to one. And remove `buffer` variable that becomes unused. --- lisp/vc/smerge-mode.el | 49 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el index 782c799273..694d4529b9 100644 --- a/lisp/vc/smerge-mode.el +++ b/lisp/vc/smerge-mode.el @@ -1450,30 +1450,31 @@ smerge-vc-next-conflict First tries to go to the next conflict in the current buffer, and if not found, uses VC to try and find the next file with conflict." (interactive) - (let ((buffer (current-buffer))) - (condition-case nil - ;; FIXME: Try again from BOB before moving to the next file. - (smerge-next) - (error - (if (and (or smerge-change-buffer-confirm - (and (buffer-modified-p) buffer-file-name)) - (not (or (eq last-command this-command) - (eq ?\r last-command-event)))) ;Called via M-x!? - ;; FIXME: Don't emit this message if `vc-find-conflicted-file' won't - ;; go to another file anyway (because there are no more conflicted - ;; files). - (message (if (buffer-modified-p) - "No more conflicts here. Repeat to save and go to next buffer" - "No more conflicts here. Repeat to go to next buffer")) - (if (and (buffer-modified-p) buffer-file-name) - (save-buffer)) - (vc-find-conflicted-file) - (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)) - (unless (ignore-errors (not (smerge-next))) - (goto-char prev-pos))))))))) + (condition-case nil + ;; FIXME: Try again from BOB before moving to the next file. + (smerge-next) + (error + (if (and (or smerge-change-buffer-confirm + (and (buffer-modified-p) buffer-file-name)) + (not (or (eq last-command this-command) + (eq ?\r last-command-event)))) ;Called via M-x!? + ;; FIXME: Don't emit this message if `vc-find-conflicted-file' won't + ;; go to another file anyway (because there are no more conflicted + ;; files). + (message (if (buffer-modified-p) + "No more conflicts here. Repeat to save and go to next buffer" + "No more conflicts here. Repeat to go to next buffer")) + (if (and (buffer-modified-p) buffer-file-name) + (save-buffer)) + (vc-find-conflicted-file) + ;; At this point, the caret will only be at a conflict marker + ;; if the file did not correspond to an opened + ;; buffer. Otherwise we need to jump to a marker explicitly. + (unless (looking-at "^<<<<<<<") + (let ((prev-pos (point))) + (goto-char (point-min)) + (unless (ignore-errors (not (smerge-next))) + (goto-char prev-pos)))))))) (provide 'smerge-mode) -- 2.30.1