[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r109616: Fix and improve GUD Tooltip
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r109616: Fix and improve GUD Tooltip mode. |
Date: |
Tue, 14 Aug 2012 21:48:39 +0300 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 109616
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Tue 2012-08-14 21:48:39 +0300
message:
Fix and improve GUD Tooltip mode.
lisp/tooltip.el (tooltip-identifier-from-point): Don't treat tokens
inside comments and strings as identifiers.
lisp/progmodes/gud.el (gud-tooltip-print-command): Quote the
expression to evaluate. This allows to evaluate expressions with
embedded whitespace.
(gud-tooltip-tips): Add a blank before the newline in the
message-box text, for the benefit of message-box emulation on
MS-Windows.
lisp/progmodes/gdb-mi.el (gdb-tooltip-print): Don't ignore error
messages from GDB, pop them up in a tooltip to give feedback to
user.
(gdb-tooltip-print-1): Quote the expression to evaluate. This
allows to evaluate expressions with embedded whitespace.
(gdb-inferior-io--init-proc): Don't send "-inferior-tty" command
if the TTY name is nil or empty (which happens when communicating
with the inferior via pipes, e.g. on MS-Windows).
(gdb-internals): If GDB sends a "&\n" empty debugging message,
don't send that to the GUD buffer.
doc/emacs/building.texi (Debugger Operation): Correct and improve
documentation of the GUD Tooltip mode.
modified:
doc/emacs/ChangeLog
doc/emacs/building.texi
lisp/ChangeLog
lisp/progmodes/gdb-mi.el
lisp/progmodes/gud.el
lisp/tooltip.el
=== modified file 'doc/emacs/ChangeLog'
--- a/doc/emacs/ChangeLog 2012-08-09 07:15:04 +0000
+++ b/doc/emacs/ChangeLog 2012-08-14 18:48:39 +0000
@@ -1,3 +1,8 @@
+2012-08-14 Eli Zaretskii <address@hidden>
+
+ * building.texi (Debugger Operation): Correct and improve
+ documentation of the GUD Tooltip mode.
+
2012-07-31 Chong Yidong <address@hidden>
* emacs.texi: Fix ISBN (Bug#12080).
=== modified file 'doc/emacs/building.texi'
--- a/doc/emacs/building.texi 2012-06-17 05:13:40 +0000
+++ b/doc/emacs/building.texi 2012-08-14 18:48:39 +0000
@@ -588,19 +588,25 @@
GUD Tooltip mode is a global minor mode that adds tooltip support to
GUD. To toggle this mode, type @kbd{M-x gud-tooltip-mode}. It is
disabled by default. If enabled, you can move the mouse cursor over a
-variable to show its value in a tooltip (@pxref{Tooltips}); this takes
-effect in the GUD interaction buffer, and in all source buffers with
-major modes listed in the variable @code{gud-tooltip-modes}. If the
-variable @code{gud-tooltip-echo-area} is address@hidden, values are
-shown in the echo area instead of a tooltip.
+variable, a function, or a macro (collectively called
address@hidden) to show their values in tooltips
+(@pxref{Tooltips}). Alternatively, mark an identifier or an
+expression by dragging the mouse over it, then leave the mouse in the
+marked area to have the value of the expression displayed in a
+tooltip. The GUD Tooltip mode takes effect in the GUD interaction
+buffer, and in all source buffers with major modes listed in the
+variable @code{gud-tooltip-modes}. If the variable
address@hidden is address@hidden, or if you turned off
+the tooltip mode, values are shown in the echo area instead of a
+tooltip.
- When using GUD Tooltip mode with @kbd{M-x gud-gdb}, you should note
-that displaying an expression's value in GDB can sometimes expand a
-macro, potentially causing side effects in the debugged program. If
-you use the @kbd{M-x gdb} interface, this problem does not occur, as
-there is special code to avoid side-effects; furthermore, you can
-display macro definitions associated with an identifier when the
-program is not executing.
+ When using GUD Tooltip mode with @kbd{M-x gud-gdb}, displaying an
+expression's value in GDB can sometimes expand a macro, potentially
+causing side effects in the debugged program. For that reason, using
+tooltips in @code{gud-gdb} is disabled. If you use the @kbd{M-x gdb}
+interface, this problem does not occur, as there is special code to
+avoid side-effects; furthermore, you can display macro definitions
+associated with an identifier when the program is not executing.
@node Commands of GUD
@subsection Commands of GUD
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-08-14 18:23:10 +0000
+++ b/lisp/ChangeLog 2012-08-14 18:48:39 +0000
@@ -1,3 +1,26 @@
+2012-08-14 Eli Zaretskii <address@hidden>
+
+ * tooltip.el (tooltip-identifier-from-point): Don't treat tokens
+ inside comments and strings as identifiers.
+
+ * progmodes/gud.el (gud-tooltip-print-command): Quote the
+ expression to evaluate. This allows to evaluate expressions with
+ embedded whitespace.
+ (gud-tooltip-tips): Add a blank before the newline in the
+ message-box text, for the benefit of message-box emulation on
+ MS-Windows.
+
+ * progmodes/gdb-mi.el (gdb-tooltip-print): Don't ignore error
+ messages from GDB, pop them up in a tooltip to give feedback to
+ user.
+ (gdb-tooltip-print-1): Quote the expression to evaluate. This
+ allows to evaluate expressions with embedded whitespace.
+ (gdb-inferior-io--init-proc): Don't send "-inferior-tty" command
+ if the TTY name is nil or empty (which happens when communicating
+ with the inferior via pipes, e.g. on MS-Windows).
+ (gdb-internals): If GDB sends a "&\n" empty debugging message,
+ don't send that to the GUD buffer.
+
2012-08-14 Glenn Morris <address@hidden>
* emacs-lisp/bytecomp.el (byte-compile-setq-default):
=== modified file 'lisp/progmodes/gdb-mi.el'
--- a/lisp/progmodes/gdb-mi.el 2012-07-28 15:12:12 +0000
+++ b/lisp/progmodes/gdb-mi.el 2012-08-14 18:48:39 +0000
@@ -944,11 +944,16 @@
(defun gdb-tooltip-print (expr)
(with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
(goto-char (point-min))
- (if (re-search-forward ".*value=\\(\".*\"\\)" nil t)
- (tooltip-show
- (concat expr " = " (read (match-string 1)))
- (or gud-tooltip-echo-area
- (not (display-graphic-p)))))))
+ (cond
+ ((re-search-forward ".*value=\\(\".*\"\\)" nil t)
+ (tooltip-show
+ (concat expr " = " (read (match-string 1)))
+ (or gud-tooltip-echo-area
+ (not (display-graphic-p)))))
+ ((re-search-forward "msg=\\(\".+\"\\)$" nil t)
+ (tooltip-show (read (match-string 1))
+ (or gud-tooltip-echo-area
+ (not (display-graphic-p))))))))
;; If expr is a macro for a function don't print because of possible dangerous
;; side-effects. Also printing a function within a tooltip generates an
@@ -958,7 +963,7 @@
(goto-char (point-min))
(if (search-forward "expands to: " nil t)
(unless (looking-at "\\S-+.*(.*).*")
- (gdb-input (concat "-data-evaluate-expression " expr)
+ (gdb-input (concat "-data-evaluate-expression \"" expr "\"")
`(lambda () (gdb-tooltip-print ,expr)))))))
(defun gdb-init-buffer ()
@@ -1513,12 +1518,13 @@
;; Set up inferior I/O. Needs GDB 6.4 onwards.
(set-process-filter proc 'gdb-inferior-filter)
(set-process-sentinel proc 'gdb-inferior-io-sentinel)
- (gdb-input
- (concat "-inferior-tty-set "
- ;; The process can run on a remote host.
- (or (process-get proc 'remote-tty)
- (process-tty-name proc)))
- 'ignore))
+ ;; The process can run on a remote host.
+ (let ((tty (or (process-get proc 'remote-tty)
+ (process-tty-name proc))))
+ (unless (or (null tty)
+ (string= tty ""))
+ (gdb-input
+ (concat "-inferior-tty-set " tty) 'ignore))))
(defun gdb-inferior-io-sentinel (proc str)
(when (eq (process-status proc) 'failed)
@@ -2100,13 +2106,15 @@
(setq gdb-filter-output
(gdb-concat-output
gdb-filter-output
- (let ((error-message
- (read output-field)))
- (put-text-property
- 0 (length error-message)
- 'face font-lock-warning-face
- error-message)
- error-message))))
+ (if (string= output-field "\"\\n\"")
+ ""
+ (let ((error-message
+ (read output-field)))
+ (put-text-property
+ 0 (length error-message)
+ 'face font-lock-warning-face
+ error-message)
+ error-message)))))
;; Remove the trimmings from the console stream and send to GUD buffer
;; (frontend MI commands should not print to this stream)
=== modified file 'lisp/progmodes/gud.el'
--- a/lisp/progmodes/gud.el 2012-07-11 23:13:41 +0000
+++ b/lisp/progmodes/gud.el 2012-08-14 18:48:39 +0000
@@ -3411,7 +3411,7 @@
(defun gud-tooltip-print-command (expr)
"Return a suitable command to print the expression EXPR."
(pcase gud-minor-mode
- (`gdbmi (concat "-data-evaluate-expression " expr))
+ (`gdbmi (concat "-data-evaluate-expression \"" expr "\""))
(`dbx (concat "print " expr))
((or `xdb `pdb) (concat "p " expr))
(`sdb (concat expr "/"))))
@@ -3456,7 +3456,10 @@
(let ((cmd (gud-tooltip-print-command expr)))
(when (and gud-tooltip-mode (eq gud-minor-mode 'gdb))
(gud-tooltip-mode -1)
- (message-box "Using GUD tooltips in this mode is unsafe\n\
+ ;; The blank before the newline is for MS-Windows,
+ ;; whose emulation of message box removes newlines and
+ ;; displays a single long line.
+ (message-box "Using GUD tooltips in this mode is unsafe \n\
so they have been disabled."))
(unless (null cmd) ; CMD can be nil if unknown debugger
(if (eq gud-minor-mode 'gdbmi)
=== modified file 'lisp/tooltip.el'
--- a/lisp/tooltip.el 2012-05-13 03:05:06 +0000
+++ b/lisp/tooltip.el 2012-08-14 18:48:39 +0000
@@ -25,6 +25,8 @@
;;; Code:
+(require 'syntax)
+
(defvar comint-prompt-regexp)
(defgroup tooltip nil
@@ -277,8 +279,11 @@
is based on the current syntax table."
(save-excursion
(goto-char point)
- (let ((start (progn (skip-syntax-backward "w_") (point))))
- (unless (looking-at "[0-9]")
+ (let* ((start (progn (skip-syntax-backward "w_") (point)))
+ (pstate (syntax-ppss)))
+ (unless (or (looking-at "[0-9]")
+ (nth 3 pstate)
+ (nth 4 pstate))
(skip-syntax-forward "w_")
(when (> (point) start)
(buffer-substring start (point)))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r109616: Fix and improve GUD Tooltip mode.,
Eli Zaretskii <=