100 |
(defvar server-process nil |
(defvar server-process nil |
101 |
"The current server process.") |
"The current server process.") |
102 |
|
|
|
(defvar server-previous-strings nil) |
|
|
|
|
103 |
(defvar server-clients nil |
(defvar server-clients nil |
104 |
"List of current server clients. |
"List of current server clients. |
105 |
Each element is (CLIENTID BUFFERS...) where CLIENTID is a string |
Each element is (CLIENTID BUFFERS...) where CLIENTID is a string |
177 |
(or (bolp) (newline))))) |
(or (bolp) (newline))))) |
178 |
|
|
179 |
(defun server-sentinel (proc msg) |
(defun server-sentinel (proc msg) |
|
;; Purge server-previous-strings of the now irrelevant entry. |
|
|
(setq server-previous-strings |
|
|
(delq (assq proc server-previous-strings) server-previous-strings)) |
|
180 |
(let ((client (assq proc server-clients))) |
(let ((client (assq proc server-clients))) |
181 |
;; Remove PROC from the list of clients. |
;; Remove PROC from the list of clients. |
182 |
(when client |
(when client |
277 |
"Process a request from the server to edit some files. |
"Process a request from the server to edit some files. |
278 |
PROC is the server process. Format of STRING is \"PATH PATH PATH... \\n\"." |
PROC is the server process. Format of STRING is \"PATH PATH PATH... \\n\"." |
279 |
(server-log string proc) |
(server-log string proc) |
280 |
(let ((ps (assq proc server-previous-strings))) |
(let ((prev (process-get proc 'previous-string))) |
281 |
(when (cdr ps) |
(when prev |
282 |
(setq string (concat (cdr ps) string)) |
(setq string (concat prev string)) |
283 |
(setcdr ps nil))) |
(process-put proc 'previous-string nil))) |
284 |
;; If the input is multiple lines, |
;; If the input is multiple lines, |
285 |
;; process each line individually. |
;; process each line individually. |
286 |
(while (string-match "\n" string) |
(while (string-match "\n" string) |
357 |
"When done with a buffer, type \\[server-edit]"))))))) |
"When done with a buffer, type \\[server-edit]"))))))) |
358 |
;; Save for later any partial line that remains. |
;; Save for later any partial line that remains. |
359 |
(when (> (length string) 0) |
(when (> (length string) 0) |
360 |
(let ((ps (assq proc server-previous-strings))) |
(process-put proc 'previous-string string))) |
|
(if ps (setcdr ps string) |
|
|
(push (cons proc string) server-previous-strings))))) |
|
361 |
|
|
362 |
(defun server-goto-line-column (file-line-col) |
(defun server-goto-line-column (file-line-col) |
363 |
(goto-line (nth 1 file-line-col)) |
(goto-line (nth 1 file-line-col)) |