greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, packages, and more.
https://www.racket-mode.com/
GNU General Public License v3.0
682 stars 93 forks source link

Documentation path issues #488

Closed bhrgunatha closed 3 years ago

bhrgunatha commented 4 years ago

emacs: 27.1 racket-mode: 20200810 1513 (installed from MELPA) I'm on Linux using the official Arch kernel 5.8

racket-bug-report contents:

``` ((alist-get 'racket-mode package-alist) #s(package-desc racket-mode (20200810 1513) "Racket editing, REPL, and more" ((emacs (25 1)) (faceup (0 0 2)) (pos-tip (20191127 1028))) nil nil "/home/bhrgunatha/.emacs.d/.cask/27.1/elpa/racket-mode-20200810.1513" ((:url . "https://www.racket-mode.com/") (:maintainer "Greg Hendershott") (:authors ("Greg Hendershott")) (:commit . "c55fd70c5e9a371f262486f7d5d8837481388b95")) nil)) ((emacs-version "27.1") (system-type gnu/linux) (x-gtk-use-system-tooltips t) (major-mode racket-mode) (racket--el-source-dir "/home/bhrgunatha/.emacs.d/.cask/27.1/elpa/racket-mode-20200810.1513/") (racket--rkt-source-dir "/home/bhrgunatha/.emacs.d/.cask/27.1/elpa/racket-mode-20200810.1513/racket/") (racket-program "racket") (racket-command-timeout 10) (racket-xp-after-change-refresh-delay 1) (racket-xp-highlight-unused-regexp "^[^_]") (racket-repl-buffer-name-function nil) (racket-memory-limit 8192) (racket-error-context medium) (racket-history-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'") (racket-images-inline t) (racket-images-keep-last 100) (racket-images-system-viewer "display") (racket-images-system-viewer "display") (racket-use-repl-submit-predicate nil) (racket-pretty-print t) (racket-indent-curly-as-sequence t) (racket-indent-sequence-depth 0) (racket-pretty-lambda nil) (racket-smart-open-bracket-enable nil) (racket-module-forms "\\s(\\(?:module[*+]?\\|library\\)") (racket-logger-config ((cm-accomplice . warning) (GC . info) (module-prefetch . warning) (optimizer . info) (racket/contract . error) (sequence-specialization . info) (* . fatal))) (racket-show-functions (racket-show-pseudo-tooltip))) (enabled-minor-modes (auto-composition-mode) (auto-compression-mode) (auto-encryption-mode) (auto-fill-mode) (auto-save-mode) (company-mode) (delete-selection-mode) (display-line-numbers-mode) (electric-indent-mode) (file-name-shadow-mode) (font-lock-mode) (global-company-mode) (global-display-line-numbers-mode) (global-eldoc-mode) (global-font-lock-mode) (global-hl-line-mode) (global-visual-line-mode) (hs-minor-mode) (ido-vertical-mode) (ivy-mode) (line-number-mode) (menu-bar-mode) (mouse-wheel-mode) (paredit-mode) (pcre-mode) (pyvenv-mode) (racket-xp-mode) (rainbow-delimiters-mode) (recentf-mode) (shell-dirtrack-mode) (show-paren-mode) (tooltip-mode) (transient-mark-mode) (visual-line-mode) (yas-global-mode) (yas-minor-mode)) (disabled-minor-modes (abbrev-mode) (auto-fill-function) (auto-save-visited-mode) (blink-cursor-mode) (buffer-read-only) (cl-old-struct-compat-mode) (column-number-mode) (company-search-mode) (compilation-minor-mode) (compilation-shell-minor-mode) (completion-in-region-mode) (counsel-mode) (defining-kbd-macro) (diff-auto-refine-mode) (diff-minor-mode) (dired-hide-details-mode) (eldoc-mode) (electric-layout-mode) (electric-quote-mode) (elpy-django) (elpy-mode) (flymake-mode) (global-prettify-symbols-mode) (highlight-indentation-current-column-mode) (highlight-indentation-mode) (hl-line-mode) (horizontal-scroll-bar-mode) (ido-everywhere) (isearch-mode) (jit-lock-debug-mode) (next-error-follow-minor-mode) (overwrite-mode) (package-build-minor-mode) (paragraph-indent-minor-mode) (prettify-symbols-mode) (pyvenv-tracking-mode) (racket-smart-open-bracket-mode) (rxt--read-pcre-mode) (rxt-global-mode) (rxt-mode) (server-mode) (sh-electric-here-document-mode) (show-smartparens-global-mode) (show-smartparens-mode) (size-indication-mode) (smartparens-global-mode) (smartparens-global-strict-mode) (smartparens-mode) (smartparens-strict-mode) (tab-bar-history-mode) (tab-bar-mode) (temp-buffer-resize-mode) (tool-bar-mode) (unify-8859-on-decoding-mode) (unify-8859-on-encoding-mode) (url-handler-mode) (use-hard-newlines) (view-mode) (visible-mode) (window-divider-mode) (xref-etags-mode)) ```

