Browse code
feat(emacs): generalize magit-log propertizing
Showing 1 changed files
... | ... |
@@ -183,6 +183,14 @@ |
183 | 183 |
`((t :foreground ,zenburn-blue :inherit magit-keyword)) |
184 | 184 |
"Face for parts of commit messages inside brackets." |
185 | 185 |
:group 'magit-faces) |
186 |
+ (defface magit-keyword-test |
|
187 |
+ `((t :foreground ,zenburn-blue-1 :inherit magit-keyword)) |
|
188 |
+ "Face for parts of commit messages inside brackets." |
|
189 |
+ :group 'magit-faces) |
|
190 |
+ (defface magit-keyword-refactor |
|
191 |
+ `((t :foreground ,zenburn-green+1 :inherit magit-keyword)) |
|
192 |
+ "Face for parts of commit messages inside brackets." |
|
193 |
+ :group 'magit-faces) |
|
186 | 194 |
(defface magit-keyword-misc |
187 | 195 |
`((t :foreground ,zenburn-fg-1 :inherit magit-keyword)) |
188 | 196 |
"Face for parts of commit messages inside brackets." |
... | ... |
@@ -192,22 +200,23 @@ |
192 | 200 |
"Face for parts of commit messages inside brackets." |
193 | 201 |
:group 'magit-faces)) |
194 | 202 |
|
203 |
+(defvar fwoar::*magit-log-regexp-faces* |
|
204 |
+ '((magit-keyword-feature |
|
205 |
+ "^\\(\\(?:feat\\(?:ure\\)?(\\([^)]+?\\))\\)\\|\\(?:feat\\(ure\\)?\\>\\)\\)") |
|
206 |
+ (magit-keyword-chore "^\\(\\(?:chore(\\([^)]+?\\))\\)\\|\\(?:chore\\>\\)\\)") |
|
207 |
+ (magit-keyword-test "^\\(\\(?:test(\\([^)]+?\\))\\)\\|\\(?:test\\>\\)\\)") |
|
208 |
+ (magit-keyword-refactor "^\\(\\(?:refactor(\\([^)]+?\\))\\)\\|\\(?:refactor\\>\\)\\)") |
|
209 |
+ (magit-keyword-bug "^\\(\\(?:bug(\\([^)]+?\\))\\)\\|\\(?:bug\\>\\)\\)") |
|
210 |
+ (magit-keyword-test "^\\(\\(?:test(\\([^)]+?\\))\\)\\|\\(?:test\\>\\)\\)") |
|
211 |
+ )) |
|
212 |
+ |
|
195 | 213 |
(defun fwoar/propertize-magit-log (_rev msg) |
196 |
- (let ((boundary 0)) |
|
197 |
- (while (string-match "^\\(\\(?:feat\\(?:ure\\)?(\\([^)]+?\\))\\)\\|\\(?:feat\\(ure\\)?\\>\\)\\)" msg boundary) |
|
198 |
- (setq boundary (match-end 0)) |
|
199 |
- (magit--put-face (match-beginning 0) boundary |
|
200 |
- 'magit-keyword-feature msg))) |
|
201 |
- (let ((boundary 0)) |
|
202 |
- (while (string-match "^\\(\\(?:chore(\\([^)]+?\\))\\)\\|\\(?:chore\\>\\)\\)" msg boundary) |
|
203 |
- (setq boundary (match-end 0)) |
|
204 |
- (magit--put-face (match-beginning 0) boundary |
|
205 |
- 'magit-keyword-chore msg))) |
|
206 |
- (let ((boundary 0)) |
|
207 |
- (while (string-match "^\\(\\(?:bug(\\([^)]+?\\))\\)\\|\\(?:bug\\>\\)\\)" msg boundary) |
|
208 |
- (setq boundary (match-end 0)) |
|
209 |
- (magit--put-face (match-beginning 0) boundary |
|
210 |
- 'magit-keyword-bug msg))) |
|
214 |
+ (cl-loop for (face regexp) in fwoar::*magit-log-regexp-faces* |
|
215 |
+ do (let ((boundary 0)) |
|
216 |
+ (while (string-match regexp msg boundary) |
|
217 |
+ (setq boundary (match-end 0)) |
|
218 |
+ (magit--put-face (match-beginning 0) boundary face msg)))) |
|
219 |
+ |
|
211 | 220 |
(let ((boundary 0)) |
212 | 221 |
(while (string-match "^\\([^:\n\t]+\\):" msg boundary) |
213 | 222 |
(setq boundary (match-end 0)) |