Merge branch 'master' of github.com:mawww/kakoune

This commit is contained in:
Maxime Coste 2015-08-09 23:20:10 +01:00
commit f5e4562bd9
2 changed files with 55 additions and 5 deletions

47
contrib/Tupfile Normal file
View File

@ -0,0 +1,47 @@
##
## Tupfile for kakoune
## by lenormf
##
## How to use:
## Initialize a tup database in the main directory with `tup init`
## Create a symlink from `contrib/Tupfile` to `src/Tupfile`
## Start the build with the `tup` command
##
.gitignore
debug = yes
CXX = g++
CXXFLAGS = -std=gnu++11 -Wall -Wno-reorder -Wno-sign-compare -pedantic
CPPFLAGS =
LDFLAGS =
LIBS =
ifeq ($(debug),yes)
CXXFLAGS += -O0 -g
CPPFLAGS += -DKAK_DEBUG
else
CXXFLAGS += -O3
endif
ifeq (@(TUP_PLATFORM),macosx)
LIBS += -lncurses -lboost_regex-mt
else
ifeq (@(TUP_PLATFORM),win32)
LIBS += -lncursesw -lboost_regex -ldbghelp
else
LIBS += -lncursesw -lboost_regex
CPPFLAGS += -I/usr/include/ncursesw
ifeq ($(CXX),g++)
LDFLAGS += -rdynamic
endif
endif
endif
!cxx = |> $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c %f -o %o |>
!ld = |> $(CXX) $(LDFLAGS) $(LIBS) %f -o %o |>
:foreach *.cc |> !cxx |> obj/%B.o {objects}
:{objects} |> !ld |> kak

View File

@ -7,14 +7,16 @@ def autorestore-restore-buffer -docstring "Restore the backup for the current fi
buffer_basename="${kak_bufname##*/}" buffer_basename="${kak_bufname##*/}"
buffer_dirname=$(dirname "${kak_bufname}") buffer_dirname=$(dirname "${kak_bufname}")
test ! -f "${kak_bufname}" && exit
## Find the name of the latest backup created for the buffer that was open ## Find the name of the latest backup created for the buffer that was open
## The backup file has to have been last modified more recently than the file we are editing ## The backup file has to have been last modified more recently than the file we are editing
latest_backup_path=$(find "${buffer_dirname}" -maxdepth 1 -type f -readable -newer "${kak_bufname}" -name "\.${buffer_basename}\.kak\.*" -printf '%A@/%p\n' 2>/dev/null \ latest_backup_path=$(find "${buffer_dirname}" -maxdepth 1 -type f -readable -newer "${kak_bufname}" -name "\.${buffer_basename}\.kak\.*" -printf '%A@/%p\n' 2>/dev/null \
| sort -n -t. -k1 | sed -nr 's/^[^\/]+\///;$p') | sort -n -t. -k1 | sed -nr 's/^[^\/]+\///;$p')
test ! -z "${latest_backup_path}" || { if [ -z "${latest_backup_path}" ]; then
echo "eval -draft %{ autorestore-purge-backups }"; echo "eval -draft %{ autorestore-purge-backups }";
exit; exit;
} fi
## Replace the content of the buffer with the content of the backup file ## Replace the content of the buffer with the content of the backup file
echo " echo "
@ -29,8 +31,7 @@ def autorestore-restore-buffer -docstring "Restore the backup for the current fi
echo " echo "
hook -group autorestore global BufWritePost (.+/)?${kak_bufname} %{ hook -group autorestore global BufWritePost (.+/)?${kak_bufname} %{
nop %sh{ nop %sh{
if [ \"\${kak_opt_autorestore_purge_restored,,}\" = yes \ if [ \"\${kak_opt_autorestore_purge_restored,,}\" = true ]; then
-o \"\${kak_opt_autorestore_purge_restored,,}\" = true ]; then
rm -f '${latest_backup_path}' rm -f '${latest_backup_path}'
fi fi
} }
@ -45,7 +46,9 @@ def autorestore-purge-backups -docstring "Remove all the backups of the current
buffer_basename="${kak_bufname##*/}" buffer_basename="${kak_bufname##*/}"
buffer_dirname=$(dirname "${kak_bufname}") buffer_dirname=$(dirname "${kak_bufname}")
find "${buffer_dirname}" -type f -readable -name "\.${buffer_basename}\.kak\.*" -delete 2>/dev/null test ! -f "${kak_bufname}" && exit
find "${buffer_dirname}" -maxdepth 1 -type f -readable -name "\.${buffer_basename}\.kak\.*" -delete 2>/dev/null
} }
echo -color 'Information Backup files removed' echo -color 'Information Backup files removed'
} }