2

After a recent update, my Perl files are rendered like this:

example of an emacs window showing highlighted whitespace

Note that trailing spaces are shown in red and empty lines in yellow. This is happening despite my having the following in my ~/.emacs:

(setq cperl-invalid-face nil)
(setq sp-highlight-pair-overlay nil)

This does not seem to be related to anything in my ~/.emacs or ~/.emacs.d/init.el files since renaming them and launching emacs still shows the same behavior. However, the problem is not there if I launch with emacs -Q. In case they are relevant, here are my .emacs and .init.el files. Finally, I also tried launching emacs as a different user and had the same issue so it seems to be a site-wide problem.

I get the same behavior in Elisp, C and Perl/CPerl modes but not in Fundamental or shell modes. How can I remove this highlighting?

I am running emacs 24.4.1 on Debian.

4

You should generally start Emacs with emacs -q to make sure it's not your configuration. If that doesn't get rid of it, but emacs -Q does, chances are it's the way your Emacs was packaged or a site file that's used for every user on your system.

Additionally to that you can inspect the faces involved by placing point at the highlighted area and doing M-x describe-char. This will tell you what functionality is responsible for the highlighting.

  • 1
    As always... If your init file is problematic, recursively bisect it by commenting out sections until you find the problematic piece. Use comment-region to comment (or with C-u uncomment) the region. Comment out 1/2, then 3/4, 7/8,... until you find exactly which tiny bit is causing the problem. Very quick to do. – Drew Jan 14 '15 at 15:46
  • M-; is a quicker alternative to M-x comment-region gnu.org/software/emacs/manual/html_node/emacs/… (not perfectly equivalent, but close enough for most purposes) – flies Jun 6 '17 at 15:58
3

The accepted answer is absolutely right. I am posting this to specify which file was the issue for me. After noticing that the problem persisted with emacs -q but gone with emacs --no-site-file, I checked the files in /etc/emacs/site-start.d. After sequentially deleting each of them and launching emacs, I found that the culprit on my Debian system, running 24.4.1, was

/etc/emacs/site-start.d/50develock-el.el

This file in turn loads /usr/share/emacs24/site-lisp/develock-el/develock.el and that's where the whitespace highlighting was being set.

I solved it by simply commenting out all lines from /etc/emacs/site-start.d/50develock-el.el. This is not very elegant and a better way would be to disable the specific features that annoy me in /usr/share/emacs24/site-lisp/develock-el/develock.el but that is beyond my ken. So far, this brute force approach seems to be working.

  • Sounds like it's the Debian develock-el package you should be able to remove with your package manager. If that's possible and solves your problem, report a bug with that package because a package enabling itself is generally considered a bug. – wasamasa Jan 14 '15 at 16:44
  • Why not just look for where whitespace-mode is enabled and comment out that one-liner (taking care, of course, to not comment out any closing parentheses of a prior section)? It is either (whitespace-mode . . .) or (global-whitespace-mode . . . – lawlist Jan 14 '15 at 17:10
  • @lawlist because there are several dozen (perhaps a hundred) cases of whitespace in that file and I don't have the knowledge or patience to go through them. And it seems to have nothing to do with whitespace-mode. I don't use that as far as I know and it is not mentioned anywhere in develock.el. – terdon Jan 14 '15 at 17:20
  • After looking at the source-code emacswiki.org/emacs/DevelockMode there does not appear to be an easy method of turning it off except to prevent it from loading. And, you are correct, it is not whitespace-mode. – lawlist Jan 14 '15 at 17:46
  • I applied Terdon's fix, blunt as it is. Shouldn't there be a way to turn develock off in .emacs? – flies Jun 6 '17 at 16:34
1

Like wasamasa suggested, put the cursor on the character or highlighted area and do

M-x describe-char

Suppose the face is "whitespace-empty" (I was looking to get rid of the yellow highlight)

(custom-set-faces
  '(whitespace-empty ((t (:background "grey20" :foreground "gray30"))))
)

in your ~/.emacs file.

0

I fixed it by commenting out:

(add-hook 'prog-mode-hook
      (lambda () (interactive)
        (setq show-trailing-whitespace 1)))

in the file ~/.emacs.d/custom/setup-general.el

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.