all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Nicolas P. Rougier (inria)" <nicolas.rougier@inria.fr>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Philip Kaludercic <philipk@posteo.net>,
	Stefan Kangas <stefan@marxist.se>,
	emacs-devel@gnu.org
Subject: Re: ELPA: New package: nano-theme
Date: Thu, 30 Sep 2021 09:21:37 +0200	[thread overview]
Message-ID: <m1pmsqplri.fsf@wu-ext-00946.univ-lyon1.fr> (raw)
In-Reply-To: <jwvmtnvvav9.fsf-monnier+emacs@gnu.org>


I think it is possible by first setting the frame-background-mode 
(to 'dark or 'light in my case), then create a new frame and call 
frame-set-background-mode on the newly created frame. It seems to 
work consistently on my system but maybe this is a side 
effect. Here is the code:

#+BEGIN_SRC elisp
(defun nano-new-frame (&optional mode)
  (interactive)
  (let ((mode (or mode (frame-parameter nil 'background-mode)))
        (background-mode frame-background-mode)
        (selected-frame (selected-frame))
        (new-frame nil))

    ;; Set mode
    (setq frame-background-mode mode)
    (setq new-frame (make-frame-command))
    (select-frame new-frame)

    ;; This forces recomputation of faces on the new frame
    (frame-set-background-mode (selected-frame))
           
    (when (eq mode 'light)
      (set-foreground-color nano-light-foreground)
      (set-background-color nano-light-background))

    (when (eq mode 'dark)
      (set-foreground-color nano-dark-foreground)
      (set-background-color nano-dark-background))

    ;; Restore background mode
    (setq frame-background-mode background-mode)
    (frame-set-background-mode selected-frame)
    
    new-frame))
#+END_SRC

Nicolas

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I search for how to apply a theme to a single frame but did not 
>> find any
>> obvious way.
>
> Custom themes are sets of user settings (i.e. affecting 
> typically
> variables and faces), so they're naturally global.
>
> So you can't have that "single frame" effect directly by 
> specifying face
> settings in the theme.
>
> What you can do instead is:
> - You can have a custom theme set a particular minor mode 
> (provided as
>   part of the theme, for example) and arrange for that minor 
>   mode to
>   affect faces in a single frame.
> - You can use the DISPLAY spec of face settings to restrict your 
> face
>   settings to specific classes of frames.  The DISPLAY specs 
>   could be
>   extended to be more flexible if needed (file a bug report for 
>   that).
>
>
>         Stefan




  reply	other threads:[~2021-09-30  7:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 13:11 ELPA: New package: nano-theme Nicolas P. Rougier (inria)
2021-09-28 17:47 ` Philip Kaludercic
2021-09-28 17:57   ` Nicolas P. Rougier (inria)
2021-09-28 18:32     ` Stefan Kangas
2021-09-28 18:48       ` Stefan Monnier
2021-09-29 15:20         ` Stefan Kangas
2021-09-29 16:39           ` Stefan Monnier
2021-09-29  5:13       ` Nicolas P. Rougier (inria)
2021-09-29 12:18         ` Stefan Monnier
2021-09-30  7:21           ` Nicolas P. Rougier (inria) [this message]
2021-09-28 18:37     ` Philip Kaludercic
2021-09-29  5:07       ` Nicolas P. Rougier (inria)
2021-09-29  6:24         ` Philip Kaludercic
2021-10-01  9:59   ` Philip Kaludercic
2021-10-01 10:05     ` Nicolas P. Rougier (inria)
2021-10-01 10:15       ` Philip Kaludercic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1pmsqplri.fsf@wu-ext-00946.univ-lyon1.fr \
    --to=nicolas.rougier@inria.fr \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=philipk@posteo.net \
    --cc=stefan@marxist.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.