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

racket-xp-unused-face not applied to identifiers beginning with an underscore. #648

Closed jasonhemann closed 1 year ago

jasonhemann commented 1 year ago

I open the following file in racket-mode.

#lang racket

(define f
 (λ (_1 _a a a_b 3_)
   'cat))

Of those five identifiers, I see only the last three as having the racket-xp-unused-face applied. It's possible this is a feature, i'm not sure.

((alist-get 'racket-mode package-alist))
((emacs-version "28.2")
 (system-type darwin)
 (x-gtk-use-system-tooltips UNDEFINED)
 (major-mode racket-mode)
 (racket--el-source-dir "/Users/jhemann/.emacs.d/straight/build/racket-mode/")
 (racket--rkt-source-dir "/Users/jhemann/.emacs.d/straight/build/racket-mode/racket/")
 (racket-program "racket")
 (racket-command-timeout 10)
 (racket-path-from-emacs-to-racket-function UNDEFINED)
 (racket-path-from-racket-to-emacs-function UNDEFINED)
 (racket-browse-url-function racket-browse-url-using-temporary-file)
 (racket-documentation-search-location "https://docs.racket-lang.org/search/index.html?q=%s")
 (racket-xp-after-change-refresh-delay 1)
 (racket-xp-mode-lighter
  (:eval
   (racket--xp-mode-lighter)))
 (racket-xp-highlight-unused-regexp "^[^_]")
 (racket-repl-buffer-name-function nil)
 (racket-submodules-to-run
  ((test)
   (main)))
 (racket-memory-limit 2048)
 (racket-error-context medium)
 (racket-repl-history-directory "~/.emacs.d/racket-mode/")
 (racket-history-filter-regexp "\\`\\s *\\'")
 (racket-images-inline t)
 (racket-imagemagick-props nil)
 (racket-images-keep-last 100)
 (racket-images-system-viewer "open")
 (racket-pretty-print t)
 (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)
   (racket-mode-debugger . info)
   (sequence-specialization . info)
   (* . fatal)))
 (racket-show-functions
  (racket-show-pseudo-tooltip)))
(enabled-minor-modes
 (anzu-mode)
 (async-bytecomp-package-mode)
 (auto-composition-mode)
 (auto-compression-mode)
 (auto-encryption-mode)
 (auto-fill-mode)
 (auto-save-mode)
 (column-number-mode)
 (company-mode)
 (display-line-numbers-mode)
 (el-patch-use-package-mode)
 (electric-indent-mode)
 (electric-quote-mode)
 (eshell-vterm-mode)
 (file-name-shadow-mode)
 (flyspell-lazy-mode)
 (font-lock-mode)
 (global-anzu-mode)
 (global-company-mode)
 (global-display-line-numbers-mode)
 (global-eldoc-mode)
 (global-flycheck-mode)
 (global-font-lock-mode)
 (global-visual-line-mode)
 (hs-minor-mode)
 (line-number-mode)
 (mac-auto-operator-composition-mode)
 (mac-mouse-wheel-mode)
 (menu-bar-mode)
 (org-roam-bibtex-mode)
 (org-roam-db-autosync-mode)
 (org-roam-ui-follow-mode)
 (org-roam-ui-mode)
 (override-global-mode)
 (prescient-persist-mode)
 (projectile-mode)
 (racket-smart-open-bracket-mode)
 (racket-xp-mode)
 (save-place-mode)
 (savehist-mode)
 (selectrum-mode)
 (selectrum-prescient-mode)
 (semantic-minor-modes-format)
 (shell-dirtrack-mode)
 (show-paren-mode)
 (smartparens-global-mode)
 (smartparens-mode)
 (smartparens-strict-mode)
 (straight-package-neutering-mode)
 (straight-use-package-mode)
 (tooltip-mode)
 (transient-mark-mode)
 (visual-line-mode)
 (volatile-highlights-mode)
 (which-key-mode)
 (wrap-region-global-mode)
 (wrap-region-mode)
 (ws-butler-global-mode)
 (ws-butler-mode))
(disabled-minor-modes
 (abbrev-mode)
 (ace-window-display-mode)
 (ace-window-mode)
 (artbollocks-mode)
 (auto-fill-function)
 (auto-image-file-mode)
 (auto-revert-mode)
 (auto-revert-tail-mode)
 (auto-save-visited-mode)
 (avy-linum-mode)
 (bibtex-completion-notes-global-mode)
 (bibtex-completion-notes-mode)
 (blink-cursor-mode)
 (buffer-face-mode)
 (buffer-read-only)
 (button-mode)
 (cl-old-struct-compat-mode)
 (company-search-mode)
 (compilation-minor-mode)
 (compilation-shell-minor-mode)
 (completion-in-region-mode)
 (context-menu-mode)
 (dash-fontify-mode)
 (defining-kbd-macro)
 (diff-auto-refine-mode)
 (diff-minor-mode)
 (dired-hide-details-mode)
 (dired-isearch-filenames-mode)
 (dired-omit-mode)
 (diredp-breadcrumbs-in-header-line-mode)
 (doc-view-minor-mode)
 (doc-view-presentation-mode)
 (edebug-mode)
 (edit-indirect--overlay)
 (eldoc-mode)
 (electric-layout-mode)
 (ert--current-run-stats)
 (eshell-arg-mode)
 (flycheck-mode)
 (flyspell-mode)
 (flyspell-popup-auto-correct-mode)
 (global-auto-revert-mode)
 (global-dash-fontify-mode)
 (global-dired-hide-details-mode)
 (global-hl-line-mode)
 (global-prettify-symbols-mode)
 (global-semantic-highlight-edits-mode)
 (global-semantic-highlight-func-mode)
 (global-semantic-show-parser-state-mode)
 (global-semantic-show-unmatched-syntax-mode)
 (global-semantic-stickyfunc-mode)
 (gnus-dead-summary-mode)
 (gnus-undo-mode)
 (helm--minor-mode)
 (helm--remap-mouse-mode)
 (helm-autoresize-mode)
 (helm-display-line-numbers-mode)
 (helm-ff--delete-async-modeline-mode)
 (helm-ff-icon-mode)
 (helm-migemo-mode)
 (helm-popup-tip-mode)
 (hl-line-mode)
 (hmouse-dired-display-here-mode)
 (horizontal-scroll-bar-mode)
 (hycontrol-frames-mode)
 (hycontrol-local-frames-mode)
 (hycontrol-local-windows-mode)
 (hycontrol-windows-mode)
 (hyperbole-mode)
 (ibuffer-auto-mode)
 (ido-everywhere)
 (image-dired-minor-mode)
 (image-minor-mode)
 (impatient-mode)
 (indent-tabs-mode)
 (isearch-mode)
 (ispell-minor-mode)
 (jit-lock-debug-mode)
 (lock-file-mode)
 (mac-auto-ascii-mode)
 (mac-font-panel-mode)
 (mail-abbrevs-mode)
 (markdown-live-preview-mode)
 (matlab-functions-have-end-minor-mode)
 (midnight-mode)
 (mindstream-mode)
 (minibuffer-electric-default-mode)
 (mml-mode)
 (mouse-wheel-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)
 (org-trello-mode)
 (orgtbl-mode)
 (outline-minor-mode)
 (overwrite-mode)
 (paragraph-indent-minor-mode)
 (paredit-mode)
 (prettify-symbols-mode)
 (semantic-highlight-edits-mode)
 (semantic-highlight-func-mode)
 (semantic-mode)
 (semantic-show-parser-state-mode)
 (semantic-show-unmatched-syntax-mode)
 (semantic-stickyfunc-mode)
 (sh-electric-here-document-mode)
 (show-smartparens-global-mode)
 (show-smartparens-mode)
 (size-indication-mode)
 (smartparens-global-strict-mode)
 (straight-live-modifications-mode)
 (straight-symlink-emulation-mode)
 (tab-bar-history-mode)
 (tab-bar-mode)
 (table-fixed-width-mode)
 (table-mode-indicator)
 (temp-buffer-resize-mode)
 (text-scale-mode)
 (tool-bar-mode)
 (unify-8859-on-decoding-mode)
 (unify-8859-on-encoding-mode)
 (url-handler-mode)
 (use-hard-newlines)
 (view-mode)
 (visible-mode)
 (vterm-copy-mode)
 (w3m-fb-mode)
 (w3m-minor-mode)
 (wc-mode)
 (window-divider-mode)
 (winner-mode)
 (wordsmith-mode)
 (writegood-mode)
 (xref-etags-mode))
sorawee commented 1 year ago

This is intentional. You can adjust racket-xp-highlight-unused-regexp to modify the behavior. See the documentation at https://racket-mode.com/#racket_002dxp_002dhighlight_002dunused_002dregexp

greghendershott commented 1 year ago

Yes, what @sorawee said.

One precedent for this convention: The Emacs Lisp byte compiler warns about unused variables, unless they're underscore prefixed. It can also be a nice hint for human readers.

I believe there's another precedent I can't recall right now.

Anyway it's an intentional feature, which you can change or disable via that customization variable.

jasonhemann commented 1 year ago

Okay great thank you all