File: generate-indent-cases

package info (click to toggle)
ess 18.10.2%2Bgit20220915.f45542e-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,616 kB
  • sloc: lisp: 23,453; makefile: 337; sh: 7
file content (41 lines) | stat: -rwxr-xr-x 1,574 bytes parent folder | download | duplicates (2)
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
33
34
35
36
37
38
39
40
41
#!/usr/bin/env emacs --script
;; (Re)generate files with test cases for indentation

(let ((current-directory (file-name-directory load-file-name)))
  (setq ess-test-path (expand-file-name "." current-directory))
  (setq ess-styles-path (expand-file-name "./styles/" current-directory))
  (setq ess-root-path (expand-file-name "../lisp/" current-directory))
  (setq etest-path (expand-file-name "etest/" ess-test-path)))

(add-to-list 'load-path ess-root-path)
(add-to-list 'load-path ess-test-path)
(add-to-list 'load-path etest-path)

(require 'ess-r-mode)
(load (expand-file-name "ess-test-indentation.el" ess-test-path) nil t)

;; The RRR file is taken as a model, so modify this file to add or
;; adjust test cases.
(let ((ess-style-alist ess-test-style-alist)
      (RRR-file (expand-file-name "RRR.R" ess-styles-path)))

  ;; Regenerate indentation in RRR file
  (set-buffer (find-file-noselect RRR-file))
  (setq ess-indent-with-fancy-comments t)
  (ess-set-style 'RRR)
  (indent-region (point-min) (point-max))
  (save-buffer)

  (mapc
   (lambda (test-conf)
     (let* ((test-name (car test-conf))
            (test-file (expand-file-name
                        (concat (symbol-name test-name) ".R")
                        ess-styles-path)))
       (set-buffer (find-file-noselect test-file))
       (setq ess-indent-with-fancy-comments t)
       (ess-set-style test-name)
       (insert-file-contents-literally RRR-file nil nil nil 'replace)
       (indent-region (point-min) (point-max))
       (save-buffer)))
   (assq-delete-all 'RRR ess-test-style-alist)))