-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathnoisy-change.el
75 lines (56 loc) · 2.35 KB
/
noisy-change.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
;;; noisy-change.el --- Make changes noisily -*- lexical-binding: t -*-
;;; Header:
;; This file is not part of Emacs
;; Author: Phillip Lord <[email protected]>
;; Maintainer: Phillip Lord <[email protected]>
;; The contents of this file are subject to the GPL License, Version 3.0.
;; Copyright (C) 2014-2022 Free Software Foundation, Inc.
;; 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:
;; Make changes noisily. This is useful for developing lentic.
(defvar noisy-change-log nil)
(make-variable-buffer-local 'noisy-change-log)
(defun noisy-change-toggle ()
(interactive)
(if noisy-change-log
(progn (setq noisy-change-log nil)
(message "Noise-change off"))
(setq noisy-change-log t)
(message "noisy-change on")))
(defmacro noisy-change-log (&rest rest)
"Log REST."
`(when noisy-change-log
(with-current-buffer
(get-buffer-create "*noisy-change-log*")
(goto-char (point-max))
(insert
(concat
(format ,@rest)
"\n")))))
(defvar noisy-change-last-bcf nil)
(defun noisy-change-before-function (start stop)
(setq noisy-change-last-bcf '(start . stop))
(noisy-change-log "before(%s,%s,%s)" start stop this-command))
(defun noisy-change-after-function (start stop length)
(when
(and noisy-change-last-bcf
(and (< 0 length)
(not (= start stop))))
(noisy-change-log "Skew Detected"))
(noisy-change-log "after(%s,%s,%s,%s)" start stop length
this-command))
;; FIXME: The mere act of loading a file should not make such changes.
(add-hook 'before-change-functions #'noisy-change-before-function)
(add-hook 'after-change-functions #'noisy-change-after-function)
;; Local Variables:
;; no-update-autoloads: t
;; End: