From ac3da1dd9626bc475e78b18c0b438435790e8926 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 30 Mar 2020 23:16:03 +0300 Subject: [PATCH] Handle project--files-in-directory finding no files better * lisp/progmodes/project.el (project--find-regexp-in-files): Signal user-error when passed an empty list of files. * lisp/progmodes/xref.el (xref-matches-in-files): Make sure FILES is not empty. --- lisp/progmodes/project.el | 2 ++ lisp/progmodes/xref.el | 1 + 2 files changed, 3 insertions(+) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index f4678681858..1f4cbe96ad8 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -480,6 +480,8 @@ pattern to search for." nil))) (defun project--find-regexp-in-files (regexp files) + (unless files + (user-error "Empty file list")) (let ((xrefs (xref-matches-in-files regexp files))) (unless xrefs (user-error "No matches for: %s" regexp)) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 1a344563405..c36a9bd9940 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1232,6 +1232,7 @@ IGNORES is a list of glob patterns for files to ignore." "Find all matches for REGEXP in FILES. Return a list of xref values. FILES must be a list of absolute file names." + (cl-assert (consp files)) (pcase-let* ((output (get-buffer-create " *project grep output*")) (`(,grep-re ,file-group ,line-group . ,_) (car grep-regexp-alist)) -- 2.39.2