All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: tools@kernel.org
Subject: [PATCH b4 v2 4/4] review: emacs: highlighting and keystroke for >--cut--
Date: Mon,  7 Sep 2026 16:22:54 -0300	[thread overview]
Message-ID: <4-v2-de162fd5fc4a+2b7-trimming_jgg@nvidia.com> (raw)
In-Reply-To: <0-v2-de162fd5fc4a+2b7-trimming_jgg@nvidia.com>

Add a default highlighting in yellow for the cut marker and bind an
automatic insertion to C-c C-x.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 misc/emacs/b4-review-mode.el | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/misc/emacs/b4-review-mode.el b/misc/emacs/b4-review-mode.el
index c2342ff29bdf4b..81b49079efd630 100644
--- a/misc/emacs/b4-review-mode.el
+++ b/misc/emacs/b4-review-mode.el
@@ -111,6 +111,11 @@ whole-line deletion worth a breadcrumb.")
   "Face for instruction lines (# ...)."
   :group 'b4-review)
 
+(defface b4-review-cut-marker
+  '((t :foreground "yellow" :weight bold))
+  "Face for a \">--cut--\" snip marker line."
+  :group 'b4-review)
+
 (defface b4-review-quote-background
   '((t :inherit default :extend t))
   "Background face for prefixed lines (`> ' quotes, `| ' external comments,
@@ -125,6 +130,17 @@ on every line — without it, the fill stops at the last character."
   "Background face for the reviewer's own, unprefixed comment lines."
   :group 'b4-review)
 
+(defface b4-review-cut-background
+  '((t :inherit default :extend t))
+  "Background face for a \">--cut--\" snip marker line.
+Applied the same way as `b4-review-quote-background' /
+`b4-review-own-background' so the marker line can be set off with its own
+background, e.g.:
+
+  (custom-set-faces
+   \\='(b4-review-cut-background ((t :background \"dark red\"))))"
+  :group 'b4-review)
+
 (defvar b4-review-font-lock-keywords
   `(
     ;; Order matters — earlier rules take priority in Emacs font-lock
@@ -153,6 +169,10 @@ on every line — without it, the fill stops at the last character."
      (2 'b4-review-diff-file)
      (3 'b4-review-diff-file))
 
+    ;; Snip marker, quoted or bare — checked before the plain-quoted catch-all
+    ;; below so it isn't swallowed by that more general rule.
+    ("^\\(?:> \\)?>--cut--[ \t]*$" (0 'b4-review-cut-marker))
+
     ;; Plain quoted lines (catch-all for > lines not matched above)
     ("^\\(> \\)\\(.*\\)$"
      (1 'b4-review-quote-prefix)
@@ -173,6 +193,9 @@ on every line — without it, the fill stops at the last character."
     ;; itself, and `:extend t' on these two faces (see their defface above)
     ;; is what makes the display fill the rest of the line's width with that
     ;; face's background instead of stopping at the last glyph.
+    ;; Checked ahead of the general quote-background rule below so its
+    ;; :background wins over `b4-review-quote-background' on the marker line.
+    ("^\\(?:> \\)?>--cut--[ \t]*\n?" (0 'b4-review-cut-background append))
     ("^>.*\n?" (0 'b4-review-quote-background append))
     ("^|.*\n?" (0 'b4-review-quote-background append))
     ("^#.*\n?" (0 'b4-review-quote-background append))
@@ -419,11 +442,20 @@ the comment text in place under the same diff line, ready to edit."
       (when lines
         (insert (mapconcat #'identity lines "\n") "\n")))))
 
+(defun b4-review-add-cut ()
+  "Insert a cut marker that will remove itself and everything
+before until the previous user comment. The current line is
+placed in the removed area before the cut marker."
+  (interactive)
+  (end-of-line)
+  (insert "\n>--cut--"))
+
 (defvar b4-review-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "C-c C-k") #'b4-review-delete-hunk)
     (define-key map (kbd "C-c C-b") #'b4-review-delete-hunks-before)
     (define-key map (kbd "C-c C-a") #'b4-review-adopt-comment)
+    (define-key map (kbd "C-c C-x") #'b4-review-add-cut)
     map)
   "Keymap for `b4-review-mode'.")
 
-- 
2.43.0


      parent reply	other threads:[~2026-09-07 19:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07 19:22 [PATCH b4 v2 0/4] Improve email quote trimming Jason Gunthorpe
2026-09-07 19:22 ` [PATCH b4 v2 1/4] review: trim trailing quoted when adding a tag Jason Gunthorpe
2026-09-07 19:22 ` [PATCH b4 v2 2/4] review: discard blank lines between | and > quotes when trimming Jason Gunthorpe
2026-09-07 19:22 ` [PATCH b4 v2 3/4] review: add >--cut-- inline marker to snip quoted reply context Jason Gunthorpe
2026-09-07 19:22 ` Jason Gunthorpe [this message]

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=4-v2-de162fd5fc4a+2b7-trimming_jgg@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=tools@kernel.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.
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.