| 1 | : |
| 2 | |
| 3 |
|
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 |
|
| 9 | |
| 10 |
|
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 |
|
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 |
|
| 21 | |
| 22 | |
| 23 |
|
| 24 | |
| 25 |
|
| 26 | |
| 27 | |
| 28 |
|
| 29 | |
| 30 |
|
| 31 | |
| 32 | (with-temp-buffer
|
| 33 | (scheme-mode)
|
| 34 | (let ((default-directory (file-name-as-directory load-file-name))
|
| 35 | (enable-local-variables :all))
|
| 36 | (hack-dir-local-variables)
|
| 37 | (hack-local-variables-apply)))
|
| 38 |
|
| 39 | |
| 40 | |
| 41 | |
| 42 | (defmacro guix-syntax--scheme-indent (&rest pairs)
|
| 43 | `(progn ,@(mapcar (lambda (p)
|
| 44 | `(put ',(car p) 'scheme-indent-function ',(cadr p)))
|
| 45 | pairs)))
|
| 46 |
|
| 47 | (guix-syntax--scheme-indent
|
| 48 | (and-let* 1)
|
| 49 | (case-lambda 0)
|
| 50 | (catch defun)
|
| 51 | (class defun)
|
| 52 | (dynamic-wind 0)
|
| 53 | (guard 1)
|
| 54 | (let*-values 1)
|
| 55 | (let-values 1)
|
| 56 | (let/ec 1)
|
| 57 | (letrec* 1)
|
| 58 | (match 1)
|
| 59 | (match-lambda 0)
|
| 60 | (match-lambda* 0)
|
| 61 | (match-let scheme-let-indent)
|
| 62 | (match-let* 1)
|
| 63 | (match-letrec 1)
|
| 64 | (opt-lambda 1)
|
| 65 | (parameterize 1)
|
| 66 | (parameterize* 1)
|
| 67 | (receive 2)
|
| 68 | (require-extension 0)
|
| 69 | (syntax-case 2)
|
| 70 | (test-approximate 1)
|
| 71 | (test-assert 1)
|
| 72 | (test-eq 1)
|
| 73 | (test-equal 1)
|
| 74 | (test-eqv 1)
|
| 75 | (test-group-with-cleanup 1)
|
| 76 | (test-runner-on-bad-count! 1)
|
| 77 | (test-runner-on-bad-end-name! 1)
|
| 78 | (test-runner-on-final! 1)
|
| 79 | (test-runner-on-group-begin! 1)
|
| 80 | (test-runner-on-group-end! 1)
|
| 81 | (test-runner-on-test-begin! 1)
|
| 82 | (test-runner-on-test-end! 1)
|
| 83 | (test-with-runner 1)
|
| 84 | (unless 1)
|
| 85 | (when 1)
|
| 86 | (while 1)
|
| 87 | (with-exception-handler 1)
|
| 88 | (with-syntax 1))
|
| 89 |
|
| 90 |
|
| 91 | (defun main ()
|
| 92 | (pcase command-line-args-left
|
| 93 | (`(,file-name ,package-name)
|
| 94 | |
| 95 | (find-file file-name)
|
| 96 | (goto-char (point-min))
|
| 97 | (if (re-search-forward (concat "^(define\\(\\|-public\\) +"
|
| 98 | package-name)
|
| 99 | nil t)
|
| 100 | (let ((indent-tabs-mode nil))
|
| 101 | (beginning-of-defun)
|
| 102 | (indent-sexp)
|
| 103 | (save-buffer)
|
| 104 | (message "Done!"))
|
| 105 | (error "Package '%s' not found in '%s'"
|
| 106 | package-name file-name)))
|
| 107 | (`(,file-name)
|
| 108 | |
| 109 | (find-file file-name)
|
| 110 | (let ((indent-tabs-mode nil))
|
| 111 | (indent-region (point-min) (point-max))
|
| 112 | (save-buffer)
|
| 113 | (message "Done!")))
|
| 114 | (x
|
| 115 | (error "Usage: indent-code.el FILE [PACKAGE]"))))
|
| 116 |
|
| 117 | |