all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#60100: 29.0.60; project-current is not resilient
@ 2022-12-15 19:00 Juri Linkov
  2022-12-18  0:41 ` Dmitry Gutov
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2022-12-15 19:00 UTC (permalink / raw)
  To: 60100

Is this intentional that

```
(project-current nil "/tmp/nonexistent/")
```

raises the error

  Debugger entered--Lisp error: (file-missing "Opening directory" "No such file or directory" "/tmp/nonexistent")

instead of silently returning nil.  Because when called with
an existing non-project dir, it just returns nil:

```
(project-current nil "/tmp/") => nil
```





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

* bug#60100: 29.0.60; project-current is not resilient
  2022-12-15 19:00 bug#60100: 29.0.60; project-current is not resilient Juri Linkov
@ 2022-12-18  0:41 ` Dmitry Gutov
  2022-12-18  8:38   ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Gutov @ 2022-12-18  0:41 UTC (permalink / raw)
  To: Juri Linkov, 60100

On 15/12/2022 21:00, Juri Linkov wrote:
> Is this intentional that
> 
> ```
> (project-current nil "/tmp/nonexistent/")
> ```
> 
> raises the error
> 
>    Debugger entered--Lisp error: (file-missing "Opening directory" "No such file or directory" "/tmp/nonexistent")
> 
> instead of silently returning nil.

I would say this is expected.

How could we avoid this? By adding a file-exists-p check somewhere 
inside, right? And failing silently if it returns nil.

Right now the caller code needs to use that check. Or, more likely, 
figure out why they are passing in a directory that does not exist.

> Because when called with
> an existing non-project dir, it just returns nil:
> 
> ```
> (project-current nil "/tmp/") => nil
> ```

nil is a normal return value in this case: it means "no project here", 
that's a regular occasion. The callers who don't want to deal with nil 
should pass t as the first argument.





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

* bug#60100: 29.0.60; project-current is not resilient
  2022-12-18  0:41 ` Dmitry Gutov
@ 2022-12-18  8:38   ` Juri Linkov
  0 siblings, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2022-12-18  8:38 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 60100

tags 60100 + notabug
close 60100 29.0.60
quit

>> Is this intentional that
>> ```
>> (project-current nil "/tmp/nonexistent/")
>> ```
>> raises the error
>>    Debugger entered--Lisp error: (file-missing "Opening directory" "No
>> such file or directory" "/tmp/nonexistent")
>> instead of silently returning nil.
>
> I would say this is expected.
>
> How could we avoid this? By adding a file-exists-p check somewhere inside,
> right? And failing silently if it returns nil.
>
> Right now the caller code needs to use that check. Or, more likely, figure
> out why they are passing in a directory that does not exist.

The problem is that callers are unaware that they need to handle this case
until they get the error that then get to use file-exists-p.  But actually
this problem is not specific to project.  Many other commands fail in such
circumstances too.  For example, 'dired-jump' raises an error on a deleted
directory as well:

  (file-missing "Setting current directory" "No such file or directory")

So now closing.





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

end of thread, other threads:[~2022-12-18  8:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 19:00 bug#60100: 29.0.60; project-current is not resilient Juri Linkov
2022-12-18  0:41 ` Dmitry Gutov
2022-12-18  8:38   ` Juri Linkov

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.