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@debbugs.gnu.org
Cc: warren ferguson <gobold1y@hotmail.com>
Subject: bug#21492: 25.0.50: Make untabify work nicely with write-file-functions
Date: Tue, 15 Sep 2015 23:35:37 -0400	[thread overview]
Message-ID: <CAFyQvY0SU0ne0GuSt2S4CnaoFo8eYpLiuUT9LQeMNpKcC+fFbw@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2015-09-16  3:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16  3:35 Kaushal Modi [this message]
2015-09-16  8:24 ` bug#21492: 25.0.50: Make untabify work nicely with write-file-functions 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

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=CAFyQvY0SU0ne0GuSt2S4CnaoFo8eYpLiuUT9LQeMNpKcC+fFbw@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=21492@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.