all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: 21492-done@debbugs.gnu.org
Cc: warren ferguson <gobold1y@hotmail.com>
Subject: bug#21492: 25.0.50: Make untabify work nicely with write-file-functions
Date: Wed, 16 Sep 2015 15:54:25 +0000	[thread overview]
Message-ID: <CAFyQvY39hBDYRg_2YasH8u+ffHp3iF_=irKxYFksLp=6KBS3BA@mail.gmail.com> (raw)
In-Reply-To: <jwvbnd2y09u.fsf-monnier+emacsbugs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2152 bytes --]

Thanks for the right direction, Stefan.

I am closing this bug as it makes sense to not modify the untabify
function. I was following the example of delete-trailing-whitespace.

For reference, I now have put the crux of this discussion in my config as
below:

(defun modi/untabify-buffer ()
  "Untabify the current buffer.

http://www.veripool.org/issues/345-Verilog-mode-can-t-get-untabify-on-save-to-work
Note that the function's return value is set to nil because if this
function is
added to `write-file-functions' hook, emacs will stay stuck at at the
\"Saving file ..\" message and the file won't be saved if any function
added to
`write-file-functions' returned a non-nil value.

As per the suggestion in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21492
,
for this purpose, it makes a better sense to use `before-save-hook' (a
normal
hook) instead of `write-file-functions' (an abnormal hook that relies on
stuff
like the function return values).

So below would be a recommended way of using this function:

    (defun my/verilog-mode-customizations ()
      (add-hook 'before-save-hook #'modi/untabify-buffer nil :local))
    (add-hook 'verilog-mode-hook #'my/verilog-mode-customizations)

Note that it is suggested to add this function to the `before-save-hook'
*locally* within a hook for a major mode which does not require the use of
tabs instead of spaces. Do NOT add this function to the hook globally,
because it can cause issues with files like Makefiles that rely on the use
of
tabs explicitly."
  (interactive)
  (untabify (point-min) (point-max))
  ;; Return nil for the benefit of `write-file-functions'.
  nil)

I also have now started using before-save-hook instead of
write-file-functions where I don't care about the return values of the
functions added to the hook.

Thanks Glenn, Stefan!


On Wed, Sep 16, 2015 at 9:14 AM Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> > I personally have dealt with the issue where I cannot add untabify
> directly
> > to write-file-functions hook, because untabify does not return nil.
>
> If it hurts, then don't do that.  We have before-save-hook for that.
>
>
>         Stefan
>

[-- Attachment #2: Type: text/html, Size: 3124 bytes --]

  reply	other threads:[~2015-09-16 15:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16  3:35 bug#21492: 25.0.50: Make untabify work nicely with write-file-functions Kaushal Modi
2015-09-16  8:24 ` Glenn Morris
2015-09-16 12:55   ` Kaushal Modi
2015-09-16 13:13     ` Kaushal Modi
2015-09-16 13:14 ` Stefan Monnier
2015-09-16 15:54   ` Kaushal Modi [this message]
2015-09-17  1:54     ` Stefan Monnier
2015-09-17  2:54       ` Kaushal Modi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFyQvY39hBDYRg_2YasH8u+ffHp3iF_=irKxYFksLp=6KBS3BA@mail.gmail.com' \
    --to=kaushal.modi@gmail.com \
    --cc=21492-done@debbugs.gnu.org \
    --cc=gobold1y@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.