aquamacs-emacs / aquamacs-emacs

Aquamacs Emacs
http://aquamacs.org
GNU General Public License v3.0
411 stars 39 forks source link

Custom Themes #127

Open 7stud opened 7 years ago

7stud commented 7 years ago

When I type M-x custom-themes, I am presented with a buffer listing about 15 custom themes that come with aquamacs. I checked the checkbox for the theme wombat, and then I clicked the Save Theme Settings button in the buffer. However, if I quit aquamacs and relaunch it, the text that was white in the wombat theme is now nearly the same color as the background, making the text unreadable. The color of the text is actually a few shades darker than the background, which creates a shadow effect: I can see where the white text was, but I can't read it anymore.

My fix is to type M-x custom-themes (I can't see "custom-themes" in the minibuffer because the font color is the same color as the background), and when the buffer with the custom themes opens I uncheck the wombat theme and recheck it (I can't see some of the text in the custom themes buffer either because it is the same color as the background).

Also, if I want to use a third party custom theme, where should I put the file? My aquamacs preferences file, Preferences.el, is in the directory:

`~/Library/Preferences/Aquamacs Emacs

Am I supposed to put third party custom themes somewhere in that directory as well? I notice that the 15 custom themes that are offered to me by default are located in the file:

/Applications/Aquamacs.app/Contents/Resources/lisp/aquamacs/color-theme-library.el
nega0 commented 7 years ago

i get this behavior too with both included themes (tango-dark) and third party themes (sanityinc-tomorrow). even stripping down to a minimal init.el (just (load-theme tango-dark)), you see this behavior.

@7stud to manage themes (and other elisp) by hand, i personally find it best to put things in ~/.emacs.d/lisp. then you add

(add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp"))

to the start of your Preferences.el. of course you can use whatever directory you want, just be sure to add it to your load-path.

davidswelt commented 7 years ago

Any ideas on what is causing this?

On Mar 31, 2017, at 6:28 PM, nega0 notifications@github.com wrote:

i get this behavior too with both included themes (tango-dark) and third party themes (sanityinc-tomorrow). even stripping down to a minimal init.el (just (load-theme tango-dark)), you see this behavior.

@7stud to manage themes (and other elisp) by hand, i personally find it best to put things in ~/.emacs.d/lisp. then you add

(add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp"))

to the start of your Preferences.el. of course you can use whatever directory you want, just be sure to add it to your load-path.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

nega0 commented 7 years ago

Well, if i do a minimal config:

~/.emacs.d/init.el:

(package-initialize)
(debug)
(load-theme 'tango-dark t)
(debug)

and:

$ cd ~/Library/Preferences/Aquamacs Emacs/
$ ln -s /dev/null Preferences.el
$ ls -s /dev/null customizations.el

Start Aquamacs with something that will get fontified:

$ aquamacs ~/source.c

We get an Aquamacs frame with the buffer of source.c fontified in the default emacs theme. (Black text on white background, red comments, purple strings, etc). C-x 5 b *Bac<tab><return> to open a frame at the *Backtrace* buffer that's debugging our init.el file. Hit c to load our theme, and drop to the debugger again. Now both frames are fontified, correctly, with our chosen theme (tango-dark). In the *Backtrace* frame, hit c again to finish and we eventually get a *scratch* buffer with text color set to black. (Also, the font has been set to Lucida Grande.)

Changing our init file to: ~/.emacs.d/init.el:

(add-hook 'after-init-hook 'debug)
(package-initialize)
(load-theme 'tango-dark t)

and starting the process over again, we get an Aquamacs frame fontified with our chosen theme, but the background is white. Switching to the debugger again and hitting c to continue, we get a *scratch* frame+buffer with our theme, the background is correct, but the default text is black. (And the font is Lucida Grande again.)

Lastly we change our init file to: ~/.emacs.d/init.el:

(debug)
(load-theme 'tango-dark t)
(debug)

and start Aquamacs with:

$ aquamacs --args --no-site-file ~/source.c

we get a split Aquamacs frame with source.c in the top window, and the startup screen in the bottom window, both correctly fontified with our chosen theme.

So if i'd have to guess, it's something that is getting setup in site-start.el (maybe aquamacs.el?), and getting called after the init file is loaded. (Maybe in after-init-hook?)

davidswelt commented 7 years ago

OK, the next step would be to narrow in what happens that overrides the font color. This code could be in many places, of course.

Not sure how helpful it is, but you can start it with “-Q”, which does not load most of the Aquamacs customizations (that distinguish it from Emacs). Then you can execute code manually, and call (aquamacs-setup) to complete the Aquamacs initialization.

Another thing might be to look for “Lucida” using grep. It’s probably best to get the whole Aquamacs git repository and do that from there rather than just in the Aquamacs.app bundle.

On Apr 3, 2017, at 11:54 PM, nega0 notifications@github.com wrote:

Well, if i do a minimal config:

~/.emacs.d/init.el:

(package-initialize) (debug) (load-theme 'tango-dark t ) (debug)

and:

$ cd ~/Library/Preferences/Aquamacs Emacs/ $ ln -s /dev/null Preferences.el $ ls -s /dev/null customizations.el

Start Aquamacs with something that will get fontified:

$ aquamacs ~/source.c

We get an Aquamacs frame with the buffer of source.c fontified in the default emacs theme. (Black text on white background, red comments, purple strings, etc). C-x 5 b Bac to open a frame at the Backtrace buffer that's debugging our init.el file. Hit c to load our theme, and drop to the debugger again. Now both frames are fontified, correctly, with our chosen theme (tango-dark). In the Backtrace frame, hit c again to finish and we eventually get a scratch* buffer with text color set to black. (Also, the font has been set to Lucida Grande.)

Changing our init file to: ~/.emacs.d/init.el:

(add-hook 'after-init-hook 'debug) (package-initialize) (load-theme 'tango-dark t) and starting the process over again, we get an Aquamacs frame fontified with our chosen theme, but the background is white. Switching to the debugger again and hitting c to continue, we get a scratch frame+buffer with our theme, the background is correct, but the default text is black. (And the font is Lucida Grande again.)

Lastly we change our init file to: ~/.emacs.d/init.el:

(debug) (load-theme 'tango-dark t ) (debug)

and start Aquamacs with:

$ aquamacs --args --no-site-file ~/source.c

we get a split Aquamacs frame with source.c in the top window, and the startup screen in the bottom window, both correctly fontified with our chosen theme.

So if i'd have to guess, it's something that is getting setup in site-start.el (maybe aquamacs.el?), and getting called after the init file is loaded. (Maybe in after-init-hook?)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

nega0 commented 7 years ago

I'd start scanning through aquamacs.el. There are direct references to "Lucida Grande" in there.

nega0 commented 7 years ago
$ /Applications/Aquamacs.app/Contents/MacOS/Aquamacs --debug-init -Q

M-: (load-theme 'tango-dark t) C-x 5 2, we get a frame themed correctly. M-: (load "site-start") C-x 5 2, we get a frame themed correctly, except the background is white, and the text is black. Any pointers?

davidswelt commented 7 years ago

If you load site-start, it’ll load and execute everything. Also, normally, the theme would come after site-start, so it’s not quite clear that this is what’s causing it. During startup, when is the theme applied, and what that comes after is causing the font color to be wrong?

On Apr 4, 2017, at 8:01 PM, nega0 notifications@github.com wrote:

$ /Applications/Aquamacs.app/Contents/MacOS/Aquamacs --debug-init -Q

M-: (load-theme 'tango-dark t) C-x 5 2, we get a frame themed correctly. M-: (load "site-start") C-x 5 2, we get a frame themed correctly, except the background is white, and the text is black. Any pointers?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

nega0 commented 7 years ago

If you load site-start, it’ll load and execute everything.

Well according to https://www.gnu.org/software/emacs/manual/html_node/elisp/Startup-Summary.html, no site-start doesn't do that, unless you've changed that behavior.

Also, normally, the theme would come after site-start, so it’s not quite clear that this is what’s causing it.

Correct, but as you can see from my previous comment, I did change the order, and something under site-start is violating theming.

During startup, when is the theme applied,

I think the 4 line init.el in my 2 second post in this issue makes that clear.

and what that comes after is causing the font color to be wrong?

This is what I'm trying to find out from you. If I knew, I'd have a patch for you. As the Aquamacs guy, I would assume that you would be much more familiar with the codebase and where it diverges from mainline Emacs (where this issue doesn't exist) than I would be, and be able to offer some insight, or at least an educated guess, on where to start looking. So, do you have any pointers or insight that would help narrow down the search?

davidswelt commented 7 years ago

All the lisp-level Aquamacs customizations are called from site-start. That is why -Q works the way it does as an argument to Aquamacs.

This means that what’s under site-start is providing defaults for colors, fonts, and so on. That is what you’re seeing.

The advice as to narrow things down is to look for color names or font names in the Aquamacs code base, specifically aquamacs.el and maybe what’s in macosx/.

You can also, after -Q, start executing code (regions of code) in order to narrow down where it’s happening.

I really don’t know what’s causing this, and if I had time right now, I would investigate it in the same way.

On Apr 4, 2017, at 11:21 PM, nega0 notifications@github.com wrote:

If you load site-start, it’ll load and execute everything.

Well according to https://www.gnu.org/software/emacs/manual/html_node/elisp/Startup-Summary.html, no site-start doesn't do that, unless you've changed that behavior.

Also, normally, the theme would come after site-start, so it’s not quite clear that this is what’s causing it.

Correct, but as you can see from my previous comment, I did change the order, and something under site-start is violating theming.

During startup, when is the theme applied,

I think the 4 line init.el in my 2 second post in this issue makes that clear.

and what that comes after is causing the font color to be wrong?

This is what I'm trying to find out from you. If I knew, I'd have a patch for you. As the Aquamacs guy, I would assume that you would be much more familiar with the codebase and where it diverges from mainline Emacs (where this issue doesn't exist) than I would be, and be able to offer some insight, or at least an educated guess, on where to start looking. So, do you have any pointers or insight that would help narrow down the search?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

nega0 commented 7 years ago

fixed:


❯ diff -u Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el\~ Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el
--- Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el~    2013-09-27 08:02:08.000000000 -0400
+++ Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el 2017-04-05 00:37:54.000000000 -0400
@@ -80,8 +80,9 @@
 ;; do not set any fonts here. aquamacs.el takes care of this,
 ;; checking that the fonts actually exist.
    (default-frame-alist 
-     ((foreground-color . "Black") (background-color . "White") 
-      (cursor-type . box) (cursor-color . "Red")   (vertical-scroll-bars . right)  
+     (;;(foreground-color . "Black") (background-color . "White") 
+      (cursor-type . box) ;;(cursor-color . "Red")
+      (vertical-scroll-bars . right)  
       (tool-bar-lines . 1 ) 
       (internal-border-width . 0)
       (left-fringe . 1) (right-fringe . nil) (fringe . nil)))
davidswelt commented 7 years ago

If you do that, what does the cursor look like when you start up Aquamacs without any settings? Is it red as before?

davidswelt commented 7 years ago

On Apr 5, 2017, at 1:11 AM, nega0 notifications@github.com wrote:

All the lisp-level Aquamacs customizations are called from site-start. That is why -Q works the way

Well, not quite the same as everything. Maybe you should add that to the troubleshooting FAQ.

Not frequently asked, but certainly important.

It would be good to have a guide for fellow developers.

/Applications/Aquamacs.app ❯ find ./Contents/Resources/lisp/aquamacs/macosx -type f -name *.el -o -name *.el.gz |xargs zgrep 'Black|White' |wc -l 2

I absolutely would have looked at that 2 item hit before the 410 and we could have knocked this PR out a couple of days ago.

Yes, hindsight. It was a guess on my part. The frame file you changed probably shouldn’t be under macosx, and this bug didn’t have much to do with Mac-specific setup anyway.

In any case, I don’t think we have the bug just yet.

nega0 commented 7 years ago

If you do that, what does the cursor look like when you start up Aquamacs without any settings? Is it red as before?

WIth open -a Aquamacs --args -q no, it's a black bar, not the black box I would expect (and what emacs -q provides).

(Note: I don't particularly care about cursor shape. Even w/o theming, I force it to (bar . 2).)

In any case, I don’t think we have the bug just yet.

Well, I now reproducibly get the expected behavior and custom-themes called from my init-file work as expected too.

davidswelt commented 7 years ago

On Apr 6, 2017, at 11:59 AM, nega0 notifications@github.com wrote:

Well, I now reproducibly get the expected behavior and custom-themes called from my init-file work as expected too.

OK, so that is another piece of information.

Now the next step is to figure out why the frame setting overrides the custom theme. My guess is that for some reason, the custom theme is loaded before the frame setting is applied. It should be the other way around: the defaults come first, and then the theme is applied. But why is this not happening?

nega0 commented 7 years ago

Now the next step is to figure out why the frame setting overrides the custom theme. My guess is that for some reason, the custom theme is loaded before the frame setting is applied. It should be the other way around: the defaults come first, and then the theme is applied. But why is this not happening?

Because you're using default-frame-alist.

This is an alist specifying default values of frame parameters for all Emacs frames—the first frame, and subsequent frames.

So, if you're intent is to, on startup, set the look of the initial (OS X) window of Aquamacs (if the user hasn't overridden it in their init-files), you should be using initial-frame-alist instead.

In fact, using

--- Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el.orig    2017-04-06 14:38:45.000000000 -0400
+++ Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el 2017-04-06 14:39:47.000000000 -0400
@@ -79,7 +79,7 @@
  '((create-frame-min-width 68)
 ;; do not set any fonts here. aquamacs.el takes care of this,
 ;; checking that the fonts actually exist.
-   (default-frame-alist 
+   (initial-frame-alist 
      ((foreground-color . "Black") (background-color . "White") 
       (cursor-type . box) (cursor-color . "Red")
       (vertical-scroll-bars . right)  

things work as expected.

But, I'm not sure why you're even bothering to do that in the first place. If we start Aquamacs with -Q you get the expected black-on-white-with-red-comments-initial-theme. If you look at the values of default-frame-alist and initial-frame-alist you'll see they're set to nil. If you look at the frame settings by eval'ing (print (frame-parameters (selected-frame))) you get:

((tool-bar-position . top) (parent-id) (explicit-name)
 (display . "YOUR.SPECIAL.HOST.NAME") (icon-name) (window-id . "1")
 (bottom-divider-width . 0) (right-divider-width . 0) (top . 23)
 (left . 0) (buried-buffer-list) (buffer-list #<buffer *scratch*>)
 (unsplittable) (minibuffer . #<window 4 on *Minibuf-0*>) (modeline . t)
 (width . 80) (height . 36) (name . "*scratch*") (environment)
 (visibility . t) (cursor-color . "black") (background-mode . light)
 (display-type . color) (window-system . ns) (fullscreen) (alpha)
 (scroll-bar-height . 0) (scroll-bar-width . 15) (cursor-type . box)
 (auto-lower) (auto-raise) (icon-type) (title) (buffer-predicate)
 (tool-bar-lines . 1) (menu-bar-lines . 1) (right-fringe . 8)
 (left-fringe . 8) (line-spacing) (background-color . "White")
 (foreground-color . "Black") (horizontal-scroll-bars)
 (vertical-scroll-bars . right) (internal-border-width . 2)
 (border-width . 0)
 (font . "-*-Monaco-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1")
 (fontsize . 0) (font-backend mac-ct))

These frame parameters are set somewhere in the Emacs C code. The ones you're setting in aquamacs-frame-setup.el are [x] (foreground-color . "Black") [x] (background-color . "White") [x] (cursor-type . box) [ ] (cursor-color . "Red") [x] (vertical-scroll-bars . right) [x] (tool-bar-lines . 1 ) [ ] (internal-border-width . 0) [ ] (left-fringe . 1)1 [x] (right-fringe . nil) 1 [ ] (fringe . nil) 2

1. *setting* `left-fringe` or `right-fringe` to *nil* is the same as setting it to the default value of '8' 2. I don't remember what setting `(fringe. nil)` does. I *think* it means to set the fringe to the default values, thus in this case overriding the left-fringe value of 1.

Thus, all but 2-4 settings are just redundant. Therefore I propose the following patches (in my particular order of preference).

Accept the inherited settings from Emacs' C

--- Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el.orig    2017-04-06 14:38:45.000000000 -0400
+++ Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el 2017-04-06 15:18:59.000000000 -0400
@@ -79,14 +79,6 @@
  '((create-frame-min-width 68)
 ;; do not set any fonts here. aquamacs.el takes care of this,
 ;; checking that the fonts actually exist.
-   (default-frame-alist 
-     ((foreground-color . "Black") (background-color . "White") 
-      (cursor-type . box) (cursor-color . "Red")
-      (vertical-scroll-bars . right)  
-      (tool-bar-lines . 1 ) 
-      (internal-border-width . 0)
-      (left-fringe . 1) (right-fringe . nil) (fringe . nil)))
-   
    (special-display-frame-alist
     ((unsplittable . nil)
      (width . 75)

Minimal changes to the frame

--- Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el.orig    2017-04-06 14:38:45.000000000 -0400
+++ Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el 2017-04-06 15:22:35.000000000 -0400
@@ -79,11 +79,8 @@
  '((create-frame-min-width 68)
 ;; do not set any fonts here. aquamacs.el takes care of this,
 ;; checking that the fonts actually exist.
-   (default-frame-alist 
-     ((foreground-color . "Black") (background-color . "White") 
-      (cursor-type . box) (cursor-color . "Red")
-      (vertical-scroll-bars . right)  
-      (tool-bar-lines . 1 ) 
+   (initial-frame-alist 
+     ((cursor-color . "Red")
       (internal-border-width . 0)
       (left-fringe . 1) (right-fringe . nil) (fringe . nil)))

Swap from default-frame-alist to initial-frame-alist

--- Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el.orig    2017-04-06 14:38:45.000000000 -0400
+++ Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el 2017-04-06 16:30:54.000000000 -0400
@@ -79,7 +79,7 @@
  '((create-frame-min-width 68)
 ;; do not set any fonts here. aquamacs.el takes care of this,
 ;; checking that the fonts actually exist.
-   (default-frame-alist 
+   (initial-frame-alist 
      ((foreground-color . "Black") (background-color . "White") 
       (cursor-type . box) (cursor-color . "Red")
       (vertical-scroll-bars . right)

Of course there's also the option to tell the user to always do:

(setq default-frame-alist nil)
(load-frame 'special-foo-theme t)

in their init files 😜 .

Something is still messing with fonts, but I'll file a new issue after I narrow that down.

davidswelt commented 7 years ago

OK, but the intent is to set the default appearance of all frames.

Now, my code pre-dates the newer Emacs “themes”, and I’m wondering whether it wouldn’t be much better to define a theme that can serve as default, or can be undone or overwritten by the user or by the themes package.

And you are right that there must be redundancies. This is because Emacs, 10 years ago (Aquamacs was born in 2005), didn’t make these choices on the Mac platform.

I haven’t really played with themes much, but I’m assuming that this the more modern way of doing things.

On Apr 6, 2017, at 3:34 PM, nega0 notifications@github.com wrote:

Now the next step is to figure out why the frame setting overrides the custom theme. My guess is that for some reason, the custom theme is loaded before the frame setting is applied. It should be the other way around: the defaults come first, and then the theme is applied. But why is this not happening?

Because you're using default-frame-alist.

This is an alist specifying default values of frame parameters for all Emacs frames—the first frame, and subsequent frames.

So, if you're intent is to, on startup, set the look of the initial (OS X) window of Aquamacs (if the user hasn't overridden it in their init-files), you should be using initial-frame-alist instead.

In fact, using

--- Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el.orig 2017-04-06 14:38:45.000000000 -0400 +++ Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el 2017-04-06 14:39:47.000000000 -0400 @@ -79,7 +79,7 @@

'((create-frame-min-width 68) ;; do not set any fonts here. aquamacs.el takes care of this, ;; checking that the fonts actually exist.

  • (default-frame-alist
  • (initial-frame-alist

    ((foreground-color . "Black") (background-color . "White") (cursor-type . box) (cursor-color . "Red") (vertical-scroll-bars . right)

things work as expected.

But, I'm not sure why you're even bothering to do that in the first place. If we start Aquamacs with -Q you get the expected black-on-white-with-red-comments-initial-theme. If you look at the values of default-frame-alist and initial-frame-alist you'll see they're set to nil. If you look at the frame settings by eval'ing (print (frame-parameters (selected-frame))) you get:

((tool-bar-position . top) (parent-id) (explicit-name) (display . "YOUR.SPECIAL.HOST.NAME") (icon-name) (window-id . "1" ) (bottom-divider-width . 0) (right-divider-width . 0) (top . 23 ) (left . 0) (buried-buffer-list) (buffer-list #<buffer scratch

) (unsplittable) (minibuffer .

<window 4 on Minibuf-0>) (modeline . t

) (width . 80) (height . 36) (name . "scratch" ) (environment) (visibility . t) (cursor-color . "black" ) (background-mode . light) (display-type . color) (window-system . ns) (fullscreen) (alpha) (scroll-bar-height . 0) (scroll-bar-width . 15 ) (cursor-type . box) (auto-lower) (auto-raise) (icon-type) (title) (buffer-predicate) (tool-bar-lines . 1) (menu-bar-lines . 1) (right-fringe . 8 ) (left-fringe . 8) (line-spacing) (background-color . "White" ) (foreground-color . "Black" ) (horizontal-scroll-bars) (vertical-scroll-bars . right) (internal-border-width . 2 ) (border-width . 0 ) (font . "--Monaco-normal-normal-normal--12---*-m-0-iso10646-1" ) (fontsize . 0) (font-backend mac-ct)) These frame parameters are set somewhere in the Emacs C code. The ones you're setting in aquamacs-frame-setup.el are

• (foreground-color . "Black") • (background-color . "White") • (cursor-type . box) • (cursor-color . "Red") • (vertical-scroll-bars . right) • (tool-bar-lines . 1 ) • (internal-border-width . 0) • (left-fringe . 1)1 • (right-fringe . nil) 1 • (fringe . nil) 2 • setting left-fringe or right-fringe to nil is the same as setting it to the default value of '8' • I don't remember what setting (fringe. nil) does. I think it means to set the fringe to the default values, thus in this case overriding the left-fringe value of 1. Thus, all but 2-4 settings are just redundant. Therefore I propose the following patches (in my particular order of preference).

Accept the inherited settings from Emacs' C

--- Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el.orig 2017-04-06 14:38:45.000000000 -0400 +++ Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el 2017-04-06 15:18:59.000000000 -0400 @@ -79,14 +79,6 @@

'((create-frame-min-width 68) ;; do not set any fonts here. aquamacs.el takes care of this, ;; checking that the fonts actually exist.

  • (default-frame-alist
  • ((foreground-color . "Black") (background-color . "White")
  • (cursor-type . box) (cursor-color . "Red")
  • (vertical-scroll-bars . right)
  • (tool-bar-lines . 1 )
  • (internal-border-width . 0)
  • (left-fringe . 1) (right-fringe . nil) (fringe . nil)))
  • (special-display-frame-alist ((unsplittable . nil) (width . 75)

Minimal changes to the frame

--- Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el.orig 2017-04-06 14:38:45.000000000 -0400 +++ Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el 2017-04-06 15:22:35.000000000 -0400 @@ -79,11 +79,8 @@

'((create-frame-min-width 68) ;; do not set any fonts here. aquamacs.el takes care of this, ;; checking that the fonts actually exist.

  • (default-frame-alist
  • ((foreground-color . "Black") (background-color . "White")
  • (cursor-type . box) (cursor-color . "Red")
  • (vertical-scroll-bars . right)
  • (tool-bar-lines . 1 )
  • (initial-frame-alist
  • ((cursor-color . "Red")

    (internal-border-width . 0) (left-fringe . 1) (right-fringe . nil) (fringe . nil)))

Swap from default-frame-alist to initial-frame-alist

--- Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el.orig 2017-04-06 14:38:45.000000000 -0400 +++ Contents/Resources/lisp/aquamacs/macosx/aquamacs-frame-setup.el 2017-04-06 15:22:35.000000000 -0400 @@ -79,11 +79,8 @@

'((create-frame-min-width 68) ;; do not set any fonts here. aquamacs.el takes care of this, ;; checking that the fonts actually exist.

  • (default-frame-alist
  • ((foreground-color . "Black") (background-color . "White")
  • (cursor-type . box) (cursor-color . "Red")
  • (vertical-scroll-bars . right)
  • (tool-bar-lines . 1 )
  • (initial-frame-alist
  • ((cursor-color . "Red")

    (internal-border-width . 0) (left-fringe . 1) (right-fringe . nil) (fringe . nil)))

Of course there's also the option to tell the user to always do:

(setq default-frame-alist nil ) (load-frame 'special-foo-theme t) in their init files 😜 .

Something is still messing with fonts, but I'll file a new issue after I narrow that down.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

nega0 commented 7 years ago

OK, but the intent is to set the default appearance of all frames.

I'm not sure you get it. These things all set the appearance of all frames. They cascade. But if a user wants to change how that looks, you are currently preventing that.

Don't mess with default-frame-alist/initial-frame-alist. Every time you create a new frame you'll have same "black-on-white-with-red-comments" "theme" every time you create a new frame. Every time. Until a user loads a theme. Then those settings will take over.

Use initial-frame-alist to set the colors of the first window that pops up when Aquamacs starts, and every time you create a frame/window after that it will have those settings. Every time. Until a users loads a theme. Then those settings will take over.

Use default-frame-alist to set the colors of the first window that pops up when Aquamacs starts, and every time you create a frame/window after that it will have those settings. Every time. But, and this is a big but, when a user loads a theme, those settings will take over, except for the foreground and background colors. Those will be the colors what are set in default-frame-alist. Every time.

This is Aquamacs now:

Add theme with dark background and pretty colors to init file. Restart Aquamacs "Theme kinda looks OK, but I have black text on my dark background." Reload theme. "Yay. now my theme looks like it's supposed to." Work. Work. Work. Create a new frame. (C-x 5 2 or C-x 5 f or whatever) "Oh look, there's half of my new theme except I have black text on a white background" Reload theme. "Yay. now my theme looks like it's supposed to." Work. Work. Work. Create a new frame. (C-x 5 2 or C-x 5 f or whatever) "Oh look, another new frame with black text on a white background. F' this" Drag Aquamacs to the trash. Download an emacs that "works".

This is how Aquamacs should be: Add theme with dark background and pretty colors to init file. Restart Aquamacs "This theme is sweet!" Work. Work. Work. Joy.

This guy gave up because themes don't work. At least @7stud here filed a bug report and beat me to it; and I was only going to do it because I'm tired of working around this problem myself. How many others are dropping because Aquamacs "doesn't work"?

I haven’t really played with themes much, but I’m assuming that this the more modern way of doing things.

❯ head /Applications/Aquamacs.app/Contents/Resources/lisp/aquamacs/color-theme.el
;;; color-theme.el --- install color themes

;; Copyright (C) 1999, 2000  Jonadab the Unsightly One <jonadab@bright.net>
;; Copyright (C) 2000, 2001, 2002, 2003  Alex Schroeder <alex@gnu.org>
;; Copyright (C) 2003, 2004, 2005, 2006  Xavier Maillard <zedek@gnu.org>

;; Version: 6.6.0b/Aquamacs
;; Keywords: faces
;; Author: Jonadab the Unsightly One <jonadab@bright.net>
;; Maintainer: Xavier Maillard <zedek@gnu.org>

Theming in general has been around for just a little bit, as you can see.

Look, I spent over and hour (and multiple hours total at this point) doing up the last post, explaining the docs, giving you multiple solutions. The least you could do is try these things out for yourself instead of flippantly tossing off a response via the email interface.

If you don't want to be bothered, just apply the last patch from my previous post. Like everything I've provided so far, it doesn't affect you, and it restores functionality that users expect.

This was the one single thing that has been a problem for me with Aquamacs, and now I've finally tracked it down and fixed it. But, given the exchange in this PR I'll definitely think twice about submitting another PR or a fix, even for anything as trivial as a typo.

davidswelt commented 7 years ago

So, thank you for spending time tracking down this bug. Clearly, there is progress. As a bit of background, I have had countless users and programmers find workarounds and propose them as fixed on the basis of "works for me", without looking at the implications. However, I'm keeping an open mind, because after 12 years of making and hacking Aquamacs, there is still much to learn. As you can see, I try to respect people regardless of whether I think they are right, or ignorant (like I must appear to you).

I understand your description of `initial-frame-alist', specifically, "These things all set the appearance of all frames. They cascade. ", and:

