Good Haskell Style
nominolo at googlemail.com
Thu Aug 2 12:16:25 EDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
On 2 aug 2007, at 18.03, David Brown wrote:
> Thomas Schilling wrote:
>> The simplest thing I can think of, is to not remove whitespace at
>> all, but to only remove it when you're saving the file. I know that
>> some modes use such a save hook. It also wouldn't modify the actual
>> file (ie, don't remove the whitespace until you save the file for
>> the first time), as long as you edit it. The only time the spaces
>> would be removed permanently were if you save the file, close the
>> buffer, and then re-open the file.
> Picture mode removes trailing space when you exit it, so perhaps the
> function that does that is available to call upon saving.
Well, this works:
(defun delete-trailing-space ()
"Deletes trailing space from all lines in buffer."
(message "Deleting trailing spaces ... ")
(while (< (point) (point-max))
(message "Deleting trailing spaces ... done.")))
nil) ; indicates buffer-not-saved for write-file-hook
(add-hook 'haskell-mode-hook 'my-haskell-mode-hook)
;; Make the hook a named function, so we can redefine it
:: without having torestart emacs.
(defun my-haskell-mode-hook ()
(add-hook 'write-file-hooks 'delete-trailing-space)
But it has the problem that it will delete the whitespace also in the
open buffer, so you have to re-insert the whitespace at the end of
the line. I am just looking at how to modify the editing functions,
to have this work more seamlessly.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
-----END PGP SIGNATURE-----
More information about the Libraries