Skip to content

Instantly share code, notes, and snippets.

@greghendershott
Created November 28, 2015 19:42
Show Gist options
  • Save greghendershott/c3e5952a655735c26f0a to your computer and use it in GitHub Desktop.
Save greghendershott/c3e5952a655735c26f0a to your computer and use it in GitHub Desktop.
Prevent paredit from adding a space before delimiters in Racket at-expressions.
(defun racket-at-expression-paredit-space-for-delimiter-predicate (endp delimiter)
"`paredit-mode' shouldn't insert space before [ or { in Racket at-expressions.
For example:
@[]
@{}
@[]{}
@foo[]
@foo{}
@foo[]{}
This function is a suitable element for the list variable
`paredit-space-for-delimiter-predicates'. For example:
(use-package paredit
:ensure t
:config
(progn
;; ... other config you may have ...
(add-hook 'paredit-space-for-delimiter-predicates
#'racket-at-expression-paredit-space-for-delimiter-predicate)))
"
(if (and (eq major-mode 'racket-mode)
(not endp))
(not (or
;; @foo[ @foo{
(and (memq delimiter '(?\[ ?\{))
(looking-back (rx ?@ (* (or (syntax word) (syntax symbol))))))
;; @foo[]{
(and (eq delimiter ?\{)
(looking-back (rx ?@ (* (or (syntax word) (syntax symbol)))
?\[
(* (or (syntax word) (syntax symbol)))
?\])))))
t))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment