GNU bug report logs - #44979
project-search fails with file-missing error

Previous Next

Package: emacs;

Reported by: Dmitry Gutov <dgutov <at> yandex.ru>

Date: Tue, 1 Dec 2020 03:16:02 UTC

Severity: normal

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 44979 in the body.
You can then email your comments to 44979 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#44979; Package emacs. (Tue, 01 Dec 2020 03:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dmitry Gutov <dgutov <at> yandex.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 01 Dec 2020 03:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: project-search fails with file-missing error
Date: Tue, 1 Dec 2020 05:15:50 +0200
I have a few broken symlinks in the current project, and when doing a 
search, it stops at the first one it sees, with a backtrace like

(file-missing "Opening input file" "No such file or directory" 
"etc/etc/etc")
  insert-file-contents("etc/etc/etc" nil)
  (if (not (and new novisit)) (set-buffer (find-file-noselect next)) 
(set-buffer (get-buffer-create " *next-file*")) 
(kill-all-local-variables) (erase-buffer) (setq new next) 
(insert-file-contents new nil))
  (let* ((buffer (get-file-buffer next)) (new (not buffer))) (and 
buffer fileloop-revert-buffers (not (verify-visited-file-modtime 
buffer)) (if (eq fileloop-revert-buffers 'silent) (and (not 
(buffer-modified-p buffer)) (let ((revertible nil)) (let 
((--dolist-tail-- revert-without-query)) (while --dolist-tail-- (let ... 
... ...))) revertible)) (y-or-n-p (format (if (buffer-modified-p buffer) 
"File %s changed on disk.  Discard your edits? " "File %s changed on 
disk.  Reread from disk? ") next))) (save-current-buffer (set-buffer 
buffer) (revert-buffer t t))) (if (not (and new novisit)) (set-buffer 
(find-file-noselect next)) (set-buffer (get-buffer-create " 
*next-file*")) (kill-all-local-variables) (erase-buffer) (setq new next) 
(insert-file-contents new nil)) new)
  (let ((next (condition-case nil (iter-next fileloop--iterator) 
(iter-end-of-sequence nil)))) (if next nil (and novisit (get-buffer " 
*next-file*") (kill-buffer " *next-file*")) (user-error "All files 
processed")) (let* ((buffer (get-file-buffer next)) (new (not buffer))) 
(and buffer fileloop-revert-buffers (not (verify-visited-file-modtime 
buffer)) (if (eq fileloop-revert-buffers 'silent) (and (not 
(buffer-modified-p buffer)) (let ((revertible nil)) (let (...) (while 
--dolist-tail-- ...)) revertible)) (y-or-n-p (format (if 
(buffer-modified-p buffer) "File %s changed on disk.  Discard your 
edits? " "File %s changed on disk.  Reread from disk? ") next))) 
(save-current-buffer (set-buffer buffer) (revert-buffer t t))) (if (not 
(and new novisit)) (set-buffer (find-file-noselect next)) (set-buffer 
(get-buffer-create " *next-file*")) (kill-all-local-variables) 
(erase-buffer) (setq new next) (insert-file-contents new nil)) new))
  fileloop-next-file(t)

Not such what's the best solution, but either all commands which use 
fileloop should pre-filter the list with file-exists-p, or 
fileloop-next-file should skip over nonexistent files. This seems to work:

diff --git a/lisp/fileloop.el b/lisp/fileloop.el
index b778eca8e9..289df6d593 100644
--- a/lisp/fileloop.el
+++ b/lisp/fileloop.el
@@ -120,7 +120,10 @@ fileloop-next-file
         (kill-all-local-variables)
         (erase-buffer)
         (setq new next)
-        (insert-file-contents new nil))
+        (condition-case nil
+            (insert-file-contents new nil)
+          (file-missing
+           (fileloop-next-file novisit))))
       new)))

 (defun fileloop-continue ()




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44979; Package emacs. (Tue, 01 Dec 2020 15:35:01 GMT) Full text and rfc822 format available.

Message #8 received at 44979 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 44979 <at> debbugs.gnu.org
Subject: Re: bug#44979: project-search fails with file-missing error
Date: Tue, 01 Dec 2020 17:34:11 +0200
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> Date: Tue, 1 Dec 2020 05:15:50 +0200
> 
> Not such what's the best solution, but either all commands which use 
> fileloop should pre-filter the list with file-exists-p, or 
> fileloop-next-file should skip over nonexistent files. This seems to work:

If we want to fix this in fileloop, I think it should be conditioned
on some variable, so that packages could opt-in to and opt-out of this
behavior.  I see no reason to assume that every application using
fileloop will always want to silently skip such files.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44979; Package emacs. (Tue, 01 Dec 2020 16:13:02 GMT) Full text and rfc822 format available.

Message #11 received at 44979 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 44979 <at> debbugs.gnu.org
Subject: Re: bug#44979: project-search fails with file-missing error
Date: Tue, 1 Dec 2020 18:12:20 +0200
On 01.12.2020 17:34, Eli Zaretskii wrote:
> If we want to fix this in fileloop, I think it should be conditioned
> on some variable, so that packages could opt-in to and opt-out of this
> behavior.  I see no reason to assume that every application using
> fileloop will always want to silently skip such files.

TBH, I'm okay with any kind of fix.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44979; Package emacs. (Tue, 01 Dec 2020 18:26:02 GMT) Full text and rfc822 format available.

Message #14 received at 44979 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 44979 <at> debbugs.gnu.org
Subject: Re: bug#44979: project-search fails with file-missing error
Date: Tue, 01 Dec 2020 20:25:32 +0200
> Cc: 44979 <at> debbugs.gnu.org
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> Date: Tue, 1 Dec 2020 18:12:20 +0200
> 
> On 01.12.2020 17:34, Eli Zaretskii wrote:
> > If we want to fix this in fileloop, I think it should be conditioned
> > on some variable, so that packages could opt-in to and opt-out of this
> > behavior.  I see no reason to assume that every application using
> > fileloop will always want to silently skip such files.
> 
> TBH, I'm okay with any kind of fix.

I'm okay with the patch you proposed, just let's add a variable that
can be used to disable the silent skipping of non-existing files.

And this probably needs a NEWS entry.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44979; Package emacs. (Fri, 30 Jul 2021 13:01:01 GMT) Full text and rfc822 format available.

Message #17 received at 44979 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 44979 <at> debbugs.gnu.org
Subject: Re: bug#44979: project-search fails with file-missing error
Date: Fri, 30 Jul 2021 15:00:32 +0200
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> Not such what's the best solution, but either all commands which use
> fileloop should pre-filter the list with file-exists-p, or
> fileloop-next-file should skip over nonexistent files. This seems to
> work:
>
> diff --git a/lisp/fileloop.el b/lisp/fileloop.el
> index b778eca8e9..289df6d593 100644
> --- a/lisp/fileloop.el
> +++ b/lisp/fileloop.el
> @@ -120,7 +120,10 @@ fileloop-next-file
>          (kill-all-local-variables)
>          (erase-buffer)
>          (setq new next)
> -        (insert-file-contents new nil))
> +        (condition-case nil
> +            (insert-file-contents new nil)
> +          (file-missing
> +           (fileloop-next-file novisit))))

I think this makes sense, so I've pushed it to Emacs 28.  Eli noted that
there may be libraries using fileloop that doesn't want this behaviour,
but I'm having problems envisioning any.  If this turns out to be a
problem, we can add a variable to allow tweaking this behaviour, but I
think it's premature to add one before it's shown that there's a demand
for one.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 44979 <at> debbugs.gnu.org and Dmitry Gutov <dgutov <at> yandex.ru> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 30 Jul 2021 13:01:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 28 Aug 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 238 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.