Anonymous avatar Anonymous committed d4f6535

Long outstanding eldoc patches from David A. Panariti
<davep@meduseld.net>;.

Comments (0)

Files changed (2)

+2003-03-07  David A. Panariti  <davep@meduseld.net>
+
+	* eldoc.el (eldoc-get-doc): Factored document string extraction
+	code out of `eldoc-print-current-symbol-info'.
+
+	(eldoc-print-current-symbol-info): Calls `eldoc-get-doc' to get
+	doc to print.
+
+	(eldoc-doc): New function.  Gets doc for current symbol and
+	displays it in the echo area.
+
+	(eldoc-insert-elisp-func-template): New function.  Converts doc
+	from `eldoc-get-doc' into a function template and inserts it at
+	point.
+
 2003-08-19  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 1.58 released.
        (not (eq (selected-window) (minibuffer-window)))))
 
 
+(defun eldoc-get-doc ()
+  "Return the doc for the current symbol."
+  (let ((current-symbol (eldoc-current-symbol))
+	(current-fnsym  (eldoc-fnsym-in-current-sexp)))
+    (cond ((eq current-symbol current-fnsym)
+	   (or (eldoc-get-fnsym-args-string current-fnsym)
+	       (eldoc-get-var-docstring current-symbol)))
+	  (t
+	   (or (eldoc-get-var-docstring current-symbol)
+	       (eldoc-get-fnsym-args-string current-fnsym))))))
+
 (defun eldoc-print-current-symbol-info ()
   (and (eldoc-display-message-p)
-       (let* ((current-symbol (eldoc-current-symbol))
-              (current-fnsym  (eldoc-fnsym-in-current-sexp))
-              (doc (cond ((eq current-symbol current-fnsym)
-                          (or (eldoc-get-fnsym-args-string current-fnsym)
-                              (eldoc-get-var-docstring current-symbol)))
-                         (t
-                          (or (eldoc-get-var-docstring current-symbol)
-                              (eldoc-get-fnsym-args-string current-fnsym))))))
-         (eldoc-message doc))))
+       (eldoc-message (eldoc-get-doc))))
+
+(defun eldoc-insert-elisp-func-template (doc)
+  "Insert function template extracted from an eldoc help message."
+  (interactive "*")
+  (message "%s" doc)
+  (if (not doc)
+      (error "could not find doc.")
+    (if (string-match "[^(]*(\\(.*\\))[^)]*" doc)
+	(save-excursion
+	  (insert (substring doc (match-beginning 1) (match-end 1)) ")"))
+      (message "Cannot find args, none?"))))
+
+(defun eldoc-doc (&optional insert-template)
+  "Display simple help summary in echo area on demand.
+If INSERT-TEMPLATE is non-nil (interactively with prefix arg) then insert a
+function template at point.
+@todo can we add possibility of specifying what to get help on?"
+  (interactive "P")
+  (let ((doc (eldoc-get-doc)))
+    (if insert-template
+	(eldoc-insert-elisp-func-template doc)
+    (message "%s" (or doc 
+		      (format "No doc for `%s'" (eldoc-current-symbol)))))))
 
 ;; Return a string containing the function parameter list, or 1-line
 ;; docstring if function is a subr and no arglist is obtainable from the
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.