help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extra info in modeline (tip and questions)


From: Decebal
Subject: Re: Extra info in modeline (tip and questions)
Date: Wed, 15 Apr 2009 09:13:02 -0700 (PDT)
User-agent: G2/1.0

On 15 apr, 15:23, Nikolaj Schumacher <m...@nschum.de> wrote:
> Decebal <CLDWester...@gmail.com> wrote:
> > I understand that this is the default way to handle a break out of a
> > loop, but I found it ugly, and I expect it is also expensive.
>
> Ugly yes, but not that expensive.  Depending on the list length testing
> the additional not-ready variable can even be slower.

Well, in principal I find neatness off code more important as
performance, so only when the not-ready variable has a to big
performance hit, I would use the catch again.


> If you use CL macros, something can be done about the ugliness, though.
> It could be written like this
>
> (defun get-mode-line-struct (type)
>   (dotimes (i (length mode-line-array))
>     (when (equal type (mode-line-struct-type (aref mode-line-array i)))
>       (return (aref mode-line-array i)))))

I use cl because of the defstruct, so I could use your code, and that
is even more neat and concise.


> You're using a vector, probably because you're used to it.  Since you're
> not doing random-access, a list would be more "natural" in lisp.
>
> (defun get-mode-line-struct (type)
>   (dolist (s mode-line-array)
>     (when (equal type (mode-line-struct-type s))
>       (return s))))

I understood that vectors are much more efficient as lists. That is
why I used them. But your solution with a list is more beautifull, so
I should rewrite for using a list. (Only change mode-line-array to
mode-line-list.)

Thanks for the input. Very usefull.
By the way: anybody found my functionality usefull?


reply via email to

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