18

(setq whitespace-global-modes '(not org-mode)) See C-hv whitespace-global-modes RET


15

The ws-butler package removes whitespace only from the touched lines. The package is available on Melpa. From that package's README on github: Only lines touched get trimmed. If the white space at end of buffer is changed, then blank lines at the end of buffer are truncated respecting require-final-newline. Trimming only happens when saving.


9

I just added the following to my init.el: (defun prevent-whitespace-mode-for-magit () (not (derived-mode-p 'magit-mode))) (add-function :before-while whitespace-enable-predicate 'prevent-whitespace-mode-for-magit) This basically advises the function whitespace-enable-predicate, which whitespace-mode uses to determine, which buffers should receive global-...


7

First off, since you didn't mention it: Using the same version of Emacs (24.4.1), the behavior you describe can be reproduced in emacs -Q. Secondly, what you are doing should work (AFAICT). It seems that turning on whitespace-mode globally (or even in a mode hook) before visiting a file with a custom whitespace-line-column is what's causing the problem. You ...


5

This should do what you want. Define regexps that match what you want, and faces. Then match the subgroups in the function you add to font-lock-keywords. The subgroups are used to say that you want only the spaces after indenting tabs, and only non-indenting tabs. (defface my-tab '((t (:background "LemonChiffon"))) "..." :group 'faces) (defface my-space '...


4

There is a set of conventions for minor modes documented in the docstring of define-minor-mode: The defined mode command takes one optional (prefix) argument. Interactively with no prefix argument, it toggles the mode. A prefix argument enables the mode if the argument is positive, and disables it otherwise. When called from Lisp, the mode ...


4

Customize option whitespace-display-mappings. That's what it's for. M-x customize-option whitespace-display-mappings RET The doc gives you details (below), but just look at the Customize buffer and things will be even clearer. You can use C-u C-x = with the cursor before a given character, to see its Unicode code point. C-h v whitespace-display-mappings ...


4

It is probably easier to turn off whitespace mode directly, using (whitespace-mode -1) Also, whitespace-style is not a buffer-local variable, so it is modified for all other buffers as well. Try instead (set (make-local-variable 'whitespace-style) nil)


4

As erikstokes correctly points out, the variable that controls this behaviour is whitespace-line-column. If you unconditionally set this variable in your user-init-file, however, it will affect all modes. The standard mechanism that Emacs provides for mode-specific customisations is hooks. So, to modify the variable in question for rust-mode only, you can ...


3

If you look at the docstring of whitespace-mode (emphasis mine): whitespace-mode is an interactive autoloaded compiled Lisp function in ‘whitespace.el’. (whitespace-mode &optional ARG) Toggle whitespace visualization (Whitespace mode). ... The elisp manual section on autoloading begins with: The autoload facility lets you register ...


3

whitespace-mode is already an interactive function and, if called interactively, toggles the mode. So the simplest answer to your question is: (global-set-key (kbd "<f6>") 'whitespace-mode)


3

You can do like that: (define-global-minor-mode my-global-whitespace-mode whitespace-mode (lambda () (unless (derived-mode-p 'rmail-mode 'term-mode) (whitespace-mode)))) (my-global-whitespace-mode 1) Or activate only for prog-mode (define-global-minor-mode my-global-whitespace-mode whitespace-mode (lambda () (when (derived-mode-p 'prog-...


3

I don't think whitespace-mode can do what you're asking out-of-the-box. But this is Emacs! You can get (maybe?) what you want by redefining the functions whitespace-empty-at-eob-regexp and whitespace-post-command-hook. In whitespace-empty-at-eob-regexp (the function, not the actual regexp) you should find the following branch: (cond ;; at eob ((= limit ...


3

Indeed you can't specify different glyphs for different kinds of spaces because this feature makes use of a display table. The relevant values in variable whitespace-style are (emacs manual): space-mark Draw space and non-breaking characters with a special glyph. tab-mark Draw tab characters with a special glyph. newline-mark ...


3

Prelude's own prelude-whitespace was causing the behavior. You can disable it using: M-x customize-group RET prelude Set Prelude Whitespace (prelude-whitespace) to off/nil (default is on). According to the prelude docs you can also set this variable in your configuration: (setq prelude-whitespace nil)


3

Two things to check in this case: Does whitespace-tab have non-transparent background? Use M-x list-faces-display to check faces. In my case solarized-dark had whitespace-tab with transparent background. Remove indentation because it turns out that this thing has the ability to override tab face in indentation with indentation face which was also ...


2

You probably have to restart whitespace mode for the changes to take effect. Try the following: (add-hook 'prog-mode-hook '(lambda () (interactive) (whitespace-mode 0) (setq whitespace-line-column 80) (whitespace-mode 1))) (add-hook 'web-mode-...


2

Customize option whitespace-display-mappings, to get rid of this entry: (space-mark ?\ [?\u00B7] [?.]) ; space - centered dot That maps a SPC char to a centered dot. M-x customize-option RET whitespace-display-mappings RET This is the entry to remove or change, in the Customize UI: You can just click the first DEL to remove it, if you ...


2

First, ^M is the carriage-return character, not the linefeed char (that one is ^J. Here is one answer for this part of your question: How to show the line feed chars - ^M in its original form and not as $: By default, ^M characters should be highlighted using face escape-glyph. Are you sure this is what you are seeing? Try customizing that face (M-x ...


2

Is this not supported out of the box? It is; see (emacs) Useless Whitespace. My current settings are: (global-whitespace-mode) (setq whitespace-style '(face trailing lines tabs big-indent)) As per the aforementioned manual node, you're only missing an empty element for your whitespace-style setting. Quoth C-hvwhitespace-styleRET: empty empty lines at ...


1

Ok I narrowed it down to the following line (setq whitespace-style ' (face space-mark tab-mark)) If I remove it whitespace-cleanup works. Probably I'm overwriting something that is necessary for it to work. If I change the line to (setq-default whitespace-style ' (face tabs spaces trailing space-before-tab newline indentation empty space-after-tab space-...


1

It turns out that the set up with a multitude of additional packages is responsible for this problem. (Vanilla Emacs does not have this issue.) But it is hard to determine what exactly causes the problem. However if the issue occurs, a manual ad hoc fix is possible: Just erase the local display table. I have defined a command for this: (defun my-erase-...


1

The following lisp code defines a new minor mode hl-ws-eob-mode. If you have installed the code in your init files you can try it by M-x hl-ws-eob-mode RET. It works for buffers that are fontified by font-lock-mode. I think buffers with php-mode as major mode belong to this class. The final lonely newline is not highlighted if the option hl-ws-eob-accept-...


1

Looking at whitespace.el I see we could also do this: (with-eval-after-load 'whitespace (setq whitespace-enable-predicate `(lambda () (and (funcall ,whitespace-enable-predicate) (not (derived-mode-p 'magit-mode)))))) This is somewhat similar to @JulianKniephoff's answer, but not using advice. However I note that advice ...


1

You could customize the whitespace-global-modes variable to be: (not magit-mode) Edit: In fact, as pointed out by Julian Kniephoff in the comments, this would have to be a more complete list of magit modes, which is pretty cumbersome, and would need maintaining. Something like: (not magit-mode magit-cherry-mode magit-diff-mode magit-log-mode magit-log-...


1

One workaround I'd found is to temporarily change the face background color. ;; Don't show trailing space in insert mode. (defvar i42/whitespace-trailing-bg (face-attribute 'whitespace-trailing :background)) (defun i42/enter-insert-mode () (set-face-attribute 'whitespace-trailing nil :background nil :foreground nil)) (defun i42/exit-insert-mode () (set-...


1

C-h f whitespace-mode tells you what your problem is: whitespace-mode is an interactive autoloaded Lisp function in whitespace.el. (whitespace-mode &optional ARG) Toggle whitespace visualization (Whitespace mode). With a prefix argument ARG, enable Whitespace mode if ARG is positive, and disable it otherwise. If called from Lisp, ...


1

As phils already said in the comments whitespace-style needs to include space-mark. See my answer here for details.


1

Your settings work. Make sure that you don't have grayish window background.


1

I've had the same problem with Prelude. The reason was that whitespace-style has the value (face tabs empty trailing lines-tail). It is set in .emacs.d/core/prelude-editor.el. What whitespace-mode highlights seems to be governed by the value of whitespace-display-mappings, which was ((space-mark 32 [183] [46]) (space-mark 160 [164] [95]) (newline-mark 10 [...


Only top voted, non community-wiki answers of a minimum length are eligible