all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* elisp errors
@ 2009-01-22 16:56 synhedionn
  2009-01-23  3:48 ` Barry Margolin
  0 siblings, 1 reply; 6+ messages in thread
From: synhedionn @ 2009-01-22 16:56 UTC (permalink / raw
  To: help-gnu-emacs

hi,
I try to evaluate, for doing indentation of poub.y(so C-mode):
(defun indentTabs()
 (interactive)
  (   save-excursion ; cf
http://www.cs.tut.fi/lintula/manual/elisp/emacs-lisp-intro-1.05/emacs-lisp-intro_13.html#SEC145
restores point to its original position
    (   message "coucou"   )
    (goto-char (point-min))
(let  ((cpt 100))    ;double parenthese obligee
    (while (> cpt 0)
      (
    ((c-indent-command));   widget-forward			;TAB
      ( move-beginning-of-line 0)
     (  next-line 1)

	(setq cpt   (1- cpt)) ;  (1- cpt))
; ( message "cpt=%d"( 3 )  );!! parentheses autour cpt
	   (   message "fin partielle"   )
	      )) )  ) )

I do C-x C-e at end of command
Then , in my poub.y : M-x indentTabs
But error: Invalid read syntax: expected lambda expression (((c-indent-
command));   widget-forward			;TAB	)
What does it mean(evaluate by own your correction suggestion, please)?




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: elisp errors
  2009-01-22 16:56 elisp errors synhedionn
@ 2009-01-23  3:48 ` Barry Margolin
  2009-01-23 20:27   ` synhedionn
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Barry Margolin @ 2009-01-23  3:48 UTC (permalink / raw
  To: help-gnu-emacs

In article 
<26488aad-8ff8-4dda-bda5-ce5036de3617@w39g2000prb.googlegroups.com>,
 synhedionn@gmail.com wrote:

> hi,
> I try to evaluate, for doing indentation of poub.y(so C-mode):
> (defun indentTabs()
>  (interactive)
>   (   save-excursion ; cf
> http://www.cs.tut.fi/lintula/manual/elisp/emacs-lisp-intro-1.05/emacs-lisp-int
> ro_13.html#SEC145
> restores point to its original position
>     (   message "coucou"   )
>     (goto-char (point-min))
> (let  ((cpt 100))    ;double parenthese obligee
>     (while (> cpt 0)
>       (
>     ((c-indent-command));   widget-forward			;TAB
>       ( move-beginning-of-line 0)
>      (  next-line 1)
> 
> 	(setq cpt   (1- cpt)) ;  (1- cpt))
> ; ( message "cpt=%d"( 3 )  );!! parentheses autour cpt
> 	   (   message "fin partielle"   )
> 	      )) )  ) )
> 
> I do C-x C-e at end of command
> Then , in my poub.y : M-x indentTabs
> But error: Invalid read syntax: expected lambda expression (((c-indent-
> command));   widget-forward			;TAB	)
> What does it mean(evaluate by own your correction suggestion, please)?

You have too many parentheses around the body of your while loop, and 
then another extra set around the call to c-indent-command.  It should 
be:

(while (> cpt 0)
  (c-indent-command)
  (move-beginning-of-line 0)
  (next-line 1)
  (setq cpt (1- cpt))
  (message "fin partielle"))

This can also be simplified as:

(dotimes (i 100)
  (c-indent-command)
  (move-beginning-of-line 0)
  (next-line 1)
  (message "fin partielle"))

Also, do you really want to write that message every time through the 
loop instead of at the very end?

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: elisp errors
  2009-01-23  3:48 ` Barry Margolin
@ 2009-01-23 20:27   ` synhedionn
  2009-01-24  4:19     ` Barry Margolin
  2009-02-01  2:52   ` Samuel Wales
       [not found]   ` <mailman.6394.1233456736.26697.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 6+ messages in thread
