-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-hdl-faceup.el
57 lines (45 loc) · 2.06 KB
/
test-hdl-faceup.el
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
;;; test-hdl-faceup.el --- Verilog/VHDL Elisp Faceup -*- lexical-binding: t -*-
;; Copyright (C) 2022-2024 Gonzalo Larumbe
;; Author: Gonzalo Larumbe <gonzalomlarumbe@gmail.com>
;; URL: https://github.com/gmlarumbe/test-hdl
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; ERT font-lock tests:
;; - https://github.com/Lindydancer/faceup
;;
;;; Code:
(require 'faceup)
(defun test-hdl-faceup-test-file (mode)
(test-hdl-no-messages
(funcall mode))
;; It is needed to explicitly fontify for batch-mode updates, since by
;; default batch mode does not enable font-lock. Initially tried with
;; `font-lock-ensure' but gave different results for tree-sitter. Plus,
;; `faceup-write-file' calls internally `font-lock-fontify-region' so
;; it's more consistent
(font-lock-fontify-region (point-min) (point-max))
;; The code below is copied/adapted from `faceup-write-file':
;; - The target is to replace the content of current buffer with its
;; corresponding faceup format
;; - `faceup-markup-to-buffer' first arg is the target buffer, which
;; will be the original one
;; - A temp buffer is used as temporary storage to place the data to
;; be processed
(let ((buffer-orig (current-buffer)))
(with-temp-buffer
(insert-buffer-substring buffer-orig)
(with-current-buffer buffer-orig
(erase-buffer))
(faceup-markup-to-buffer buffer-orig (current-buffer)))))
(provide 'test-hdl-faceup)
;;; test-hdl-faceup.el ends here