rolandwalker / nav-flash

Briefly highlight the current line in Emacs
28 stars 2 forks source link

What is `mangle-whitespace` supposed to be? #2

Open wasamasa opened 9 years ago

wasamasa commented 9 years ago

I've noticed this file-local variable in a few more of your projects thanks to this Stackexchange question, but couldn't find it in any Emacs release you're supporting. What purpose does it fulfill?

rolandwalker commented 9 years ago

Hi!

I use that variable to affirmatively enable management of whitespace by Emacs. This defends against mangling the whitespace when submitting to someone else's project.

With newer Emacs releases, personal local variables can be migrated out of the source into .dir-locals.el, which I should probably do.

If you commonly edit a file with certain local variables and want to skip the prompt that asks you whether they are "safe", you can tell Emacs which values are OK by setting safe-local-variable-values like this

(add-to-list 'safe-local-variable-values '(mangle-whitespace . t))
(add-to-list 'safe-local-variable-values '(mangle-whitespace . nil))    ; synonym for '(mangle-whitespace)
wasamasa commented 9 years ago

Well, it's kind of obvious that this is a file-local variable which could be migrated to a directory-local variable, I guess what I'm asking for is what is defining and making use of it.

rolandwalker commented 9 years ago

I'm not sure it is obvious, to others who may read or search this issue, and even now I'm not sure I explained sufficiently: my intended implication in making the variable directory-local is that .dir-locals.el would be covered by .gitignore and the variable would no longer be published.

The variable is respected by my internal Emacs config, so it is a mismatch that the variable gets published.

For example, I might have

(add-hook 'lisp-mode-hook
          #'(lambda ()
              (when (eq major-mode 'lisp-mode)
                (when (and (boundp 'mangle-whitespace) mangle-whitespace)
                  (set (make-local-variable 'require-final-newline) t)))))
wasamasa commented 9 years ago

Ah, I see, thank you. I'll keep this issue open then in case you should decide to use it as reminder to switching to a solution covered by .gitignore.