[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Function Defintion
From: |
D . Goel |
Subject: |
Re: Function Defintion |
Date: |
28 Feb 2003 23:15:37 -0500 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
> I know how to see it via find-function and I don't want to use macro.
find-function is not a macro. it is a function that takes you to the
code definition .
you indicate that you want your find-function to just return you the
definition as a string, a quick hack would be to just copy the string
from the found function. here's a hack i use for a similar need:
the hack below strips out the docs of the function found before
returning it as a string.. you can comment that out.. :)
(defun erbc-find-function-internal (&optional function nolimitp &rest nada)
(unless function
(error
"Syntax: (ff 'fucntion)"))
(if (stringp function) (setq function (read function)))
(cond
(let* ((fstrbare
(save-excursion
;; This has the problem that it is interactive.. asks to
;; reread file if has changed etc.
;;(find-function function)
(find-function-do-it function nil 'set-buffer)
(buffer-substring (point)
(save-excursion
(forward-sexp 1)
(point)))))
(fstr (erbutils-function-minus-doc fstrbare)))
(if (equal nolimitp 'nolimit)
fstr
(concat (format "%s characters.." (length
fstr))
fstr))))
(t "\n")))
(defun erbutils-function-minus-doc (fstr &rest ignore)
"fstr is the string containing the function"
(let* ((fdoc (if (stringp fstr) fstr (format "%s" fstr)))
newdoc)
(setq newdoc
(with-temp-buffer
(insert fdoc)
(goto-char (point-min))
(search-forward "(" nil t)
(forward-sexp 4)
(if (stringp (sexp-at-point))
;; this sets mark.. bad programming, i know..
(backward-kill-sexp 1))
(buffer-string)))
(erbutils-single-lines newdoc)))
(defun erbutils-single-lines (str)
"Eliminates all \n or lines comprising entirely of whitespace"
(mapconcat
'identity
(delete-if
(lambda (str)
(string-match "^[ \t]*$" str))
(split-string str
"\n"))
"\n"))
hth
DG http://gnufans.net/
--