Skip to content

exp: add overlay indication of hunks#1

Open
phye wants to merge 26 commits intomasterfrom
exp
Open

exp: add overlay indication of hunks#1
phye wants to merge 26 commits intomasterfrom
exp

Conversation

@phye
Copy link
Copy Markdown
Owner

@phye phye commented Apr 21, 2026

No description provided.

Comment thread code-review-minimal-faces.el Outdated

;;;; ─── Hunk highlighting ─────────────────────────────────────────────────────

(defface code-review-minimal-hunk-added-face
Copy link
Copy Markdown
Owner Author

@phye phye Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test comment 1 reeditted

Comment thread code-review-minimal.el Outdated
:type 'boolean
:group 'code-review-minimal)

(defcustom code-review-minimal-highlight-hunks t
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test comment 2 in code-review-minimal.el

Comment thread code-review-minimal-diff.el Outdated
;;; Code:

(require 'cl-lib)
(require 'code-review-minimal-faces)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another test comment 2

Philip Ye added 17 commits April 23, 2026 08:49
diff --git a/code-review-minimal-diff.el b/code-review-minimal-diff.el
index a80a956..71102d6 100644
--- a/code-review-minimal-diff.el
+++ b/code-review-minimal-diff.el
@@ -52,7 +52,7 @@ Each element of CHANGES is a plist with :old-path, :new-path, and :patch."
   "Format removed LINES as a display string.
 LINES is a list in push-order (most-recent first); the result is
 returned in original source order."
-  (mapconcat (lambda (l) (concat "- " l)) (nreverse lines) "\n"))
+  (mapconcat #'identity (nreverse lines) "\n"))

 (defun code-review-minimal--parse-patch (patch)
   "Parse unified diff PATCH string for a single file.
@@ -159,7 +159,8 @@ ANCHOR is the new-file line number after which the removed lines should appear;
                    (ov (make-overlay beg end)))
               (overlay-put
                ov 'before-string
-               (propertize "+ "
+               (propertize " "
+                           'display '((margin left-margin) "+")
                            'face 'code-review-minimal-hunk-added-face))
               (overlay-put ov 'face 'code-review-minimal-hunk-added-face)
               (overlay-put ov 'code-review-minimal-hunk t)
@@ -177,10 +178,19 @@ ANCHOR is the new-file line number after which the removed lines should appear;
                 (let* ((pos (save-excursion
                               (goto-char (point-min))
                               (point)))
-                       (ov (make-overlay pos pos nil t nil)))
+                       (ov (make-overlay pos pos nil t nil))
+                       (lines (split-string text "\n"))
+                       (marked-text
+                        (mapconcat
+                         (lambda (l)
+                           (concat (propertize " "
+                                               'display '((margin left-margin) "-")
+                                               'face 'code-review-minimal-hunk-removed-face)
+                                   " " l))
+                         lines "\n")))
                   (overlay-put
                    ov 'before-string
-                   (propertize (concat text "\n")
+                   (propertize (concat marked-text "\n")
                                'face 'code-review-minimal-hunk-removed-face))
                   (overlay-put ov 'code-review-minimal-hunk t)
                   (overlay-put ov 'evaporate t)
@@ -192,10 +202,19 @@ ANCHOR is the new-file line number after which the removed lines should appear;
                             (goto-char (point-min))
                             (forward-line (1- anchor))
                             (line-end-position)))
-                     (ov (make-overlay pos pos nil t nil)))
+                     (ov (make-overlay pos pos nil t nil))
+                     (lines (split-string text "\n"))
+                     (marked-text
+                      (mapconcat
+                       (lambda (l)
+                         (concat (propertize " "
+                                             'display '((margin left-margin) "-")
+                                             'face 'code-review-minimal-hunk-removed-face)
+                                 " " l))
+                       lines "\n")))
                 (overlay-put
                  ov 'after-string
-                 (propertize (concat "\n" text)
+                 (propertize (concat "\n" marked-text)
                              'face 'code-review-minimal-hunk-removed-face))
                 (overlay-put ov 'code-review-minimal-hunk t)
                 (overlay-put ov 'evaporate t)
diff --git a/code-review-minimal.el b/code-review-minimal.el
index 3a1c9ef..673f757 100644
--- a/code-review-minimal.el
+++ b/code-review-minimal.el
@@ -532,6 +532,10 @@ Commands:
               ;; review-url already refreshes overlays and handles the rest; bail out
               (setq code-review-minimal-mode nil)
               (cl-return-from nil))))
+        ;; Set left margin for diff fringe indicators
+        (dolist (win (get-buffer-window-list (current-buffer) nil t))
+          (let ((margins (window-margins win)))
+            (set-window-margins win 2 (cdr margins))))
         ;; Refresh diff and comment overlays
         (code-review-minimal--refresh-overlays))
     ;; Disable
@@ -539,6 +543,9 @@ Commands:
     (code-review-minimal--clear-hunk-overlays)
     (when code-review-minimal--input-overlay
       (code-review-minimal--cancel-comment))
+    (dolist (win (get-buffer-window-list (current-buffer) nil t))
+      (let ((margins (window-margins win)))
+        (set-window-margins win 0 (cdr margins))))
     (setq code-review-minimal--mr-iid nil
           code-review-minimal--mr-id nil
           code-review-minimal--project-info nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant