unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21492: 25.0.50: Make untabify work nicely with write-file-functions
@ 2015-09-16  3:35 Kaushal Modi
  2015-09-16  8:24 ` Glenn Morris
  2015-09-16 13:14 ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Kaushal Modi @ 2015-09-16  3:35 UTC (permalink / raw)
  To: 21492; +Cc: warren ferguson

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

Hi,

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 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date: Tue, 15 Sep 2015 23:24:27 -0400
Subject: [PATCH] Make untabify work with write-file-functions hook

- write-file-functions requires the hooked functions to return nil in
  order 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.el
index 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.gec371ff

​Please 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 Modi

On Tue, Sep 15, 2015 at 6:58 PM, warren ferguson <gobold1y@hotmail.com>
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
> From: kaushal.modi@gmail.com
> To: gobold1y@hotmail.com
>
>
> 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#L99
> On Sep 15, 2015 5:22 PM, "warren ferguson" <gobold1y@hotmail.com> 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
> x86-64_linux30
>
> 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.
>
>
>

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-09-17  2:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2015-09-17  1:54     ` Stefan Monnier
2015-09-17  2:54       ` Kaushal Modi

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).