title: emacs only delete-trailing-whitespace while saving in programming mode
body: <p>following line removes all training white space while saving.</p>
  
  <pre><code>(add-hook 'write-file-hooks 'delete-trailing-whitespace)
  </code></pre>
  
  <p>but I want to hook this feature only when i'm in programming mode, so i did</p>
  
  <pre><code>(defun nuke_traling ()
    (add-hook 'write-file-hooks 'delete-trailing-whitespace) 
  )
  
  (add-hook 'prog-mode-hook 'nuke_traling)
  </code></pre>
  
  <p>which doesn't is not stopping which are not in programming mode.</p>