File: example.scm

package info (click to toggle)
xchat-guile 0.3-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,416 kB
  • ctags: 333
  • sloc: sh: 11,115; ansic: 1,023; makefile: 78; lisp: 72
file content (45 lines) | stat: -rw-r--r-- 1,536 bytes parent folder | download | duplicates (3)
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
;
; Copyright (C) 2009 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>.
;
; This file is part of XChat-Guile.
;
; XChat-Guile 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 2 of the License, or
; (at your option) any later version.
;
; XChat-Guile 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, write to the Free Software Foundation,
; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

(define xchat:plugin-name "guile-example")
(define xchat:plugin-description "This is a demo XChat Guile plugin")
(define xchat:plugin-version "0.1")

(define timer-id #f)

(define (xchat:plugin-init)
  ; This code deliberately makes use of closures to demonstrate why this
  ; procedure does not need a 'user-data' argument in scheme as needed in
  ; other languages
  (set! timer-id 
	(xchat:hook-timer 1000 
			  (let ((clock 0))
			    (lambda ()
			      (set! clock (+ clock 1))
			      (display "seconds passed = ")
			      (display clock)
			      (newline)))))
  (display "Plugin Initialized")
  (newline))

(define (xchat:plugin-deinit)
  (xchat:unhook timer-id)
  (display "Plugin De-initialized")
  (newline))