|From:||GNU bug Tracking System|
|Subject:||[debbugs-tracker] bug#21492: closed (25.0.50: Make untabify work nicely with write-file-functions)|
|Date:||Wed, 16 Sep 2015 15:55:01 +0000|
Your message dated Wed, 16 Sep 2015 15:54:25 +0000 with message-id <address@hidden> and subject line Re: bug#21492: 25.0.50: Make untabify work nicely with write-file-functions has caused the debbugs.gnu.org bug report #21492, regarding 25.0.50: Make untabify work nicely with write-file-functions to be marked as done. (If you believe you have received this mail in error, please contact address@hidden) -- 21492: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21492 GNU Bug Tracking System Contact address@hidden with problems
--- Begin Message ---
Subject: 25.0.50: Make untabify work nicely with write-file-functions Date: Tue, 15 Sep 2015 23:35:37 -0400Hi,I personally have dealt with the issue where I cannot add untabify directly to write-file-functions hook, because untabify does not return nil.I need some sort of custom wrapper that runs untabify and then returns nil.Today I noticed that another user on help-gnu-emacs list faced the same problem.That made me submit this minor edit to the untabify function; it simply returns nil. I noticed that similar edit had to be done for another function commonly added to write-file-functions: delete-trailing-whitespace.PATCH follows:From 1e12773ffa7c94610df070e38aaf8b2315c18fa8 Mon Sep 17 00:00:00 2001From: Kaushal Modi <address@hidden>Date: Tue, 15 Sep 2015 23:24:27 -0400Subject: [PATCH] Make untabify work with write-file-functions hook- write-file-functions requires the hooked functions to return nil inorder to proceed with the file saving.- So the return value of untabify is set to nil.---lisp/tabify.el | 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)diff --git a/lisp/tabify.el b/lisp/tabify.elindex c2f4e0c..9df3eaa 100644--- a/lisp/tabify.el+++ b/lisp/tabify.el@@ -53,7 +53,9 @@ The variable `tab-width' controls the spacing of tab stops."(setq column (current-column))(delete-region tab-beg (point))(indent-to column)))))- (move-to-column c)))+ (move-to-column c))+ ;; Return nil for the benefit of `write-file-functions'.+ nil)(defvar tabify-regexp " [ \t]+""Regexp matching whitespace that tabify should consider.--2.6.0.rc0.24.gec371ffPlease review and commit to the master branch if this is fine.For these few lines, I will not need the copyright paperwork, but I would like to mention that I have already got the copyright paperwork approved and in place (#1029578).
Kaushal ModiOn Tue, Sep 15, 2015 at 6:58 PM, warren ferguson <address@hidden> wrote:You are correct.
In my .emacs file I too had a detabify function, and when I added nil as the return value my saves started working.
Thanks so much, Warren
Date: Tue, 15 Sep 2015 17:55:56 -0400
Subject: Re: Issues with edited files not being saved
Have you added functions to the write-file-functions hook? Or to the old hook name that this new name obsoleted?
If so, make sure that all of those functions return nil. To test if one or more of the functions added to this hook are a problem, remove all functions from the hook, and then saving should work fine.
I had to create a custom untabify function that returned nil to fix this issue: https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-editing.el#L99On Sep 15, 2015 5:22 PM, "warren ferguson" <address@hidden> wrote:I've just downloaded and build a recent version of emacs.
GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll bars)
> head -n 1 /.image
LinuxSET EC Image SLES11SP2-2 Revision 0 ia32e
> sysname -afs
Unfortunately, when I edit a file and try to save it, the status line shows the usual "saving" message but that message never goes away indicating the save completed. While the attempt to save is ongoing, I can go to the terminal window and check that the file has not been updated to reflect the edits.
Interestingly, if I save the edited file to a new unused file name, the save does complete.
How do I determine why emacs is unable to write over the original file?
I checked file permissions, and they don't seem to be the source of the problem. Indeed, the emacs (version 23.2.1) that came with the OS is able to save edits to the same file.
--- End Message ---
--- Begin Message ---
Subject: Re: bug#21492: 25.0.50: Make untabify work nicely with write-file-functions Date: Wed, 16 Sep 2015 15:54:25 +0000Thanks 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.Note that the function's return value is set to nil because if this function isadded 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 normalhook) instead of `write-file-functions' (an abnormal hook that relies on stufflike 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 oftabs 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 oftabs 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 <address@hidden> 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.
--- End Message ---
|[Prev in Thread]||Current Thread||[Next in Thread]|