Last active
September 21, 2024 17:39
-
-
Save Metaxal/f45ea1a893a1bdedaadbeafd11144e3d to your computer and use it in GitHub Desktop.
Quickscript for sorawee's `fmt`
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 | |
(require quickscript | |
fmt ; needs to be installed first | |
racket/class) | |
;;; Author: Laurent Orseau | |
;;; 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. | |
(script-help-string "Format the selection or the whole program using `fmt`") | |
(define-script fmt | |
#:label "fmt" | |
#:menu-path ("Re&factor") | |
(λ (selection #:definitions defs) | |
(cond | |
[(equal? selection "") | |
(define txt (send defs get-text)) | |
(define new-txt (program-format txt)) | |
(send defs begin-edit-sequence) | |
(send defs erase) | |
(send defs insert new-txt) | |
(send defs end-edit-sequence) | |
#f] | |
[else (program-format selection)]))) | |
(module url2script-info racket/base | |
(provide filename url) | |
(define filename "fmt.rkt") | |
(define url "https://gist.github.com/Metaxal/f45ea1a893a1bdedaadbeafd11144e3d")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment