-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathchat.el
More file actions
29 lines (26 loc) · 1.02 KB
/
chat.el
File metadata and controls
29 lines (26 loc) · 1.02 KB
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
;; Let's make something like Unix talk.
(defun chat (you me)
(interactive "sChat with: \nsAs: \n")
(let ((you-buf (concat "from " you))
(you-fifo (concat "/tmp/" you)))
(call-process "mkfifo" nil nil nil you-fifo)
(call-process "chmod" nil nil nil "a+w" you-fifo)
(start-process "tail-f" you-buf "tail" "-f" you-fifo)
(switch-to-buffer you-buf))
(let ((me-buf (get-buffer-create (concat "to " you)))
(me-fifo (concat "/tmp/" me)))
(call-process "mkfifo" nil nil nil me-fifo)
(call-process "chmod" nil nil nil "a+r" me-fifo)
(switch-to-buffer-other-window me-buf)
(make-local-hook 'after-change-functions)
(add-hook 'after-change-functions
`(lambda (begin end length)
(chat-send ,me-fifo begin end length))
nil
t)))
(defun chat-send (fifo begin end length)
(write-region begin end fifo))
;; TO DO:
;; only seeing comms one way?!
;; permission problems depending on who creates the files?
;; rm fifos when done with them