[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] [patch] not setting modified flag when nothing was spel
From: |
Chris Allegretta |
Subject: |
Re: [Nano-devel] [patch] not setting modified flag when nothing was spell corrected |
Date: |
Mon, 16 Mar 2015 10:44:19 -0400 |
LGTM, thanks Benno!
On 3/14/15, Benno Schulenberg <address@hidden> wrote:
>
> On Sat, Feb 21, 2015, at 12:54, Benno Schulenberg wrote:
>> In Savannah the following bug was posted:
>> https://savannah.gnu.org/bugs/?44320
>> It points out that when using an external spell checker,
>> like aspell, doing a spell check will always set the file-
>> -is-modified flag, even when nothing at all was changed.
>
> Below patch fixes this for me. Comments and improvements
> are welcome.
>
>
> Index: src/text.c
> ===================================================================
> --- src/text.c (revision 5138)
> +++ src/text.c (working copy)
> @@ -2664,6 +2664,8 @@
> size_t pww_save = openfile->placewewant;
> ssize_t current_y_save = openfile->current_y;
> ssize_t lineno_save = openfile->current->lineno;
> + struct stat spellfileinfo;
> + __time_t timestamp;
> pid_t pid_spell;
> char *ptr;
> static int arglen = 3;
> @@ -2699,6 +2701,10 @@
> return NULL;
> }
>
> + /* Get the timestamp of the temporary file. */
> + stat(tempfile_name, &spellfileinfo);
> + timestamp = spellfileinfo.st_mtime;
> +
> endwin();
>
> /* Set up an argument list to pass execvp(). */
> @@ -2738,6 +2744,10 @@
> /* Wait for the alternate spell checker to finish. */
> wait(&alt_spell_status);
>
> + /* Reread the timestamp of the temporary file, so it can be compared
> + * to the saved one later on. */
> + stat(tempfile_name, &spellfileinfo);
> +
> /* Reenter curses mode. */
> doupdate();
>
> @@ -2841,10 +2851,13 @@
> }
> #endif
>
> - /* Go back to the old position, and mark the file as modified. */
> + /* Go back to the old position. */
> do_gotopos(lineno_save, current_x_save, current_y_save, pww_save);
> - set_modified();
>
> + /* Mark the buffer as modified only if the temp file was modified. */
> + if (spellfileinfo.st_mtime != timestamp)
> + set_modified();
> +
> #ifndef NANO_TINY
> /* Handle a pending SIGWINCH again. */
> allow_pending_sigwinch(TRUE);
>
>
> --
> http://www.fastmail.com - Access your email from home and the web
>
>
> _______________________________________________
> Nano-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/nano-devel
>