unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Zhiwei Chen <chenzhiwei03@kuaishou.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Lars Ingebrigtsen <larsi@gnus.org>,
	"condy0919@gmail.com" <condy0919@gmail.com>,
	"emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: Highlight current line when using gud
Date: Thu, 1 Jul 2021 03:17:22 +0000	[thread overview]
Message-ID: <851BB31A-011B-47A5-9B3C-8878543C1533@kuaishou.com> (raw)
In-Reply-To: <83bl7nmjvr.fsf@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 859 bytes --]


> On Jun 30, 2021, at 11:50 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>
> Thanks.  It all looks to me as differences in personal preferences.  I
> have no doubt that some of us (myself included) have no problems
> finding the current line in the source buffer, and others use
> hl-line-mode with the above code and have no problems at all.  So I
> wonder what would be the best way of adding the feature you want
> without disappointing those who like the existing behavior.

> FWIW, I'm not opposed to such a change, but it must be an optional
feature (we could discuss the default value).  I don't think we can
force people to use this overlay.  Especially since on GUI displays
the arrow is shown in the fringe (not to mention the fact that
gud-gdb is deprecated in favor of gdb-mi.el).

A user option is introduced.



--
Zhiwei Chen

[-- Attachment #1.2: Type: text/html, Size: 1381 bytes --]

[-- Attachment #2: 0001-lisp-progmodes-gud.el-Highlight-current-line.patch --]
[-- Type: application/octet-stream, Size: 2286 bytes --]

From 654f3c2728741117642c8b762fb6a9fa78ff7309 Mon Sep 17 00:00:00 2001
From: condy <condy0919@gmail.com>
Date: Thu, 1 Jul 2021 11:11:04 +0800
Subject: [PATCH] * lisp/progmodes/gud.el: Highlight current line

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

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 740a6e2581..57bb610287 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -85,6 +85,14 @@ gud
   :group 'processes
   :group 'tools)
 
+(defface gud-highlight-face '((t (:inherit secondary-selection)))
+  "Face to use to highlight current line."
+  :group 'gud)
+
+(defcustom gud-highlight-line nil
+  "If non-nil, highlight the current line when debugging."
+  :group 'gud
+  :type 'boolean)
 
 (defcustom gud-key-prefix "\C-x\C-a"
   "Prefix of all GUD commands valid in C buffers."
@@ -2768,6 +2776,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 +2800,10 @@ 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'.
+         (when gud-highlight-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 +2899,12 @@ 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'
+          (when gud-highlight-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.30.1 (Apple Git-130)


  reply	other threads:[~2021-07-01  3:17 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
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 [this message]
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=851BB31A-011B-47A5-9B3C-8878543C1533@kuaishou.com \
    --to=chenzhiwei03@kuaishou.com \
    --cc=condy0919@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.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).