[Top][All Lists]

[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
     "Syntax: (ff 'fucntion)"))
  (if (stringp function) (setq function (read function)))
     (let* ((fstrbare
             ;; 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)
                                 (forward-sexp 1)
          (fstr (erbutils-function-minus-doc fstrbare)))
      (if (equal nolimitp 'nolimit)
        (concat (format "%s characters.." (length
   (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)))
    (setq newdoc
            (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))
    (erbutils-single-lines newdoc)))

(defun erbutils-single-lines (str)
  "Eliminates all \n or lines comprising entirely of whitespace"
    (lambda (str) 
      (string-match "^[ \t]*$" str))
    (split-string str


reply via email to

[Prev in Thread] Current Thread [Next in Thread]