From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.devel Subject: Re: CC Mode 5.31.3 Date: Sun, 26 Feb 2006 20:39:20 +0000 (GMT) Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sea.gmane.org 1140986118 23411 80.91.229.2 (26 Feb 2006 20:35:18 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 26 Feb 2006 20:35:18 +0000 (UTC) Cc: emacs-devel@gnu.org, bug-cc-mode@gnu.org, mast@lysator.liu.se Original-X-From: cc-mode-help-admin@lists.sourceforge.net Sun Feb 26 21:35:16 2006 Return-path: Envelope-to: sf-cc-mode-help@m.gmane.org Original-Received: from lists-outbound.sourceforge.net ([66.35.250.225]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FDSbf-0005Am-3h for sf-cc-mode-help@m.gmane.org; Sun, 26 Feb 2006 21:35:03 +0100 Original-Received: from sc8-sf-list1-b.sourceforge.net (sc8-sf-list1-b.sourceforge.net [10.3.1.7]) by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP id DB427128F2; Sun, 26 Feb 2006 12:35:01 -0800 (PST) Original-Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.92] helo=mail.sourceforge.net) by sc8-sf-list1.sourceforge.net with esmtp (Exim 4.30) id 1FDSb5-0001o8-Hz for cc-mode-help@lists.sourceforge.net; Sun, 26 Feb 2006 12:34:27 -0800 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by mail.sourceforge.net with esmtps (TLSv1:RC4-SHA:128) (Exim 4.44) id 1FDSb2-00081V-Sc for cc-mode-help@lists.sourceforge.net; Sun, 26 Feb 2006 12:34:27 -0800 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.34) id 1FDSb0-0005wm-A7 for bug-cc-mode@gnu.org; Sun, 26 Feb 2006 15:34:22 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.52) id 1FDSbb-0003k6-L1 for bug-cc-mode@gnu.org; Sun, 26 Feb 2006 15:35:02 -0500 Original-Received: from [193.149.49.134] (helo=acm.acm) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FDSba-0003jh-5N; Sun, 26 Feb 2006 15:34:59 -0500 Original-Received: from localhost (root@localhost) by acm.acm (8.8.8/8.8.8) with SMTP id UAA00828; Sun, 26 Feb 2006 20:39:22 GMT X-Sender: root@acm.acm Original-To: Richard Stallman In-Reply-To: X-Spam-Score: 1.0 (+) X-Spam-Report: Spam Filtering performed by sourceforge.net. See http://spamassassin.org/tag/ for more details. Report problems to http://sf.net/tracker/?func=add&group_id=1&atid=200001 1.0 FORGED_RCVD_HELO Received: contains a forged HELO Original-Sender: cc-mode-help-admin@lists.sourceforge.net Errors-To: cc-mode-help-admin@lists.sourceforge.net X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.0.9-sf.net Precedence: bulk List-Unsubscribe: , List-Id: Bug reports, feature requests, and general talk about CC Mode. List-Post: List-Help: List-Subscribe: , List-Archive: X-Original-Date: Sun, 26 Feb 2006 20:39:20 +0000 (GMT) Xref: news.gmane.org gmane.emacs.cc-mode.general:3094 gmane.emacs.devel:50989 Archived-At: Hi, Emacs! On Sun, 26 Feb 2006, Richard Stallman wrote: > The issues with the Mode Name, and minor mode flags in the mode line are > still unresolved. On typing M-x smerge-mode, C Mode's flags (the "/la" > of "C/la") now stay with the major mode, but this is done by setting > mode-name to "C/la", a stop-gap solution at best. >Anyway, can't you achieve what you want with a local >binding for mode-line-modes? Or mode-line-process? I've now got a solution, almost complete, to the CC Mode submode flags. It works in Emacs 2[012] and XEmacs 21.4.4. My new functions walk through mode-line-format, and insert c-submode-flags into whatever appropriate structure, just after mode-name, making a buffer-local copy of whatever. It still needs text properties (help-echo) applying to it. Anyhow, see what you think of the following: ######################################################################### (defvar c-submode-indicators "/la" "The dummy submode indicators for CC Mode") (or (fboundp 'caddr) (defun caddr (kons) (car (cdr (cdr kons))))) (defun c-locate-mode-name (ml-form) "In ML-FORM, a mode-line construct, locate the variable `mode-name'. Returns: \(i) (t . SYMBOL) if SYMBOL is the symbol within ml-form that directly contains mode-name. \(ii) The cons whose car is or generates mode-name. \(iii) t if ml-form is an atom which is mode-name, or an eval: form which generates it. \(iv) nil, if we don't find it." (let (rec-return (mode-name "Ceci n'est pas un nom de mode.")) (cond ((null ml-form) nil) ((stringp ml-form) (string= ml-form mode-name)) ((symbolp ml-form) (when (and (boundp ml-form) (setq rec-return (c-locate-mode-name (symbol-value ml-form)))) (cond ((eq rec-return t) t) ; the symbol is `mode-name'. ((consp rec-return) (if (eq (car rec-return) t) rec-return ; a recursively included symbol. `(t . ,ml-form)))))) ; `mode-name' is directly "in" this symbol. ((consp ml-form) (cond ((eq (car ml-form) ':eval) (if (string= mode-name (eval (cadr ml-form))) t)) ; maybe we should test for string inclusion?? ((symbolp (car ml-form)) (if (boundp (car ml-form)) (c-locate-mode-name (if (symbol-value (car ml-form)) (cadr ml-form) (caddr ml-form))))) (t (while (and ml-form (not (setq rec-return (c-locate-mode-name (car ml-form)))) (consp (cdr ml-form))) (setq ml-form (cdr ml-form))) (if (and ml-form (not rec-return)) ; dotted pair at end of list (XEmacs) (setq rec-return (c-locate-mode-name (cdr ml-form)))) (if (eq rec-return t) ml-form rec-return))))))) (defun c-copy-tree (kons) "Make a copy of the list structure, KONS, such that it is completely distinct from the original list. Don't use on circular lists!" (if (consp kons) (cons (c-copy-tree (car kons)) (c-copy-tree (cdr kons))) kons)) (defun c-splice-submode-indicators () (interactive) ; Remove this, eventually. FIXME!!! (let (target-cons new-link symb) ;; Identify the variable we need to make buffer-local and copy. (setq target-cons (c-locate-mode-name 'mode-line-format)) (unless (and (consp target-cons) (eq (car target-cons) t)) (error "c-locate-mode-name, seeking symbol, returned %s" target-cons)) (setq symb (cdr target-cons)) ;; Make a buffer local copy of this symbol's value. (make-local-variable symb) (set symb (c-copy-tree (symbol-value symb))) ;; Find the cons within this symbol which generates MODE-NAME. (setq target-cons (c-locate-mode-name (symbol-value symb))) (if (or (not (consp target-cons)) (eq (car target-cons) t)) (error "c-locate-mode-name, seeking cons, returned %s" target-cons)) ;; Splice c-submode-indicators into the list structure. (setcdr target-cons (cons 'c-submode-indicators (cdr target-cons))))) ######################################################################### -- Alan Mackenzie (Munich, Germany) ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642