Mercurial > emacs
comparison lispref/processes.texi @ 63583:99e9892a51d9
Fix formatting ugliness.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 18 Jun 2005 13:57:17 +0000 |
parents | bd65461db3b8 |
children | 3d8efebded47 b7da78284d4c |
comparison
equal
deleted
inserted
replaced
63582:6dfe79da09ed | 63583:99e9892a51d9 |
---|---|
167 @example | 167 @example |
168 ;; @r{This example shows the behavior on GNU and Unix systems.} | 168 ;; @r{This example shows the behavior on GNU and Unix systems.} |
169 (shell-quote-argument "foo > bar") | 169 (shell-quote-argument "foo > bar") |
170 @result{} "foo\\ \\>\\ bar" | 170 @result{} "foo\\ \\>\\ bar" |
171 | 171 |
172 ;; @r{This example shows the behavior on MS-DOS and MS-Windows systems.} | 172 ;; @r{This example shows the behavior on MS-DOS and MS-Windows.} |
173 (shell-quote-argument "foo > bar") | 173 (shell-quote-argument "foo > bar") |
174 @result{} "\"foo > bar\"" | 174 @result{} "\"foo > bar\"" |
175 @end example | 175 @end example |
176 | 176 |
177 Here's an example of using @code{shell-quote-argument} to construct | 177 Here's an example of using @code{shell-quote-argument} to construct |
2275 (or index (concat cookies ".dat"))) | 2275 (or index (concat cookies ".dat"))) |
2276 (bindat-unpack fcookie-index-spec | 2276 (bindat-unpack fcookie-index-spec |
2277 (buffer-string)))) | 2277 (buffer-string)))) |
2278 (sel (random (bindat-get-field info :count))) | 2278 (sel (random (bindat-get-field info :count))) |
2279 (beg (cdar (bindat-get-field info :offset sel))) | 2279 (beg (cdar (bindat-get-field info :offset sel))) |
2280 (end (or (cdar (bindat-get-field info :offset (1+ sel))) | 2280 (end (or (cdar (bindat-get-field info |
2281 :offset (1+ sel))) | |
2281 (nth 7 (file-attributes cookies))))) | 2282 (nth 7 (file-attributes cookies))))) |
2282 (switch-to-buffer (get-buffer-create | 2283 (switch-to-buffer |
2283 (format "*Fortune Cookie: %s*" | 2284 (get-buffer-create |
2284 (file-name-nondirectory cookies)))) | 2285 (format "*Fortune Cookie: %s*" |
2286 (file-name-nondirectory cookies)))) | |
2285 (erase-buffer) | 2287 (erase-buffer) |
2286 (insert-file-contents-literally cookies nil beg (- end 3)))) | 2288 (insert-file-contents-literally |
2289 cookies nil beg (- end 3)))) | |
2287 | 2290 |
2288 (defun fcookie-create-index (cookies &optional index delim) | 2291 (defun fcookie-create-index (cookies &optional index delim) |
2289 "Scan file COOKIES, and write out its index file. | 2292 "Scan file COOKIES, and write out its index file. |
2290 Optional second arg INDEX specifies the index filename, | 2293 Optional second arg INDEX specifies the index filename, |
2291 which is by default constructed by appending \".dat\" to | 2294 which is by default constructed by appending \".dat\" to |
2309 max (max max len) | 2312 max (max max len) |
2310 min (min (or min max) len) | 2313 min (min (or min max) len) |
2311 offsets (cons (1- p) offsets)))) | 2314 offsets (cons (1- p) offsets)))) |
2312 (with-temp-buffer | 2315 (with-temp-buffer |
2313 (set-buffer-multibyte nil) | 2316 (set-buffer-multibyte nil) |
2314 (insert (string-make-unibyte | 2317 (insert |
2315 (bindat-pack | 2318 (string-make-unibyte |
2316 fcookie-index-spec | 2319 (bindat-pack |
2317 `((:version . 2) | 2320 fcookie-index-spec |
2318 (:count . ,count) | 2321 `((:version . 2) |
2319 (:longest . ,max) | 2322 (:count . ,count) |
2320 (:shortest . ,min) | 2323 (:longest . ,max) |
2321 (:flags . 0) | 2324 (:shortest . ,min) |
2322 (:delim . ,delim) | 2325 (:flags . 0) |
2323 (:offset . ,(mapcar (lambda (o) | 2326 (:delim . ,delim) |
2324 (list (cons :foo o))) | 2327 (:offset . ,(mapcar (lambda (o) |
2325 (nreverse offsets))))))) | 2328 (list (cons :foo o))) |
2329 (nreverse offsets))))))) | |
2326 (let ((coding-system-for-write 'raw-text-unix)) | 2330 (let ((coding-system-for-write 'raw-text-unix)) |
2327 (write-file (or index (concat cookies ".dat"))))))) | 2331 (write-file (or index (concat cookies ".dat"))))))) |
2328 @end lisp | 2332 @end lisp |
2329 | 2333 |
2330 Following is an example of defining and unpacking a complex structure. | 2334 Following is an example of defining and unpacking a complex structure. |
2390 @end lisp | 2394 @end lisp |
2391 | 2395 |
2392 The corresponding decoded structure: | 2396 The corresponding decoded structure: |
2393 | 2397 |
2394 @lisp | 2398 @lisp |
2395 (setq decoded-structure (bindat-unpack packet-spec binary-data)) | 2399 (setq decoded (bindat-unpack packet-spec binary-data)) |
2396 @result{} | 2400 @result{} |
2397 ((header | 2401 ((header |
2398 (dest-ip . [192 168 1 100]) | 2402 (dest-ip . [192 168 1 100]) |
2399 (src-ip . [192 168 1 101]) | 2403 (src-ip . [192 168 1 101]) |
2400 (dest-port . 284) | 2404 (dest-port . 284) |
2413 @end lisp | 2417 @end lisp |
2414 | 2418 |
2415 Fetching data from this structure: | 2419 Fetching data from this structure: |
2416 | 2420 |
2417 @lisp | 2421 @lisp |
2418 (bindat-get-field decoded-structure 'item 1 'id) | 2422 (bindat-get-field decoded 'item 1 'id) |
2419 @result{} "BCDEFG" | 2423 @result{} "BCDEFG" |
2420 @end lisp | 2424 @end lisp |
2421 | 2425 |
2422 @ignore | 2426 @ignore |
2423 arch-tag: ba9da253-e65f-4e7f-b727-08fba0a1df7a | 2427 arch-tag: ba9da253-e65f-4e7f-b727-08fba0a1df7a |