commit 71c35d3ca2c0c46753aed073695ecee1e90d4dba
parent 38af812a82fc0d684c1629c82e8a900762f8887c
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 6 Mar 2020 17:00:31 +0100
tweaks: move a function to where it is used
Diffstat:
3 files changed, 40 insertions(+), 46 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -469,48 +469,6 @@ bool open_buffer(const char *filename, bool new_one)
return TRUE;
}
-#ifdef ENABLE_SPELLER
-/* Open the specified file, and if that succeeds, remove the text of the marked
- * region or of the entire buffer and read the file contents into its place. */
-bool replace_buffer(const char *filename, undo_type action, bool marked,
- const char *operation)
-{
- linestruct *was_cutbuffer = cutbuffer;
- int descriptor;
- FILE *f;
-
- descriptor = open_file(filename, FALSE, &f);
-
- if (descriptor < 0)
- return FALSE;
-
- cutbuffer = NULL;
-
-#ifndef NANO_TINY
- add_undo(COUPLE_BEGIN, operation);
-
- /* Cut either the marked region or the whole buffer. */
- add_undo(action, NULL);
-#endif
- do_snip(FALSE, marked, !marked, FALSE);
-#ifndef NANO_TINY
- update_undo(action);
-#endif
-
- /* Discard what was cut. */
- free_lines(cutbuffer);
- cutbuffer = was_cutbuffer;
-
- /* Insert the spell-checked file into the cleared area. */
- read_file(f, descriptor, filename, TRUE);
-
-#ifndef NANO_TINY
- add_undo(COUPLE_END, operation);
-#endif
- return TRUE;
-}
-#endif /* ENABLE_SPELLER */
-
/* Mark the current file as modified if it isn't already, and
* then update the title bar to display the file's new status. */
void set_modified(void)
diff --git a/src/proto.h b/src/proto.h
@@ -278,10 +278,6 @@ void make_new_buffer(void);
bool delete_lockfile(const char *lockfilename);
#endif
bool open_buffer(const char *filename, bool new_buffer);
-#ifdef ENABLE_SPELLER
-bool replace_buffer(const char *filename, undo_type action, bool marked,
- const char *operation);
-#endif
void set_modified(void);
void prepare_for_display(void);
#ifdef ENABLE_MULTIBUFFER
diff --git a/src/text.c b/src/text.c
@@ -2479,6 +2479,46 @@ const char *do_int_speller(const char *tempfile_name)
return NULL;
}
+/* Open the specified file, and if that succeeds, remove the text of the marked
+ * region or of the entire buffer and read the file contents into its place. */
+bool replace_buffer(const char *filename, undo_type action, bool marked,
+ const char *operation)
+{
+ linestruct *was_cutbuffer = cutbuffer;
+ int descriptor;
+ FILE *f;
+
+ descriptor = open_file(filename, FALSE, &f);
+
+ if (descriptor < 0)
+ return FALSE;
+
+ cutbuffer = NULL;
+
+#ifndef NANO_TINY
+ add_undo(COUPLE_BEGIN, operation);
+
+ /* Cut either the marked region or the whole buffer. */
+ add_undo(action, NULL);
+#endif
+ do_snip(FALSE, marked, !marked, FALSE);
+#ifndef NANO_TINY
+ update_undo(action);
+#endif
+
+ /* Discard what was cut. */
+ free_lines(cutbuffer);
+ cutbuffer = was_cutbuffer;
+
+ /* Insert the spell-checked file into the cleared area. */
+ read_file(f, descriptor, filename, TRUE);
+
+#ifndef NANO_TINY
+ add_undo(COUPLE_END, operation);
+#endif
+ return TRUE;
+}
+
/* Execute the given program, with the given temp file as last argument. */
const char *treat(char *tempfile_name, char *theprogram, bool spelling)
{