comparison lisp/tooltip.el @ 61897:c770a716e5cb

(tooltip-gud-tips): Show the associated #define directives when a C program under GDB is not executing.
author Nick Roberts <nickrob@snap.net.nz>
date Wed, 27 Apr 2005 22:01:14 +0000
parents c7e8695076af
children 55735e23c27d
comparison
equal deleted inserted replaced
61896:e8b38798dd7b 61897:c770a716e5cb
451 451
452 (defun tooltip-gud-tips (event) 452 (defun tooltip-gud-tips (event)
453 "Show tip for identifier or selection under the mouse. 453 "Show tip for identifier or selection under the mouse.
454 The mouse must either point at an identifier or inside a selected 454 The mouse must either point at an identifier or inside a selected
455 region for the tip window to be shown. If tooltip-gud-dereference is t, 455 region for the tip window to be shown. If tooltip-gud-dereference is t,
456 add a `*' in front of the printed expression. 456 add a `*' in front of the printed expression. In the case of a C program
457 controlled by GDB, show the associated #define directives when program is
458 not executing.
457 459
458 This function must return nil if it doesn't handle EVENT." 460 This function must return nil if it doesn't handle EVENT."
459 (let (process) 461 (let (process)
460 (when (and (eventp event) 462 (when (and (eventp event)
461 tooltip-gud-tips-p 463 tooltip-gud-tips-p
462 (boundp 'gud-comint-buffer) 464 (boundp 'gud-comint-buffer)
465 gud-comint-buffer
466 (buffer-name gud-comint-buffer); gud-comint-buffer might be killed
463 (setq process (get-buffer-process gud-comint-buffer)) 467 (setq process (get-buffer-process gud-comint-buffer))
464 (posn-point (event-end event)) 468 (posn-point (event-end event))
465 (progn (setq tooltip-gud-event event) 469 (or (eq gud-minor-mode 'gdba)
466 (eval (cons 'and tooltip-gud-display)))) 470 (progn (setq tooltip-gud-event event)
471 (eval (cons 'and tooltip-gud-display)))))
467 (let ((expr (tooltip-expr-to-print event))) 472 (let ((expr (tooltip-expr-to-print event)))
468 (when expr 473 (when expr
469 (let ((cmd (tooltip-gud-print-command expr))) 474 (if (and (eq gud-minor-mode 'gdba)
470 (unless (null cmd) ; CMD can be nil if unknown debugger 475 (not gdb-active-process))
471 (case gud-minor-mode 476 (progn
472 (gdba (gdb-enqueue-input 477 (with-current-buffer
473 (list (concat cmd "\n") 'gdb-tooltip-print))) 478 (window-buffer (let ((mouse (mouse-position)))
474 (t 479 (window-at (cadr mouse)
475 (setq tooltip-gud-original-filter (process-filter process)) 480 (cddr mouse))))
476 (set-process-filter process 'tooltip-gud-process-output) 481 (when (boundp 'cc-define-alist) ; might be a Fortran program
477 (gud-basic-call cmd))) 482 (let ((define-elt (assoc expr cc-define-alist)))
478 expr))))))) 483 (unless (null define-elt)
484 (tooltip-show (cdr define-elt))
485 expr)))))
486 (let ((cmd (tooltip-gud-print-command expr)))
487 (unless (null cmd) ; CMD can be nil if unknown debugger
488 (case gud-minor-mode
489 (gdba (gdb-enqueue-input
490 (list (concat cmd "\n") 'gdb-tooltip-print)))
491 (t
492 (setq tooltip-gud-original-filter (process-filter process))
493 (set-process-filter process 'tooltip-gud-process-output)
494 (gud-basic-call cmd)))
495 expr))))))))
479 496
480 (defun gdb-tooltip-print () 497 (defun gdb-tooltip-print ()
481 (tooltip-show 498 (tooltip-show
482 (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer) 499 (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
483 (let ((string (buffer-string))) 500 (let ((string (buffer-string)))