Re: Editor support for refactoring with macros?
- From: Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Dec 2006 01:41:42 +0100
"phr" <philrand@xxxxxxxxx> writes:
Pascal Bourguignon wrote:
The first idea would be:
M-x replace-regexp RET (purchk \(.*\) "QFC" \(.*\)) RET (qfc \1 \2) RET
but indeed, since the forms are not regular expressions, this cannot
work in most cases.>
So what I do is:
(replace-sexps "source.lisp"
(lambda (sexp)
(if (eq (car sexp) 'purchk)
`(qfc (second sexp) (third sexp) "QFC" (cdddr sexp))
sexp))
:deeply t :atoms nil)
http://darcs.informatimago.com/darcs/public/emacs/pjb-sources.el
http://darcs.informatimago.com/darcs/public/emacs/
Well actually, it should work ok on emacs lisp sources, but on Common
Lisp sources, there may be some problems relative to reader macros.
I've got some code in
http://darcs.informatimago.com/darcs/public/lisp/common-lisp/source.lisp
but it's incomplete (I've not implemented most of the standard reader
macros yet).
Cool code, Pascal.
It seems to me that it ought to be possible to generate your
transformer lambda expression directly from the defmacro form, though
now that I've looked at your code, I see that's the easy part.
Do experienced Lisp programmers use transformation tools like that a
lot, or are they simply better than me at spotting the need for a macro
early? I suspect the latter. Also they seem to be much better with
emacs than me.
I must confess that I don't use it a lot. I've used it twice or
thrice to do some such transforms, (or one of the variants to search
for specific forms). Perhaps the most often use I make of this code
is in insert-generics which scans the source for DEFMETHOD forms and
inserts corresponding DEFGENERIC forms.
But not for plain "refactoring": as soon as a pattern emerge (which
may be as soon as I type twice the same thing), I usually factor it
out immediately, be it in a function or a macro depending on the
cases.
--
__Pascal Bourguignon__ http://www.informatimago.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d? s++:++ a+ C+++ UL++++ P--- L+++ E+++ W++ N+++ o-- K- w---
O- M++ V PS PE++ Y++ PGP t+ 5+ X++ R !tv b+++ DI++++ D++
G e+++ h+ r-- z?
------END GEEK CODE BLOCK------
.
- References:
- Editor support for refactoring with macros?
- From: phr
- Re: Editor support for refactoring with macros?
- From: Pascal Bourguignon
- Re: Editor support for refactoring with macros?
- From: phr
- Editor support for refactoring with macros?
- Prev by Date: Re: Editor support for refactoring with macros?
- Next by Date: Re: which one of these with-gensym implementations is better?
- Previous by thread: Re: Editor support for refactoring with macros?
- Next by thread: Any different? '(1 2) (list 1 2)
- Index(es):
Relevant Pages
|
|