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: god-mode color Date: Fri, 29 Aug 2014 00:03:38 +0200 Message-ID: <878um846h1.fsf@web.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1409263475 11488 80.91.229.3 (28 Aug 2014 22:04:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Aug 2014 22:04:35 +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 29 00:04:28 2014 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 1XN7nw-0002IM-2x for geh-help-gnu-emacs@m.gmane.org; Fri, 29 Aug 2014 00:04:28 +0200 Original-Received: from localhost ([::1]:39143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN7nv-0005sx-Mt for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Aug 2014 18:04:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN7nc-0005ib-DE for help-gnu-emacs@gnu.org; Thu, 28 Aug 2014 18:04:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XN7nT-00039A-5J for help-gnu-emacs@gnu.org; Thu, 28 Aug 2014 18:04:08 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:47530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN7nS-000393-VW for help-gnu-emacs@gnu.org; Thu, 28 Aug 2014 18:03:59 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XN7nR-0001pa-F7 for help-gnu-emacs@gnu.org; Fri, 29 Aug 2014 00:03:57 +0200 Original-Received: from ip-90-187-5-104.web.vodafone.de ([90.187.5.104]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 29 Aug 2014 00:03:57 +0200 Original-Received: from michael_heerdegen by ip-90-187-5-104.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 29 Aug 2014 00:03:57 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 49 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-90-187-5-104.web.vodafone.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (gnu/linux) Cancel-Lock: sha1:Zh4yNkdgjqXcCoopXUJrWpHNoBo= 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:99487 Archived-At: BP writes: > I'm trying to make some cosmetic changes of my emacs depending on > god-mode state. For now I have this : > > (defun my-update-color () > (setq cursor-type (if (or god-local-mode buffer-read-only) > 'box > 'bar)) > (set-cursor-color (if (or god-local-mode buffer-read-only) > "firebrick1" > "LawnGreen")) > (set-face-background 'mode-line (if (or god-local-mode > buffer-read-only) > "red4" > "DarkCyan"))) > > (add-hook 'god-mode-enabled-hook 'my-update-color) > (add-hook 'god-mode-disabled-hook 'my-update-color) > > However my-update-color is not called when I switch to another buffer > and the appearance of emacs remains unchanged whatever the state of > god-mode in the new buffer. Let's first ignore `buffer-read-only' and concentrate on the appearance depending on god-local-mode. You miss something very important: setting `cursor-type' is a buffer local thing (good). `set-cursor-color' sets the cursor color of a frame (not so good). `set-face-background' again has a global effect (not good at all), unless you use the optional argument, which makes per frame. When you would use only per buffer settings, you would not need to do anything when switching buffers. The cursor-type thing already works. Of course it only has an effect in any buffer where the god-mode hooks were actually called. Use `setq-default' to set a default for all other buffers. For cursor color and mode-line, face remapping would probably be the better approach. This is a per-buffer feature. The buffer-read-only dependent appearance is harder. I guess you would also want to switch appearance when you toggle the read only state of a buffer? `buffer-read-only' is just a plain variable, so, there is no easy way to run code automatically when it is toggled. Michael.