unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Condy Chen <condy0919@gmail.com>
To: Zhiwei Chen <chenzhiwei03@kuaishou.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Highlight current line when using gud
Date: Wed, 30 Jun 2021 04:00:02 +0800	[thread overview]
Message-ID: <CAHO21CJQ+qqcJ7SYmEHbmBdEcNSvuRooFvp4vxwDOgp2qj7iFw@mail.gmail.com> (raw)
In-Reply-To: <46933061-DFBC-406C-8489-F3DC7EE770BA@kuaishou.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 592 bytes --]

[image: image.png]
What it looks like in emacs -Q.

Before this patch, dark theme users cannot distinguish the line from the
background even though hl-line-mode is enabled. Personally I can't.
[image: image.png]

Furthermore,  users must set hl-line-sticky-flag to t to enable highlight
in all windows or move the point to the source file buffer, otherwise only
the arrow in fringe is helpful for which line program run to. It's too
restricted in such a situation.

So I propose to add a new overlay of current line to make gud more friendly
and deprecate the old one.

Here is my patch. :-)

[-- Attachment #1.1.2: Type: text/html, Size: 850 bytes --]

[-- Attachment #1.2: image.png --]
[-- Type: image/png, Size: 55153 bytes --]

[-- Attachment #1.3: image.png --]
[-- Type: image/png, Size: 27480 bytes --]

[-- Attachment #2: 0001-lisp-progmodes-gud.el-Highlight-current-line.patch --]
[-- Type: text/x-patch, Size: 2046 bytes --]

From 1b896f5e7f351cabbc43c7ce730e17d43e4dfc7f Mon Sep 17 00:00:00 2001
From: condy <condy0919@gmail.com>
Date: Wed, 30 Jun 2021 03:57:09 +0800
Subject: [PATCH] * lisp/progmodes/gud.el: Highlight current line

---
 lisp/progmodes/gud.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 740a6e2581..7f1ec20e47 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -85,6 +85,9 @@ gud
   :group 'processes
   :group 'tools)
 
+(defface gud-highlight-face '((t (:inherit secondary-selection)))
+  "Face to use to highlight current line."
+  :group 'gud)
 
 (defcustom gud-key-prefix "\C-x\C-a"
   "Prefix of all GUD commands valid in C buffers."
@@ -2768,6 +2771,7 @@ gud-filter
 	      (gud-filter proc ""))))))
 
 (defvar gud-minor-mode-type nil)
+(defvar gud-overlay-line nil)
 (defvar gud-overlay-arrow-position nil)
 (add-to-list 'overlay-arrow-variable-list 'gud-overlay-arrow-position)
 
@@ -2791,6 +2795,9 @@ gud-sentinel
 	((memq (process-status proc) '(signal exit))
 	 ;; Stop displaying an arrow in a source file.
 	 (setq gud-overlay-arrow-position nil)
+         ;; Stop displaying the `gud-overlay-line'.
+         (delete-overlay gud-overlay-line)
+         (setq gud-overlay-line nil)
 	 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
 		   'gdbmi)
 	     (gdb-reset)
@@ -2886,6 +2893,11 @@ gud-display-line
 	  (or gud-overlay-arrow-position
 	      (setq gud-overlay-arrow-position (make-marker)))
 	  (set-marker gud-overlay-arrow-position (point) (current-buffer))
+          ;; Update the position of `gud-overlay-line'
+          (unless gud-overlay-line
+            (setq gud-overlay-line (make-overlay (point) (point)))
+            (overlay-put gud-overlay-line 'face 'gud-highlight-face))
+          (move-overlay gud-overlay-line (line-beginning-position) (line-end-position) (current-buffer))
 	  ;; If they turned on hl-line, move the hl-line highlight to
 	  ;; the arrow's line.
 	  (when (featurep 'hl-line)
-- 
2.32.0


  reply	other threads:[~2021-06-29 20:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 12:43 Highlight current line when using gud Zhiwei Chen
2021-06-29 20:00 ` Condy Chen [this message]
2021-06-30 11:54   ` Lars Ingebrigtsen
2021-06-30 12:27     ` Eli Zaretskii
2021-06-30 13:07       ` Zhiwei Chen
2021-06-30 12:53     ` Zhiwei Chen
2021-06-30 12:59       ` Zhiwei Chen
2021-06-30 13:18         ` Eli Zaretskii
2021-06-30 13:17       ` Eli Zaretskii
2021-06-30 14:26         ` Zhiwei Chen
2021-06-30 15:50           ` Eli Zaretskii
2021-07-01  3:17             ` Zhiwei Chen
2021-07-01 11:26           ` Lars Ingebrigtsen
2021-07-01 11:35             ` Zhiwei Chen
2021-07-01 17:27               ` Condy Chen
2021-07-01 18:25             ` Zhiwei Chen
2021-07-02 11:01               ` Lars Ingebrigtsen
2021-07-02 11:39                 ` Eli Zaretskii
2021-07-04  0:12                   ` Zhiwei Chen
2021-07-04  4:30                     ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=CAHO21CJQ+qqcJ7SYmEHbmBdEcNSvuRooFvp4vxwDOgp2qj7iFw@mail.gmail.com \
    --to=condy0919@gmail.com \
    --cc=chenzhiwei03@kuaishou.com \
    --cc=emacs-devel@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).