Closed bhrgunatha closed 3 years ago
I've tried to find out the cause using message debugging to see what procedure are getting called with what arguments:
DIAG: (racket-xp-documentation nil)
DIAG: (get-text-property (point) ’racket-xp-doc) -> nil
DIAG: (racket--doc prefix: nil how: /home/bhrgunatha/scratch/code/test.rkt completions: nil)
DIAG: search-p nil
DIAG: (racket--symbol-at-point-or-prompt force-prompt-p: nil
prompt: Documentation for:
completions: nil
allow-blank-p: nil)
DIAG: (racket--doc-command repl-session-id: nil how: /home/bhrgunatha/scratch/code/test.rkt str: for/list)
DIAG: (racket--cmd/async repl-session-id: nil command-sexpr: (doc /home/bhrgunatha/scratch/code/test.rkt for/list) callback: (closure ((str . for/list) (how . /home/bhrgunatha/scratch/code/test.rkt) (repl-session-id) t) (maybe-url) (if maybe-url (racket-browse-url maybe-url) (racket--search-doc str))))
DIAG: (racket-browse-url (url: file:///usr/share/doc/racket/reference/for.html#(form._((lib._racket/private/base..rkt)._for/list))
args: nil)
DIAG: racket-browse-url-function: browse-url
In the scratch buffer BOTH
(browse-url "file:///usr/share/doc/racket/reference/for.html#(form._((lib._racket/private/base..rkt)._for/list))")
(browse-url "file:///usr/share/doc/racket/reference/for.html#(form._((lib._racket/private/base..rkt)._for/list))" nil)
open the browser at the correct page at the correct url-slug.
I can't understand the difference between what the code and my debugging show and the actual behaviour I see from emacs..
I'm totally stuck.
I've unstuck myself by learning how to use edebug!
If anyone else stumbles over this problem I fixed it by adding this in my config:
(setq browse-url-handlers '(("\\`file://.*\\.html?" . browse-url-default-browser)))
You should probably write something better to determine valid html documents though.
Explanation:
There is a change in how emacs' built-in browse-url
works.
The reason emacs is opening the file (instead of a browser) is because browse-url
calls browse-url-select-handler
whose behaviour has changed.
It checks these in order:
In my case because the url is a local file (file:///...) and the url doesn't end with "htm" or "html", the new behaviour falls through all the test cases to determine what to handle the url with and defaults to emacs itself as a last resort.
Note:
None of this explains why evaluating (browse-url "file:///usr/share/doc/racket/reference/for.html#(form._((lib._racket/private/base..rkt)._for/list))")
from the *scratch*
buffer opens the file in a browser, but when racket-mode calls browse-url
it fails. :(
I'm sorry I didn't comment on this issue before.
My excuse: I was focused on other things, and, this seemed like it might be less urgent due to it being for pre-release Emacs.
But I was really happy you reported this, and were even investigating -- thanks!!
I'm actually going to re-open this issue as a to-do for me to make Racket Mode work with 28.0.50 better "out-of-box". (Of course I'd understand if you want to mute this issue if you've had enough of it by now!)
Thanks again!
If you need anything from me just let me know here.
The only odd thing for me is the note in my comment above.
I've started to reload my brain with some of the history here, including #476.
Quick question: What happens if you change the customization variable racket-browse-url-function
from its default value of browse-url
to instead be racket-browse-url-using-temporary-file
?
p.s. I notice I have an open PR #530 which I should review and merge, but I think that's orthogonal to the issue you reported.
Success!
Removing
(setq browse-url-handlers '(("\\`file://.*\\.html?" . browse-url-default-browser)))
and adding
(setq racket-browse-url-function 'racket-browse-url-using-temporary-file)
Opens the correct local racket html documentation file (including the # slug) at the correct anchor within the document in my browser.
Interesting. Probably I should just default that to racket-browse-url-using-temporary-file
on Linux, as well.
I notice I also have recent-ish open PR #530 I need to review and merge.
I'll try to tackle both items today.
Thanks again for your help!
I'm not sure if this is a true bug or just a heads-up for a potential future problem. (I did see you mention using emacs 28 in a different issue though) so I thought I'd post here as it's currently affecting
racket-mode
for me.racket-xp-documentation
behaves differently with the native comp branch of emacs 28 from emacs 27.2.racket-xp-documentation
(whether keyboard shortcut orM-x racket-xp-documentation
I see messages in the echo area and a new fundamental mode buffer appears in a window (split to the right). An example looking forfor/list
documentation opens a buffer named "list))" and is visiting "file:///usr/share/doc/racket/reference/for.html#(form._((lib._racket/private/base..rkt)._for/list))" - which is the correct file and the correct url slug!I see 2 messages "File exists, but cannot be read" then a longer message "File mode specification error: (file-error Setting current directory Not a directory file:///usr/share/doc/racket/reference/for.html#(form.((lib._racket/private/base..rkt)._for/)".
After repeatedly trying to open documentation the messages can change e.g. if I try documentation for for/list followed by for/or - the message says "file:///...for/html#..._for./or" and file file:///...for/html#..._for./list are the same file. I think the underlying problem of opening the OS file in a buffer instead of a browser is the same.
racket-bug-report
Steps to reproduce:
Open it with
racket -mode
andracket-xp-mode
. Put cursor onfor/list
- hitC-c C-d
orM-x racket-xp-documentation
.My racket-mode config has:
I do use e.g. paredit and company as well as other too.
Using the Arch linux default emacs package - 27.2 works fine!
I compiled the native comp branch of 28.0.5 using the AUR package but basically all that does is compile the current state of the native comp branch. I understand that's different every time it's compiled but I see the same behaviour each time.