bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12769: 24.2; Files won't save on Macintosh/Mountain Lion


From: martin rudalics
Subject: bug#12769: 24.2; Files won't save on Macintosh/Mountain Lion
Date: Wed, 31 Oct 2012 08:41:32 +0100

> I tracked the problem down to the following (in red):
> (setq-default indent-tabs-mode nil)
> (add-hook 'write-file-hooks
>   (lambda ()
>     (if (not indent-tabs-mode)
>       (untabify (point-min) (point-max))
>       (delete-trailing-whitespace))))

> So, is this a bug or is the untabify command no longer supported?  If
> it's now a bug, this should now be reproducible.  If it's an obsolete
> package, do you have any suggestions for a replacement?

Properly indented, the `add-hook' form above here appears as

(add-hook 'write-file-hooks
          (lambda ()
            (if (not indent-tabs-mode)
                (untabify (point-min) (point-max))
              (delete-trailing-whitespace))))

so if `indent-tabs-mode' is on, you delete trailing whitespace and if
it's off, you untabify.  Is this what you really want?

Anyway, the problem seems that `untabify' returns non-nil and according
to the doc-string of `write-file-hooks' we know that this is a

  List of functions to be called before writing out a buffer to a file.
  If one of them returns non-nil, the file is considered already written
  and the rest are not called.

which is slightly ambiguous: One might think that if one of them returns
non-nil Emacs will "not call the rest" but nevertheless save the buffer
to its file.

In your case writing the file is aborted because `untabify' returns the
"current column `move-to-column' moved to" (whatever that is it seems to
be non-nil).  So maybe we should modify the return value of `untabify'
(like in `delete-trailing-whitespace') or you should use

(add-hook 'write-file-hooks
          (lambda ()
            (if (not indent-tabs-mode)
                (progn
                  (untabify (point-min) (point-max))
                  nil)
              (delete-trailing-whitespace))))

still modulo your real intentions of what that lambda is supposed to do.

martin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]