From xemacs-m  Thu Sep 11 06:16:19 1997
Received: from frege.math.ethz.ch (root@frege-d-math-north-g-west.math.ethz.ch [129.132.145.3])
	by xemacs.org (8.8.5/8.8.5) with SMTP id GAA07351
	for <xemacs-beta@xemacs.org>; Thu, 11 Sep 1997 06:16:18 -0500 (CDT)
Received: from midget (vroonhof@midget [129.132.145.4]) by frege.math.ethz.ch (8.6.12/Main-STAT-mailer) with ESMTP id NAA26550 for <xemacs-beta@xemacs.org>; Thu, 11 Sep 1997 13:16:15 +0200
Received: (vroonhof@localhost) by midget (SMI-8.6/D-MATH-client) id NAA24459; Thu, 11 Sep 1997 13:16:14 +0200
To: xemacs-beta@xemacs.org
Subject: Quick tips
Mime-Version: 1.0 (generated by tm-edit 7.106)
Content-Type: multipart/mixed;
 boundary="Multipart_Thu_Sep_11_13:16:14_1997-1"
Content-Transfer-Encoding: 7bit
From: Jan Vroonhof <vroonhof@math.ethz.ch>
Date: 11 Sep 1997 13:16:14 +0200
Message-ID: <byn2lkhzi9.fsf@midget.math.ethz.ch>
Lines: 208
X-Mailer: Gnus v5.4.55/XEmacs 19.15

--Multipart_Thu_Sep_11_13:16:14_1997-1
Content-Type: text/plain; charset=US-ASCII


The German C't magazine hat a review of QuickBasic v5 which included a
neat feature. If the user pauses while typing a function call a small
window pops up with the functions definitions.

Of course Emacs can do that to (Kyle, thanks!) with a bit of help from
balloon-help and itimer!

Load "qb.el", enable balloon-help and start hacking elisp:


--Multipart_Thu_Sep_11_13:16:14_1997-1
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="qb.pat"
Content-Transfer-Encoding: 7bit

--- qb.orig	Wed Sep 10 21:38:35 1997
+++ qb.el	Wed Sep 10 21:39:09 1997
@@ -0,0 +1,10 @@
+(setq balloon-help-after-idle 2)
+
+(defun describe-function-called-at-point (object)
+      (let ((func (function-called-at-point (nth 1 object) (nth 2 object))))
+	(if func (ba)
+	    (describe-function-short-string func))))
+
+(defun 'emacs-lisp-mode-balloon-hook
+    (make-local-variable 'balloon-help-function)
+    (setq balloon-help-function 'describe-function-called-at-point))
--- /scratch/xemacs/xemacs-20.3-b18/lisp/prim/help.el	Wed Sep  3 21:19:12 1997
+++ help.el	Wed Sep 10 20:00:35 1997
@@ -745,12 +745,15 @@
  	  (call-interactively defn)
  	(ding)))))
 
