-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEldev
More file actions
93 lines (80 loc) · 3.44 KB
/
Copy pathEldev
File metadata and controls
93 lines (80 loc) · 3.44 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
; -*- mode: emacs-lisp; lexical-binding: t -*-
;; Uncomment some calls below as needed for your project.
;(eldev-use-package-archive 'gnu-elpa)
;(eldev-use-package-archive 'nongnu-elpa)
(eldev-use-package-archive 'melpa)
(eldev-use-plugin 'autoloads)
(eldev-use-plugin 'undercover)
(defconst name "mermaid-docker-mode.el")
(eldev-defcommand tag (tag)
"Make a new tag"
:parameters "TAG"
(unless tag
(signal 'eldev-wrong-command-usage))
(render)
(let ((buff (get-buffer-create "*output*")))
(when (< 0 (call-process "git" nil buff nil "add" "-f" "."))
(eldev-output (with-current-buffer buff (buffer-string)))
(error "Failed to add files"))
(when (< 0 (call-process "git" nil buff nil "stash"))
(eldev-output (with-current-buffer buff (buffer-string)))
(error "Failed to stash files"))
(with-temp-buffer
(insert-file-contents name)
(goto-char (point-min))
(re-search-forward tag))
(when (< 0 (call-process "git" nil buff nil "tag" tag "--sign"))
(eldev-output (with-current-buffer buff (buffer-string)))
(error "Failed to tag and sign"))))
(eldev-defcommand render ()
"Render customization in README.md"
(with-temp-file "README.md.new"
(insert-file-contents-literally "README.md")
(goto-char (point-min))
(search-forward "## Customization")
(search-forward "\n\n")
(unwind-protect
(progn (advice-add 'message :override (lambda (&rest _))) (push-mark))
(advice-remove 'message (lambda (&rest _))))
(re-search-forward "\\[.*?]: ")
(delete-region (mark) (line-beginning-position))
(goto-char (mark))
(let ((header '(:name :type :default :description))
(order '(:name :default :description :type))
widths tmp lines groups)
(with-temp-buffer
(insert-file-contents-literally name)
(goto-char (point-min))
(while (re-search-forward
(rx (literal "(") "defcustom" (+ blank) (group (+? ascii)) "\n"
(+ blank) (group (+? not-newline)) "\n" (+ blank)
(literal "\"") (group (+? not-newline)) (literal "\"") "\n"
(+? not-newline) "\n" (+ blank) (literal ":type '")
(group (+? ascii)) (literal ")"))
nil t)
(dotimes (idx (length order))
(setq tmp (plist-put tmp (nth idx order) (match-string (1+ idx)))))
(push tmp lines) (setq tmp nil)))
(dolist (item (reverse lines))
(dolist (col header)
(setq widths
(plist-put widths col (max (or (plist-get widths col) 0)
(length (plist-get item col)))))))
(dolist (col header)
(unless (eq :description col)
(setq widths (plist-put widths col (+ 2 (plist-get widths col)))))
(insert (string-pad (capitalize (substring (format "%s" col) 1))
(plist-get widths col)))
(insert "|"))
(insert "\n")
(dolist (col header)
(insert (format "%s|" (string-pad "" (plist-get widths col) ?-))))
(insert "\n")
(dolist (item (reverse lines))
(dolist (col header)
(let ((value (plist-get item col)) (padding (plist-get widths col)))
(unless (eq :description col) (setq value (format "`%s`" value)))
(insert (format "%s|" (string-pad value padding)))))
(insert "\n"))
(insert "\n")))
(rename-file "README.md.new" "README.md" t))