Initial git import
[emchat] / emchat-setup.el
1 ;; emchat-setup.el --- Setup user directory and files for EMchat.
2
3 ;; Copyright (C) 2002 - 2007 Steve Youngs
4
5 ;; Author:        Steve Youngs <steve@emchat.org>
6 ;; Maintainer:    Steve Youngs <steve@emchat.org>
7 ;; Created:       2002-10-03
8 ;; Homepage:      http://www.emchat.org/
9 ;; Keywords:      comm ICQ
10
11 ;; This file is part of EMchat.
12
13 ;; Redistribution and use in source and binary forms, with or without
14 ;; modification, are permitted provided that the following conditions
15 ;; are met:
16 ;;
17 ;; 1. Redistributions of source code must retain the above copyright
18 ;;    notice, this list of conditions and the following disclaimer.
19 ;;
20 ;; 2. Redistributions in binary form must reproduce the above copyright
21 ;;    notice, this list of conditions and the following disclaimer in the
22 ;;    documentation and/or other materials provided with the distribution.
23 ;;
24 ;; 3. Neither the name of the author nor the names of any contributors
25 ;;    may be used to endorse or promote products derived from this
26 ;;    software without specific prior written permission.
27 ;;
28 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
29 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31 ;; DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
35 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
37 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
38 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
40 (defconst emchat-world-user-file-template
41   "
42 Literally you can put anything you like in this resource file, such as
43 this introduction.  EMchat will only consider a line to be a valid buddy
44 if...
45
46     -- `:icq' starts at column zero (there's no leading whitespace or
47        characters).
48
49     -- There is one space between `:icq' and a UIN.
50
51     -- There is one space between a UIN and a buddy name.
52
53     -- The buddy name does NOT contain any colon `:' characters.
54        Buddy names can contain whitespace anywhere except as the
55        first character.
56
57     -- There is one space between the buddy name and any group names.
58        Group names begin with a colon `:'.
59
60 So, for example...
61
62 :icq 34307457 emchat
63 :icq 12345678 me
64 :icq 88888888 the queen :royalty
65
66 This way, it defines three buddies: \"emchat\", \"me\", and \"the
67 queen\". It reads alias name until the end of the line, or until the
68 first group name.  In that example, the buddy \"the queen\" is in
69 the group `:royalty'.
70
71 Adding your own UIN:
72
73 Just change \"12345678 me\" above to your UIN/alias.  And don't
74 forget to change the (setq emchat-user-alias \"me\") line in your
75 `user-init-file' to match.
76
77 BTW, that 1st buddy up there, 34307457 emchat, is a valid UIN, it's
78 mine. :-)
79
80 Remember to M-x emchat-world-update after changing this rc file.
81
82 "
83   "Template used to create user's initial EMchat rc file.")
84
85 (eval-when-compile
86   (defvar emchat-history-directory))
87
88 ;;;###autoload
89 (defun emchat-setup ()
90   "Setup your personal EMchat directory.
91
92 This directory, which defaults to '~/.emchat/', holds the resource file
93 for your ICQ contacts and any log files.  It's also a good place to
94 put your sound files."
95   (interactive)
96   (unless (featurep '(and emchat emchat-history emchat-world emchat-setup))
97     (require 'emchat)
98     (require 'emchat-history)
99     (require 'emchat-world)
100     (require 'emchat-setup))
101   ;; Create necessary directories.
102   (unless (file-directory-p emchat-directory)
103     (make-directory emchat-directory t))
104   (unless (file-directory-p emchat-sound-directory)
105     (make-directory emchat-sound-directory t))
106   (unless (file-directory-p emchat-history-directory)
107     (make-directory emchat-history-directory t))
108   ;; Create a world file if needed.
109   (unless (file-exists-p emchat-world-rc-filename)
110     (save-excursion
111       (switch-to-buffer (find-file emchat-world-rc-filename))
112       (insert (symbol-value 'emchat-world-user-file-template))
113       (save-buffer)
114       (kill-buffer nil)))
115   (message "Don't forget to edit %s to your requirements"
116            emchat-world-rc-filename))
117               
118 (provide 'emchat-setup)
119 ;;; emchat-setup.el ends here