Function: gud-display-line

gud-display-line is a byte-compiled function defined in gud.el.gz.

Signature

(gud-display-line TRUE-FILE LINE &optional COLUMN)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/gud.el.gz
(defun gud-display-line (true-file line &optional column)
  (let* ((last-nonmenu-event t)	 ; Prevent use of dialog box for questions.
	 (buffer
	  (with-current-buffer gud-comint-buffer
	    (gud-find-file true-file)))
	 (window
          (when buffer
            (if (eq gud-minor-mode 'gdbmi)
                (gdb-display-source-buffer buffer)
              ;; Gud still has the old behavior.
              (or (get-buffer-window buffer)
                  (display-buffer buffer '(nil (inhibit-same-window . t)))))))
	 (pos))
    (when buffer
      (with-current-buffer buffer
	(unless (or (verify-visited-file-modtime buffer) gud-keep-buffer)
	  (if (yes-or-no-p
	       (format "File %s changed on disk.  Reread from disk? "
		       (buffer-name)))
	      (revert-buffer t t)
	    (setq gud-keep-buffer t)))
	(save-restriction
	  (widen)
	  (goto-char (point-min))
	  (forward-line (1- line))
	  (setq pos (point))
          (when column
            (forward-char (1- column)))
	  (or gud-overlay-arrow-position
	      (setq gud-overlay-arrow-position (make-marker)))
	  (set-marker gud-overlay-arrow-position (point) (current-buffer))
          (if gud-highlight-current-line
              (progn
                (unless gud-highlight-current-line-overlay
                  ;; Create the highlight overlay if it does not yet
                  ;; exist.
                  (let ((overlay (make-overlay (point) (point))))
                    (overlay-put overlay 'priority -45) ; 5 less than hl-line.
                    (overlay-put overlay 'face 'gud-highlight-current-line-face)
                    (setq gud-highlight-current-line-overlay overlay)))
                ;; Next, move the overlay to the current line.
                (move-overlay gud-highlight-current-line-overlay
                              (line-beginning-position)
                              (line-beginning-position 2)
                              (current-buffer)))
            ;; Delete any overlay introduced if g-h-c-l-f has changed.
            (when gud-highlight-current-line-overlay
              (delete-overlay gud-highlight-current-line-overlay)
              (setq gud-highlight-current-line-overlay nil))
	    ;; If they turned on hl-line, move the hl-line highlight to
	    ;; the arrow's line.
	    (when (featurep 'hl-line)
	      (cond
	       (global-hl-line-mode
                (global-hl-line-highlight))
	       ((and hl-line-mode hl-line-sticky-flag)
                (hl-line-highlight))))))
	(cond ((or (< pos (point-min)) (> pos (point-max)))
	       (widen)
	       (goto-char pos))))
      (when window
	(set-window-point window gud-overlay-arrow-position)))))