The only configuration for racket-mode I have is:

(require 'racket-xp)
(add-hook 'racket-mode-hook #'racket-xp-mode)
(add-hook 'racket-mode-hook #'bhr/configure-racket)
...
...
(defun bhr/configure-racket ()
  (interactive)
  (set-face-attribute 'racket-keyword-argument-face  nil :foreground "DeepSkyBlue3")
  (set-face-attribute 'racket-selfeval-face  nil :foreground "gold3")
  (define-key racket-mode-map (kbd "C-M-\\")   #'racket-insert-lambda)
  (setq racket-memory-limit 8192))

While editing a racket file with the point on a for/fold I hit C-c C-d (bound to racket-xp-documentation) and an error occurs. I'm sorry for this screenshot but I can't copy the text from the dialogue (not sure if that's an emacs issue or my desktop environment - XFCE 4.14).

Edit: Screenshot image added to the bug report: image

DrRacket successfully open the correct URI: file:///home/bhrgunatha/.racket/7.8/doc/search/index.html?q=for%2Ffold

The error report seems to indicate a malformed URI - notice it ends with for%252Ffold - what's weird is %25 is URI encoding for a space and %2F is a standard '/' so I'm not sure why it's displaying %252F - that seems wrong.

In a REPL, buffer, putting the point on for/fold and hitting C-c C-d (bound to racket-repl-documentation) opens the following file: file:///usr/share/doc/racket/reference/for.html#(form._((lib._racket/private/base..rkt)._for/fold))

I also have a couple of questions.

  1. Why are the REPL and edit buffers looking in different locations for documentation?
  2. Why is the edit buffer issuing a search for the keyword and the REPL opens the for/fold documentation directly?
greghendershott commented 4 years ago

Thanks for reporting.

Although I have seen something like this happen, I haven't seen it recently and haven't been able to track it down (not being able to reproduce it again).

The extra %25 space seems like a potentially helpful clue -- thanks!

  1. What is the minimal buffer text where you can make it happen?

    I can't repro the problem with just

    #lang racket/base
    for/fold

    ... can you?

  2. In a buffer where you can make the problem happen, could you please try this:

    Move point to the for/fold and press C-u C-x =. In the resulting *Help* buffer, where it describes text properties, is there a racket-xp-doc property and if so what is its value?

    (Normally, it would be something like ("/home/greg/racket/7.7/doc/reference/for.html" "(form._((lib._racket/private/base..rkt)._for/fold))"). This value comes from the drracket/check-syntax library. If such a value exists, we use it to open the docs directly. If not, we go to the search page -- which seems to be the scenario you're describing.)

bhrgunatha commented 4 years ago

I'm sorry. I think it must have been a weird transient issue because I can't reproduce the error myself now. This morning, even after restarting emacs, it was occuring, but now after returning several hours later it's not.

There is a difference though. The earlier error report was using the racket docs in my home directory under /home/bhrgunatha/.racket/7.8, (as was DrRacket!) but now that it's no longer causing an error, it's opening up the system racket docs under /usr/share/doc/racket/reference/

I'll monitor for a day or so and if it repeats I'll check for racket-xp-doc, if not I'll close the issue.

greghendershott commented 4 years ago

Thanks for following up.

If it does recur, even if you can't reproduce it consistently, please do let me know.

p.s. It's also interesting that, in the error dialog, the URI at the bottom looks correct -- only the bold, bigger, first one has the URI encoding of the query parameter portion, including the extra %25. I'm not clear exactly what is issuing that error dialog -- emacs or your browser or XFCE or what -- but whatever it is does seem to know the correct URL... as well as the bad one. Weird.

bhrgunatha commented 4 years ago

It's been 4 days now and I haven;t had any repeat. I'll close this report assuming some weird state in either emacs or the buffer in question was causing the problem. Thanks for your quick support though I appreciate it!

sarna commented 3 years ago

I'm having similar issues.

racket-bug-report:

``` ((alist-get 'racket-mode package-alist)) ((emacs-version "27.1") (system-type gnu/linux) (x-gtk-use-system-tooltips nil) (major-mode racket-mode) (racket--el-source-dir "/home/me/.emacs.d/.local/straight/build/racket-mode/") (racket--rkt-source-dir "/home/me/.emacs.d/.local/straight/build/racket-mode/racket/") (racket-program "racket") (racket-command-timeout 10) (racket-xp-after-change-refresh-delay 1) (racket-xp-highlight-unused-regexp "^[^_]") (racket-repl-buffer-name-function nil) (racket-memory-limit 2048) (racket-error-context medium) (racket-history-filter-regexp "\\`\\s *\\'") (racket-images-inline t) (racket-images-keep-last 100) (racket-images-system-viewer "display") (racket-images-system-viewer "display") (racket-use-repl-submit-predicate nil) (racket-pretty-print t) (racket-indent-curly-as-sequence t) (racket-indent-sequence-depth 0) (racket-pretty-lambda nil) (racket-smart-open-bracket-enable nil) (racket-module-forms "\\s(\\(?:module[*+]?\\|library\\)") (racket-logger-config ((cm-accomplice . warning) (GC . info) (module-prefetch . warning) (optimizer . info) (racket/contract . error) (sequence-specialization . info) (* . fatal))) (racket-show-functions (racket-show-pseudo-tooltip))) (enabled-minor-modes (+popup-mode) (async-bytecomp-package-mode) (auto-composition-mode) (auto-compression-mode) (auto-encryption-mode) (auto-fill-mode) (auto-save-mode) (better-jumper-local-mode) (better-jumper-mode) (centaur-tabs-mode) (column-number-mode) (company-mode) (display-line-numbers-mode) (doom-modeline-mode) (dtrt-indent-mode) (electric-indent-mode) (emojify-mode) (evil-escape-mode) (evil-goggles-mode) (evil-local-mode) (evil-mode) (evil-snipe-local-mode) (evil-snipe-mode) (evil-snipe-override-local-mode) (evil-snipe-override-mode) (evil-surround-mode) (file-name-shadow-mode) (flycheck-mode) (flycheck-popup-tip-mode) (font-lock-mode) (gcmh-mode) (general-override-mode) (global-company-mode) (global-eldoc-mode) (global-emojify-mode) (global-evil-surround-mode) (global-flycheck-mode) (global-font-lock-mode) (global-git-commit-mode) (global-magit-file-mode) (global-so-long-mode) (global-undo-fu-session-mode) (highlight-indent-guides-mode) (highlight-numbers-mode) (highlight-quoted-mode) (hl-line-mode) (hl-todo-mode) (hs-minor-mode) (ivy-mode) (ivy-rich-mode) (line-number-mode) (mouse-wheel-mode) (persp-mode) (projectile-mode) (racket-smart-open-bracket-mode) (rainbow-delimiters-mode) (recentf-mode) (save-place-mode) (savehist-mode) (shell-dirtrack-mode) (show-paren-mode) (size-indication-mode) (smartparens-global-mode) (smartparens-mode) (solaire-global-mode) (solaire-mode) (transient-mark-mode) (treemacs-filewatch-mode) (treemacs-fringe-indicator-mode) (treemacs-git-mode) (undo-fu-mode) (undo-fu-session-mode) (vi-tilde-fringe-mode) (which-key-mode) (whitespace-mode) (window-divider-mode) (winner-mode) (ws-butler-global-mode) (ws-butler-mode) (xclip-mode) (xterm-mouse-mode) (yas-minor-mode)) (disabled-minor-modes (+ansible-yaml-mode) (+emacs-lisp-ert-mode) (+lsp-optimization-mode) (+popup-buffer-mode) (abbrev-mode) (ace-window-display-mode) (ace-window-mode) (amx-debug-mode) (amx-mode) (archive-subfile-mode) (auto-fill-function) (auto-revert-mode) (auto-revert-tail-mode) (auto-save-visited-mode) (avy-linum-mode) (blink-cursor-mode) (buffer-face-mode) (buffer-read-only) (centaur-tabs-local-mode) (cl-old-struct-compat-mode) (company-search-mode) (compilation-minor-mode) (compilation-shell-minor-mode) (completion-in-region-mode) (counsel-mode) (cursor-intangible-mode) (cursor-sensor-mode) (defining-kbd-macro) (delete-selection-mode) (diff-auto-refine-mode) (diff-minor-mode) (dired-hide-details-mode) (dtrt-indent-global-mode) (eldoc-mode) (electric-layout-mode) (electric-quote-mode) (emojify-debug-mode) (emojify-mode-line-mode) (evil-magit-toggle-text-minor-mode) (flyspell-mode) (general-override-local-mode) (git-commit-mode) (global-auto-revert-mode) (global-display-line-numbers-mode) (global-emojify-mode-line-mode) (global-hide-mode-line-mode) (global-hl-line-mode) (global-hl-todo-mode) (global-prettify-symbols-mode) (global-reveal-mode) (global-vi-tilde-fringe-mode) (global-visual-line-mode) (global-whitespace-mode) (global-whitespace-newline-mode) (hide-mode-line-mode) (horizontal-scroll-bar-mode) (ibuffer-auto-mode) (ido-everywhere) (isearch-mode) (ispell-minor-mode) (jit-lock-debug-mode) (magit-auto-revert-mode) (magit-blame-mode) (magit-blame-read-only-mode) (magit-blob-mode) (magit-file-mode) (magit-popup-help-mode) (magit-todos-mode) (magit-wip-after-apply-mode) (magit-wip-after-save-local-mode) (magit-wip-after-save-mode) (magit-wip-before-change-mode) (magit-wip-initial-backup-mode) (magit-wip-mode) (mail-abbrevs-mode) (menu-bar-mode) (mml-mode) (next-error-follow-minor-mode) (org-capture-mode) (org-cdlatex-mode) (org-list-checkbox-radio-mode) (org-src-mode) (org-table-follow-field-mode) (org-table-header-line-mode) (orgtbl-mode) (outline-minor-mode) (overwrite-mode) (paragraph-indent-minor-mode) (pcre-mode) (prettify-symbols-mode) (racket-xp-mode) (rectangle-mark-mode) (reveal-mode) (rxt--read-pcre-mode) (rxt-global-mode) (rxt-mode) (server-mode) (sh-electric-here-document-mode) (shell-command-with-editor-mode) (show-smartparens-global-mode) (show-smartparens-mode) (smartparens-global-strict-mode) (smartparens-strict-mode) (smerge-mode) (so-long-minor-mode) (tab-bar-history-mode) (tab-bar-mode) (tar-subfile-mode) (temp-buffer-resize-mode) (text-scale-mode) (tool-bar-mode) (tooltip-mode) (transient-resume-mode) (treemacs-follow-mode) (treemacs-tag-follow-mode) (unify-8859-on-decoding-mode) (unify-8859-on-encoding-mode) (url-handler-mode) (use-hard-newlines) (vc-parent-buffer) (view-mode) (visible-mode) (visual-line-mode) (which-function-mode) (whitespace-newline-mode) (with-editor-mode) (xref-etags-mode) (yas-global-mode)) ```

When opening a file with real code, I get this in the message buffer:

Suspicious state from syntax checker racket: Flycheck checker racket returned 1, but its output contained no errors: open-input-file: cannot open module file
  module path: /home/me/other/foo.rkt
  path: /home/me/other/foo.rkt
  system error: no such file or directory; rktio_err=3
  context...:
   maybe-raise-missing-module
   default-load-handler
   standard-module-name-resolver
   module-path-index-resolve
   perform-require!
   for-loop
   finish
   [repeats 3 more times]
   pass-1-and-2-loop
   module-begin-k
   expand-module
   expand-submodule
   loop
   [repeats 2 more times]
   module-begin-k
   expand-module
   ...

Try installing a more recent version of racket, and please open a bug report if the issue persists in the latest release.  Thanks!

I have Racket 7.8.

With that for/fold minimal example, when I try to use racket-xp-describe, I get

racket--cmd/await: describe: broke its own contract
  promised: string?
  produced: #f
  in: the range of
      (->
       (or/c
        (or/c 'namespace path-string?)
        (cons/c path-string? string?)
        (list/c path-string?))
       string?
       string?)
  contract from: (function describe)
  blaming: (function describe)
   (assuming the contract is correct)
  at: /home/me/.emacs.d/.local/straight/build/racket-mode/racket/commands/describe.rkt:57.18

It's really frustrating, as it breaks randomly and nuking .emacs.d doesn't help.

EDIT: I'm using pretty much vanilla Doom Emacs, here's the Racket module: https://github.com/hlissner/doom-emacs/tree/develop/modules/lang/racket

greghendershott commented 3 years ago
  1. The first error message appears to be from flycheck, not Racket Mode, and AFAIK flycheck doesn't utilize Racket Mode. So I think that's its own separate problem. Definitely a separate issue, and probably not even one for this repo. Actually one idea here would be simply to disable flycheck in racket-mode buffers? AFAIK it doesn't add much beyond the minor mode racket-xp-mode, which it appears you're using? (Of course if I'm mistaken about it not adding much value, please let me know!)

  2. As for the second error message: I spent more time prodding this. I can reproduce this in one scenario --- when the source file has an error preventing it from expanding (e.g. when the mode-line for the buffer is showing Rkt✗ in red). Presumably whatever problem is causing expansion failure for flycheck, is causing the same for racket-xp-mode, and you are seeing this Rkt✗, too? If you do C-c # N (capital N) what does it tell you?

    I will push a commit to handle this problem by reporting "can't find docs" instead of reflecting a Racket contract error up to Emacs. Thank you for reporting this!

    (Although strictly speaking this isn't related to #488 for both our convenience I'll just re-open this issue, and close it with the commit.)

greghendershott commented 3 years ago

p.s. re 1 it looks like Doom Emacs is already supposed to disable flycheck as of July? https://github.com/hlissner/doom-emacs/pull/3594