[Emacs-ada-mode] Cleaning buffer before saving

Simon Wright simon at pushface.org
Sat Feb 6 12:47:44 PST 2010


On 6 Feb 2010, at 19:19, Stephen Leake wrote:

> Simon Wright <simon at pushface.org> writes:
> 
>> In 4.01, ada-clean-buffer-before-saving is marked as obsolete, with a
>> recommendation to use the write-file-functions in Emacs 23.2. I'm
>> using Carbon Emacs, which doesn't appear to have write-file-functions
>> or anything apropos,
> 
> According to http://homepage.mac.com/zenitani/emacs-e.html, "Carbon
> Emacs Package is a Mac-friendly distribution of the GNU Emacs text
> editor".
> 
> However, the history page there says the latest Carbon Emacs is based
> on Gnu Emacs 22.
> 
> What do you get when you do M-x version?

22.3.1

> The general rule here is "don't duplicate functionality". There's a
> perfectly good way for people to set a customization that cleans a
> buffer before saving; no need for ada-mode to get involved.
> 
> This is what ada-clean-buffer-before-saving used to do:
>  (if ada-clean-buffer-before-saving
>      (progn
> 	;; remove all spaces at the end of lines in the whole buffer.
> 	(add-hook 'local-write-file-hooks 'delete-trailing-whitespace)
> 	;; convert all tabs to the correct number of spaces.
> 	(add-hook 'local-write-file-hooks
> 		  (lambda () (untabify (point-min) (point-max))))))
> 
> The approved emacs 22 compatible replacement is to put this in your
> .emacs:
> 
> (add-hook 'before-save-hook 'delete-trailing-whitespace)
> (setq-default indent-tabs-mode nil)

OK, but no mention of this in ada-mode.html (that I could see). Work for me!

I expect the reason Emmanuel put the option in was that the default style-check (-gnaty) complains about both trailing white space and tabs, and you need to get this right if you're developing GNAT itself. Personally (and in my work project) we use -gnaty as the most straightforward style-check setting.

In Carbon Emacs, the customisation buffer for Ada still says "Ada Clean Buffer Before Saving: ... Non-nil means remove trailing spaces and untabify the buffer before saving." Perhaps it needs a small essay like the above instead ... or a pointer to the info. The current make-obsolete-variable (surely make-variable-obsolete?!) only outputs a message on byte compilation.






More information about the Emacs-ada-mode mailing list