Use initial-frame-alist to set the colors of the first window that pops up when Aquamacs starts, and every time you create a frame/window after that it will have those settings. Every time. Until a users loads a theme. Then those settings will take over.

Now, oddly, this is not what the documentation of `initial-frame-alist' says: "Alist of parameters for the initial X window frame."

But, as per your request, I tried out your patch this morning. Having applied the patch, I compiled Aquamacs (make / make install), and started the resulting binary with "-q" (start without user customizations). In the screenshot below, you can see what the first frame looks like, and then the second frame, opened with Command-N. This is with your patch.

screen shot 2017-04-07 at 9 31 53 am

As for how long themes have existed, there is a bit of a name confusion. The "color themes" you refer to have been around for a long time, and that is correct. The "custom themes", on the other hand, were introduced in Emacs 22.1. Excerpt from the NEWS.22 file:

*** Custom themes are collections of customize options. Create a custom theme with M-x customize-create-theme. Use M-x load-theme to load and enable a theme, and M-x disable-theme to disable it. Use M-x enable-theme to enable a disabled theme.

Aquamacs does not use custom themes (much), because it essentially predates them. But I think it should. Also, one would think that color themes should use the all-encompassing custom themes, and indeed, there have been efforts to that effect.

So far for answers to your various assertions. Again, I apologize for questioning your work, but ultimately, we all want some scrutiny when it comes to making changes in software that will be used by many people. If I misunderstand something, or still "don't get it", as you might say, please tell me.

davidswelt commented 7 years ago

So, to summarize what we know right now:

custom theme settings (and that is not the old color-themes.el) are saved into custom-file, i.e., customizations.el:

'(custom-enabled-themes (quote (light-blue)))

This file is loaded after Aquamacs applies its settings. Aquamacs specifies a default frame appearance with the standard Emacs variable default-frame-alist'. This happens inaquamacs-osx-defaults-setup', within macosx / frame settings.

I'm thinking that `default-frame-alist' overrides custom themes, and I think that is what nega0 has found out through his/her experimentation.

To me, the solution would be to change the frame settings in Aquamacs to define a new custom theme and set that by default. Then users can add other custom themes, or remove the Aquamacs one. This would play nicely with other packages, going forward.

davidswelt commented 7 years ago

Update. I have committed code that moves the Aquamacs-specific settings for default-frame-alist and cursor-type into a theme called aquamacs-frame-look. We also warn users that themes are overridden by the custom file after .emacs is loaded, so Preferences.el should be used.

However, loading the tango-dark theme, I see that Emacs does not graciously handle multiple themes; mine sets default-frame-alist, while tango-dark manipulates fore/background colors via faces. We should probably switch to modifying the faces as a more up-to-date way of doing things.

It is unclear to me whether a face or manipulating the C-level defaults for frames and colors would be the more compatible solution, especially because users might want to set their own defaults in default-frame-alist and so on.