From 1b896f5e7f351cabbc43c7ce730e17d43e4dfc7f Mon Sep 17 00:00:00 2001 From: condy 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