From 7ef56789fa447a5638b949585346182b00af37ee Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Wed, 5 Aug 2015 15:05:15 +0300 Subject: [PATCH 1/5] Implement a Tupfile to build kak with `tup` --- contrib/Tupfile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 contrib/Tupfile diff --git a/contrib/Tupfile b/contrib/Tupfile new file mode 100644 index 00000000..24adcf41 --- /dev/null +++ b/contrib/Tupfile @@ -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 From e29f8d32612d64a043f028a1db9eee579b1ea13c Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Wed, 5 Aug 2015 15:09:27 +0300 Subject: [PATCH 2/5] Fix an unecessary files listing when restoring buffers --- rc/autorestore.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/autorestore.kak b/rc/autorestore.kak index 16b54973..daa989f2 100644 --- a/rc/autorestore.kak +++ b/rc/autorestore.kak @@ -45,7 +45,7 @@ def autorestore-purge-backups -docstring "Remove all the backups of the current buffer_basename="${kak_bufname##*/}" buffer_dirname=$(dirname "${kak_bufname}") - find "${buffer_dirname}" -type f -readable -name "\.${buffer_basename}\.kak\.*" -delete 2>/dev/null + find "${buffer_dirname}" -maxdepth 1 -type f -readable -name "\.${buffer_basename}\.kak\.*" -delete 2>/dev/null } echo -color 'Information Backup files removed' } From d44214f136900933f858f8b8b8234e6dd48e5ac4 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Wed, 5 Aug 2015 17:30:21 +0300 Subject: [PATCH 3/5] Prevent the autorestore to recover backups on non-existent files --- rc/autorestore.kak | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rc/autorestore.kak b/rc/autorestore.kak index daa989f2..8956a5ac 100644 --- a/rc/autorestore.kak +++ b/rc/autorestore.kak @@ -7,6 +7,8 @@ def autorestore-restore-buffer -docstring "Restore the backup for the current fi buffer_basename="${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 ## 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 \ @@ -45,6 +47,8 @@ def autorestore-purge-backups -docstring "Remove all the backups of the current buffer_basename="${kak_bufname##*/}" buffer_dirname=$(dirname "${kak_bufname}") + 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' From d3f9cce386dd440f5ee27c8dfaada6e63be2ac61 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Wed, 5 Aug 2015 17:32:33 +0300 Subject: [PATCH 4/5] Remove a useless check for the 'yes' value of a bool option --- rc/autorestore.kak | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rc/autorestore.kak b/rc/autorestore.kak index 8956a5ac..678040a2 100644 --- a/rc/autorestore.kak +++ b/rc/autorestore.kak @@ -31,8 +31,7 @@ def autorestore-restore-buffer -docstring "Restore the backup for the current fi echo " hook -group autorestore global BufWritePost (.+/)?${kak_bufname} %{ nop %sh{ - if [ \"\${kak_opt_autorestore_purge_restored,,}\" = yes \ - -o \"\${kak_opt_autorestore_purge_restored,,}\" = true ]; then + if [ \"\${kak_opt_autorestore_purge_restored,,}\" = true ]; then rm -f '${latest_backup_path}' fi } From 46d1f438d6dd24a220df93fa28e205c8c33ad505 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 7 Aug 2015 09:18:12 +0100 Subject: [PATCH 5/5] Style tweak in autorestore.kak --- rc/autorestore.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/autorestore.kak b/rc/autorestore.kak index 678040a2..544d558e 100644 --- a/rc/autorestore.kak +++ b/rc/autorestore.kak @@ -13,10 +13,10 @@ def autorestore-restore-buffer -docstring "Restore the backup for the current fi ## 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 \ | 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 }"; exit; - } + fi ## Replace the content of the buffer with the content of the backup file echo "