]> code.delx.au - gnu-emacs/commitdiff
Fix and improve GUD Tooltip mode.
authorEli Zaretskii <eliz@gnu.org>
Tue, 14 Aug 2012 18:48:39 +0000 (21:48 +0300)
committerEli Zaretskii <eliz@gnu.org>
Tue, 14 Aug 2012 18:48:39 +0000 (21:48 +0300)
 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.

doc/emacs/ChangeLog
doc/emacs/building.texi
lisp/ChangeLog
lisp/progmodes/gdb-mi.el
lisp/progmodes/gud.el
lisp/tooltip.el

index 1e8cfc5e7292e5019ba0d511a0349e30067e8146..fa78cc4c50255dab3b81873cfe606bd80cfb599d 100644 (file)
@@ -1,3 +1,8 @@
+2012-08-14  Eli Zaretskii  <eliz@gnu.org>
+
+       * building.texi (Debugger Operation): Correct and improve
+       documentation of the GUD Tooltip mode.
+
 2012-07-31  Chong Yidong  <cyd@gnu.org>
 
        * emacs.texi: Fix ISBN (Bug#12080).
index 01e6e67b07e0a5dd087bad7231548fa374ec767e..05ea667e5f7fa3c1fbf80998b8b7fd38505379b0 100644 (file)
@@ -588,19 +588,25 @@ to recompile and restart the program.
   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 non-@code{nil}, 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.
+variable, a function, or a macro (collectively called
+@dfn{identifiers}) 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
+@code{gud-tooltip-echo-area} is non-@code{nil}, 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}, 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
index b58580f64298daaf9e2df456204e4ad393119bc4..83ac7fa86ef0c191b8439db332aca3f7aa007ce6 100644 (file)
@@ -1,3 +1,26 @@
+2012-08-14  Eli Zaretskii  <eliz@gnu.org>
+
+       * 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  <rgm@gnu.org>
 
        * emacs-lisp/bytecomp.el (byte-compile-setq-default):
index 80afdc0bedfdd1911abad21b92cb4644af6a748e..0a99c2f5c24790723c2471b088069eaced131222 100644 (file)
@@ -944,11 +944,16 @@ no input, and GDB is waiting for input."
 (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 @@ no input, and GDB is waiting for input."
     (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 @@ DOC is an optional documentation string."
   ;; 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 @@ current thread and update GDB buffers."
   (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)
index 8912e67d6031ce29fdc64b2d8a94883895a3d313..5946e93f34deca48e7b9c922ef9f71a20cc7a8ef 100644 (file)
@@ -3411,7 +3411,7 @@ With arg, dereference expr if ARG is positive, otherwise do not dereference."
 (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 @@ This function must return nil if it doesn't handle EVENT."
            (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)
index 9d0fbaae9d84335e1b77b440dd047e95dab6faee..a57054acdd60caaa7f6defb047906cb2f3e60d32 100644 (file)
@@ -25,6 +25,8 @@
 
 ;;; Code:
 
+(require 'syntax)
+
 (defvar comint-prompt-regexp)
 
 (defgroup tooltip nil
@@ -277,8 +279,11 @@ Value is nil if no identifier exists at point.  Identifier extraction
 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)))))))