From 13f48d2c2402a5576856988bbf185dbcafd40652 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Tue, 21 Jul 2015 14:56:37 +0200 Subject: [PATCH] adding variable bba-keep-whitespaces to disable delete-trailing-whitespace on a per file basis by setting bba-keep-whitespaces. --- bba.org | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/bba.org b/bba.org index 7feb98bc..24e3ade8 100644 --- a/bba.org +++ b/bba.org @@ -1120,13 +1120,24 @@ With this you can do /sudo:ssh-host:file-on-ssh-host There are some file formats out there where you shouldn't use this function. [[http://en.wikipedia.org/wiki/YAML][YAML]] is only one of them. +You can disable this functionality on a per file basis by adding lines +like these: + +#+BEGIN_SRC cperl + # Local Variables: + # bba-keep-whitespaces: 1 + # End: +#+END_SRC #+BEGIN_SRC emacs-lisp (eval-after-load "cfengine3-mode" '(add-hook 'cfengine3-mode-hook (lambda() (add-hook 'write-contents-functions (lambda() - (save-excursion - (delete-trailing-whitespace)))) + (unless (boundp 'bba-keep-whitespaces) + (save-excursion + (delete-trailing-whitespace))) + ) + ) ) )) @@ -1134,8 +1145,11 @@ function. [[http://en.wikipedia.org/wiki/YAML][YAML]] is only one of them. (eval-after-load "cperl-mode" '(add-hook 'cperl-mode-hook (lambda() (add-hook 'write-contents-functions (lambda() - (save-excursion - (delete-trailing-whitespace)))) + (unless (boundp 'bba-keep-whitespaces) + (save-excursion + (delete-trailing-whitespace))) + ) + ) ) )) @@ -1143,7 +1157,8 @@ function. [[http://en.wikipedia.org/wiki/YAML][YAML]] is only one of them. '(add-hook 'dns-mode-hook (lambda() (add-hook 'write-contents-functions (lambda() (save-excursion - (delete-trailing-whitespace)))) + (delete-trailing-whitespace))) + ) ) )) @@ -1151,23 +1166,28 @@ function. [[http://en.wikipedia.org/wiki/YAML][YAML]] is only one of them. '(add-hook 'json-mode-hook (lambda() (add-hook 'write-contents-functions (lambda() (save-excursion - (delete-trailing-whitespace)))) + (delete-trailing-whitespace))) + ) ) )) (eval-after-load "org-mode" '(add-hook 'org-mode-hook (lambda() (add-hook 'write-contents-functions (lambda() - (save-excursion - (delete-trailing-whitespace)))) + (unless (boundp 'bba-keep-whitespaces) + (save-excursion + (delete-trailing-whitespace))))) ) )) (eval-after-load "text-mode" '(add-hook 'text-mode-hook (lambda() (add-hook 'write-contents-functions (lambda() - (save-excursion - (delete-trailing-whitespace)))) + (unless (boundp 'bba-keep-whitespaces) + (save-excursion + (delete-trailing-whitespace))) + ) + ) ) )) -- 2.47.3