Last active
March 3, 2021 14:48
-
-
Save Metaxal/52ec3ee6fc43b0e8917d19c3daf2c57b to your computer and use it in GitHub Desktop.
Replaces all occurrences of #t and #f with #true and #false in the selected text (quickscript)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
;;; License: [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or | |
;;; [MIT license](http://opensource.org/licenses/MIT) at your option. | |
(require quickscript | |
racket/class) | |
(script-help-string | |
"Replaces all occurrences of #t and #f with #true and #false in the selected text (warning: in strings too!)") | |
(define-script fix-true-false | |
#:label "fix-true-false" | |
(λ (selection #:definitions defs) | |
(when (equal? selection "") | |
(send defs set-position 0 (send defs last-position)) | |
(set! selection (send defs get-text))) | |
(regexp-replaces | |
selection | |
'([#px"#t\\b" "#true"] | |
[#px"#f\\b" "#false"])))) | |
(module url2script-info racket/base | |
(provide filename url) | |
(define filename "fix-true-false.rkt") | |
(define url "https://gist.github.com/Metaxal/52ec3ee6fc43b0e8917d19c3daf2c57b")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment