summary refs log tree commit diff
path: root/etc/snippets/tempel/text-mode
blob: c635b7ee6f1413726ead149489d1b4151afb1d27 (plain) (blame)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
-*- mode: lisp-data -*-

text-mode :when (bound-and-true-p git-commit-mode)

(add\ "gnu: Add "
      (p (with-temp-buffer
           (magit-git-wash #'magit-diff-wash-diffs
             "diff" "--staged")
           (goto-char (point-min))
           (when (re-search-forward "\\+(define-public \\(\\S-+\\)"
                                    nil 'noerror)
             (match-string-no-properties 1)))
         var)
      "." n n
      "* " (p (or (car (magit-staged-files)) ""))
      " (" (s var ) "): New variable.")

(remove\ "gnu: Remove "
         (p (with-temp-buffer
              (magit-git-wash #'magit-diff-wash-diffs
                "diff" "--staged")
              (goto-char (point-min))
              (when (re-search-forward "\\-(define-public \\(\\S-+\\)"
                                       nil 'noerror)
                (match-string-no-properties 1)))
            var)
         "." n n
         "* " (p (or (car (magit-staged-files)) ""))
         " (" (s var) "): Delete variable.")

(rename\ "gnu: "
         (p (with-temp-buffer
              (magit-git-wash #'magit-diff-wash-diffs
                "diff" "--staged")
              (beginning-of-buffer)
              (when (search-forward "-(define-public " nil 'noerror)
                (thing-at-point 'sexp 'no-properties)))
            prev-var)
         ": Rename package to "
         (p (with-temp-buffer
              (magit-git-wash #'magit-diff-wash-diffs
                "diff" "--staged")
              (beginning-of-buffer)
              (when (search-forward "+(define-public " nil 'noerror)
                (thing-at-point 'sexp 'no-properties)))
            new-var)
         "." n n
         "* " (p (or (car (magit-staged-files)) "")) " (" (s prev-var) "): "
         "Define in terms of" n
         "'deprecated-package'." n
         "(" (s new-var) "): New variable, formerly known as \""
         (s prev-var) "\".")

(update\ "gnu: "
         (p (with-temp-buffer
              (magit-git-wash #'magit-diff-wash-diffs
                "diff" "--staged")
              (goto-char (point-min))
              (when (re-search-forward "^[ ]*(define-public \\(\\S-+\\)"
                                       nil 'noerror)
                (match-string-no-properties 1)))
            var)
         ": Update to "
         (p (with-temp-buffer
              (magit-git-wash #'magit-diff-wash-diffs
                "diff" "--staged")
              (goto-char (point-min))
              (search-forward "name" nil 'noerror)
              (search-forward "+" nil 'noerror)   ; first change
              (when (and (search-forward "version " nil 'noerror)
                         (looking-at-p "\""))
                (let ((end (save-excursion (search-forward "\")"
                                                           nil 'noerror))))
                  (when end
                    (forward-char)
                    (buffer-substring-no-properties (point) (- end 2))))))
            version)
         "." n n
         "* " (p (or (car (magit-staged-files)) "")) " (" (s var) "): "
         "Update to " (s version) "." n
         (mapconcat (lambda (file) (concat "* " file))
                    (cdr (magit-staged-files))
                    "\n"))

(addcl\ "gnu: Add cl-"
        (p (replace-regexp-in-string
            "^cl-" "" (with-temp-buffer
                        (magit-git-wash #'magit-diff-wash-diffs
                          "diff" "--staged")
                        (beginning-of-buffer)
                        (when (search-forward "+(define-public " nil 'noerror)
                          (replace-regexp-in-string
                           "^sbcl-" ""
                           (thing-at-point 'sexp 'no-properties)))))
           var)
        "." n n
        "* " (p (or (car (magit-staged-files)) ""))
        " (cl-" (s var)
        ", ecl-" (s var)
        ", sbcl-" (s var) "): New variables.")

(https\ "gnu: "
        (p (with-temp-buffer
             (magit-git-wash #'magit-diff-wash-diffs
               "diff" "--staged")
             (goto-char (point-min))
             (when (re-search-forward "^[ ]*(define-public \\(\\S-+\\)"
                                      nil 'noerror)
               (match-string-no-properties 1)))
           var)
        ": Use HTTPS home page." n n
        "* " (p (or (car (magit-staged-files)) ""))
        " (" (s var) ")[home-page]: Use HTTPS."
        n
        (mapconcat (lambda (file) (concat "* " file))
                   (cdr (magit-staged-files))
                   "\n"))

(move\ "gnu: "
       (p (with-temp-buffer
            (magit-git-wash #'magit-diff-wash-diffs
              "diff" "--staged")
            (goto-char (point-min))
            (when (re-search-forward "\\-(define-public \\(\\S-+\\)"
                                     nil 'noerror)
              (match-string-no-properties 1)))
          var)
       ": Move to ("
       (p (with-temp-buffer
            (magit-git-wash #'magit-diff-wash-diffs
              "diff" "--staged")
            (goto-char (point-min))
            (when (and
                   (re-search-forward "\\+(define-public \\(\\S-+\\)"
                                      nil 'noerror)
                   (re-search-backward "modified[ ]*\\(\\S-+\\)"
                                       nil 'noerror))
              (string-replace
               "\.scm" ""
               (string-replace "/" " "
                               (match-string-no-properties 1)))))
          new-module)
       ")." n
       n
       "* " (p (with-temp-buffer
                  (magit-git-wash #'magit-diff-wash-diffs
                    "diff" "--staged")
                  (goto-char (point-min))
                  (when (and
                         (re-search-forward "\\-(define-public \\(\\S-+\\)"
                                            nil 'noerror)
                         (re-search-backward "modified[ ]*\\(\\S-+\\)"
                                             nil 'noerror))
                    (match-string-no-properties 1)))
                source)
       " (" (s var) "): Move from here…" n
       "* " (concat (string-replace " " "/" new-module) ".scm")
       " (" (s var) "): …to here.")