From 2f4899065ebd0a7e6f58b2cf0f0aa7cbaa3b708a Mon Sep 17 00:00:00 2001 From: Greg Hendershott Date: Sun, 13 Oct 2024 14:20:38 -0400 Subject: [PATCH] Add abbrev-mode support, plus an insert-symbol command Intended to replace racket-unicode-input-method (which would remain but become deprecated), which I'd originally cargo-culted from haskell-mode. On a fresh look, ,I don't see why this kind of feature should be implemented as an input method. Instead these can be seen simply as abbreviations: When I type X, substitute it with Y. Although I haven't used abbrev-mode previously, and it seems like a fairly ancient Emacs feature, the basic functionality seems fine. A major mode can specify a set of "system" abbrevs, which is what we do here. Allow customization of: - the list of substitutions - an optional prefix (such as "\\"), which can avoid unintended substitutions Both of which should mean users don't need to open an issue about changing some particular substitution, as has happened a couple times recently. IOW this is an effort to solve this generally, not ad hoc, by making it super easy for users to self-help. --- doc/generate.el | 4 +- doc/racket-mode.org | 21 ++- doc/racket-mode.texi | 145 +++++++++--------- racket-abbrev.el | 348 +++++++++++++++++++++++++++++++++++++++++++ racket-common.el | 10 +- racket-hash-lang.el | 2 + racket-mode.el | 3 +- racket-repl.el | 2 + racket-util.el | 7 + 9 files changed, 452 insertions(+), 90 deletions(-) create mode 100644 racket-abbrev.el diff --git a/doc/generate.el b/doc/generate.el index 5a5c23db..416bf6a5 100644 --- a/doc/generate.el +++ b/doc/generate.el @@ -16,7 +16,6 @@ (require 'racket-xp) (require 'racket-util) (require 'racket-show) -(require 'racket-unicode-input-method) (require 'racket-smart-open) (require 'racket-repl-buffer-name) (require 'racket-hash-lang) @@ -49,7 +48,6 @@ racket-insert-closing racket-cycle-paren-shapes racket-backward-up-list - racket-unicode-input-method-enable racket-align racket-unalign racket-complete-at-point @@ -198,6 +196,8 @@ racket-xp-eldoc-level racket-documentation-search-location racket-expand-hiding + racket-abbrevs + racket-abbrev-prefix "Hash lang variables" racket-hash-lang-token-face-alist racket-hash-lang-pairs diff --git a/doc/racket-mode.org b/doc/racket-mode.org index 01b323c5..40a96e79 100644 --- a/doc/racket-mode.org +++ b/doc/racket-mode.org @@ -382,20 +382,29 @@ Note: Racket Mode does not support the "old" eldoc API that uses ~eldoc-document You can use {{{ref(racket-mode-start-faster)}}} to make the Racket REPL start faster. -** Unicode input method +** Math and programming symbols -An optional Emacs input method, ~racket-unicode~, lets you easily type various Unicode symbols that might be useful when writing Racket code. +Various modes supply an Eamcs abbrev table which you can use by enabling the minor mode ~abbrev-mode~. -To automatically enable the ~racket-unicode~ input method in ~racket-mode~ and ~racket-repl-mode~ buffers, put the following code in your Emacs init file: +#+BEGIN_SRC lisp +(add-hook 'racket-mode-hook #'abbrev-mode) +(add-hook 'racket-repl-mode-hook #'abbrev-mode) +#+END_SRC + +This abbrev table is populated from the customization variables {{{ref(racket-abbrevs)}}} and {{{ref(racket-abbrev-prefix)}}}. + +By default this table defines names for various math and programming symbols, and uses a {{{kbd(\)}}} prefix key. So for example you can type ~\gg~ followed by a space, and it will change to ~≫~. + +*** Deprecated racket-unicode input method + +Older versions supplied an Emacs input method, ~racket-unicode~. This is now deprecated. If you have configuration like this: #+BEGIN_SRC lisp (add-hook 'racket-mode-hook #'racket-unicode-input-method-enable) (add-hook 'racket-repl-mode-hook #'racket-unicode-input-method-enable) #+END_SRC -{{{see(racket-unicode-input-method-enable)}}}. - -{{{see(racket-insert-lambda)}}}. +You can delete that and instead use the ~abbrev-mode~ configuration described above. ** Ligatures diff --git a/doc/racket-mode.texi b/doc/racket-mode.texi index edd87c62..7c509c70 100644 --- a/doc/racket-mode.texi +++ b/doc/racket-mode.texi @@ -77,9 +77,13 @@ Configure * Edit buffers and REPL buffers:: * eldoc:: * Start faster:: -* Unicode input method:: +* Math and programming symbols:: * Ligatures:: +Math and programming symbols + +* Deprecated racket-unicode input method:: + Commands * Edit:: @@ -108,7 +112,6 @@ Edit * racket-insert-closing:: * racket-cycle-paren-shapes:: * racket-backward-up-list:: -* racket-unicode-input-method-enable:: * racket-align:: * racket-unalign:: * racket-complete-at-point:: @@ -218,6 +221,8 @@ General variables * racket-xp-eldoc-level:: * racket-documentation-search-location:: * racket-expand-hiding:: +* racket-abbrevs:: +* racket-abbrev-prefix:: Hash lang variables @@ -557,7 +562,7 @@ You can @code{setq} this directly in your Emacs init file (@samp{~/.emacs} or @s * Edit buffers and REPL buffers:: * eldoc:: * Start faster:: -* Unicode input method:: +* Math and programming symbols:: * Ligatures:: @end menu @@ -844,21 +849,35 @@ Note: Racket Mode does not support the ``old'' eldoc API that uses @code{eldoc-d You can use @ref{racket-mode-start-faster} to make the Racket REPL start faster. -@node Unicode input method -@section Unicode input method +@node Math and programming symbols +@section Math and programming symbols + +Various modes supply an Eamcs abbrev table which you can use by enabling the minor mode @code{abbrev-mode}. + +@lisp +(add-hook 'racket-mode-hook #'abbrev-mode) +(add-hook 'racket-repl-mode-hook #'abbrev-mode) +@end lisp + +This abbrev table is populated from the customization variables @ref{racket-abbrevs} and @ref{racket-abbrev-prefix}. + +By default this table defines names for various math and programming symbols, and uses a @kbd{\} prefix key. So for example you can type @code{\gg} followed by a space, and it will change to @code{≫}. + +@menu +* Deprecated racket-unicode input method:: +@end menu -An optional Emacs input method, @code{racket-unicode}, lets you easily type various Unicode symbols that might be useful when writing Racket code. +@node Deprecated racket-unicode input method +@subsection Deprecated racket-unicode input method -To automatically enable the @code{racket-unicode} input method in @code{racket-mode} and @code{racket-repl-mode} buffers, put the following code in your Emacs init file: +Older versions supplied an Emacs input method, @code{racket-unicode}. This is now deprecated. If you have configuration like this: @lisp (add-hook 'racket-mode-hook #'racket-unicode-input-method-enable) (add-hook 'racket-repl-mode-hook #'racket-unicode-input-method-enable) @end lisp -@xref{racket-unicode-input-method-enable}. - -@xref{racket-insert-lambda}. +You can delete that and instead use the @code{abbrev-mode} configuration described above. @node Ligatures @section Ligatures @@ -951,7 +970,6 @@ You can also view these by using the normal Emacs help mechanism: * racket-insert-closing:: * racket-cycle-paren-shapes:: * racket-backward-up-list:: -* racket-unicode-input-method-enable:: * racket-align:: * racket-unalign:: * racket-complete-at-point:: @@ -1034,7 +1052,12 @@ penultimate step during initialization. Insert λ. -To insert Unicode symbols generally, see @ref{racket-unicode-input-method-enable}. +To insert Unicode symbols generally, see the command +@code{racket-insert-symbol}. + +Also you can enable @code{abbrev-mode} to type abbreviations in the +buffer that are automatically substituted. For more information +see the customization variable @ref{racket-abbrevs}. @node racket-fold-all-tests @subsection racket-fold-all-tests @@ -1390,71 +1413,6 @@ especially not repeatedly. Instead, initially use string or comment, if any, then use normal @code{backward-up-list} repeatedly. -@node racket-unicode-input-method-enable -@subsection racket-unicode-input-method-enable - -@kbd{M-x} @code{racket-unicode-input-method-enable} - -Set input method to racket-unicode. - -The racket-unicode input method lets you easily type various -Unicode symbols that might be useful when writing Racket code. - -To automatically enable the racket-unicode input method in -racket-mode and racket-repl-mode buffers, put the following code -in your Emacs init file: - -@lisp - (add-hook 'racket-mode-hook #'racket-unicode-input-method-enable) - (add-hook 'racket-repl-mode-hook #'racket-unicode-input-method-enable) -@end lisp - -To temporarily enable this input method for a single buffer you -can use ``M-x racket-unicode-input-method-enable''. - -Use the standard Emacs key C-\ to toggle the input method. - -When the racket-unicode input method is active, you can for -example type ``All'' and it is immediately replaced with ``∀''. A -few other examples: - -@multitable {aaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaa} -@item omega -@tab ω -@item x@math{_1} -@tab x₁ -@item x@math{^1} -@tab x¹ -@item A -@tab 𝔸 -@item test-->>E -@tab test-->>∃ (racket/redex) -@item vdash -@tab ⊢ -@end multitable - -To see a table of all key sequences use ``M-x -describe-input-method racket-unicode''. - -If you want to add your own mappings to the ``racket-unicode'' -input method, you may add code like the following example in your -Emacs init file: - -@lisp - ;; Either (require 'racket-mode) here, or, if you use - ;; use-package, put the code below in the :config section. - (with-temp-buffer - (racket-unicode-input-method-enable) - (set-input-method "racket-unicode") - (let ((quail-current-package (assoc "racket-unicode" - quail-package-alist))) - (quail-define-rules ((append . t)) - ("^o" ["ᵒ"])))) -@end lisp - -If you don’t like the highlighting of partially matching tokens you -can turn it off by setting @code{input-method-highlight-flag} to nil. - @node racket-align @subsection racket-align @@ -3111,6 +3069,8 @@ Delete the ``compiled'' directories made by @ref{racket-mode-start-faster}. * racket-xp-eldoc-level:: * racket-documentation-search-location:: * racket-expand-hiding:: +* racket-abbrevs:: +* racket-abbrev-prefix:: @end menu @node racket-program @@ -3300,6 +3260,37 @@ string should be a properly encoded URL@. The macro hiding policy for commands like @ref{racket-expand-file}. +@node racket-abbrevs +@subsection racket-abbrevs + +List of abbreviations and expansions. + +Used by @code{abbrev-mode} when that is enabled, as well as by the +command @code{racket-insert-symbol}. + +By default, the abbreviations are names for expansions that use +various Unicode symbols. + +The abbreviations in this list do @emph{not} include +@ref{racket-abbrev-prefix}, which you can configure separately. + +If you change this using @code{setq} or @code{add-to-list} -- instead of +@code{setopt} or the customization UI -- be sure to call +@code{racket-abbrev-setup} afterwards. + +@node racket-abbrev-prefix +@subsection racket-abbrev-prefix + +A non-blank string prefix with which to start all abbrevs, or nil. + +When not nil, this is automatically added to all the items in +@ref{racket-abbrevs}, to form the abbreviations used by +@code{abbrev-mode}. + +If you change this using @code{setq} -- instead of @code{setopt} or the +customization UI -- be sure to call @code{racket-abbrev-setup} +afterwards. + @node Hash lang variables @section Hash lang variables diff --git a/racket-abbrev.el b/racket-abbrev.el new file mode 100644 index 00000000..72e1ddb0 --- /dev/null +++ b/racket-abbrev.el @@ -0,0 +1,348 @@ +;;; racket-abbrev.el -*- lexical-binding: t -*- + +;; Copyright (c) 2024 by Greg Hendershott. +;; Portions Copyright (C) 1985-1986, 1999-2013 Free Software Foundation, Inc. + +;; Author: Greg Hendershott +;; URL: https://github.com/greghendershott/racket-mode + +;; SPDX-License-Identifier: GPL-3.0-or-later + +(require 'racket-complete) + +(defgroup racket-abbrev nil + "racket-abbrev options" + :group 'racket) + +(defun racket-abbrev-custom-set (sym val) + (set-default-toplevel-value sym val) + (racket-abbrev-setup)) + +(defcustom racket-abbrevs + '(;; Typed Racket + ("All" "∀") + ("Union" "U") + ("Intersection" "∩") + + ;; Redex + ("test-->>E" "test-->>∃") + + ;; Turnstile + ("vdash" "⊢") + ("gg" "≫") + ("rightarrow" "→") + ("Rightarrow" "⇒") + ("Leftarrow" "⇐") + ("succ" "≻") + + ;; Other type rule symbols + ;; (added: common math chars currently unsupported) + ("times" "×") + ("Uparrow" "⇑") + ("Downarrow" "⇓") + ("Leftrightarrow" "⇔") + ("rightarrow" "→") + ("leftarrow" "←") + ("Rightarrow" "⇒") + ("Leftarrow" "⇐") + ("nwarrow" "↖") + ("nearrow" "↗") + ("uparrow" "↑") + ("downarrow" "↓") + ("searrow" "↘") + ("swarrow" "↙") + ("leftrightarrow" "↔") + ("updownarrow" "⇕") + ("aleph" "א") + ("emptyset" "∅") + ("nabla" "∇") + ("surd" "√") + ("negation" "¬") + ("infinity" "∞") + ("prod" "∏") + ("coprod" "∐") + ("integrate" "∫") + ("oint" "∮") + ("vee" "∨") + ("wedge" "∧") + ("follows" "∘") + ("setin" "∈") + ("ni" "∋") + ("notin" "∉") + ("sqsubset" "⊏") + ("sqsupset" "⊐") + ("sqsubseteq" "⊑") + ("sqsupseteq" "⊒") + ("subset" "⊂") + ("superset" "⊃") + ("subseteq" "⊆") + ("supseteq" "⊇") + ("approx" "≈") + ("cong" "≌") + ("neq" "≠") + ("sqcap" "⊓") + ("sqcup" "⊔") + ("models" "⊧") + + ;; Greek letters + ("alpha" "α") + ("Alpha" "Α") + ("beta" "β") + ("Beta" "Β") + ("gamma" "γ") + ("Gamma" "Γ") + ("delta" "δ") + ("Delta" "Δ") + ("epsilon" "ε") + ("Epsilon" "Ε") + ("zeta" "ζ") + ("Zeta" "Ζ") + ("eta" "η") + ("Eta" "Η") + ("theta" "θ") + ("Theta" "Θ") + ("iota" "ι") + ("Iota" "Ι") + ("kappa" "κ") + ("Kappa" "Κ") + ("lambda" "λ") + ("Lambda" "Λ") + ("lamda" "λ") + ("Lamda" "Λ") + ("mu" "μ") + ("Mu" "Μ") + ("nu" "ν") + ("Nu" "Ν") + ("xi" "ξ") + ("Xi" "Ξ") + ("omicron" "ο") + ("Omicron" "Ο") + ("pi" "π") + ("Pi" "Π") + ("rho" "ρ") + ("Rho" "Ρ") + ("sigma" "σ") + ("Sigma" "Σ") + ("tau" "τ") + ("Tau" "Τ") + ("upsilon" "υ") + ("Upsilon" "Υ") + ("phi" "φ") + ("Phi" "Φ") + ("chi" "χ") + ("Chi" "Χ") + ("psi" "ψ") + ("Psi" "Ψ") + ("omega" "ω") + ("Omega" "Ω") + ("digamma" "ϝ") + ("Digamma" "Ϝ") + ("san" "ϻ") + ("San" "Ϻ") + ("qoppa" "ϙ") + ("Qoppa" "Ϙ") + ("sampi" "ϡ") + ("Sampi" "Ϡ") + ("stigma" "ϛ") + ("Stigma" "Ϛ") + ("heta" "ͱ") + ("Heta" "Ͱ") + ("sho" "ϸ") + ("Sho" "Ϸ") + + ;; Double-struck letters + ("|A|" "𝔸") + ("|B|" "𝔹") + ("|C|" "ℂ") + ("|D|" "𝔻") + ("|E|" "𝔼") + ("|F|" "𝔽") + ("|G|" "𝔾") + ("|H|" "ℍ") + ("|I|" "𝕀") + ("|J|" "𝕁") + ("|K|" "𝕂") + ("|L|" "𝕃") + ("|M|" "𝕄") + ("|N|" "ℕ") + ("|O|" "𝕆") + ("|P|" "ℙ") + ("|Q|" "ℚ") + ("|R|" "ℝ") + ("|S|" "𝕊") + ("|T|" "𝕋") + ("|U|" "𝕌") + ("|V|" "𝕍") + ("|W|" "𝕎") + ("|X|" "𝕏") + ("|Y|" "𝕐") + ("|Z|" "ℤ") + ("|gamma|" "ℽ") + ("|Gamma|" "ℾ") + ("|pi|" "ℼ") + ("|Pi|" "ℿ") + + ;; Quantifiers + ("forall" "∀") + ("exists" "∃") + + ;; Numeric subscripts + ("_0" "₀") + ("_1" "₁") + ("_2" "₂") + ("_3" "₃") + ("_4" "₄") + ("_5" "₅") + ("_6" "₆") + ("_7" "₇") + ("_8" "₈") + ("_9" "₉") + + ;; Numeric superscripts + ("^0" "⁰") + ("^1" "¹") + ("^2" "²") + ("^3" "³") + ("^4" "⁴") + ("^5" "⁵") + ("^6" "⁶") + ("^7" "⁷") + ("^8" "⁸") + ("^9" "⁹")) + "List of abbreviations and expansions. + +Used by `abbrev-mode' when that is enabled, as well as by the +command `racket-insert-symbol'. + +By default, the abbreviations are names for expansions that use +various Unicode symbols. + +The abbreviations in this list do /not/ include +`racket-abbrev-prefix', which you can configure separately. + +If you change this using `setq' or `add-to-list' -- instead of +`setopt' or the customization UI -- be sure to call +`racket-abbrev-setup' afterwards." + :initialize 'custom-initialize-default + :set #'racket-abbrev-custom-set + :type '(repeat (list (string :tag "Abbrev") (string :tag "Expansion")))) + +(defcustom racket-abbrev-prefix "\\" + "A non-blank string prefix with which to start all abbrevs, or nil. + +When not nil, this is automatically added to all the items in +`racket-abbrevs', to form the abbreviations used by +`abbrev-mode'. + +If you change this using `setq' -- instead of `setopt' or the +customization UI -- be sure to call `racket-abbrev-setup' +afterwards." + :initialize 'custom-initialize-default + :set #'racket-abbrev-custom-set + :type '(choice (string :tag "Prefix") + (const :tag "No prefix" nil))) + +(defvar racket-abbrev-table (make-abbrev-table) + "The `abbrev' table used by various modes. +e.g. `racket-mode', `racket-repl-mode', `racket-hash-lang-mode'. + +Don't change this directly, it is populated by +`racket-abbrev-setup' from the avlues `racket-abbrevs' and +`racket-abbrev-prefix'.") + +(defun racket-abbrev-setup () + (cl-flet ((trim (str) + (save-match-data + (when (string-match (rx bos (* " ") + (group-n 1 (+ (not " "))) + (* " ") eos) + str) + (match-string 1 str))))) + (clear-abbrev-table racket-abbrev-table) + ;; When there's a prefix and it's not all word char-syntax, we + ;; must supply a :regexp abbrev table property that looks back for + ;; the prefix. Otherwise we can use the default `backword-word' + ;; behavior. + (let ((prefix (trim racket-abbrev-prefix))) + (abbrev-table-put racket-abbrev-table + :regexp + (when (and prefix + (not + (seq-every-p (lambda (ch) + (eq ?w (char-syntax ch))) + prefix))) + (rx (group-n 1 (literal prefix) (+ any)))))) + ;; Add all the items, adding the prefix, as "system" abbrevs. + (dolist (v racket-abbrevs) + (pcase-let* ((`(,abbrev ,expansion) v) + (abbrev (trim abbrev)) + (expansion (trim expansion)) + (abbrev (concat racket-abbrev-prefix abbrev))) + (when (and abbrev expansion) + (define-abbrev racket-abbrev-table + abbrev expansion + nil ;HOOK + :system t)))))) + +;; Initialize +(racket-abbrev-setup) + +;;; Stand-alone command with completing-read annotations + +(defun racket-insert-symbol () + "Insert an expansion from `racket-abbrevs'. + +When you don't already know the abbreviation names, and want to +see a \"preview\" of the expansion that will be inserted, this +command can be more useful than typing abbreviations in the +buffer for `abbrev-mode' to expand. + +The `thing-at-point', if any, is the initial input to +`completing-read'. When that matches the choice, it is deleted +from the buffer, as well as inserting the symbol. In other words +you can type the abbreviation in the buffer, then choose this +command, if you do not want to use `abbrev-mode' to expand +automatically." + (interactive) + (pcase (racket--bounds-of-thing-at-point 'symbol) + (`(,beg . ,end) + (let ((thing (buffer-substring-no-properties beg end))) + (pcase (racket--choose-symbol thing) + (`(,key ,str) + (when (string-equal key thing) + (delete-region beg end)) + (insert str))))) + (_ (pcase (racket--choose-symbol) + (`(,_key ,str) + (insert str)))))) + +(defun racket--choose-symbol (&optional initial-input) + (let ((collection (racket--completion-table + racket-abbrevs + `((category . racket-symbol-name) + (affixation-function . ,#'racket--symbol-affixator)))) + (predicate nil) + (require-match t)) + (when-let (str (completing-read "Symbol: " + collection + predicate + require-match + initial-input)) + (assoc str racket-abbrevs)))) + +(defun racket--symbol-affixator (strs) + (let ((max-len 16)) + (dolist (str strs) + (setq max-len (max max-len (1+ (length str))))) + (seq-map (lambda (str) + (list str + "" + (concat + (make-string (- max-len (length str)) 32) + (propertize (cadr (assoc str racket-abbrevs)) + 'face 'bold)))) + strs))) + +(provide 'racket-abbrev) + +;; racket-abbrev.el ends here diff --git a/racket-common.el b/racket-common.el index 59b61ac3..bce079ab 100644 --- a/racket-common.el +++ b/racket-common.el @@ -21,9 +21,6 @@ (require 'racket-ppss) (require 'racket-util) -(defvar racket-mode-abbrev-table nil) -(define-abbrev-table 'racket-mode-abbrev-table ()) - ;;; syntax-table and syntax-propertize-function (defvar racket-mode-syntax-table @@ -207,7 +204,12 @@ property whose value is STRING. The close | syntax is set by (defun racket-insert-lambda () "Insert λ. -To insert Unicode symbols generally, see `racket-unicode-input-method-enable'." +To insert Unicode symbols generally, see the command +`racket-insert-symbol'. + +Also you can enable `abbrev-mode' to type abbreviations in the +buffer that are automatically substituted. For more information +see the customization variable `racket-abbrevs'." (interactive) (insert-char racket-lambda-char 1)) (put 'racket-insert-lambda 'delete-selection t) diff --git a/racket-hash-lang.el b/racket-hash-lang.el index 29c7efa0..749a632c 100644 --- a/racket-hash-lang.el +++ b/racket-hash-lang.el @@ -11,6 +11,7 @@ (require 'cl-lib) (require 'elec-pair) (require 'seq) +(require 'racket-abbrev) (require 'racket-cmd) (require 'racket-mode) (require 'racket-repl) @@ -220,6 +221,7 @@ A discussion of the information provided by a Racket language: \\{racket-hash-lang-mode-map} " + :abbrev-table racket-abbrev-table (racket--polite-user-f-keys racket-hash-lang-mode-map racket--f5-bindings) (racket-call-racket-repl-buffer-name-function) (add-hook 'kill-buffer-hook diff --git a/racket-mode.el b/racket-mode.el index f898a4f9..a3cb218a 100644 --- a/racket-mode.el +++ b/racket-mode.el @@ -23,6 +23,7 @@ ;;; Code: +(require 'racket-abbrev) (require 'racket-doc) (require 'racket-edit) (require 'racket-xp) @@ -133,6 +134,7 @@ "Major mode for editing Racket source files. \\{racket-mode-map}" + :abbrev-table racket-abbrev-table (racket--polite-user-f-keys racket-mode-map racket--f5-bindings) ;;; Syntax (set-syntax-table racket-mode-syntax-table) @@ -182,7 +184,6 @@ '(racket-mode "(" ")" ";" nil nil)) ;; ----------------------------------------------------------------- ;;; Misc - (setq-local local-abbrev-table racket-mode-abbrev-table) (setq-local paragraph-start (concat "$\\|" page-delimiter)) (setq-local paragraph-separate paragraph-start) (setq-local paragraph-ignore-fill-prefix t) diff --git a/racket-repl.el b/racket-repl.el index 826a95dc..b346795e 100644 --- a/racket-repl.el +++ b/racket-repl.el @@ -9,6 +9,7 @@ ;; SPDX-License-Identifier: GPL-3.0-or-later +(require 'racket-abbrev) (require 'racket-browse-url) (require 'racket-scribble-anchor) (require 'racket-complete) @@ -1460,6 +1461,7 @@ You may use `xref-find-definitions' \\[xref-find-definitions] and identifier bindings and modules from the REPL's namespace. \\{racket-repl-mode-map}" + :abbrev-table racket-abbrev-table ;; Here we set some values that will definitely be used when the ;; buffer is created by the `racket-repl' command. Otherwise, ;; `racket--hash-lang-configure-repl-buffer-from-edit-buffer' will diff --git a/racket-util.el b/racket-util.el index 4684225b..2db00aa4 100644 --- a/racket-util.el +++ b/racket-util.el @@ -171,6 +171,13 @@ s-expressions." (thing-at-point thing no-properties)) (thing-at-point thing no-properties))) +(defun racket--bounds-of-thing-at-point (thing) + (if-let (pos (racket--menu-position)) + (save-excursion + (goto-char pos) + (bounds-of-thing-at-point thing)) + (bounds-of-thing-at-point thing))) + (defun racket--symbol-at-point-or-prompt (force-prompt-p prompt &optional