Bugfixes, and allowed suppression of join messages.
[lurk.git] / lurk.el
1 ;;; lurk.el --- Little Unified iRc Klient -*- lexical-binding:t -*-
2
3 ;; Copyright (C) 2021 Tim Vaughan
4
5 ;; Author: Tim Vaughan <timv@ughan.xyz>
6 ;; Created: 14 June 2021
7 ;; Version: 1.0
8 ;; Keywords: network
9 ;; Homepage: http://thelambdalab.xyz/lurk
10 ;; Package-Requires: ((emacs "26"))
11
12 ;; This file is not part of GNU Emacs.
13
14 ;; This program is free software: you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation, either version 3 of the License, or
17 ;; (at your option) any later version.
18
19 ;; This program is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with this file.  If not, see <http://www.gnu.org/licenses/>.
26
27 ;;; Commentary:
28
29 ;;; Code:
30
31 (provide 'lurk)
32
33
34 ;;; Customizations
35 ;;
36
37 (defgroup lurk nil
38   "Little Unified iRc Klient."
39   :group 'network)
40
41 (defcustom lurk-nick "plugd"
42   "Default nick.")
43
44 (defcustom lurk-default-quit-msg "Bye"
45   "Default quit message when none supplied.")
46
47 (defcustom lurk-networks
48   '(("libera" "irc.libera.chat" 6697)
49     ("freenode" "chat.freenode.net" 6697)
50     ("tilde" "tilde.chat" 6697)
51     ("mbr" "mbrserver.com" 6667 :notls)
52     ("local" "localhost" 6697))
53   "IRC networks.")
54
55 (defcustom lurk-allow-ipv6 nil
56   "Set to non-nil to allow use of IPv6.")
57
58 (defcustom lurk-show-joins nil
59   "Set to non-nil to be notified of joins, parts and quits.")
60
61 ;;; Faces
62 ;;
63
64 (defface lurk-text
65   '((t :inherit font-lock-preprocessor-face))
66   "Face used for Lurk text.")
67
68 (defface lurk-your-nick
69   '((t :inherit font-lock-constant-face))
70   "Face used for highlighting your nick.")
71
72 (defface lurk-prompt
73   '((t :inherit org-level-2))
74   "Face used for the prompt.")
75
76 (defface lurk-context
77   '((t :inherit org-list-dt))
78   "Face used for the context name in the prompt.")
79
80 (defface lurk-faded
81   '((t :inherit font-lock-preprocessor-face))
82   "Face used for faded Lurk text.")
83
84 (defface lurk-bold
85   '((t :inherit font-lock-function-name-face))
86   "Face used for bold Lurk text.")
87
88 (defface lurk-error
89   '((t :inherit font-lock-regexp-grouping-construct))
90   "Face used for Lurk error text.")
91
92 ;;; Global variables
93 ;;
94
95 (defvar lurk-version "Lurk v0.1")
96
97 (defvar lurk-notice-prefix
98   (concat
99    (propertize
100     "-" 'face 'lurk-faded)
101    (propertize
102     "!" 'face 'lurk-bold)
103    (propertize
104     "-" 'face 'lurk-faded)))
105
106 (defvar lurk-error-prefix
107   (propertize "!!!" 'face 'lurk-error))
108
109 (defvar lurk-prompt-string
110   (propertize "> " 'face 'lurk-prompt))
111
112
113 ;;; Network process
114 ;;
115
116 (defvar lurk-response "")
117
118 (defun lurk-filter (proc string)
119   (dolist (line (split-string (concat lurk-response string) "\n"))
120     (if (string-suffix-p "\r" line)
121         (lurk-eval-msg-string (string-trim line))
122       (setq lurk-response line))))
123
124 (defun lurk-sentinel (proc string)
125   (unless (equal "open" (string-trim string))
126     (lurk-display-error "Disconnected from server.")
127     (clrhash lurk-contexts)
128     (setq lurk-current-context nil)
129     (lurk-render-prompt)
130     (cancel-timer lurk-ping-timer)))
131
132 (defun lurk-start-process (network)
133   (let* ((row (assoc network lurk-networks))
134          (host (elt row 1))
135          (port (elt row 2))
136          (flags (seq-drop row 3)))
137     (make-network-process :name "lurk"
138                           :host host
139                           :service port
140                           :family (if lurk-allow-ipv6 nil 'ipv4)
141                           :filter #'lurk-filter
142                           :sentinel #'lurk-sentinel
143                           :nowait nil
144                           :tls-parameters (if (memq :notls flags)
145                                               nil
146                                             (cons 'gnutls-x509pki
147                                                   (gnutls-boot-parameters
148                                                    :type 'gnutls-x509pki
149                                                    :hostname host)))
150                           :buffer "*lurk*")))
151
152 (defvar lurk-ping-timer nil)
153 (defvar lurk-ping-period 60)
154
155 (defun lurk-ping-function ()
156   (lurk-send-msg (lurk-msg nil nil "PING" (car (process-contact (get-process "lurk")))))
157   (setq lurk-ping-timer (run-with-timer lurk-ping-period nil #'lurk-ping-function)))
158
159 (defun lurk-connect (network)
160   (if (get-process "lurk")
161       (lurk-display-error "Already connected.  Disconnect first.")
162     (if (not (assoc network lurk-networks))
163         (lurk-display-error "Network '" network "' is unknown.")
164       (clrhash lurk-contexts)
165       (setq lurk-current-context nil)
166       (lurk-start-process network)
167       (lurk-send-msg (lurk-msg nil nil "USER" lurk-nick 0 "*" lurk-nick))
168       (lurk-send-msg (lurk-msg nil nil "NICK" lurk-nick))
169       (setq lurk-ping-timer (run-with-timer lurk-ping-period nil #'lurk-ping-function)))))
170
171 (defun lurk-connected-p ()
172   (let ((proc (get-process "lurk")))
173     (and proc (eq (process-status proc) 'open))))
174
175 (defun lurk-send-msg (msg)
176   (let ((proc (get-process "lurk")))
177     (if (and proc (eq (process-status proc) 'open))
178         (process-send-string proc (concat (lurk-msg->string msg) "\r\n"))
179       (lurk-display-error "No server connection established.")
180       (error "No server connection established"))))
181
182
183 ;;; Server messages
184 ;;
185
186 (defun lurk--as-string (obj)
187   (if obj
188       (with-output-to-string (princ obj))
189     nil))
190
191 (defun lurk-msg (tags src cmd &rest params)
192   (list (lurk--as-string tags)
193         (lurk--as-string src)
194         (upcase (lurk--as-string cmd))
195         (mapcar #'lurk--as-string
196                 (if (and params (listp (elt params 0)))
197                     (elt params 0)
198                   params))))
199
200 (defun lurk-msg-tags (msg) (elt msg 0))
201 (defun lurk-msg-src (msg) (elt msg 1))
202 (defun lurk-msg-cmd (msg) (elt msg 2))
203 (defun lurk-msg-params (msg) (elt msg 3))
204 (defun lurk-msg-trail (msg)
205   (let ((params (lurk-msg-params msg)))
206     (if params
207         (elt params (- (length params) 1)))))
208
209 (defvar lurk-msg-regex
210   (rx
211    (opt (: "@" (group (* (not (or "\n" "\r" ";" " ")))))
212         (* whitespace))
213    (opt (: ":" (: (group (* (not (any space "!" "@"))))
214                   (* (not (any space)))))
215         (* whitespace))
216    (group (: (* (not whitespace))))
217    (* whitespace)
218    (opt (group (+ not-newline))))
219   "Regex used to parse IRC messages.
220 Note that this regex is incomplete.  Noteably, we discard the non-nick
221 portion of the source component of the message, as LURK doesn't use this.")
222
223 (defun lurk-string->msg (string)
224   (if (string-match lurk-msg-regex string)
225       (let* ((tags (match-string 1 string))
226              (src (match-string 2 string))
227              (cmd (upcase (match-string 3 string)))
228              (params-str (match-string 4 string))
229              (params
230               (if params-str
231                   (let* ((idx (cl-search ":" params-str))
232                          (l (split-string (string-trim (substring params-str 0 idx))))
233                          (r (if idx (list (substring params-str (+ 1 idx))) nil)))
234                     (append l r))
235                 nil)))
236         (apply #'lurk-msg (append (list tags src cmd) params)))
237     (error "Failed to parse string " string)))
238
239 (defun lurk--filtered-join (&rest args)
240   (string-join (seq-filter (lambda (el) el) args) " "))
241
242 (defun lurk-msg->string (msg)
243   (let ((tags (lurk-msg-tags msg))
244         (src (lurk-msg-src msg))
245         (cmd (lurk-msg-cmd msg))
246         (params (lurk-msg-params msg)))
247     (lurk--filtered-join
248      (if tags (concat "@" tags) nil)
249      (if src (concat ":" src) nil)
250      cmd
251      (if (> (length params) 1)
252          (string-join (seq-take params (- (length params) 1)) " ")
253        nil)
254      (if (> (length params) 0)
255          (concat ":" (elt params (- (length params) 1)))
256        nil))))
257
258
259 ;;; Contexts
260 ;;
261
262 (defvar lurk-current-context nil)
263 (defvar lurk-contexts (make-hash-table :test #'equal))
264
265 (defun lurk-add-context (name)
266   (puthash name nil lurk-contexts))
267
268 (defun lurk-del-context (name)
269   (remhash name lurk-contexts))
270
271 (defun lurk-get-context-users (name)
272   (gethash name lurk-contexts))
273
274 (defun lurk-add-context-users (context users)
275   (puthash context
276            (append users
277                    (gethash context lurk-contexts))
278            lurk-contexts))
279
280 (defun lurk-del-context-user (context user)
281   (puthash context
282            (remove user (gethash context lurk-contexts))
283            lurk-contexts))
284
285 (defun lurk-del-user (user)
286   (dolist (context (lurk-get-context-list))
287     (lurk-del-context-user context user)))
288
289 (defun lurk-rename-user (old-nick new-nick)
290   (dolist (context (lurk-get-context-list))
291     (lurk-del-context-user context old-nick)
292     (lurk-add-context-users context (list new-nick))))
293
294 (defun lurk-get-context-type (name)
295   (cond
296    ((string-prefix-p "#" name) 'channel)
297    ((string-match-p (rx (or "." "localhost")) name) 'host)
298    (t 'nick)))
299
300 (defun lurk-get-context-list ()
301   (let ((res nil))
302     (maphash (lambda (key val)
303                (cl-pushnew key res))
304              lurk-contexts)
305     res))
306
307 (defun lurk-get-next-context (&optional prev)
308   (if lurk-current-context
309       (let* ((context-list (if prev
310                                (reverse (lurk-get-context-list))
311                              (lurk-get-context-list)))
312              (context-list* (member lurk-current-context context-list)))
313         (if (> (length context-list*) 1)
314             (cadr context-list*)
315           (car context-list)))
316     nil))
317
318 (defun lurk-cycle-contexts (&optional rev)
319   (if lurk-current-context
320       (progn
321         (setq lurk-current-context (lurk-get-next-context rev))
322         (lurk-render-prompt))
323     (lurk-display-error "No channels joined.")))
324
325 (defun lurk-cycle-contexts-forward ()
326   (interactive)
327   (lurk-cycle-contexts))
328
329 (defun lurk-cycle-contexts-reverse ()
330   (interactive)
331   (lurk-cycle-contexts t))
332
333
334 ;;; Buffer
335 ;;
336
337 (defun lurk-display-string (&rest strings)
338   (with-current-buffer (get-buffer-create "*lurk*")
339     (save-excursion
340       (goto-char lurk-prompt-marker)
341       (let ((inhibit-read-only t)
342             (old-pos (marker-position lurk-prompt-marker))
343             (adaptive-fill-regexp (rx (= 6 anychar)))
344             (fill-column 80))
345         (insert-before-markers
346          (propertize (concat (format-time-string "%H:%M") " ")
347                      'face 'lurk-text
348                      'read-only t)
349          (propertize (concat (apply #'concat strings) "\n")
350                      'read-only t))
351         (fill-region old-pos lurk-prompt-marker nil t)))))
352
353 (defun lurk-render-prompt ()
354   (with-current-buffer "*lurk*"
355     (let ((update-point (= lurk-input-marker (point)))
356           (update-window-points (mapcar (lambda (w)
357                                           (list (= (window-point w) lurk-input-marker)
358                                                 w))
359                                         (get-buffer-window-list nil nil t))))
360       (save-excursion
361         (set-marker-insertion-type lurk-prompt-marker nil)
362         (set-marker-insertion-type lurk-input-marker t)
363         (let ((inhibit-read-only t))
364           (delete-region lurk-prompt-marker lurk-input-marker)
365           (goto-char lurk-prompt-marker)
366           (insert
367            (propertize (if lurk-current-context
368                            lurk-current-context
369                          "")
370                        'face 'lurk-context
371                        'read-only t)
372            (propertize lurk-prompt-string
373                        'face 'lurk-prompt
374                        'read-only t
375                        'rear-nonsticky t)))
376         (set-marker-insertion-type lurk-input-marker nil))
377       (if update-point
378           (goto-char lurk-input-marker))
379       (dolist (v update-window-points)
380         (if (car v)
381             (set-window-point (cadr v) lurk-input-marker))))))
382   
383 (defvar lurk-prompt-marker nil
384   "Marker for prompt position in LURK buffer.")
385
386 (defvar lurk-input-marker nil
387   "Marker for prompt position in LURK buffer.")
388
389 (defun lurk-setup-buffer ()
390   (with-current-buffer (get-buffer-create "*lurk*")
391     (setq-local scroll-conservatively 1)
392     (if (markerp lurk-prompt-marker)
393         (set-marker lurk-prompt-marker (point-max))
394       (setq lurk-prompt-marker (point-max-marker)))
395     (if (markerp lurk-input-marker)
396         (set-marker lurk-input-marker (point-max))
397       (setq lurk-input-marker (point-max-marker)))
398     (goto-char (point-max))
399     (lurk-render-prompt)))
400
401
402 ;;; Output formatting
403 ;;
404
405 (defun lurk-display-message (from to text)
406   (let ((context (if (eq 'channel (lurk-get-context-type to))
407                      to
408                    (if (equal to lurk-nick) from to))))
409     (lurk-display-string
410      (propertize
411       (pcase (lurk-get-context-type to)
412         ('channel (concat to " <" from "> " text))
413         ('nick (concat "[" from " -> " to "] " text))
414         (_
415          (error "Unsupported context type")))
416       'face 'lurk-text
417       'help-echo (concat "Context: " context)
418       'context context))))
419
420 (defun lurk-display-notice (context &rest notices)
421   (lurk-display-string
422    (propertize
423     (concat lurk-notice-prefix " " (apply #'concat notices))
424     'help-echo (concat "Context: " (or context "none"))
425     'context context)))
426
427 (defun lurk-display-error (&rest messages)
428   (lurk-display-string
429    (concat lurk-error-prefix " "
430            (propertize (apply #'concat messages)
431                        'face 'lurk-error))))
432
433 (defun lurk-highlight-context (context)
434   (with-current-buffer "*lurk*"
435     (let* ((pos lurk-prompt-marker)
436            (nextpos (previous-single-property-change pos 'context))
437            (inhibit-read-only t))
438       (while (> pos nextpos)
439         (let ((thiscontext (get-text-property nextpos 'context)))
440           (if thiscontext
441               (if (equal context thiscontext)
442                   (add-text-properties nextpos pos
443                                        '(face (foreground-color . "green")))
444                 (add-text-properties nextpos pos
445                                      '(face (foreground-color . "blue"))))
446             (add-text-properties nextpos pos
447                                  '(face lurk-text)))
448           thiscontext
449           (setq pos nextpos)
450           (setq nextpos (previous-single-property-change pos 'context nil 1)))))))
451
452 ;;; Message evaluation
453 ;;
454
455 (defun lurk-eval-msg-string (string)
456   ;; (lurk-display-string string)
457   (let* ((msg (lurk-string->msg string)))
458     ;; (message (pp msg))
459     (pcase (lurk-msg-cmd msg)
460       ("PING"
461        (lurk-send-msg
462         (lurk-msg nil nil "PONG" (lurk-msg-params msg))))
463        ;; (lurk-display-notice nil "ping-pong (server initiated)"))
464
465       ("PONG")
466        ;; (lurk-display-notice nil "ping-pong (client initiated)"))
467
468       ("001"
469        (let* ((params (lurk-msg-params msg))
470               (nick (elt params 0))
471               (text (string-join (seq-drop params 1) " ")))
472          (setq lurk-nick nick)
473          (lurk-display-notice nil text)))
474
475       ("353" ; NAMEREPLY
476        (let* ((params (lurk-msg-params msg))
477               (channel (elt params 2))
478               (names (split-string (elt params 3))))
479          (lurk-add-context-users channel names)))
480
481       ("366" ; ENDOFNAMES
482        (let* ((params (lurk-msg-params msg))
483               (channel (elt params 1)))
484          (lurk-display-notice
485           channel
486           (lurk--as-string (length (lurk-get-context-users channel)))
487           " users in " channel)))
488
489       ((rx (= 3 (any digit)))
490        (lurk-display-notice nil (mapconcat 'identity (cdr (lurk-msg-params msg)) " ")))
491
492       ((and "JOIN"
493             (guard (equal lurk-nick (lurk-msg-src msg))))
494        (let ((channel (car (lurk-msg-params msg))))
495          (lurk-add-context channel)
496          (setq lurk-current-context channel)
497          (lurk-display-notice channel "Joining channel " channel)
498          (lurk-render-prompt)))
499
500       ("JOIN"
501        (let ((channel (car (lurk-msg-params msg)))
502              (nick (lurk-msg-src msg)))
503          (lurk-add-context-users channel (list nick))
504          (lurk-display-notice channel nick " joined channel " channel)))
505
506       ((and "PART"
507             (guard (equal lurk-nick (lurk-msg-src msg))))
508        (let ((channel (car (lurk-msg-params msg))))
509          (lurk-display-notice channel "Left channel " channel)
510          (lurk-del-context channel)
511          (if (equal channel lurk-current-context)
512              (setq lurk-current-context (lurk-get-next-context)))
513          (lurk-render-prompt)))
514
515       ("PART"
516        (let ((channel (car (lurk-msg-params msg)))
517              (nick (lurk-msg-src msg)))
518          (lurk-del-context-user channel nick)
519          (lurk-display-notice channel nick " left channel " channel)))
520
521       ("QUIT"
522        (let ((nick (lurk-msg-src msg))
523              (reason (mapconcat 'identity (lurk-msg-params msg) " ")))
524          (lurk-del-user nick)
525          (lurk-display-notice nil nick " quit: " reason)))
526
527       ((and "NICK"
528             (guard (equal lurk-nick (lurk-msg-src msg))))
529        (setq lurk-nick (car (lurk-msg-params msg)))
530        (lurk-display-notice nil "Set nick to " lurk-nick))
531
532       ("NICK"
533        (let ((old-nick (lurk-msg-src msg))
534              (new-nick (car (lurk-msg-params msg))))
535          (lurk-display-notice nil old-nick " is now known as " new-nick)
536          (lurk-rename-user old-nick new-nick)))
537
538       ("NOTICE"
539        (let ((nick (lurk-msg-src msg))
540              (channel (car (lurk-msg-params msg)))
541              (text (cadr (lurk-msg-params msg))))
542          (pcase text
543            ((rx (: "\01VERSION "
544                    (let version (* (not "\01")))
545                    "\01"))
546             (lurk-display-notice nil "CTCP version reply from " nick ": " version))
547            (_
548             (lurk-display-notice nil text)))))
549
550       ("PRIVMSG"
551        (let* ((from (lurk-msg-src msg))
552               (params (lurk-msg-params msg))
553               (to (car params))
554               (text (cadr params)))
555          (pcase text
556            ("\01VERSION\01"
557             (let ((version-string (concat lurk-version " - running on GNU Emacs " emacs-version)))
558               (lurk-send-msg (lurk-msg nil nil "NOTICE"
559                                        (list from (concat "\01VERSION "
560                                                           version-string
561                                                           "\01")))))
562             (lurk-display-notice nil "CTCP version request received from " from))
563
564            ((rx (let ping (: "\01PING " (* (not "\01")) "\01")))
565             (lurk-send-msg (lurk-msg nil nil "NOTICE" (list from ping)))
566             (lurk-display-notice "CTCP ping received from " from))
567
568            ("\01USERINFO\01"
569             (lurk-display-notice "CTCP userinfo request from " from " (no response sent)"))
570
571            (_
572             (lurk-display-message from to text)))))
573       (_
574        (lurk-display-string (lurk-msg->string msg))))))
575
576
577 ;;; Command entering
578 ;;
579
580 (defun lurk-enter-string (string)
581   (if (string-prefix-p "/" string)
582       (pcase (substring string 1)
583         ((rx (: "CONNECT " (let network (* not-newline))))
584          (lurk-display-notice nil "Attempting to connect to " network "...")
585          (lurk-connect network))
586
587         ((rx (: "TOPIC " (let new-topic (* not-newline))))
588          (lurk-send-msg (lurk-msg nil nil "TOPIC" lurk-current-context new-topic)))
589
590         ((rx (: "ME " (let action (* not-newline))))
591          (lurk-send-msg (lurk-msg nil nil "PRIVMSG"
592                                   (list lurk-current-context
593                                         (concat "\01ACTION " action "\01"))))
594          (lurk-display-action lurk-nick action))
595
596         ((rx (: "VERSION" " " (let nick (+ (not whitespace)))))
597          (lurk-send-msg (lurk-msg nil nil "PRIVMSG"
598                                   (list nick "\01VERSION\01")))
599          (lurk-display-notice nil "CTCP version request sent to " nick))
600
601         ((rx "PART" (opt (: " " (let channel (* not-newline)))))
602          (if (or lurk-current-context channel)
603              (lurk-send-msg (lurk-msg nil nil "PART" (if channel
604                                                          channel
605                                                        lurk-current-context)))
606            (lurk-display-error "No current channel to leave.")))
607
608         ((rx "QUIT" (opt (: " " (let quit-msg (* not-newline)))))
609          (lurk-send-msg (lurk-msg nil nil "QUIT"
610                                   (or quit-msg lurk-default-quit-msg))))
611
612         ((rx (: "NICK" (* whitespace) string-end))
613          (lurk-display-notice nil "Current nick: " lurk-nick))
614
615         ((rx (: "NICK" (+ whitespace) (let nick (+ (not whitespace)))))
616          (if (lurk-connected-p)
617              (lurk-send-msg (lurk-msg nil nil "NICK" nick))
618            (setq lurk-nick nick)
619            (lurk-display-notice nil "Set default nick to '" nick "'")))
620
621         ((rx "MSG "
622              (let to (* (not whitespace)))
623              " "
624              (let text (* not-newline)))
625          (lurk-send-msg (lurk-msg nil nil "PRIVMSG" to text))
626          (lurk-display-message lurk-nick to text))
627
628         ((rx (: (let cmd-str (+ (not whitespace)))
629                 (opt (: " " (let params-str (* not-newline))))))
630          (lurk-send-msg (lurk-msg nil nil (upcase cmd-str)
631                                   (if params-str
632                                       (split-string params-str)
633                                     nil)))))
634
635     (unless (string-empty-p string)
636       (if lurk-current-context
637           (progn
638             (lurk-send-msg (lurk-msg nil nil "PRIVMSG"
639                                      lurk-current-context
640                                      string))
641             (lurk-display-message lurk-nick lurk-current-context string))
642         (lurk-display-error "No current context.")))))
643
644 (defun lurk-enter ()
645   "Enter current contents of line after prompt."
646   (interactive)
647   (with-current-buffer "*lurk*"
648     (let ((line (buffer-substring lurk-input-marker (point-max))))
649       (let ((inhibit-read-only t))
650         (delete-region lurk-input-marker (point-max)))
651       (lurk-enter-string line))))
652
653
654 ;;; Mode
655 ;;
656
657 (defvar lurk-mode-map
658   (let ((map (make-sparse-keymap)))
659     (define-key map (kbd "RET") 'lurk-enter)
660     (define-key map (kbd "<C-tab>") 'lurk-cycle-contexts-forward)
661     (define-key map (kbd "<C-S-tab>") 'lurk-cycle-contexts-reverse)
662     map))
663
664 (define-derived-mode lurk-mode text-mode "lurk"
665   "Major mode for LURK.")
666
667 (when (fboundp 'evil-set-initial-state)
668   (evil-set-initial-state 'lurk-mode 'insert))
669
670 ;;; Main start procedure
671 ;;
672
673 (defun lurk ()
674   "Switch to *lurk* buffer."
675   (interactive)
676   (if (get-buffer "*lurk*")
677       (switch-to-buffer "*lurk*")
678     (switch-to-buffer "*lurk*"))
679   (lurk-mode)
680   (lurk-setup-buffer)
681   "Started LURK.")
682
683
684
685 ;;; lurk.el ends here