From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.bugs Subject: bug#21492: 25.0.50: Make untabify work nicely with write-file-functions Date: Wed, 16 Sep 2015 15:54:25 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b33d318b80869051fdf50dd X-Trace: ger.gmane.org 1442419500 17700 80.91.229.3 (16 Sep 2015 16:05:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Sep 2015 16:05:00 +0000 (UTC) Cc: warren ferguson To: 21492-done@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Sep 16 18:04:51 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZcFCS-0001tr-U1 for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Sep 2015 18:04:49 +0200 Original-Received: from localhost ([::1]:51787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcFCS-0004mM-Bg for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Sep 2015 12:04:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcFCJ-0004cC-87 for bug-gnu-emacs@gnu.org; Wed, 16 Sep 2015 12:04:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcFCF-0005jZ-UA for bug-gnu-emacs@gnu.org; Wed, 16 Sep 2015 12:04:39 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42784) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcF30-0002HD-GN for bug-gnu-emacs@gnu.org; Wed, 16 Sep 2015 11:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZcF30-0000em-4R for bug-gnu-emacs@gnu.org; Wed, 16 Sep 2015 11:55:02 -0400 Resent-From: Kaushal Modi Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Sep 2015 15:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 21492 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 21492@debbugs.gnu.org, kaushal.modi@gmail.com, kaushal.modi@gmail.com Original-Received: via spool by 21492-done@debbugs.gnu.org id=D21492.14424188802470 (code D ref 21492); Wed, 16 Sep 2015 15:55:01 +0000 Original-Received: (at 21492-done) by debbugs.gnu.org; 16 Sep 2015 15:54:40 +0000 Original-Received: from localhost ([127.0.0.1]:34992 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZcF2d-0000dl-7E for submit@debbugs.gnu.org; Wed, 16 Sep 2015 11:54:39 -0400 Original-Received: from mail-ob0-f181.google.com ([209.85.214.181]:35551) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZcF2a-0000db-NQ for 21492-done@debbugs.gnu.org; Wed, 16 Sep 2015 11:54:37 -0400 Original-Received: by obbzf10 with SMTP id zf10so96912215obb.2 for <21492-done@debbugs.gnu.org>; Wed, 16 Sep 2015 08:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=TQ7zt66LpmpxtU4DNEPM2mr2WctEUbo0L57scc+HDjY=; b=QjiE7Kf3sGbzrW4BpHifbFJtWgNIXrZLyoNnb9dRMNKHxBLR0kVnJsYcOUD1wYBclP tw/29Sqkm2/KAQ1SQqI0pCYAKwPGH4lWaqrShUQZrkU6eowX9EtF7g1yuSH0OuHsmb+a RG/yq56FIFhyv4eivQ7b8I7/lC/nWmtHV5Z0wKxHfWtkFSKjjysgoLAZhATJePiwYmWW 9js1eqUTgLLMHDsuNBw4/90yLAlj40yEXYe+h8lB17lv2L3xtpc4r8lbBncWBw6ES8V1 Pad7eVTna3igCCwXTa95/DLvFzt/ujXj/sTyu/eDI45VkWz9/WQcK1bwVZJqfq8z70fj VHlA== X-Received: by 10.60.23.73 with SMTP id k9mr24076474oef.25.1442418875957; Wed, 16 Sep 2015 08:54:35 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:106649 Archived-At: --047d7b33d318b80869051fdf50dd Content-Type: text/plain; charset=UTF-8 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 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 > --047d7b33d318b80869051fdf50dd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks for the right direction, Stefan.

I am closing this bug as it makes sense to not modify the untabify functio= n. 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= ()
=C2=A0 "Untabify the current buffer.

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 an= y function added to
`write-file-functions' returned a non-nil= value.

for this purpose, it makes a bet= ter sense to use `before-save-hook' (a normal
hook) instead o= f `write-file-functions' (an abnormal hook that relies on stuff
like the function return values).

So below woul= d be a recommended way of using this function:

=C2= =A0 =C2=A0 (defun my/verilog-mode-customizations ()
=C2=A0 =C2=A0= =C2=A0 (add-hook 'before-save-hook #'modi/untabify-buffer nil :loc= al))
=C2=A0 =C2=A0 (add-hook 'verilog-mode-hook #'my/veri= log-mode-customizations)

Note that it is suggested= to add this function to the `before-save-hook'
*locally* wit= hin a hook for a major mode which does not require the use of
tab= s 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 u= se of
tabs explicitly."
=C2=A0 (interactive)
=
=C2=A0 (untabify (point-min) (point-max))
=C2=A0 ;; Return n= il for the benefit of `write-file-functions'.
=C2=A0 nil)

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

Thanks Gle= nn, Stefan!


On Wed, Sep 16, 2015 at 9:14 AM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">> I personally have dealt with the issue w= here I cannot add untabify directly
> to write-file-functions hook, because untabify does not return nil.
If it hurts, then don't do that.=C2=A0 We have before-save-hook for tha= t.


=C2=A0 =C2=A0 =C2=A0 =C2=A0 Stefan
--047d7b33d318b80869051fdf50dd--