17

I'm on GNU Emacs in OSX Mavericks and I'm trying to make my background transparent but not the text.

There's an easy way to make the whole frame transparent:

(set-frame-parameter (selected-frame) 'alpha '(85 85))
(add-to-list 'default-frame-alist '(alpha 85 85))

But this makes the whole frame transparent/translucent, including the text. I want only the frame background to be transparent and the text to be a solid black. Someone on the Emacs Wiki said that such an implementation would have to be OS-specific. So, does anyone know how to do this for OSX?

With desired settings, Emacs would look like this:
truly transparent Emacs window.

Again, I want the window 100% transparent and the foreground text 100% opaque, and it should work in Emacs' full-screen mode.

incandescentman
  • 6,168
  • 3
  • 46
  • 86
  • 1
    An alternative is if you're willing using emacs from the Terminal, you can create a new shell profile under preferences and set opacity to '0' and blur to '0'. – lubert Mar 03 '14 at 03:30

1 Answers1

12

The following are a few screen-shots and the different .emacs settings that were used. I'm using Emacs Trunk built --with-ns on February 16, 2014, and the operating system is OSX Snow Leopard 10.6.8.


SETTING # 1:

(set-frame-parameter (selected-frame) 'alpha '(85 85))

(add-to-list 'default-frame-alist '(alpha 85 85))

(set-face-attribute 'default nil :background "black"
  :foreground "white" :font "Courier" :height 180)

Example


SETTING # 2:

(set-frame-parameter (selected-frame) 'alpha '(85 85))

(add-to-list 'default-frame-alist '(alpha 85 85))

(set-face-attribute 'default nil :background "white"
  :foreground "black" :font "Courier" :height 180)

Example


SETTING # 3:

(set-frame-parameter (selected-frame) 'alpha '(75 75))

(add-to-list 'default-frame-alist '(alpha 75 75))

(set-face-attribute 'default nil :background "white"
    :foreground "black" :font "Courier" :height 180)

Example


SETTING # 4:

(set-frame-parameter (selected-frame) 'alpha '(0 0))

(add-to-list 'default-frame-alist '(alpha 0 0))

(set-face-attribute 'default nil :background "white"
    :foreground "black" :font "Courier" :height 180)

Example


EDIT (February 24, 2014):  The following is a link to a related thread where the lead developer of Aquamacs (i.e., David Reitter) has suggested modifying nsterm.m as a potential solution: http://comments.gmane.org/gmane.emacs.aquamacs.devel/836 -- "At a minimum, the changes would be to ns_clear_frame and ns_clear_frame_area. Instead of filling the background with the background color, you could try * setting the alpha component of the NSColor object so that it is transparent * copying in the actual background of the window. So, then you’d have the frame background transparent. That doesn’t take care of the frame UI elements, . . ." [In other words, the potential solution would likely entail modifying the source code prior to building a custom version of Emacs.]

lawlist
  • 13,099
  • 3
  • 49
  • 158
  • Hmm, I'm on Aquamacs and it's not working for me. If I do simply `(set-face-attribute 'default nil :background "black" :foreground "white" :font "Courier" :height 180)` then my text is white but my background is opaque black. If I do `(set-frame-parameter (selected-frame) 'alpha '(0 0)) (add-to-list 'default-frame-alist '(alpha 0 0)) (set-face-attribute 'default nil :background "black" :foreground "white" :font "Courier" :height 180)` then my text is illegible. – incandescentman Feb 22 '14 at 06:04
  • 1
    Aquamacs has a million things that have been customized by the developer(s) beyond that of the vanilla build. I'm sure you can track down the setting that is causing your issues, but it may be time consuming. My advice would be to forget about Aquamacs and use http://emacsformacosx.com/ and eventually you can build your own. I initially gravitated to Aquamacs because of the native OSX spell check and the right-click context menu. In the end, I opted for Aspell and a vanilla Emacs build and I created my own right-click context menu. – lawlist Feb 22 '14 at 06:15
  • Hmm, I tried it using GNU Emacs that I downloaded from [here](http://emacsformacosx.com/) and had the same problem--opaque black. – incandescentman Feb 22 '14 at 06:49
  • 1
    If you use a `.emacs` file containing only the two lines of code in your question and the code in my answer, then it works with a current version of Emacs trunk built `--with-ns` on OSX Snow Leopard 10.6.8. So my best guess is that you have something else in your configuration files that is conflicting. Try it with just the code in your question and my answer (with nothing else in the init file) and see if it works. – lawlist Feb 22 '14 at 07:11
  • I'm afraid not. Maybe it has to do with Mavericks. – incandescentman Feb 22 '14 at 09:06
  • On your advice I've switched to emacsformacosx.com. Do you think it would help if I build `--with-ns`? Does that still offer a full-screen mode? – incandescentman Feb 24 '14 at 02:04
  • 1
    The builds from that website are made with the ns option, so you just need to decide upon the last stable release or a developer build with a sneak preview of what is to come. The latest developer snapshot build will have many good bug fixes, but may have new issues not yet known. The latest build of Emacs Trunk does have full-screen. – lawlist Feb 24 '14 at 02:20
  • which is the "latest stable release"? I see "pretests," "nightlies," and ones at the top that aren't under either category. – incandescentman Feb 24 '14 at 03:14
  • Or just tell me which exact one you're using and I'll try that one. – incandescentman Feb 24 '14 at 03:25
  • OK, I tried it with several different versions, including the latest nightly, Emacs-2014-02-23_01-34-10-116535-universal-10.6.8.dmg. Same result. I guess the different must be Snow Leopard vs. Mavericks? I'd still love to figure out a way to do this. Would it help to put a bounty on the question? – incandescentman Feb 24 '14 at 03:31
  • I've numbered the settings 1 to 4 (with corresponding screen-shots). Are you able to duplicate those four (4) settings, and if so, is any of those settings similar to what you are seeking? – lawlist Feb 24 '14 at 04:57
  • I think we've had a miscommunication. I am able to replicate your settings. But in your #4, if I'm not mistaken, the background isn't fully transparent---you can still see a dim film of white, correct? More importantly, in your #4, the text is so faded that it's almost illegible. What I want is opaque black marker on a clear floor-to-ceiling window. I can achieve this with iTerm but not, so far, with GNU Emacs. With desired settings, Emacs would look like this: [http://i.imgur.com/V2Ugpc5.png](http://i.imgur.com/V2Ugpc5.png). – incandescentman Feb 24 '14 at 07:06
  • 2
    Your picture certainly does help me understand what you are seeking -- thank you. – lawlist Feb 24 '14 at 07:22
  • re modifying Aquamacs source code. I am open to this. Do you know how to follow the instructions provided? – incandescentman Feb 25 '14 at 12:04
  • 1
    Emacs and Aquamacs both use `nsterm.m`, so the proposed modification could be to either version. However, the code is written in "C" and is thus far beyond my present level of minimal coding knowledge. If you download the source code for either Emacs or Aquamacs and take a peek inside `nsterm.m`, you'll see what I mean. Aquamacs makes some additional custom changes to `nsterm.m` (e.g., for the native OSX spell checker): https://github.com/davidswelt/aquamacs-emacs/blob/aquamacs24/src/nsterm.m – lawlist Feb 25 '14 at 16:34