aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/net/dictionary-connection.el34
1 files changed, 18 insertions, 16 deletions
diff --git a/lisp/net/dictionary-connection.el b/lisp/net/dictionary-connection.el
index 0d93d978df3..d88c0b48f93 100644
--- a/lisp/net/dictionary-connection.el
+++ b/lisp/net/dictionary-connection.el
@@ -28,35 +28,35 @@
28;;; Code: 28;;; Code:
29 29
30(defsubst dictionary-connection-p (connection) 30(defsubst dictionary-connection-p (connection)
31 "Returns non-nil if `connection' is a connection object" 31 "Returns non-nil if CONNECTION is a connection object."
32 (get connection 'connection)) 32 (get connection 'connection))
33 33
34(defsubst dictionary-connection-read-point (connection) 34(defsubst dictionary-connection-read-point (connection)
35 "Return the read point of the connection object." 35 "Return the read point of the CONNECTION object."
36 (get connection 'dictionary-connection-read-point)) 36 (get connection 'dictionary-connection-read-point))
37 37
38(defsubst dictionary-connection-process (connection) 38(defsubst dictionary-connection-process (connection)
39 "Return the process of the connection object." 39 "Return the process of the CONNECTION object."
40 (get connection 'dictionary-connection-process)) 40 (get connection 'dictionary-connection-process))
41 41
42(defsubst dictionary-connection-buffer (connection) 42(defsubst dictionary-connection-buffer (connection)
43 "Return the buffer of the connection object." 43 "Return the buffer of the CONNECTION object."
44 (get connection 'dictionary-connection-buffer)) 44 (get connection 'dictionary-connection-buffer))
45 45
46(defsubst dictionary-connection-set-read-point (connection point) 46(defsubst dictionary-connection-set-read-point (connection point)
47 "Set the read-point for `connection' to `point'." 47 "Set the read-point for CONNECTION to POINT."
48 (put connection 'dictionary-connection-read-point point)) 48 (put connection 'dictionary-connection-read-point point))
49 49
50(defsubst dictionary-connection-set-process (connection process) 50(defsubst dictionary-connection-set-process (connection process)
51 "Set the process for `connection' to `process'." 51 "Set the process for CONNECTION to PROCESS."
52 (put connection 'dictionary-connection-process process)) 52 (put connection 'dictionary-connection-process process))
53 53
54(defsubst dictionary-connection-set-buffer (connection buffer) 54(defsubst dictionary-connection-set-buffer (connection buffer)
55 "Set the buffer for `connection' to `buffer'." 55 "Set the buffer for CONNECTION to BUFFER."
56 (put connection 'dictionary-connection-buffer buffer)) 56 (put connection 'dictionary-connection-buffer buffer))
57 57
58(defun dictionary-connection-create-data (buffer process point) 58(defun dictionary-connection-create-data (buffer process point)
59 "Create a new connection data based on `buffer', `process', and `point'." 59 "Create a new connection data based on BUFFER, PROCESS, and POINT."
60 (let ((connection (make-symbol "connection"))) 60 (let ((connection (make-symbol "connection")))
61 (put connection 'connection t) 61 (put connection 'connection t)
62 (dictionary-connection-set-read-point connection point) 62 (dictionary-connection-set-read-point connection point)
@@ -65,7 +65,7 @@
65 connection)) 65 connection))
66 66
67(defun dictionary-connection-open (server port) 67(defun dictionary-connection-open (server port)
68 "Open a connection to `server' and `port'. 68 "Open a connection to SERVER at PORT.
69A data structure identifing the connection is returned" 69A data structure identifing the connection is returned"
70 70
71 (let ((process-buffer (generate-new-buffer (format " connection to %s:%s" 71 (let ((process-buffer (generate-new-buffer (format " connection to %s:%s"
@@ -78,7 +78,7 @@ A data structure identifing the connection is returned"
78 (dictionary-connection-create-data process-buffer process (point-min))))) 78 (dictionary-connection-create-data process-buffer process (point-min)))))
79 79
80(defun dictionary-connection-status (connection) 80(defun dictionary-connection-status (connection)
81 "Return the status of the connection. 81 "Return the status of the CONNECTION.
82Possible return values are the symbols: 82Possible return values are the symbols:
83nil: argument is no connection object 83nil: argument is no connection object
84'none: argument has no connection 84'none: argument has no connection
@@ -97,7 +97,7 @@ nil: argument is no connection object
97 'up)))))) 97 'up))))))
98 98
99(defun dictionary-connection-close (connection) 99(defun dictionary-connection-close (connection)
100 "Force closing of the connection." 100 "Force closing of the CONNECTION."
101 (when (dictionary-connection-p connection) 101 (when (dictionary-connection-p connection)
102 (let ((buffer (dictionary-connection-buffer connection)) 102 (let ((buffer (dictionary-connection-buffer connection))
103 (process (dictionary-connection-process connection))) 103 (process (dictionary-connection-process connection)))
@@ -110,7 +110,7 @@ nil: argument is no connection object
110 (dictionary-connection-set-buffer connection nil)))) 110 (dictionary-connection-set-buffer connection nil))))
111 111
112(defun dictionary-connection-send (connection data) 112(defun dictionary-connection-send (connection data)
113 "Send `data' to the process." 113 "Send DATA to the process stored in CONNECTION."
114 (unless (eq (dictionary-connection-status connection) 'up) 114 (unless (eq (dictionary-connection-status connection) 'up)
115 (error "Connection is not up")) 115 (error "Connection is not up"))
116 (with-current-buffer (dictionary-connection-buffer connection) 116 (with-current-buffer (dictionary-connection-buffer connection)
@@ -119,11 +119,11 @@ nil: argument is no connection object
119 (process-send-string (dictionary-connection-process connection) data))) 119 (process-send-string (dictionary-connection-process connection) data)))
120 120
121(defun dictionary-connection-send-crlf (connection data) 121(defun dictionary-connection-send-crlf (connection data)
122 "Send `data' together with CRLF to the process." 122 "Send DATA together with CRLF to the process found in CONNECTION."
123 (dictionary-connection-send connection (concat data "\r\n"))) 123 (dictionary-connection-send connection (concat data "\r\n")))
124 124
125(defun dictionary-connection-read (connection delimiter) 125(defun dictionary-connection-read (connection delimiter)
126 "Read data until `delimiter' is found inside the buffer." 126 "Read data from CONNECTION until DELIMITER is found inside the buffer."
127 (unless (eq (dictionary-connection-status connection) 'up) 127 (unless (eq (dictionary-connection-status connection) 'up)
128 (error "Connection is not up")) 128 (error "Connection is not up"))
129 (let ((case-fold-search nil) 129 (let ((case-fold-search nil)
@@ -142,11 +142,13 @@ nil: argument is no connection object
142 result)))) 142 result))))
143 143
144(defun dictionary-connection-read-crlf (connection) 144(defun dictionary-connection-read-crlf (connection)
145 "Read until a line is completedx with CRLF" 145 "Read from CONNECTION until a line is completed with CRLF."
146 (dictionary-connection-read connection "\015?\012")) 146 (dictionary-connection-read connection "\015?\012"))
147 147
148(defun dictionary-connection-read-to-point (connection) 148(defun dictionary-connection-read-to-point (connection)
149 "Read until a line is consisting of a single point" 149 "Read from CONNECTION until an end of entry is encountered.
150End of entry is a decimal point found on a line by itself.
151"
150 (dictionary-connection-read connection "\015?\012[.]\015?\012")) 152 (dictionary-connection-read connection "\015?\012[.]\015?\012"))
151 153
152(provide 'dictionary-connection) 154(provide 'dictionary-connection)