all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Patch: gdba stack frame fix
@ 2007-10-09 17:32 Tom Tromey
  2007-10-11  4:25 ` Nick Roberts
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2007-10-09 17:32 UTC (permalink / raw)
  To: Emacs Hackers

I'm using gdb in "many windows" mode.

The stack in my inferior has more frames than there are lines in the
gdb stack frames window.  If I go "up" enough, the fringe bitmap
representing the current frame will simply disappear.

I think it is more useful in this case for the stack frame window to
scroll, making sure that the current frame is always visible.

This patch implements this idea.  The patch looks much bigger than it
is, because I added a new let binding and thus had to reindent most of
the function's body.

Tom

2007-10-09  Tom Tromey  <tromey@redhat.com>

	* progmodes/gdb-ui.el (gdb-info-stack-custom): Ensure current
	frame is visible.

Index: lisp/progmodes/gdb-ui.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/gdb-ui.el,v
retrieving revision 1.211
diff -u -r1.211 gdb-ui.el
--- lisp/progmodes/gdb-ui.el	9 Oct 2007 08:52:43 -0000	1.211
+++ lisp/progmodes/gdb-ui.el	9 Oct 2007 17:53:50 -0000
@@ -2120,62 +2120,72 @@
 
 (defun gdb-info-stack-custom ()
   (with-current-buffer (gdb-get-buffer 'gdb-stack-buffer)
-    (save-excursion
-      (unless (eq gdb-look-up-stack 'delete)
-	(let ((buffer-read-only nil)
-	      bl el)
-	  (goto-char (point-min))
-	  (while (< (point) (point-max))
-	    (setq bl (line-beginning-position)
-		  el (line-end-position))
-	    (when (looking-at "#")
-	      (add-text-properties bl el
-				   '(mouse-face highlight
-				     help-echo "mouse-2, RET: Select frame")))
-	    (goto-char bl)
-	    (when (looking-at "^#\\([0-9]+\\)")
-	      (when (string-equal (match-string 1) gdb-frame-number)
-		(if (> (car (window-fringes)) 0)
-		    (progn
-		      (or gdb-stack-position
-			  (setq gdb-stack-position (make-marker)))
-		      (set-marker gdb-stack-position (point)))
-		  (put-text-property bl (+ bl 4)
-				     'face '(:inverse-video t))))
-	      (when (re-search-forward
-		     (concat
-		      (if (string-equal (match-string 1) "0") "" " in ")
-		      "\\([^ ]+\\) (") el t)
-		(put-text-property (match-beginning 1) (match-end 1)
-				   'face font-lock-function-name-face)
-		(setq bl (match-end 0))
-		(while (re-search-forward "<\\([^>]+\\)>" el t)
-		  (put-text-property (match-beginning 1) (match-end 1)
-				     'face font-lock-function-name-face))
-		(goto-char bl)
-		(while (re-search-forward "\\(\\(\\sw\\|[_.]\\)+\\)=" el t)
-		  (put-text-property (match-beginning 1) (match-end 1)
-				     'face font-lock-variable-name-face))))
-	    (forward-line 1))
-	  (forward-line -1)
-	  (when (looking-at "(More stack frames follow...)")
-	    (add-text-properties (match-beginning 0) (match-end 0)
-	     '(mouse-face highlight
-	       gdb-max-frames t
-	       help-echo
-               "mouse-2, RET: customize gdb-max-frames to see more frames")))))
-      (when gdb-look-up-stack
+    (let (move-to)
+      (save-excursion
+	(unless (eq gdb-look-up-stack 'delete)
+	  (let ((buffer-read-only nil)
+		bl el)
 	    (goto-char (point-min))
-	    (when (re-search-forward "\\(\\S-+?\\):\\([0-9]+\\)" nil t)
-	      (let ((start (line-beginning-position))
-		    (file (match-string 1))
-		    (line (match-string 2)))
-		(re-search-backward "^#*\\([0-9]+\\)" start t)
-		(gdb-enqueue-input
-		 (list (concat gdb-server-prefix "frame "
-			       (match-string 1) "\n") 'gdb-set-hollow))
-		(gdb-enqueue-input
-		 (list (concat gdb-server-prefix "frame 0\n") 'ignore)))))))
+	    (while (< (point) (point-max))
+	      (setq bl (line-beginning-position)
+		    el (line-end-position))
+	      (when (looking-at "#")
+		(add-text-properties bl el
+				     '(mouse-face highlight
+						  help-echo "mouse-2, RET: Select frame")))
+	      (goto-char bl)
+	      (when (looking-at "^#\\([0-9]+\\)")
+		(when (string-equal (match-string 1) gdb-frame-number)
+		  (if (> (car (window-fringes)) 0)
+		      (progn
+			(or gdb-stack-position
+			    (setq gdb-stack-position (make-marker)))
+			(set-marker gdb-stack-position (point))
+			(setq move-to gdb-stack-position))
+		    (put-text-property bl (+ bl 4)
+				       'face '(:inverse-video t))
+		    (setq move-to bl)))
+		(when (re-search-forward
+		       (concat
+			(if (string-equal (match-string 1) "0") "" " in ")
+			"\\([^ ]+\\) (") el t)
+		  (put-text-property (match-beginning 1) (match-end 1)
+				     'face font-lock-function-name-face)
+		  (setq bl (match-end 0))
+		  (while (re-search-forward "<\\([^>]+\\)>" el t)
+		    (put-text-property (match-beginning 1) (match-end 1)
+				       'face font-lock-function-name-face))
+		  (goto-char bl)
+		  (while (re-search-forward "\\(\\(\\sw\\|[_.]\\)+\\)=" el t)
+		    (put-text-property (match-beginning 1) (match-end 1)
+				       'face font-lock-variable-name-face))))
+	      (forward-line 1))
+	    (forward-line -1)
+	    (when (looking-at "(More stack frames follow...)")
+	      (add-text-properties (match-beginning 0) (match-end 0)
+				   '(mouse-face highlight
+						gdb-max-frames t
+						help-echo
+						"mouse-2, RET: customize gdb-max-frames to see more frames")))))
+	(when gdb-look-up-stack
+	  (goto-char (point-min))
+	  (when (re-search-forward "\\(\\S-+?\\):\\([0-9]+\\)" nil t)
+	    (let ((start (line-beginning-position))
+		  (file (match-string 1))
+		  (line (match-string 2)))
+	      (re-search-backward "^#*\\([0-9]+\\)" start t)
+	      (gdb-enqueue-input
+	       (list (concat gdb-server-prefix "frame "
+			     (match-string 1) "\n") 'gdb-set-hollow))
+	      (gdb-enqueue-input
+	       (list (concat gdb-server-prefix "frame 0\n") 'ignore))))))
+      (when move-to
+	(let ((window (get-buffer-window (current-buffer) 0)))
+	  (when window
+	    (with-selected-window window
+	      (goto-char move-to)
+	      (unless (pos-visible-in-window-p)
+		(recenter '(center)))))))))
   (if (eq gdb-look-up-stack 'delete)
       (kill-buffer (gdb-get-buffer 'gdb-stack-buffer)))
   (setq gdb-look-up-stack nil))

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patch: gdba stack frame fix
  2007-10-09 17:32 Patch: gdba stack frame fix Tom Tromey
@ 2007-10-11  4:25 ` Nick Roberts
  2007-10-12  2:46   ` Richard Stallman
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Roberts @ 2007-10-11  4:25 UTC (permalink / raw)
  To: tromey; +Cc: Emacs Hackers

 > 2007-10-09  Tom Tromey  <tromey@redhat.com>
 > 
 > 	* progmodes/gdb-ui.el (gdb-info-stack-custom): Ensure current
 > 	frame is visible.

This looks useful, so I've checked it in on EMACS_22_BASE.  I've assumed that
you have a copyright assignment in place.  Please post to this list if this
is not the case.

-- 
Nick                                           http://www.inet.net.nz/~nickrob

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patch: gdba stack frame fix
  2007-10-11  4:25 ` Nick Roberts
@ 2007-10-12  2:46   ` Richard Stallman
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2007-10-12  2:46 UTC (permalink / raw)
  To: Nick Roberts; +Cc: tromey, emacs-devel

Red Hat has assigned all changes to all FSF-copyrighted programs made
by its employees.  So assuming Tom Tromey is a Red Hat employee,
it is covered.  If he isn't a Red Hat employee, he's covered by
his own assignment.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-10-12  2:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-09 17:32 Patch: gdba stack frame fix Tom Tromey
2007-10-11  4:25 ` Nick Roberts
2007-10-12  2:46   ` Richard Stallman

Code repositories for project(s) associated with this external index

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

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.