From: synhedionn @ 2009-01-23 20:27 UTC (permalink / raw
  To: help-gnu-emacs

On Jan 23, 4:48 am, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article
> <26488aad-8ff8-4dda-bda5-ce5036de3...@w39g2000prb.googlegroups.com>,
>
>
>
>  synhedi...@gmail.com wrote:
> > hi,
> > I try to evaluate, for doing indentation of poub.y(so C-mode):
> > (defun indentTabs()
> >  (interactive)
> >   (   save-excursion ; cf
> >http://www.cs.tut.fi/lintula/manual/elisp/emacs-lisp-intro-1.05/emacs...
> > ro_13.html#SEC145
> > restores point to its original position
> >     (   message "coucou"   )
> >     (goto-char (point-min))
> > (let  ((cpt 100))    ;double parenthese obligee
> >     (while (> cpt 0)
> >       (
> >     ((c-indent-command));   widget-forward                 ;TAB
> >       ( move-beginning-of-line 0)
> >      (  next-line 1)
>
> >    (setq cpt   (1- cpt)) ;  (1- cpt))
> > ; ( message "cpt=%d"( 3 )  );!! parentheses autour cpt
> >       (   message "fin partielle"   )
> >          )) )  ) )
>
> > I do C-x C-e at end of command
> > Then , in my poub.y : M-x indentTabs
> > But error: Invalid read syntax: expected lambda expression (((c-indent-
> > command));   widget-forward                        ;TAB    )
> > What does it mean(evaluate by own your correction suggestion, please)?
>
> You have too many parentheses around the body of your while loop, and
> then another extra set around the call to c-indent-command.  It should
> be:
>
> (while (> cpt 0)
>   (c-indent-command)
>   (move-beginning-of-line 0)
>   (next-line 1)
>   (setq cpt (1- cpt))
>   (message "fin partielle"))
>
> This can also be simplified as:
>
> (dotimes (i 100)
>   (c-indent-command)
>   (move-beginning-of-line 0)
>   (next-line 1)
>   (message "fin partielle"))
>
> Also, do you really want to write that message every time through the
> loop instead of at the very end?
>
> --
> Barry Margolin, bar...@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***

Yes , only 1 message is enough. Cool tourdotimes, I didn't know.
So accordingly to your advice:


(defun indentTabs()
 (interactive)
  (   save-excursion ; cf
http://www.cs.tut.fi/lintula/manual/elisp/emacs-lisp-intro-1.05/emacs-lisp-intro_13.html#SEC145
restores point to its original position
    (   message "coucou"   )
    (goto-char (point-min))
(dotimes (i 100)
  (c-indent-command)
  (move-beginning-of-line 0)
  (next-line 1)
  )(message "fin partielle") ))

But debbuger displays still an error on c-indent-command:
Debugger entered--Lisp error: (void-function c-indent-command)
  (c-indent-command)
  (while (< i --dotimes-limit--) (c-indent-command) (move-beginning-of-
line 0) (next-line 1) (message "fin partielle") (setq i (1+ i)))
  (let ((--dotimes-limit-- 100) (i 0)) (while (< i --dotimes-limit--)
(c-indent-command) (move-beginning-of-line 0) (next-line 1) (message
"fin partielle") (setq i ...)))
  (dotimes (i 100) (c-indent-command) (move-beginning-of-line 0) (next-
line 1) (message "fin partielle"))
  eval((dotimes (i 100) (c-indent-command) (move-beginning-of-line 0)
(next-line 1) (message "fin partielle")))
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp)
:
What is false with this command?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: elisp errors
  2009-01-23 20:27   ` synhedionn
@ 2009-01-24  4:19     ` Barry Margolin
  0 siblings, 0 replies; 6+ messages in thread
