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: Nikolaj Schumacher
Subject: Re: Extra info in modeline (tip and questions)
Date: Wed, 15 Apr 2009 15:23:43 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (darwin)

Decebal <CLDWesterhof@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.

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)))))


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))))


regards,
Nikolaj Schumacher




reply via email to

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