1
0
forked from aniani/vim

Add file save counter to undo information. Add undotree() function.

This commit is contained in:
Bram Moolenaar
2010-06-27 01:15:55 +02:00
parent d69980f9dd
commit a800b42975
15 changed files with 355 additions and 63 deletions

View File

@@ -1944,6 +1944,7 @@ tr( {src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr}
trunc( {expr} Float truncate Float {expr}
type( {name}) Number type of variable {name}
undofile( {name}) String undo file name for {name}
undotree() List undo file tree
values( {dict}) List values in {dict}
virtcol( {expr}) Number screen column of cursor or mark
visualmode( [expr]) String last visual mode used
@@ -2349,11 +2350,13 @@ confirm({msg} [, {choices} [, {default} [, {type}]]])
choice this is 1.
Note: confirm() is only supported when compiled with dialog
support, see |+dialog_con| and |+dialog_gui|.
{msg} is displayed in a |dialog| with {choices} as the
alternatives. When {choices} is missing or empty, "&OK" is
used (and translated).
{msg} is a String, use '\n' to include a newline. Only on
some systems the string is wrapped when it doesn't fit.
{choices} is a String, with the individual choices separated
by '\n', e.g. >
confirm("Save changes?", "&Yes\n&No\n&Cancel")
@@ -2363,15 +2366,18 @@ confirm({msg} [, {choices} [, {default} [, {type}]]])
confirm("file has been modified", "&Save\nSave &All")
< For the console, the first letter of each choice is used as
the default shortcut key.
The optional {default} argument is the number of the choice
that is made if the user hits <CR>. Use 1 to make the first
choice the default one. Use 0 to not set a default. If
{default} is omitted, 1 is used.
The optional {type} argument gives the type of dialog. This
is only used for the icon of the Win32 GUI. It can be one of
these values: "Error", "Question", "Info", "Warning" or
"Generic". Only the first character is relevant. When {type}
is omitted, "Generic" is used.
The optional {type} argument gives the type of dialog. This
is only used for the icon of the GTK, Mac, Motif and Win32
GUI. It can be one of these values: "Error", "Question",
"Info", "Warning" or "Generic". Only the first character is
relevant. When {type} is omitted, "Generic" is used.
If the user aborts the dialog by pressing <Esc>, CTRL-C,
or another valid interrupt key, confirm() returns 0.
@@ -5779,6 +5785,47 @@ undofile({name}) *undofile()*
When compiled without the +persistent_undo option this always
returns an empty string.
undotree() *undotree()*
Return the current state of the undo tree in a dictionary with
the following items:
"seq_last" The highest undo sequence number used.
"seq_cur" The sequence number of the current position in
the undo tree. This differs from "seq_last"
when some changes were undone.
"time_cur" Time last used for |:earlier| and related
commands. Use |strftime()| to convert to
something readable.
"save_last" Number of the last file write. Zero when no
write yet.
"synced" Non-zero when the last undo block was synced.
This happens when waiting from input from the
user. See |undo-blocks|.
"entries" A list of dictionaries with information about
undo blocks.
The first item in the "entries" list is the oldest undo item.
Each List item is a Dictionary with these items:
"seq" Undo sequence number. Same as what appears in
|:undolist|.
"time" Timestamp when the change happened. Use
|strftime()| to convert to something readable.
"newhead" Only appears in the item that is the last one
that was added. This marks the last change
and where further changes will be added.
"curhead" Only appears in the item that is the last one
that was undone. This marks the current
position in the undo tree, the block that will
be used by a redo command. When nothing was
undone after the last change this item will
not appear anywhere.
"save" Only appears on the last block before a file
write. The number is the write count. The
first write has number 1, the last one the
"save_last" mentioned above.
"alt" Alternate entry. This is again a List of undo
blocks. Each item may again have an "alt"
item.
values({dict}) *values()*
Return a |List| with all the values of {dict}. The |List| is
in arbitrary order.

View File

@@ -7890,6 +7890,7 @@ undo-two-ways undo.txt /*undo-two-ways*
undo.txt undo.txt /*undo.txt*
undo_ftplugin usr_41.txt /*undo_ftplugin*
undofile() eval.txt /*undofile()*
undotree() eval.txt /*undotree()*
unicode mbyte.txt /*unicode*
unix os_unix.txt /*unix*
unlisted-buffer windows.txt /*unlisted-buffer*

View File

@@ -1089,14 +1089,11 @@ Vim 7.3:
Use register_shell_extension()?
Patch from Geoffrey Reilly, 2010 Jun 22
- Patch for conceal feature from Vince, 2010 June 16.
Needs some more testing.
- undofile: keep markers where the file was written/read, so that it's easy to
go back to a saved version of the file: ":earlier 1f" (f for file)?
Needs some more testing, better patch is coming.
- implement ":earlier 1f" (f for file)?
Also add ":earlier 1d" (d for day).
Something like changenr() to see the "file saved" marker?
Show "file saved" marker in :undolist
- Function to get undo tree: undotree(). List of lists. Each entry is a
dictionary: {'nr': 2, 'time': 1234, 'saved': 1}
- in August remove UF_VERSION_CRYPT_PREV and UF_VERSION_PREV.
Patches to include:
- Patch for Lisp support with ECL (Mikael Jansson, 2008 Oct 25)
- Gvimext patch to support wide file names. (Szabolcs Horvat 2008 Sep 10)

View File

@@ -135,6 +135,7 @@ This is explained in the user manual: |usr_32.txt|.
The "changes" column is the number of changes to this
leaf from the root of the tree.
The "time" column is the time this change was made.
For more details use the |undotree()| function.
*g-*
g- Go to older text state. With a count repeat that many