From: Barry Margolin @ 2009-01-24  4:19 UTC (permalink / raw
  To: help-gnu-emacs

In article 
<67a737d1-49d1-4e2e-8475-bf8109ea1f8f@r10g2000prf.googlegroups.com>,
 synhedionn@gmail.com wrote:

> Yes , only 1 message is enough. Cool tourdotimes, I didn't know.
> So accordingly to your advice:
> 
> 
> (defun indentTabs()
>  (interactive)
>   (   save-excursion ; cf
> http://www.cs.tut.fi/lintula/manual/elisp/emacs-lisp-intro-1.05/emacs-lisp-int
> ro_13.html#SEC145
> restores point to its original position
>     (   message "coucou"   )
>     (goto-char (point-min))
> (dotimes (i 100)
>   (c-indent-command)
>   (move-beginning-of-line 0)
>   (next-line 1)
>   )(message "fin partielle") ))
> 
> But debbuger displays still an error on c-indent-command:
> Debugger entered--Lisp error: (void-function c-indent-command)
>   (c-indent-command)
>   (while (< i --dotimes-limit--) (c-indent-command) (move-beginning-of-
> line 0) (next-line 1) (message "fin partielle") (setq i (1+ i)))
>   (let ((--dotimes-limit-- 100) (i 0)) (while (< i --dotimes-limit--)
> (c-indent-command) (move-beginning-of-line 0) (next-line 1) (message
> "fin partielle") (setq i ...)))
>   (dotimes (i 100) (c-indent-command) (move-beginning-of-line 0) (next-
> line 1) (message "fin partielle"))
>   eval((dotimes (i 100) (c-indent-command) (move-beginning-of-line 0)
> (next-line 1) (message "fin partielle")))
>   eval-last-sexp-1(nil)
>   eval-last-sexp(nil)
>   call-interactively(eval-last-sexp)
> :
> What is false with this command?

Maybe you haven't loaded cc-mode yet, so the command isn't defined.  Put:

(require 'cc-mode)

before it.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: elisp errors
  2009-01-23  3:48 ` Barry Margolin
  2009-01-23 20:27   ` synhedionn
@ 2009-02-01  2:52   ` Samuel Wales
       [not found]   ` <mailman.6394.1233456736.26697.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 6+ messages in thread
From: Samuel Wales @ 2009-02-01  2:52 UTC (permalink / raw
  To: help-gnu-emacs

On Thu, Jan 22, 2009 at 20:48, Barry Margolin <barmar@alum.mit.edu> wrote:
> (dotimes (i 100)
>  (c-indent-command)
>  (move-beginning-of-line 0)
>  (next-line 1)
>  (message "fin partielle"))

Question: is this the usual approach?  Seems a little strange to bind
i when it's not used, especially since emacs lisp uses dynamic extent
by default.

A minor note: this might require 'cl, (an excellent package).

(For those who don't know, Barry is a very experienced Common Lisper.)

-- 
For personal and corporate gain, myalgic encephalomyelitis denialists
are knowingly causing massive suffering and 25-years-early death by
grossly corrupting science.
http://www.meactionuk.org.uk/What_Is_ME_What_Is_CFS.htm




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: elisp errors
       [not found]   ` <mailman.6394.1233456736.26697.help-gnu-emacs@gnu.org>
@ 2009-02-01  2:58     ` Barry Margolin
  0 siblings, 0 replies; 6+ messages in thread
From: Barry Margolin @ 2009-02-01  2:58 UTC (permalink / raw
  To: help-gnu-emacs

In article <mailman.6394.1233456736.26697.help-gnu-emacs@gnu.org>,
 Samuel Wales <samologist@gmail.com> wrote:

> On Thu, Jan 22, 2009 at 20:48, Barry Margolin <barmar@alum.mit.edu> wrote:
> > (dotimes (i 100)
> >  (c-indent-command)
> >  (move-beginning-of-line 0)
> >  (next-line 1)
> >  (message "fin partielle"))
> 
> Question: is this the usual approach?  Seems a little strange to bind
> i when it's not used, especially since emacs lisp uses dynamic extent
> by default.
> 
> A minor note: this might require 'cl, (an excellent package).
> 
> (For those who don't know, Barry is a very experienced Common Lisper.)

AFAIK, there's no variant of DOTIMES that doesn't require you to provide 
a variable to hold the counter.  And even if there were, it would simply 
have to have a hidden variable of its own, although it could use a 
gensym to avoid potential variable shadowing problems.

But there's virtually no chance that there's a global variable named i 
that you'll shadow with this.  Just don't do something like:

(dotimes (goal-column 100)
  ...)

and you should be OK.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-02-01  2:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-22 16:56 elisp errors synhedionn
2009-01-23  3:48 ` Barry Margolin
2009-01-23 20:27   ` synhedionn
2009-01-24  4:19     ` Barry Margolin
2009-02-01  2:52   ` Samuel Wales
     [not found]   ` <mailman.6394.1233456736.26697.help-gnu-emacs@gnu.org>
2009-02-01  2:58     ` Barry Margolin

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.