15

I am using a distraction-free mode that uses giant fringes to center the buffer called bzg-big-fringe-mode.

Problem is, these fringes often have a different color than the background which give an ugly visual effect (see the picture at the end).

I do not have a problem with fixing this manually, by setting the fringe color to the background color, like so:

(set-face-attribute 'fringe nil :background "#3F3F3F" :foreground "#3F3F3F")

Problem is, when changing themes the fringe colors remain gray, even though that does not make sense for the new theme.

Is there a way to programmatically set the fringe to the background color?

I guess I need two things:

  1. The ability to set the fringe background color to the default background color.
  2. A function that is hooked to changing themes and that does 1. above.

I think I should be able to do 2) even though I have no emacs skills, but how do I do 1)?

Or is this a bad idea for some reason? If so, what would a better approach look like?

enter image description here

3 Answers 3

15

The official way would be customizing the theme in question to make the fringe face look the same as the background face. A face spec along the lines of (fringe :inherit default) should do the trick.

Alternatively, you can modify it on the fly using a code snippet:

(defun my-tone-down-fringes ()
  (set-face-attribute 'fringe nil
                      :foreground (face-foreground 'default)
                      :background (face-background 'default)))

The only problem left would be applying it on every theme change. I can't find any hook looking like it could do the job which is a bit sad, defadvice doesn't seem to work out properly either. At least not in Emacs 24.4

3
  • Thanks. I'll wait till Monday with accepting in case sb has a solution. Commented Dec 13, 2014 at 10:55
  • 1
    Is there a reason not to use face-background and face-foreground in this code snippet? Commented Dec 13, 2014 at 16:59
  • There isn't, edited.
    – wasamasa
    Commented Dec 13, 2014 at 17:02
8

You can set the fringe color to nil, in which case you don't need to worry about any theme changes. I've got the following in my config:

(set-face-attribute 'fringe nil :background nil)

And the fringe just disappears.... :)

0

Somehow 'fringe stopped working for me, and now this does:

(set-face-attribute 'linum nil :background "gray19")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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