help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using the same custom file in two different OSes


From: Dani Moncayo
Subject: Re: Using the same custom file in two different OSes
Date: Wed, 16 Jan 2013 22:03:05 +0100

On Mon, Jan 14, 2013 at 11:05 PM, Drew Adams <drew.adams@oracle.com> wrote:
>> Mmmm I'm afraid I'm unable to keep my custom file free of my
>> platform-specific stuff. I've just seen this behavior:
>> 1. I remove the `default' and `variable-pitch' lines from my
>> custom file.
>> 2. I exit Emacs, start it again and verify that my custom file doesn't
>> have the lines I removed.  Note that this session has loaded my init
>> file, which first loads my custom file and then makes the
>> platform-specific customization (in that order).
>> 3. I do some customization (change the box-width property of the
>> `mode-line' face, for example), and save it (C-x C-s).
>> 4. I reopen my custom file and see that the two lines I removed in #1
>> have been reinserted.
>>
>> Changing the order (first do the platform-specific customization and
>> the load the custom file) doesn't help.  The custom file is
>> regenerated (when I save any customization) entirely, including the
>> `default' and `variable-pitch' faces.
>
> Right.
>
> It's because your init file changes the faces but does not save those changes 
> or
> cancel them.  Then, when you save changes with C-x C-s, that saves the faces 
> you
> changed.
>
> You want to either (a) do what you do now: redefine the faces after loading 
> your
> `custom-file' each time or (b) just tell Customize that the faces have _not_
> been changed (even though they have), before hitting C-x C-s.  That is, just
> tell Customize to ignore your changes.
>
> For that, you can just add those faces to option `customize-customized-ignore'
> (user preferences to ignore in `customize-customized').  For that you will 
> need
> to load library cus-edit+.el.
> http://www.emacswiki.org/emacs-en/download/cus-edit%2b.el
>
> If you do not want to do that, then you can use code like this in your init
> file, just after setting the faces the way you want:
>
> (face-spec-set THE-FACE (get THE-FACE 'face-defface-spec) 'reset)
>
> That should work.  This should also do the trick, as an alternative:
>
> (put THE-FACE 'saved-face nil)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

That did the trick.

So, now I'm able to keep my custom file free of platform-dependent
settings, which are moved to the init file, like this:

  ;; Set the custom-file
  (setq custom-file "whatever")
  ;; Load the platform-independent customization
  (load custom-file)
  ;; Set the platform-specific customization
  (if (display-graphic-p)
    (if (eq system-type 'windows-nt)
        (custom-set-faces <Stuff specific to MS-Windows>)
      (custom-set-faces <Stuff specific to Other OSes>)))
  ;; Reset de state of the faces customized above, so that they
  ;; don't get written to the custom-file when some customization
  ;; is saved.
  (put 'default 'saved-face nil)
  (put 'variable-pitch 'saved-face nil)


Thanks Drew!

-- 
Dani Moncayo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]