Start cleaning
[texmacs.git] / src / TeXmacs / examples / plugins / mutator / progs / init-mutator.scm
blob9c125e6fdb4059da01e04ed20a1af08568395ea7
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;;
4 ;; MODULE      : init-mutator.scm
5 ;; DESCRIPTION : Initialize the 'mutator' plugin
6 ;; COPYRIGHT   : (C) 2004  Joris van der Hoeven
7 ;;
8 ;; This software falls under the GNU general public license version 3 or later.
9 ;; It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
10 ;; in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
12 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14 (use-modules (utils library tree))
16 (tm-define (mutate-date)
17   (:secure #t)
18   (with-mutator t
19     (tree-set! t (var-eval-system "date +\"%H:%M:%S\""))))
21 (tm-define (mutate-blink)
22   (:secure #t)
23   (with-mutator t
24     (let* ((mod (lambda (x y) (* y (- (/ x y) (floor (/ x y))))))
25            (s (string->number (var-eval-system "date +\"%S\"")))
26            (e (mod s 4)))
27       (if (and (<= e 1) (not (match? t '(strong :%1))))
28           (tree-set! t `(strong ,t)))
29       (if (and (>= e 2) (match? t '(strong :%1)))
30           (tree-set! t (tree-ref t 0))))))
32 (kbd-map
33   ("C-F11" (insert '(mutator "" "(mutate-date)")))
34   ("C-F12" (insert-go-to '(mutator "text" "(mutate-blink)") '(0 4))))
36 (plugin-configure mutator
37   (:require #t))