Discussion:
How do I set a timeout for `ffap-machine-p'?
Daniel King
2018-10-29 16:33:10 UTC
Permalink
Hello!

I can rather easily make Emacs unresponsive for tens of seconds. I would like to prevent this behavior. I have isolated the cause of the behavior. I can also reproduce this behavior in vanilla Emacs:

1. start emacs: `emacs --no-init-file'
2. switch to the scratch buffer
3. type `gcr.io' on an empty line
4. move point to the `g' in `gcr.io’
5. execute `M-x find-file-at-point’

The messages buffer shows:

Pinging gcr.io (British Indian Ocean Territory)...
ffap-machine-p: Failed connect: Operation timed out

If I smash C-g several times I can prevent the second message from appearing; however, doing so does not seem to decrease the time I spend waiting. In fact, I would expect C-g to immediately cancel the network operation. I just timed this and I had to wait 80 seconds before Emacs responded to my commands.

Anyway, I’d like to set the timeout for `ffap-machine-p' to 1 second. For now, I’ve disabled this by setting `ffap-machine-p-known' to `'reject'.

I looked around a bit at docs for `open-network-stream', but don’t see anyway to specify a timeout. Moreover, there does not appear to be any way to configure the call within `ffap-machine-p', https://github.com/emacs-mirror/emacs/blob/master/lisp/ffap.el#L460 <https://github.com/emacs-mirror/emacs/blob/master/lisp/ffap.el#L460>.

Thanks!
--
Dan

Loading...