forked from gmlarumbe/verilog-ext
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verilog-ext-time-stamp.el
85 lines (65 loc) · 3.01 KB
/
verilog-ext-time-stamp.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
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
;;; verilog-ext-time-stamp.el --- Verilog-ext Timestamp -*- lexical-binding: t -*-
;; Copyright (C) 2022-2023 Gonzalo Larumbe
;; Author: Gonzalo Larumbe <[email protected]>
;; URL: https://github.com/gmlarumbe/verilog-ext
;; 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:
;; Timestamp setup
;;; Code:
(defgroup verilog-ext-time-stamp nil
"Verilog-ext time-stamp."
:group 'verilog-ext)
(defcustom verilog-ext-time-stamp-enable t
"Enable `verilog-ext-time-stamp-mode'."
:type 'boolean
:group 'verilog-ext-time-stamp)
(defcustom verilog-ext-time-stamp-regex "^// Last modified : "
"Timestamp regexp."
:type 'string
:group 'verilog-ext-time-stamp)
(defcustom verilog-ext-time-stamp-pattern (concat verilog-ext-time-stamp-regex "%%$")
"Timestamp pattern. See `time-stamp-pattern'."
:type 'string
:group 'verilog-ext-time-stamp)
(defcustom verilog-ext-time-stamp-format "%:y/%02m/%02d"
"Timestamp format. See `time-stamp-format'."
:type 'string
:group 'verilog-ext-time-stamp)
(defcustom verilog-ext-time-stamp-start nil
"If using `time-stamp-start' and `time-stamp-end':
`'time-stamp' deletes the text between the first match of `time-stamp-start'.
and the following match of `time-stamp-end', then writes the time stamp
specified by `time-stamp-format' between them."
:type 'string
:group 'verilog-ext-time-stamp)
(defcustom verilog-ext-time-stamp-end nil
"If using `time-stamp-start' and `time-stamp-end':
`time-stamp' deletes the text between the first match of `time-stamp-start'.
and the following match of `time-stamp-end', then writes the time stamp
specified by `time-stamp-format' between them."
:type 'string
:group 'verilog-ext-time-stamp)
(define-minor-mode verilog-ext-time-stamp-mode
"Setup `time-stamp' format for Verilog files.
By default `time-stamp' looks for the pattern in the first 8 lines.
This can be changed by setting the local variables `time-stamp-start'
and `time-stamp-end' for custom scenarios."
:global nil
(setq-local time-stamp-pattern verilog-ext-time-stamp-pattern)
(setq-local time-stamp-format verilog-ext-time-stamp-format)
(setq-local time-stamp-start verilog-ext-time-stamp-start)
(setq-local time-stamp-end verilog-ext-time-stamp-end)
(if verilog-ext-time-stamp-mode
(add-hook 'before-save-hook #'time-stamp nil :local)
(remove-hook 'before-save-hook #'time-stamp :local)))
(provide 'verilog-ext-time-stamp)
;;; verilog-ext-time-stamp.el ends here