files: remove the special 'quiet' mechanism for not overwriting messages
The general mechanism for not allowing important messages to be overwritten will take care of not overwriting warnings about failed file lockings.master
parent
a878f5f183
commit
906ada8fe7
39
src/files.c
39
src/files.c
|
@ -407,7 +407,6 @@ void stat_with_alloc(const char *filename, struct stat **pstat)
|
||||||
* necessary, and then open and read the file, if applicable. */
|
* necessary, and then open and read the file, if applicable. */
|
||||||
bool open_buffer(const char *filename, bool undoable)
|
bool open_buffer(const char *filename, bool undoable)
|
||||||
{
|
{
|
||||||
bool quiet = FALSE;
|
|
||||||
bool new_buffer = (openfile == NULL
|
bool new_buffer = (openfile == NULL
|
||||||
#ifndef DISABLE_MULTIBUFFER
|
#ifndef DISABLE_MULTIBUFFER
|
||||||
|| ISSET(MULTIBUFFER)
|
|| ISSET(MULTIBUFFER)
|
||||||
|
@ -453,31 +452,27 @@ bool open_buffer(const char *filename, bool undoable)
|
||||||
if (new_buffer) {
|
if (new_buffer) {
|
||||||
make_new_buffer();
|
make_new_buffer();
|
||||||
|
|
||||||
if (!has_valid_path(realname))
|
if (has_valid_path(realname)) {
|
||||||
quiet = TRUE;
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
else {
|
|
||||||
if (ISSET(LOCKING) && filename[0] != '\0') {
|
if (ISSET(LOCKING) && filename[0] != '\0') {
|
||||||
int lockstatus = do_lockfile(realname);
|
if (do_lockfile(realname) < 0) {
|
||||||
if (lockstatus < 0) {
|
|
||||||
#ifndef DISABLE_MULTIBUFFER
|
#ifndef DISABLE_MULTIBUFFER
|
||||||
if (openfile->next) {
|
if (openfile->next) {
|
||||||
close_buffer(TRUE);
|
close_buffer();
|
||||||
free(realname);
|
free(realname);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (lockstatus == 0)
|
}
|
||||||
quiet = TRUE;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the filename isn't blank, and we are not in NOREAD_MODE,
|
/* If the filename isn't blank, and we are not in NOREAD_MODE,
|
||||||
* open the file. Otherwise, treat it as a new file. */
|
* open the file. Otherwise, treat it as a new file. */
|
||||||
rc = (filename[0] != '\0' && !ISSET(NOREAD_MODE)) ?
|
rc = (filename[0] != '\0' && !ISSET(NOREAD_MODE)) ?
|
||||||
open_file(realname, new_buffer, quiet, &f) : -2;
|
open_file(realname, new_buffer, FALSE, &f) : -2;
|
||||||
|
|
||||||
/* If we have a file, and we're loading into a new buffer, update
|
/* If we have a file, and we're loading into a new buffer, update
|
||||||
* the filename. */
|
* the filename. */
|
||||||
|
@ -565,14 +560,13 @@ void display_buffer(void)
|
||||||
#ifndef DISABLE_MULTIBUFFER
|
#ifndef DISABLE_MULTIBUFFER
|
||||||
/* Switch to a neighbouring file buffer; to the next if to_next is TRUE;
|
/* Switch to a neighbouring file buffer; to the next if to_next is TRUE;
|
||||||
* otherwise, to the previous one. */
|
* otherwise, to the previous one. */
|
||||||
void switch_to_prevnext_buffer(bool to_next, bool quiet)
|
void switch_to_prevnext_buffer(bool to_next)
|
||||||
{
|
{
|
||||||
assert(openfile != NULL);
|
assert(openfile != NULL);
|
||||||
|
|
||||||
/* If only one file buffer is open, say so and get out. */
|
/* If only one file buffer is open, say so and get out. */
|
||||||
if (openfile == openfile->next) {
|
if (openfile == openfile->next) {
|
||||||
if (!quiet)
|
statusbar(_("No more open file buffers"));
|
||||||
statusbar(_("No more open file buffers"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,8 +581,7 @@ void switch_to_prevnext_buffer(bool to_next, bool quiet)
|
||||||
display_buffer();
|
display_buffer();
|
||||||
|
|
||||||
/* Indicate the switch on the statusbar. */
|
/* Indicate the switch on the statusbar. */
|
||||||
if (!quiet)
|
statusline(HUSH, _("Switched to %s"),
|
||||||
statusline(HUSH, _("Switched to %s"),
|
|
||||||
((openfile->filename[0] == '\0') ?
|
((openfile->filename[0] == '\0') ?
|
||||||
_("New Buffer") : openfile->filename));
|
_("New Buffer") : openfile->filename));
|
||||||
|
|
||||||
|
@ -601,19 +594,19 @@ void switch_to_prevnext_buffer(bool to_next, bool quiet)
|
||||||
/* Switch to the previous entry in the openfile filebuffer. */
|
/* Switch to the previous entry in the openfile filebuffer. */
|
||||||
void switch_to_prev_buffer_void(void)
|
void switch_to_prev_buffer_void(void)
|
||||||
{
|
{
|
||||||
switch_to_prevnext_buffer(FALSE, FALSE);
|
switch_to_prevnext_buffer(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Switch to the next entry in the openfile filebuffer. */
|
/* Switch to the next entry in the openfile filebuffer. */
|
||||||
void switch_to_next_buffer_void(void)
|
void switch_to_next_buffer_void(void)
|
||||||
{
|
{
|
||||||
switch_to_prevnext_buffer(TRUE, FALSE);
|
switch_to_prevnext_buffer(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete an entry from the openfile filebuffer, and switch to the one
|
/* Delete an entry from the circular list of open files, and switch to the
|
||||||
* after it. Return TRUE on success, or FALSE if there are no more open
|
* one after it. Return TRUE on success, and FALSE if there are no other
|
||||||
* buffers. quiet means not to print messages when switching buffers. */
|
* open buffers. */
|
||||||
bool close_buffer(bool quiet)
|
bool close_buffer(void)
|
||||||
{
|
{
|
||||||
assert(openfile != NULL);
|
assert(openfile != NULL);
|
||||||
|
|
||||||
|
@ -628,7 +621,7 @@ bool close_buffer(bool quiet)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Switch to the next file buffer. */
|
/* Switch to the next file buffer. */
|
||||||
switch_to_prevnext_buffer(TRUE, quiet);
|
switch_to_prevnext_buffer(TRUE);
|
||||||
|
|
||||||
/* Close the file buffer we had open before. */
|
/* Close the file buffer we had open before. */
|
||||||
unlink_opennode(openfile->prev);
|
unlink_opennode(openfile->prev);
|
||||||
|
|
|
@ -1138,7 +1138,7 @@ void close_and_go(void)
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_MULTIBUFFER
|
#ifndef DISABLE_MULTIBUFFER
|
||||||
/* If there are no more open file buffers, jump off a cliff. */
|
/* If there are no more open file buffers, jump off a cliff. */
|
||||||
if (!close_buffer(FALSE))
|
if (!close_buffer())
|
||||||
#endif
|
#endif
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,10 +290,9 @@ void replace_buffer(const char *filename);
|
||||||
#endif
|
#endif
|
||||||
void display_buffer(void);
|
void display_buffer(void);
|
||||||
#ifndef DISABLE_MULTIBUFFER
|
#ifndef DISABLE_MULTIBUFFER
|
||||||
void switch_to_prevnext_buffer(bool next, bool quiet);
|
|
||||||
void switch_to_prev_buffer_void(void);
|
void switch_to_prev_buffer_void(void);
|
||||||
void switch_to_next_buffer_void(void);
|
void switch_to_next_buffer_void(void);
|
||||||
bool close_buffer(bool quiet);
|
bool close_buffer(void);
|
||||||
#endif
|
#endif
|
||||||
filestruct *read_line(char *buf, size_t buf_len, filestruct *prevnode);
|
filestruct *read_line(char *buf, size_t buf_len, filestruct *prevnode);
|
||||||
void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable);
|
void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable);
|
||||||
|
|
Loading…
Reference in New Issue