Andrew Stacey


About
Andrew Stacey
Information about my research, teaching, and other interests.

By: Andrew Stacey
Contact details


Andrew Stacey


blosxom icon


Thu, 7th Dec 2006 (HowDidIDoThat :: Unix)

Make Emacs Transparent

I found that I spent ages deciding exactly which picture to have as my backdrop but then never saw it as there were too many windows on top. However, those windows tended to be Emacs or Xterms and so thanks to this version of Emacs and to Mrxvt I can make both of those transparent.

This is not true transparency but only pseudo-transparency. That is, if there is another window behind the Emacs one then it does not "shine through". I prefer this as my main reason for having transparency is not so that I can see the other windows but so that I can see the background image. There is an experimental line of the XWindow system which does true transparency but it was really slow on my system the last time I tried it.


This version of emacs is a development one and so has to be obtained from the source. The first step is to install the arch tools. On Ubuntu, the relevant package is called tla

To get the source code of emacs use the following commands:

Update 2009-03-05

Location altered on server (again!), commands below modified in light of this.


tla register-archive http://arch.savannah.gnu.org/archives/emacs
tla abrowse emacs@sv.gnu.org
tla get emacs@sv.gnu.org/emacs--tiling--0 share/src/emacs

The middle line is not strictly necessary. It lists the available emacs packages at savannah and so you can check that emacs-tiling--0 is still there. Obviously, change the share/src/emacs to wherever you want to put it.

Update 2009-03-26

I find that the very latest version segfaults a little more often than I'd like. It seems as though the patches are mainly merges from the main development branch of emacs. So it is worth figuring out a point at which the main branch of emacs was considered relatively stable and only going up to that patch level on the tiling branch. Patch number 56 seems to be stable as far as I can tell (it's what I've been using without problems for a while). To get a specific patch number, use:


tla get emacs@sv.gnu.org/emacs--tiling--0--patch-56 share/src/emacs

Next step, compile it. This is the usual:


./configure [--prefix=/share]
make bootstrap
make install

Update 2009-03-05

On the current version (seems to be patch-95) it won't compile due to a mismatch in xdisp.c. Here's a patch:


--- xdisp.c~	2009-03-05 10:28:50.000000000 +0100
+++ xdisp.c	2009-03-05 10:38:46.000000000 +0100
@@ -16586,7 +16586,7 @@
   else if (IMAGEP (prop))
     {
       it->what = IT_IMAGE;
-      it->image_id = lookup_image (it->f, prop);
+      it->image_id = lookup_image (it->f, prop, 0);
       it->method = GET_FROM_IMAGE;
     }
 #endif /* HAVE_WINDOW_SYSTEM */

If something else goes wrong -- as it inevitably will -- email the maintainer and not me. After the configure stage it is worth checking the list of enabled features. Most desirable features are enabled by default so if they're not there it's because you didn't have the right libraries. To get the full benefit it may be worth getting hold of those libraries (they're probably all standard) and redoing this step before going on to compile it. Do a make distclean in between.

Now comes the fun part ... fixing the background. This is reasonably straightforward but there are one or two things that can catch you out. The main thing is that the background pixmap has to be the right size. Often the program which sets the desktop background can rescale on the fly but Emacs won't do this. So scale your background first. The second thing is that you probably want to tint the background for Emacs; I tend to go for about 70%. So you need two copies of the background image, one for the desktop and one for Emacs. Once you have that, the rest is easy. Either do it via the customisation, or put the following lines in your .emacs:


(setq special-display-frame-alist '(
                            (background-tile
                              (image :type jpeg :file
                                     "~/backgrounds/display_faded.jpg"
                                     ) :origin
                              display
                              )
))
(setq default-frame-alist '(
                            (background-tile
                              (image :type jpeg :file
                                     "~/backgrounds/display_faded.jpg"
                                     ) :origin
                              display
                              )
))

You may want to put other things like foreground and background colours as well. Or this can go in a separate file to make it easier to customise when changing the background image. All sorts of things are possible.

I had a bit of trouble with this on the Mac because it didn't like resizing the initial frame. I don't have all those menu bars and so forth, but if you put these options in the .emacs file then it draws them in and then deletes them. This caused Emacs to crash. The solution was to put these options in the .Xdefaults file whereupon they never got drawn in the first place.

[Full link]
Last modified on:
Thu, 26th Mar 2009