From 7da7bcb4c1328897d3c9f4d736ae214bb72fa166 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 26 Jul 2015 23:38:10 +0200 Subject: [PATCH] Do not display recent files if there aren't any Signed-off-by: Sebastian Ramacher --- doc/man/conf.py | 14 ++++++++++++++ zathura/completion.c | 19 ++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/doc/man/conf.py b/doc/man/conf.py index d149036..743031b 100644 --- a/doc/man/conf.py +++ b/doc/man/conf.py @@ -2,11 +2,25 @@ # # See LICENSE file for license and copyright information +import os.path +import glob +import time + +dirname = os.path.dirname(__file__) +files = glob.glob(os.path.join(dirname, '*.rst')) +files.extend(glob.glob(os.path.join(dirname, '*.txt'))) + +maxdate = 0 +for path in files: + s = os.stat(path) + maxdate = max(maxdate, s.st_mtime) + # -- General configuration ------------------------------------------------ source_suffix = '.rst' master_doc = 'zathura.1' templates_path = ['_templates'] +today = time.strftime('%Y-%m-%d', time.gmtime(maxdate)) # -- Project configuration ------------------------------------------------ diff --git a/zathura/completion.c b/zathura/completion.c index d85735c..696aabb 100644 --- a/zathura/completion.c +++ b/zathura/completion.c @@ -196,13 +196,18 @@ list_files_for_cc(zathura_t* zathura, const char* input, bool check_file_ext, in goto error_free; } - const size_t path_len = strlen(path); - GIRARA_LIST_FOREACH(recent_files, const char*, iter, file) - if (strncmp(path, file, path_len) == 0) { - girara_completion_group_add_element(history_group, file, NULL); - } - GIRARA_LIST_FOREACH_END(recent_files, const char*, iter, file); - girara_list_free(recent_files); + if (girara_list_size(recent_files) != 0) { + const size_t path_len = strlen(path); + GIRARA_LIST_FOREACH(recent_files, const char*, iter, file) + if (strncmp(path, file, path_len) == 0) { + girara_completion_group_add_element(history_group, file, NULL); + } + GIRARA_LIST_FOREACH_END(recent_files, const char*, iter, file); + girara_list_free(recent_files); + } else { + girara_completion_group_free(history_group); + history_group = NULL; + } } g_free(path);