How to make everything except the text transparent?

  • I don't think this is possible. You can control the transparency of a frame as a whole, but I don't think you can control the elements of that frame. – Dan Aug 8 '18 at 12:23
  • 1
    Here is a link that may give you some ideas regarding how to implement transparency affecting the background, but not the frame borders -- "how to get transparent window in GNU Emacs on OSX": stackoverflow.com/a/21949449/2112489 – lawlist Aug 8 '18 at 13:50

I do not know for sure if the text becomes transparent, but this is what I use and I think works pretty well. However, if your font color is white, and you are reading a pdf with a white background color, even non-transparent text is going to be pretty hard to read.

(setq transparency_level 0)
(defun my:change_transparency ()
  "Toggles transparency of Emacs between 3 settings (none, mild, moderate)."
  (if (equal transparency_level 0)
      (progn (set-frame-parameter (selected-frame) 'alpha '(75 . 85))
         (setq transparency_level 1))
    (if (equal transparency_level 1)
    (progn (set-frame-parameter (selected-frame) 'alpha '(50 . 85))
           (setq transparency_level 2))
      (if (equal transparency_level 2)
      (progn (set-frame-parameter (selected-frame) 'alpha '(100 . 85))
         (setq transparency_level 0)))
(define-key global-map (kbd "C-c t") 'my:change_transparency)

If you add the code above to your init.el file or equivalent, you can use C-c t to toggle between transparency levels. If you think the transparency is too low, you can change the number 50 above to 30, for example, and that will make the frame more transparent.

I use this when I am writing things in emacs and need to read some pdf or website. This way I do not need to alt-tab. I think it works pretty well, hope it helps!

Edit 1: Here is a screenshot of it in action. transparency in emacs with pdf on the background

Edit 2: When setting the emacs transparency there are two numbers. The first is the transparency of emacs when it is active, and the second is when it is inactive (like when you alt-tab to another application).

The screenshot below shows an Emacs that is inactive, notice that it is still transparent (not much), and you can see my calendar application open in the background. Emacs is inactive because I changed my focus to the pdf reader.

enter image description here

  • 1
    As I am not sure if the transparency changes depending on the Emacs built, this is the one I use github.com/railwaycat/homebrew-emacsmacport/releases – Guilherme Salomé Aug 9 '18 at 13:05
  • What do the two numbers mean in 'alpha '(75 . 85)? The examples I have seen always set them to the same number, and it affects the whole Emacs (including the text). – HappyFace Aug 9 '18 at 14:47
  • Is Emacs open on top of a fullscreen app in your screenshot? Or have you hidden the top macOS menubar? – HappyFace Aug 9 '18 at 14:49
  • 1
    The first number is the transparency of the emacs when it is active, that is, when it is the "top most" window. The second number is the transparency when emacs is inactive. For example, if you alt-tab from emacs to another application, say a browser, and the browser window is on one side of the screen, then you would see emacs on the background, and it would be transparent. How transparent? That's the second number. – Guilherme Salomé Aug 9 '18 at 14:50
  • 1
    @HappyFace Emacs is like that because I make it "borderless fullscreen". It is like a fullscreen app, but does not actually move the application to another desktop. I wrote something awhile ago on how to achieve that with Mac (guilhermesalome.com/posts/making-emacs-look-good.html). – Guilherme Salomé Aug 9 '18 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.