Hi
I've a problem with emacs lisp:
I write code of a very unknown language ('geoscript') what looks
like this:
e[1] = P1; point; dragable; 5.0,6.0;
e[2] = P2; point; dragable; 11.0,1.0;
e[3] = s1; line; connect; P1,P2;
know I need a function which checks the numeration e[...] and corrects
mistakes if necessary.
Do you know how I can do that ?
I'm very new to lisp and emacs and I tried this here (it only would
only work if in
every line is 'e[nu]'):
(defun g-end ()
(interactive "")
(goto-char 0)
(replace-regexp "^e\\[nu\\]" "e[this here should be replaced]")
; here should be 'for..'
(let ((num 1))
(goto-char 0)
; in the next line is my problem
(replace-regexp "this here should be replaced" num)
)
(goto-char 0)
)
how can I replace "this here..." with the content of num, so with 1 in
this case ??
I'm not able to solve these problems.
Can you help me, please ?
thanks..
Marcel
·········@gmx.de (Marcel Schmittfull) writes:
> Hi
> I've a problem with emacs lisp:
> ...
(let ((count 0))
(while (re-search-forward "^e\\[[0-9]+" nil t)
(replace-match (format "e[%d" (incf count)) nil nil)))
This bit should do the replacing for you. You might want to search google for
emacs-lisp tutorial (there is of course also an emacs-lisp manual which you
can download as an info file or lookup on the web).
alex
>
> I write code of a very unknown language ('geoscript') what looks
> like this:
>
> e[1] = P1; point; dragable; 5.0,6.0;
> e[2] = P2; point; dragable; 11.0,1.0;
> e[3] = s1; line; connect; P1,P2;
>
> know I need a function which checks the numeration e[...] and corrects
> mistakes if necessary.
> Do you know how I can do that ?
>
>
> I'm very new to lisp and emacs and I tried this here (it only would
> only work if in
> every line is 'e[nu]'):
>
> (defun g-end ()
> (interactive "")
> (goto-char 0)
> (replace-regexp "^e\\[nu\\]" "e[this here should be replaced]")
>
> ; here should be 'for..'
> (let ((num 1))
> (goto-char 0)
>
> ; in the next line is my problem
> (replace-regexp "this here should be replaced" num)
> )
> (goto-char 0)
> )
>
> how can I replace "this here..." with the content of num, so with 1 in
> this case ??
>
>
> I'm not able to solve these problems.
> Can you help me, please ?
>
> thanks..
> Marcel
>
>
·········@gmx.de (Marcel Schmittfull) writes:
> On 26 May 2002 21:20:45 +0100, Alexander Schmolck <··········@gmx.net>
> wrote:
>
> >(let ((count 0))
> > (while (re-search-forward "^e\\[[0-9]+" nil t)
> > (replace-match (format "e[%d" (incf count)) nil nil)))
> >
> >This bit should do the replacing for you.
>
> it doesn't do it, I'm sorry.
> I only get this error:
>
> Debugger entered--Lisp error: (void-function incf)
> (incf count)
The `incf' function lives in the cl package (Common Lisp emulation for
Emacs Lisp), so you'll need to say `(require 'cl)' before using it.
--
Evgeny
PSM: Print and SMear