On 22:23 Sat 31 Jan , Bram Moolenaar wrote: > > Marcin - > > > Dear Bram, > > > > Some times I have lots of files opened in vim, I found it very useful to > > limit the output of `:ls` command to only modified ones, etc. The > > attached patch adds flags to the ls command which let to list files > > which are hidden or active or modified, or readonly or with nomodifiable > > set, etc. The same as what ls puts in the output. I think this might > > be useful for others as well. Let me know what do you think of it. > > Yes, that sounds useful. Thanks for the patch. > > With "overwrites the bang" I think you mean "overrules the bang". > > - Bram
Yes indeed. I updated the patch. Marcin -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index 532cca3..1284a86 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -986,9 +986,10 @@ A buffer can also be unlisted. This means it exists, but it is not in the list of buffers. |unlisted-buffer| -:files[!] *:files* -:buffers[!] *:buffers* *:ls* -:ls[!] Show all buffers. Example: +:files[!] [flag] *:files* +:buffers[!] [flag] *:buffers* *:ls* +:ls[!] [flag] + Show all buffers. Example: 1 #h "/test/text" line 1 ~ 2u "asdf" line 0 ~ @@ -1014,6 +1015,16 @@ list of buffers. |unlisted-buffer| + a modified buffer x a buffer with read errors + [flag] can be one of 'u', '%', '#', 'a', 'h', '-', '=', '+' or + 'x'. Only files with the given flag will be listed, you can + set more than one flag, e.g. > + ls + " list modified buffers + ls - " list buffers with 'modifiable' off + ls = " list readonly buffers + ls u " list unloaded buffers (overrules the bang) + ls h+ " list hidden buffers which are modified + ls a+ " list active buffers which are modified, etc +< *:bad* *:badd* :bad[d] [+lnum] {fname} Add file name {fname} to the buffer list, without loading it. diff --git a/src/buffer.c b/src/buffer.c index e4230fc..0659e9f 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2754,7 +2754,17 @@ buflist_list(eap) for (buf = firstbuf; buf != NULL && !got_int; buf = buf->b_next) { /* skip unlisted buffers, unless ! was used */ - if (!buf->b_p_bl && !eap->forceit) + if (!buf->b_p_bl && !eap->forceit && !vim_strchr((char_u *) eap->arg, 'u') || + vim_strchr((char_u *) eap->arg, 'u') && buf->b_p_bl || + vim_strchr((char_u *) eap->arg, '+') && (buf->b_flags & BF_READERR || !bufIsChanged(buf)) || + vim_strchr((char_u *) eap->arg, 'a') && (buf->b_ml.ml_mfp == NULL || buf->b_nwindows == 0) || + vim_strchr((char_u *) eap->arg, 'h') && (buf->b_ml.ml_mfp == NULL || buf->b_nwindows != 0) || + vim_strchr((char_u *) eap->arg, '-') && buf->b_p_ma || + vim_strchr((char_u *) eap->arg, '=') && !buf->b_p_ro || + vim_strchr((char_u *) eap->arg, 'x') && !(buf->b_flags & BF_READERR) || + vim_strchr((char_u *) eap->arg, '%') && buf != curbuf || + vim_strchr((char_u *) eap->arg, '#') && (buf == curbuf || curwin->w_alt_fnum != buf->b_fnum) + ) continue; msg_putchar('\n'); if (buf_spname(buf) != NULL) diff --git a/src/ex_cmds.h b/src/ex_cmds.h index 21d42d5..7945956 100644 --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -217,7 +217,7 @@ EX(CMD_browse, "browse", ex_wrongmodifier, NEEDARG|EXTRA|NOTRLCOM|CMDWIN, ADDR_LINES), EX(CMD_buffers, "buffers", buflist_list, - BANG|TRLBAR|CMDWIN, + BANG|EXTRA|TRLBAR|CMDWIN, ADDR_LINES), EX(CMD_bufdo, "bufdo", ex_listdo, BANG|NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL, @@ -526,7 +526,7 @@ EX(CMD_file, "file", ex_file, RANGE|NOTADR|ZEROR|BANG|FILE1|TRLBAR, ADDR_LINES), EX(CMD_files, "files", buflist_list, - BANG|TRLBAR|CMDWIN, + BANG|EXTRA|TRLBAR|CMDWIN, ADDR_LINES), EX(CMD_filetype, "filetype", ex_filetype, EXTRA|TRLBAR|CMDWIN, @@ -847,7 +847,7 @@ EX(CMD_lwindow, "lwindow", ex_cwindow, RANGE|NOTADR|COUNT|TRLBAR, ADDR_LINES), EX(CMD_ls, "ls", buflist_list, - BANG|TRLBAR|CMDWIN, + BANG|EXTRA|TRLBAR|CMDWIN, ADDR_LINES), EX(CMD_move, "move", ex_copymove, RANGE|WHOLEFOLD|EXTRA|TRLBAR|CMDWIN|MODIFY,
signature.asc
Description: Digital signature