Question

I am running Emacs 24.3.1 on Mac OS 10.9, compiled on my machine from source through MacPorts. (For good measure I also tried a 24.3 binary from emacsformacosx.com.) I can use the -r switch from the command line to get Emacs to run in reverse video, however adding a customization to my .emacs file (setq inverse-video t) or through the Emacs customization menu is having no effect. Does anyone know another way to reverse the video without running Emacs from the command line?

Was it helpful?

Solution

The problem is that the usual Emacs init file (~/.emacs or ~/.emacs.d/init.el) is read after the GUI is initialized, so it has no effect on reverse video. You have to stick with the command line option --reverse-video or -rv or -r.

However, Emacs 28.1 (not yet released) adds an early init file ‘~/.emacs.d/early-init.el which is loaded before GUI is initialized, and if you put

(add-to-list 'default-frame-alist '(reverse . t))
(setq initial-frame-alist default-frame-alist)

into it, your Emacs will start with reverse video.

OTHER TIPS

I put this in my .emacs file: (Running GNU Emacs 21.1.3 on x86 linux)

(set-background-color "black")
(set-foreground-color "white")

Edit / update: Works just fine for the first frame. But a new frame is opened with a white background, and black text. Have some vague recollection of separately setting the frame background/foreground colors in the past, but don't know the name of the setting.

I have found this solution which "works for me" on GNU emacs 25.3.1 running on macOS High Sierra / 10.13.2. It's obviously a bit of a hack but maybe it's a good start towards a more solid solution.

(if (display-graphic-p)
   (progn (setq default-frame-alist
             (cons (cons 'reverse t) default-frame-alist))
     (select-frame (make-frame))
     (delete-other-frames) )
 )

the if clause means that the normal terminal based emacs doesn't get messed up by this.

Run emacs with the ReverseVideo flag in Linux:

$ emacs -rv &

I'm using Emacs 24.3 downloaded from emacsformacosx.com on Mac 10.8.5.

Launch the AppleScript Editor, paste in the below line.

do shell script "open -a Emacs.app --args -r"

Now save as "ReverseEmacs" (or your preferred application name) with a File Format of "Application." Double-click your script icon and up comes Emacs with reverse video. Enjoy!

This works in 25.1 (and 27.2) on Linux, Windows, and MacOS:

(set-face-background  'default   "black")
(set-face-foreground  'default   "white")

New frames are handled too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top