From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nikolaj Schumacher Newsgroups: gmane.emacs.help Subject: Re: Extra info in modeline (tip and questions) Date: Wed, 15 Apr 2009 15:23:43 +0200 Message-ID: References: <533fdd2a-8d26-47ce-9413-1bd2300ee2d1@s20g2000yqh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1239802397 16975 80.91.229.12 (15 Apr 2009 13:33:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 15 Apr 2009 13:33:17 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Decebal Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Apr 15 15:34:37 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Lu5Fu-0001YZ-El for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Apr 2009 15:34:22 +0200 Original-Received: from localhost ([127.0.0.1]:42823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lu5EV-0001f9-QO for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Apr 2009 09:32:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lu55g-0007IS-7X for help-gnu-emacs@gnu.org; Wed, 15 Apr 2009 09:23:48 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lu55f-0007I1-NH for help-gnu-emacs@gnu.org; Wed, 15 Apr 2009 09:23:47 -0400 Original-Received: from [199.232.76.173] (port=52712 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lu55f-0007Hw-Ar for help-gnu-emacs@gnu.org; Wed, 15 Apr 2009 09:23:47 -0400 Original-Received: from dd18200.kasserver.com ([85.13.138.168]:36768) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lu55e-0008PG-VK for help-gnu-emacs@gnu.org; Wed, 15 Apr 2009 09:23:47 -0400 Original-Received: from thursday (g227018083.adsl.alicedsl.de [92.227.18.83]) by dd18200.kasserver.com (Postfix) with ESMTP id 837EA18027FCF; Wed, 15 Apr 2009 15:23:48 +0200 (CEST) In-Reply-To: (Decebal's message of "Wed, 15 Apr 2009 04:06:28 -0700 (PDT)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (darwin) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:63757 Archived-At: Decebal 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