Lisp HUG Maillist Archive

Finding definitions created using my own defining macros

I have a macro that is essentially a wrapper for DEFMETHOD,
and I want to be able to use the 'Find Source' and
'Find Source for Dspec' editor commands to find definitions
that I've created with it.

A simpler case, which I have working, is a wrapper for
DEFPARAMETER:

(dspec:define-dspec-alias my-defparameter (name)
  `(defparameter ,name))

(defmacro my-defparameter (name value)
  `(top-level-form (my-defparameter ,name)
     (defparameter ,name ,value)))

If I then compile this:

(my-defparameter fred 100)

and then evaluate

(editor:find-source-for-dspec-command
 nil
 '(my-defparameter fred))

the definition of FRED is found.


Moving on to the DEFMETHOD wrapper:

This looks to me like it might be the right thing to do:

(dspec:define-dspec-alias my-defmethod (name arg-types)
  `(defmethod ,name ,arg-types))

(defmacro my-defmethod (name args &body body)
  `(top-level-form (my-defmethod ,name
                       ,(mapcar #'second args))
     (defmethod ,name ,args ,@body)))

But with

(my-defmethod foo ((x number)) 32)

and

(editor:find-source-for-dspec-command
 nil
 '(my-defmethod foo (number)))

I get this: Cannot find (METHOD FOO (NUMBER))

What am I doing wrong?


Re: Finding definitions created using my own defining macros

Unable to parse email body. Email id is 824

Re: Finding definitions created using my own defining macros

> From: <davef@xanalys.com>
> Sent: Friday, January 31, 2003 1:08 PM
>
> Is that the whole message? I get
>   "Cannot find (METHOD FOO (NUMBER)) in foo.lisp"
> which shows that at least the file containing the definition
> is known.

Sorry for being imprecise; yes, that's what I was getting.


>    What am I doing wrong?
>
> The problem is that the Editor does not know how to recognise
> MY-DEFMETHOD forms. It needs to be able to parse the top level forms
> in the source file to find the one that matches the dspec.
>
> c.f. MY-DEFPARAMETER where the default form parser happens to get it
> right.
>
> You can do this to make it work in LW4.2:
>
> #+LispWorks4.2
> (setf (editor::get-parser 'my-defmethod) (editor::get-parser
'defmethod))
>
> In the next full release, this hack will be replaced with a proper
> interface (in the DSPEC package, rather than EDITOR internals).

Thanks.

I looked at the arg list of the function returned by
(editor::get-parser 'defmethod), and after a little playing I now know
how to write my own parser.

This will be very useful.



Updated at: 2020-12-10 09:01 UTC