diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-09-25 12:21:35 +0200 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2023-09-25 18:23:15 +0200 |
commit | c3d1d9445c70846d43d1f091ee0762e16513e225 (patch) | |
tree | d9a5b5b964993519f86a4d70695451c35381302a /src | |
parent | ed8b7aae8525625c17b72c3fac187c5aee8a2c5c (diff) | |
download | rneovim-c3d1d9445c70846d43d1f091ee0762e16513e225.tar.gz rneovim-c3d1d9445c70846d43d1f091ee0762e16513e225.tar.bz2 rneovim-c3d1d9445c70846d43d1f091ee0762e16513e225.zip |
refactor(options)!: graduate some more shortmess flags
A lot of updated places in the docs were already incorrect since long
since they did not reflect the default behaviour.
"[dos format]" could've been argued being better for discoverability
but that ship has already sailed as it is no longer displayed by default.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 2 | ||||
-rw-r--r-- | src/nvim/bufwrite.c | 4 | ||||
-rw-r--r-- | src/nvim/fileio.c | 21 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 7 | ||||
-rw-r--r-- | src/nvim/options.lua | 7 | ||||
-rw-r--r-- | src/nvim/optionstr.c | 5 |
6 files changed, 13 insertions, 33 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index df6ca4789b..7a3e65e10e 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3182,7 +3182,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate) (curbuf->b_flags & BF_NOTEDITED) && !dontwrite ? _("[Not edited]") : "", (curbuf->b_flags & BF_NEW) && !dontwrite - ? new_file_message() : "", + ? _("[New]") : "", (curbuf->b_flags & BF_READERR) ? _("[Read errors]") : "", curbuf->b_p_ro diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 445e946543..0c95314c52 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -1766,11 +1766,11 @@ restore_backup: xstrlcat(IObuff, _("[Device]"), IOSIZE); insert_space = true; } else if (newfile) { - xstrlcat(IObuff, new_file_message(), IOSIZE); + xstrlcat(IObuff, _("[New]"), IOSIZE); insert_space = true; } if (no_eol) { - msg_add_eol(); + xstrlcat(IObuff, _("[noeol]"), IOSIZE); insert_space = true; } // may add [unix/dos/mac] diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 011c5439ea..7ff3e0ec6e 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -459,7 +459,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, } if (!silent) { if (dir_of_file_exists(fname)) { - filemess(curbuf, sfname, new_file_message(), 0); + filemess(curbuf, sfname, _("[New]"), 0); } else { filemess(curbuf, sfname, _("[New DIRECTORY]"), 0); } @@ -1718,7 +1718,7 @@ failed: c = true; } if (read_no_eol_lnum) { - msg_add_eol(); + xstrlcat(IObuff, _("[noeol]"), IOSIZE); c = true; } if (ff_error == EOL_DOS) { @@ -2064,11 +2064,6 @@ static void check_marks_read(void) curbuf->b_marks_read = true; } -char *new_file_message(void) -{ - return shortmess(SHM_NEW) ? _("[New]") : _("[New File]"); -} - /// Set the name of the current buffer. Use when the buffer doesn't have a /// name and a ":r" or ":w" command with a file name is used. int set_rw_fname(char *fname, char *sfname) @@ -2142,17 +2137,17 @@ bool msg_add_fileformat(int eol_type) { #ifndef USE_CRNL if (eol_type == EOL_DOS) { - xstrlcat(IObuff, shortmess(SHM_TEXT) ? _("[dos]") : _("[dos format]"), IOSIZE); + xstrlcat(IObuff, _("[dos]"), IOSIZE); return true; } #endif if (eol_type == EOL_MAC) { - xstrlcat(IObuff, shortmess(SHM_TEXT) ? _("[mac]") : _("[mac format]"), IOSIZE); + xstrlcat(IObuff, _("[mac]"), IOSIZE); return true; } #ifdef USE_CRNL if (eol_type == EOL_UNIX) { - xstrlcat(IObuff, shortmess(SHM_TEXT) ? _("[unix]") : _("[unix format]"), IOSIZE); + xstrlcat(IObuff, _("[unix]"), IOSIZE); return true; } #endif @@ -2181,12 +2176,6 @@ void msg_add_lines(int insert_space, long lnum, off_T nchars) } } -/// Append message for missing line separator to IObuff. -void msg_add_eol(void) -{ - xstrlcat(IObuff, shortmess(SHM_LAST) ? _("[noeol]") : _("[Incomplete last line]"), IOSIZE); -} - bool time_differs(const FileInfo *file_info, long mtime, long mtime_ns) FUNC_ATTR_CONST { #if defined(__linux__) || defined(MSWIN) diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 14f29682e1..317bc989e5 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -240,11 +240,7 @@ typedef enum { enum { SHM_RO = 'r', ///< Readonly. SHM_MOD = 'm', ///< Modified. - SHM_FILE = 'f', ///< (file 1 of 2) - SHM_LAST = 'i', ///< Last line incomplete. - SHM_TEXT = 'x', ///< tx instead of textmode. SHM_LINES = 'l', ///< "L" instead of "lines". - SHM_NEW = 'n', ///< "[New]" instead of "[New file]". SHM_WRI = 'w', ///< "[w]" instead of "written". SHM_ABBREVIATIONS = 'a', ///< Use abbreviations from #SHM_ALL_ABBREVIATIONS. SHM_WRITE = 'W', ///< Don't use "written" at all. @@ -260,11 +256,10 @@ enum { SHM_RECORDING = 'q', ///< Short recording message. SHM_FILEINFO = 'F', ///< No file info messages. SHM_SEARCHCOUNT = 'S', ///< No search stats: '[1/10]' - SHM_LEN = 30, ///< Max length of all flags together plus a NUL character. }; /// Represented by 'a' flag. #define SHM_ALL_ABBREVIATIONS ((char[]) { \ - SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \ + SHM_RO, SHM_MOD, SHM_LINES, SHM_WRI, \ 0 }) // characters for p_go: diff --git a/src/nvim/options.lua b/src/nvim/options.lua index f0e4a5a1f4..429a70eb38 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -7239,22 +7239,17 @@ return { { abbreviation = 'shm', cb = 'did_set_shortmess', - defaults = { if_true = 'ilnxtToOCF' }, + defaults = { if_true = 'ltToOCF' }, desc = [=[ This option helps to avoid all the |hit-enter| prompts caused by file messages, for example with CTRL-G, and to avoid some other messages. It is a list of flags: flag meaning when present ~ - i use "[noeol]" instead of "[Incomplete last line]" *shm-i* l use "999L, 888B" instead of "999 lines, 888 bytes" *shm-l* m use "[+]" instead of "[Modified]" *shm-m* - n use "[New]" instead of "[New File]" *shm-n* r use "[RO]" instead of "[readonly]" *shm-r* w use "[w]" instead of "written" for file write message *shm-w* and "[a]" instead of "appended" for ':w >> file' command - x use "[dos]" instead of "[dos format]", "[unix]" *shm-x* - instead of "[unix format]" and "[mac]" instead of "[mac - format]" a all of the above abbreviations *shm-a* o overwrite message for writing a file with subsequent *shm-o* diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 2382219b55..797c3cb554 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -132,11 +132,12 @@ static char *(p_rdb_values[]) = { "compositor", "nothrottle", "invalid", "nodelt static char *(p_sloc_values[]) = { "last", "statusline", "tabline", NULL }; /// All possible flags for 'shm'. -static char SHM_ALL[] = { SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, +/// the literal chars before 0 are removed flags. these are safely ignored +static char SHM_ALL[] = { SHM_RO, SHM_MOD, SHM_LINES, SHM_WRI, SHM_ABBREVIATIONS, SHM_WRITE, SHM_TRUNC, SHM_TRUNCALL, SHM_OVER, SHM_OVERALL, SHM_SEARCH, SHM_ATTENTION, SHM_INTRO, SHM_COMPLETIONMENU, SHM_COMPLETIONSCAN, SHM_RECORDING, SHM_FILEINFO, - SHM_SEARCHCOUNT, 0, }; + SHM_SEARCHCOUNT, 'n', 'f', 'x', 'i', 0, }; /// After setting various option values: recompute variables that depend on /// option values. |