From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: bojohan+news@dd.chalmers.se (Johan =?utf-8?Q?Bockg=C3=A5rd?=) Newsgroups: gmane.emacs.help Subject: Re: How to highlight the current buffer's mode line ? Date: Fri, 07 Aug 2009 20:25:52 +0200 Message-ID: <874osj32hb.fsf@dd.chalmers.se> References: <346dd22e-114b-4a66-b9c4-33c8cffbb073@f37g2000yqn.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1249669611 30552 80.91.229.12 (7 Aug 2009 18:26:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Aug 2009 18:26:51 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 07 20:26:44 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 1MZU9K-0004Hp-Dt for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Aug 2009 20:26:42 +0200 Original-Received: from localhost ([127.0.0.1]:49346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MZU9J-0006Ty-FB for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Aug 2009 14:26:41 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MZU8u-0006Tl-Hf for help-gnu-emacs@gnu.org; Fri, 07 Aug 2009 14:26:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MZU8p-0006RM-Qg for help-gnu-emacs@gnu.org; Fri, 07 Aug 2009 14:26:15 -0400 Original-Received: from [199.232.76.173] (port=53723 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MZU8p-0006RJ-Jp for help-gnu-emacs@gnu.org; Fri, 07 Aug 2009 14:26:11 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:16730) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MZU8p-0004Kg-9G for help-gnu-emacs@gnu.org; Fri, 07 Aug 2009 14:26:11 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MZU8o-0007Vw-HW for help-gnu-emacs@gnu.org; Fri, 07 Aug 2009 14:26:10 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MZU8k-0001Ot-Ne for help-gnu-emacs@gnu.org; Fri, 07 Aug 2009 18:26:06 +0000 Original-Received: from c-a8cbe455.04-211-6c6b701.cust.bredbandsbolaget.se ([85.228.203.168]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Aug 2009 18:26:06 +0000 Original-Received: from bojohan+news by c-a8cbe455.04-211-6c6b701.cust.bredbandsbolaget.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Aug 2009 18:26:06 +0000 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 49 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-a8cbe455.04-211-6c6b701.cust.bredbandsbolaget.se Mail-Copies-To: never User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:5rkQLAAVL+vsis8S9Uu9LmWOSao= X-Detected-Operating-System: by mx20.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:66950 Archived-At: Francis Moreau writes: > On 6 août, 23:11, bojohan+n...@dd.chalmers.se (Johan Bockgård) wrote: >> Francis Moreau writes: >> > BTW, it looks like I can only change the face used by the entire mode >> > line. >> >> > Is it possible to change only the buffer name face only ? >> >> Not easily. > > yes I came to that conclusion too. > > And I think it does not worth the headache, customizing 'mode-line > face' is fine enough. FWIW, mode-line/mode-line-inactive can do its business by being implemented in C. The necessary info isn't readily available to Lisp (simply checking `selected-window' doesn't work since a window is always selected when its mode line is formatted; also, no hook is run when the selected window changes). For the record, here's what I came up with (this does not function perfectly): (defvar my-selected-windows nil) (add-hook 'post-command-hook (lambda () (setq my-selected-windows (cons (selected-window) (minibuffer-selected-window))) (force-mode-line-update))) (defun my-mode-line-buffer-identification () `(:propertize mode-line-buffer-identification face ,(if ;; This is what CURRENT_MODE_LINE_FACE_ID_3 does, more or less (or (eq (car my-selected-windows) (selected-window)) (and (> (minibuffer-depth) 0) (eq (selected-window) (cdr my-selected-windows)) (eq (car my-selected-windows) (minibuffer-window)))) 'highlight 'mode-line-inactive))) (setcar (member 'mode-line-buffer-identification mode-line-format) '(:eval (my-mode-line-buffer-identification)))