From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Propertize mode-line contents only for mode-line of selected window? Date: Sun, 01 Mar 2015 03:40:36 +0100 Message-ID: <87385pmod7.fsf@web.de> References: <87385q8g5v.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1425177674 9435 80.91.229.3 (1 Mar 2015 02:41:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 1 Mar 2015 02:41:14 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Mar 01 03:41:05 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YRtoV-00017X-6q for geh-help-gnu-emacs@m.gmane.org; Sun, 01 Mar 2015 03:41:03 +0100 Original-Received: from localhost ([::1]:43259 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRtoU-0003sV-J9 for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Feb 2015 21:41:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRtoJ-0003pg-A4 for help-gnu-emacs@gnu.org; Sat, 28 Feb 2015 21:40:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YRtoF-0007A2-RV for help-gnu-emacs@gnu.org; Sat, 28 Feb 2015 21:40:51 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:46450) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRtoF-00079p-Kk for help-gnu-emacs@gnu.org; Sat, 28 Feb 2015 21:40:47 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YRtoD-00012g-Fa for help-gnu-emacs@gnu.org; Sun, 01 Mar 2015 03:40:45 +0100 Original-Received: from dslb-094-217-114-065.094.217.pools.vodafone-ip.de ([94.217.114.65]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 01 Mar 2015 03:40:45 +0100 Original-Received: from michael_heerdegen by dslb-094-217-114-065.094.217.pools.vodafone-ip.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 01 Mar 2015 03:40:45 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 40 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dslb-094-217-114-065.094.217.pools.vodafone-ip.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:gQn69qhN0Cf1Vhha9HAxrpaK/hA= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:102960 Archived-At: Alexis writes: > i'd like to modify the value of `mode-line-format` such that one > specific part of it is propertized in a specific way only for the > mode-line of the currently selected window. Is there some way of > achieving this via ELisp? i've not been able to make any progress on > this with various permutations of `frame-selected-window`, > `window-buffer`, `current-buffer` etc. .... Yes, this will all not work. The reason is that when any mode-line in any window is refreshed, its window is internally temporarily selected. So you will need to remember the selected window in a variable, or something like that - here is an example: --8<---------------cut here---------------start------------->8--- (defvar my-selected-win nil) (defun my-set-selected-win () (setq my-selected-win (selected-window))) (add-hook 'post-command-hook #'my-set-selected-win) (defun my-ml-emphasize-selected-window () (and (eq (selected-window) my-selected-win) "!!!")) ;;; example (push '(:eval (my-ml-emphasize-selected-window)) (default-value 'mode-line-format)) --8<---------------cut here---------------end--------------->8--- Using `post-command-hook' seems a bit exaggerated, but `window-configuration-change-hook' is not triggered for `other-window' and the like, and advising `select-window' is also not an option because of its internal use to calculate mode-lines of all windows. Maybe it can be done better, dunno. Michael.