unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44979: project-search fails with file-missing error
@ 2020-12-01  3:15 Dmitry Gutov
  2020-12-01 15:34 ` Eli Zaretskii
  2021-07-30 13:00 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Dmitry Gutov @ 2020-12-01  3:15 UTC (permalink / raw)
  To: 44979

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 ()





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#44979: project-search fails with file-missing error
  2020-12-01  3:15 bug#44979: project-search fails with file-missing error Dmitry Gutov
@ 2020-12-01 15:34 ` Eli Zaretskii
  2020-12-01 16:12   ` Dmitry Gutov
  2021-07-30 13:00 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2020-12-01 15:34 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 44979

> From: Dmitry Gutov <dgutov@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#44979: project-search fails with file-missing error
  2020-12-01 15:34 ` Eli Zaretskii
@ 2020-12-01 16:12   ` Dmitry Gutov
  2020-12-01 18:25     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2020-12-01 16:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 44979

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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#44979: project-search fails with file-missing error
  2020-12-01 16:12   ` Dmitry Gutov
@ 2020-12-01 18:25     ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2020-12-01 18:25 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 44979

> Cc: 44979@debbugs.gnu.org
> From: Dmitry Gutov <dgutov@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#44979: project-search fails with file-missing error
  2020-12-01  3:15 bug#44979: project-search fails with file-missing error Dmitry Gutov
  2020-12-01 15:34 ` Eli Zaretskii
@ 2021-07-30 13:00 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-30 13:00 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 44979

Dmitry Gutov <dgutov@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-30 13:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-01  3:15 bug#44979: project-search fails with file-missing error Dmitry Gutov
2020-12-01 15:34 ` Eli Zaretskii
2020-12-01 16:12   ` Dmitry Gutov
2020-12-01 18:25     ` Eli Zaretskii
2021-07-30 13:00 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).