From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Re: |PATCH| describe-minor-mode and describe-minor-mode-from-indicator Date: Mon, 31 Mar 2003 12:14:56 -0500 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200303311714.h2VHEvUt017435@rum.cs.yale.edu> References: <20030330.165124.126582929.jet@gyve.org> <200303311551.h2VFp1xQ016968@rum.cs.yale.edu> <20030401.013509.115912667.jet@gyve.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1049131349 24356 80.91.224.249 (31 Mar 2003 17:22:29 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 31 Mar 2003 17:22:29 +0000 (UTC) Cc: monnier+gnu/emacs@rum.cs.yale.edu Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Mar 31 19:22:26 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1902zK-0006KX-00 for ; Mon, 31 Mar 2003 19:22:26 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 1902zW-0006qs-00 for ; Mon, 31 Mar 2003 19:22:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 1902xq-0006jF-06 for emacs-devel@quimby.gnus.org; Mon, 31 Mar 2003 12:20:54 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 1902vl-0005CV-00 for emacs-devel@gnu.org; Mon, 31 Mar 2003 12:18:45 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 1902uL-0003Kf-00 for emacs-devel@gnu.org; Mon, 31 Mar 2003 12:17:18 -0500 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.10.13) id 1902s6-00026e-00; Mon, 31 Mar 2003 12:14:58 -0500 Original-Received: from rum.cs.yale.edu (localhost [127.0.0.1]) by rum.cs.yale.edu (8.12.8/8.12.8) with ESMTP id h2VHEvPe017437; Mon, 31 Mar 2003 12:14:57 -0500 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.12.8/8.12.8/Submit) id h2VHEvUt017435; Mon, 31 Mar 2003 12:14:57 -0500 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: Masatake YAMATO Original-cc: rms@gnu.org Original-cc: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:12768 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:12768 > > > +(defun lookup-minor-mode-from-indicator (indicator) > > > + "Return a minor mode symbol from its indicator on the modeline." > > > + (if (and (< 0 (length indicator)) > > > + (not (string= " " (substring indicator 0 1)))) > > > + (setq indicator (concat " " indicator))) > > > > I'd rather not assume that indicators start with a space. > > What can I do? > > (defun lookup-minor-mode-from-indicator (indicator) > "Return a minor mode symbol from its indicator on the modeline." > (if (and (< 0 (length indicator)) > (not (eq (aref indicator 0) ?\ ))) > (setq indicator (concat " " indicator))) > (let ((minor-modes minor-mode-alist) > result) > (while minor-modes > (let* ((minor-mode (car (car minor-modes))) > (anindicator (car (cdr (car minor-modes))))) > (setq anindicator (format-mode-line anindicator)) > (if (and (stringp anindicator) > (string= anindicator indicator)) > > Should I use string-match instead of string= to compare indicator > and anindicator? > > (concat " " indicator) is wrong idea? How about (if (> (length anindicator) 0) (equal indicator (if (eq (aref anindicator 0) ?\ ) (substring anindicator 1) anindicator))) I.e. apply the exact same transformation to `anindicator' as you did to `indicator'. Stefan