all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
To: 46876@debbugs.gnu.org
Subject: bug#46876: [PATCH] Find conflict markers in opened buffers as well
Date: Tue,  2 Mar 2021 22:40:19 +0300	[thread overview]
Message-ID: <20210302194019.714751-1-Hi-Angel@yandex.ru> (raw)
In-Reply-To: <20210302162349.709999-1-Hi-Angel@yandex.ru>

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






  parent reply	other threads:[~2021-03-02 19:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 16:23 bug#46876: [PATCH] Find conflict markers in opened buffers as well Konstantin Kharlamov
2021-03-02 19:37 ` Konstantin Kharlamov
2021-03-02 19:52   ` Konstantin Kharlamov
2021-03-09  2:31     ` Dmitry Gutov
2021-03-02 19:40 ` Konstantin Kharlamov [this message]
2021-03-09  2:51   ` Dmitry Gutov
2021-03-09  6:32     ` Konstantin Kharlamov
2021-03-09 14:15       ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210302194019.714751-1-Hi-Angel@yandex.ru \
    --to=hi-angel@yandex.ru \
    --cc=46876@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.