-;; Return a function which is called by the list containing point.
-;; If that gives no function, return a function whose name is around point.
-;; If that doesn't give a function, return nil.
-(defun function-called-at-point ()
+(defun function-called-at-point (&optional point buffer)
+"   Return a function which is called by the list containing POINT in BUFFER.
+    If that gives no function, return a function whose name is around point.
+    If that doesn't give a function, return nil. If any of the arguments is nil 
+    then the current-value is use d"
   (or (condition-case ()
 	  (save-excursion
+	    (and buffer (set-buffer buffer))
+	    (and point  (goto-char point))
 	    (save-restriction
 	      (narrow-to-region (max (point-min) (- (point) 1000)) (point-max))
 	      (backward-up-list 1)
@@ -763,6 +766,8 @@
 	  (let ((stab (syntax-table)))
 	    (unwind-protect
 		(save-excursion
+		  (and buffer (set-buffer buffer))
+		  (and point  (goto-char point))
 		  (set-syntax-table emacs-lisp-mode-syntax-table)
 		  (or (not (zerop (skip-syntax-backward "_w")))
 		      (eq (char-syntax (char-after (point))) ?w)
@@ -982,6 +987,48 @@
 	       (unless (or (equal doc "")
 			   (eq ?\n (aref doc (1- (length doc)))))
 		 (terpri stream))))))))
+
+;; Adapted rom help.el's describe function 1.
+(defun describe-function-short-string (function)
+     "Return a string containing (function-name ARG1 ARG2 ...)"
+  (let* ((def function)
+         (doc (condition-case nil
+		  (or (documentation function)
+		      (gettext "not documented"))
+		(void-function "")))
+	 aliases kbd-macro-p fndef macrop)
+    ;; Loop over aliases
+    (while (and (symbolp def) (fboundp def))
+      (setq def (symbol-function def)))
+    (if (eq 'macro (car-safe def))
+	(setq fndef (cdr def)
+	      macrop t)
+      (setq fndef def))
+
+    (let ((arglist
+	    (cond ((compiled-function-p fndef)
+		      (compiled-function-arglist fndef))
+		     ((eq (car-safe fndef) 'lambda)
+		      (nth 1 fndef))
+		     ((and (subrp fndef)
+			   (string-match
+			    "[\n\t ]*\narguments: ?(\\(.*\\))\n?\\'"
+			    doc))
+		      (prog1
+			  (substring doc (match-beginning 1) (match-end 1))
+			(setq doc (substring doc 0 (match-beginning 0)))))
+		     (t t))))
+	  (cond ((listp arglist)
+		    (format "%s" (cons function
+			       (mapcar (lambda (arg)
+				       (if (memq arg '(&optional &rest))
+					   arg
+					 (intern (upcase (symbol-name arg)))))
+				       arglist))))
+		
+	        ((stringp arglist)
+		    (format "(%s %s)\n" function arglist))))))
+
 
 
 (defun describe-function-arglist (function)
--- /scratch/xemacs/xemacs-20.3-b18/lisp/packages/balloon-help.el	Thu Jun 26 04:31:13 1997
+++ balloon-help.el	Wed Sep 10 21:35:38 1997
@@ -121,6 +121,12 @@
   :type 'boolean
   :group 'balloon-help)
 
+(defcustom balloon-help-after-idle nil
+  "*Non-nil means that after that many seconds balloon-help is displayed if
+   the function balloon0help-function is defined."
+  :type 'integer
+  :group 'balooon-help)
+
 ;;;
 ;;; End of user variables.
 ;;;
@@ -163,6 +169,8 @@
 as the X server gets around to displaying it.  Nil means it
 will be invisible as soon as the X server decides to hide it.")
 
+(defvar ballon-help-itimer nil)
+
 (defun balloon-help-mode (&optional arg)
   "Toggle Balloon Help mode.
 With arg, turn Balloon Help mode on iff arg is positive.
@@ -186,20 +194,39 @@
   (interactive "P")
   (setq balloon-help-mode (or (and arg (> (prefix-numeric-value arg) 0))
 			      (and (null arg) (null balloon-help-mode))))
-  (if (null balloon-help-mode)
-      (balloon-help-undisplay-help)))
+  (if balloon-help-mode
+         (balloon-help-init-itimer)
+      (balloon-help-undisplay-help)
+      (if (itimerp balloon-help-itimer)
+	  (delete-itimer balloon-help-itimer)
+	)
+      nil))
 
 (defun balloon-help-displayed ()
   (and (frame-live-p balloon-help-frame)
        (frame-visible-p balloon-help-frame)
        (eq (frame-device balloon-help-frame) (selected-device))))
 
+(defun balloon-help-init-itimer ()
+  (when balloon-help-after-idle
+    (if (null (itimerp balloon-help-itimer))
+      (setq balloon-help-itimer (make-itimer)))
+    (set-itimer-value balloon-help-itimer balloon-help-after-idle)
+    (set-itimer-function balloon-help-itimer 'balloon-help-nocheck)
+    (set-itimer-is-idle balloon-help-itimer t)
+    (set-itimer-restart balloon-help-itimer balloon-help-after-idle)
+    (activate-itimer balloon-help-itimer)))
+
+
 (defun balloon-help (&optional event)
   "Display Balloon Help for the object under EVENT.
 If EVENT is nil, then point in the selected window is used instead.
 See the documentation for balloon-help-mode to find out what this means.
 This command must be bound to a mouse event."
   (interactive "e")
+  (balloon-help-nocheck event))
+
+(defun balloon-help-nocheck (&optional event)
   (unless (device-on-window-system-p)
     (error "Cannot display balloon help on %s device" (device-type)))
   (let ((balloon-help-mode t))
@@ -238,6 +265,10 @@
 		       button
 		     nil))
 	   (object (or modeline-extent glyph-extent extent button))
+	   (object (or object (and point 
+				   (with-current-buffer buffer
+				     (functionp balloon-help-function)
+				     (list balloon-help-function point buffer)))))
 	   (id balloon-help-timeout-id))
       (if (null object)
 	  (if (and balloon-help-frame
@@ -302,7 +333,8 @@
 			    (extent-property object 'balloon-help))
 		       (and (toolbar-button-p object)
 			    (toolbar-button-help-string object))
-		       (and (stringp object) object))))
+		       (and (stringp object) object)
+		       (and (listp object) (car object)))))
 	;; if help is non-null and is not a string, run it as
 	;; function to produuce the help string.
 	(if (or (null help) (not (symbolp help)))

--Multipart_Thu_Sep_11_13:16:14_1997-1
Content-Type: text/plain; charset=US-ASCII





--Multipart_Thu_Sep_11_13:16:14_1997-1--

