diff options
| author | Richard M. Stallman | 1994-04-16 00:02:28 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-04-16 00:02:28 +0000 |
| commit | 0822af61a5dc1082b1434f4e4736a5de0903db70 (patch) | |
| tree | e4c2d953af1ab70220585b37498e939e867d9191 | |
| parent | 7192540ba357f9c9dca74aaa7a2cf361a1ea7631 (diff) | |
| download | emacs-0822af61a5dc1082b1434f4e4736a5de0903db70.tar.gz emacs-0822af61a5dc1082b1434f4e4736a5de0903db70.zip | |
(gnus-uu-enter-interactive-file):
Escape any special characters in file names.
(gnus-uu-call-asynchronous, gnus-uu-treat-archive): Likewise.
(gnus-uu-uustrip-article-as): Added more corrections
of corrupt uucode.
(gnus-uu-uustrip-article-as): Changed the algorithm for finding
begin/body lines of encoded articles.
(gnus-uu-check-correct-stripped-uucode): Handle
extraneous empty lines in uuencoded postings.
(gnus-uu-uustrip-article-as, gnus-uu-clean-up):
Check before calling process-status.
(gnus-uu-uuencode-and-post): Added possibly non-standard
posting of uuencoded files.
Doc fixes.
(gnus-uu): New function is placeholder for docs.
(gnus-uu-summary-next-subject): Do sit-for before gnus-summary-recenter.
| -rw-r--r-- | lisp/gnus-uu.el | 956 |
1 files changed, 589 insertions, 367 deletions
diff --git a/lisp/gnus-uu.el b/lisp/gnus-uu.el index 506e81c437b..e4006a45675 100644 --- a/lisp/gnus-uu.el +++ b/lisp/gnus-uu.el | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Lars Ingebrigtsen <larsi@ifi.uio.no> | 5 | ;; Author: Lars Ingebrigtsen <larsi@ifi.uio.no> |
| 6 | ;; Created: 2 Oct 1993 | 6 | ;; Created: 2 Oct 1993 |
| 7 | ;; Version: v2.5.2 | ||
| 8 | ;; Last Modified: 1994/04/13 | ||
| 7 | ;; Keyword: news | 9 | ;; Keyword: news |
| 8 | 10 | ||
| 9 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| @@ -26,7 +28,7 @@ | |||
| 26 | 28 | ||
| 27 | ;; All gnus-uu commands start with `C-c C-v'. | 29 | ;; All gnus-uu commands start with `C-c C-v'. |
| 28 | ;; | 30 | ;; |
| 29 | ;; Typing `C-c C-v C-v' (gnus-uu-decode-and-view) in the summary | 31 | ;; Typing `C-c C-v C-v' (`gnus-uu-decode-and-view') in the summary |
| 30 | ;; buffer will try to find all articles in the same series, uudecode | 32 | ;; buffer will try to find all articles in the same series, uudecode |
| 31 | ;; them and view the resulting file(s). | 33 | ;; them and view the resulting file(s). |
| 32 | ;; | 34 | ;; |
| @@ -40,18 +42,18 @@ | |||
| 40 | ;; (2/3) Part 6 of a series", will not be properly recognized by 'C-c | 42 | ;; (2/3) Part 6 of a series", will not be properly recognized by 'C-c |
| 41 | ;; C-v C-v', and you have to mark the articles manually with '#'. | 43 | ;; C-v C-v', and you have to mark the articles manually with '#'. |
| 42 | ;; | 44 | ;; |
| 43 | ;; Typing `C-c C-v v' (gnus-uu-decode-and-save) will do the same as | 45 | ;; Typing `C-c C-v v' (`gnus-uu-decode-and-save') will do the same as |
| 44 | ;; `C-c C-v C-v', except that it will not display the resulting file, but | 46 | ;; `C-c C-v C-v', except that it will not display the resulting file, |
| 45 | ;; save it instead. | 47 | ;; but save it instead. |
| 46 | ;; | 48 | ;; |
| 47 | ;; Typing `C-c C-v s' (gnus-uu-shar-and-save) does the same as `C-c | 49 | ;; Typing `C-c C-v s' (`gnus-uu-shar-and-save') does the same as `C-c |
| 48 | ;; C-v v', and `C-c C-v C-s' (gnus-uu-shar-and-view) does the same as | 50 | ;; C-v v', and `C-c C-v C-s' (`gnus-uu-shar-and-view') does the same |
| 49 | ;; `C-c C-v C-v', except that they unshar files instead, i. e. run | 51 | ;; as `C-c C-v C-v', except that they unshar files instead, i. e. run |
| 50 | ;; them through /bin/sh. Most shar files can be viewed and/or saved | 52 | ;; them through /bin/sh. Most shar files can be viewed and/or saved |
| 51 | ;; with the normal uudecode commands, which is much safer, as no | 53 | ;; with the normal uudecode commands, which is much safer, as no |
| 52 | ;; foreign code is run. | 54 | ;; foreign code is run. |
| 53 | ;; | 55 | ;; |
| 54 | ;; `#' (gnus-uu-mark-article) marks an article for later | 56 | ;; `#' (`gnus-uu-mark-article') marks an article for later |
| 55 | ;; decoding/unsharing/saving/viewing. The files will be decoded in the | 57 | ;; decoding/unsharing/saving/viewing. The files will be decoded in the |
| 56 | ;; sequence they were marked. To decode the files after you've marked | 58 | ;; sequence they were marked. To decode the files after you've marked |
| 57 | ;; the articles you are interested in, type the corresponding key | 59 | ;; the articles you are interested in, type the corresponding key |
| @@ -62,19 +64,19 @@ | |||
| 62 | ;; handled the same way; marked uudecode and save is then `C-c C-v | 64 | ;; handled the same way; marked uudecode and save is then `C-c C-v |
| 63 | ;; M-v'. | 65 | ;; M-v'. |
| 64 | ;; | 66 | ;; |
| 65 | ;; `M-#' (gnus-uu-unmark-article) will remove the mark from a | 67 | ;; `M-#' (`gnus-uu-unmark-article') will remove the mark from a |
| 66 | ;; previosly marked article. | 68 | ;; previosly marked article. |
| 67 | ;; | 69 | ;; |
| 68 | ;; `C-c C-v C-u' (gnus-uu-unmark-all-articles) will remove the mark from | 70 | ;; `C-c C-v C-u' (`gnus-uu-unmark-all-articles') will remove the mark from |
| 69 | ;; all marked articles. | 71 | ;; all marked articles. |
| 70 | ;; | 72 | ;; |
| 71 | ;; `C-c C-v C-r' (gnus-uu-mark-by-regexp) will prompt for a regular | 73 | ;; `C-c C-v C-r' (`gnus-uu-mark-by-regexp') will prompt for a regular |
| 72 | ;; expression and mark (forward) all articles matching that regular | 74 | ;; expression and mark (forward) all articles matching that regular |
| 73 | ;; expression. | 75 | ;; expression. |
| 74 | ;; | 76 | ;; |
| 75 | ;; There's an additional way to reach the decoding functions to make | 77 | ;; There's an additional way to reach the decoding functions to make |
| 76 | ;; future expansions easier: `C-c C-v C-m' | 78 | ;; future expansions easier: `C-c C-v C-m' |
| 77 | ;; (gnus-uu-multi-decode-and-view) and the corresponding save, marked | 79 | ;; (`gnus-uu-multi-decode-and-view') and the corresponding save, marked |
| 78 | ;; view and marked save keystrokes, `C-c C-v m', `C-c C-v M-C-m' and | 80 | ;; view and marked save keystrokes, `C-c C-v m', `C-c C-v M-C-m' and |
| 79 | ;; `C-c C-v M-m' respectively. You will be prompted for decoding | 81 | ;; `C-c C-v M-m' respectively. You will be prompted for decoding |
| 80 | ;; method, like uudecode, shar, binhex or plain save. Note that | 82 | ;; method, like uudecode, shar, binhex or plain save. Note that |
| @@ -82,12 +84,12 @@ | |||
| 82 | ;; issue a view command (`C-c C-v C-m' and "binhex"), gnus-uu will | 84 | ;; issue a view command (`C-c C-v C-m' and "binhex"), gnus-uu will |
| 83 | ;; just save the resulting binhex file. | 85 | ;; just save the resulting binhex file. |
| 84 | ;; | 86 | ;; |
| 85 | ;; `C-c C-v C-b' (gnus-uu-decode-and-show-in-buffer) will decode the | 87 | ;; `C-c C-v C-b' (`gnus-uu-decode-and-show-in-buffer') will decode the |
| 86 | ;; current article and display the results in an emacs buffer. This | 88 | ;; current article and display the results in an emacs buffer. This |
| 87 | ;; might be useful if there's jsut some text in the current article | 89 | ;; might be useful if there's jsut some text in the current article |
| 88 | ;; that has been uuencoded by some perverse poster. | 90 | ;; that has been uuencoded by some perverse poster. |
| 89 | ;; | 91 | ;; |
| 90 | ;; `C-c C-v a' (gnus-uu-decode-and-save-all-articles) looks at all the | 92 | ;; `C-c C-v a' (`gnus-uu-decode-and-save-all-articles') looks at all the |
| 91 | ;; articles in the current newsgroup and tries to uudecode everything | 93 | ;; articles in the current newsgroup and tries to uudecode everything |
| 92 | ;; it can find. The user will be prompted for a directory where the | 94 | ;; it can find. The user will be prompted for a directory where the |
| 93 | ;; resulting files (if any) will be stored. `C-c C-v M-a' only looks | 95 | ;; resulting files (if any) will be stored. `C-c C-v M-a' only looks |
| @@ -96,22 +98,23 @@ | |||
| 96 | ;; weren't uuencoded articles. `C-c C-v M-w' is, as you might have | 98 | ;; weren't uuencoded articles. `C-c C-v M-w' is, as you might have |
| 97 | ;; guessed, similar to `C-c C-v M-a'. | 99 | ;; guessed, similar to `C-c C-v M-a'. |
| 98 | ;; | 100 | ;; |
| 99 | ;; `C-c C-v C-l' (gnus-uu-edit-begin-line) lets you edit the begin | 101 | ;; `C-c C-v C-l' (`gnus-uu-edit-begin-line') lets you edit the begin |
| 100 | ;; line of the current buffer. Useful to change an incorrect suffix or | 102 | ;; line of the current buffer. Useful to change an incorrect suffix or |
| 101 | ;; an incorrect begin line. | 103 | ;; an incorrect begin line. |
| 102 | ;; | 104 | ;; |
| 103 | ;; | 105 | ;; |
| 104 | ;; When using the view commands, `C-c C-v C-v' for instance, gnus-uu | 106 | ;; When using the view commands, `C-c C-v C-v' for instance, gnus-uu |
| 105 | ;; will (normally, see below) try to view the file according to the | 107 | ;; will (normally, see below) try to view the file according to the |
| 106 | ;; rules given in gnus-uu-default-view-rules and | 108 | ;; rules given in `gnus-uu-default-view-rules' and |
| 107 | ;; gnus-uu-user-view-rules. If it recognises the file, it will display | 109 | ;; `gnus-uu-user-view-rules'. If it recognises the file, it will |
| 108 | ;; it immediately. If the file is some sort of archive, gnus-uu will | 110 | ;; display it immediately. If the file is some sort of archive, |
| 109 | ;; attempt to unpack the archive and see if any of the files in the | 111 | ;; gnus-uu will attempt to unpack the archive and see if any of the |
| 110 | ;; archive can be viewed. For instance, if you have a gzipped tar file | 112 | ;; files in the archive can be viewed. For instance, if you have a |
| 111 | ;; "pics.tar.gz" containing the files "pic1.jpg" and "pic2.gif", | 113 | ;; gzipped tar file "pics.tar.gz" containing the files "pic1.jpg" and |
| 112 | ;; gnus-uu will uncompress and detar the main file, and then view the | 114 | ;; "pic2.gif", gnus-uu will uncompress and detar the main file, and |
| 113 | ;; two pictures. This unpacking process is recursive, so if the | 115 | ;; then view the two pictures. This unpacking process is recursive, so |
| 114 | ;; archive contains archives of archives, it'll all be unpacked. | 116 | ;; if the archive contains archives of archives, it'll all be |
| 117 | ;; unpacked. | ||
| 115 | ;; | 118 | ;; |
| 116 | ;; If the view command doesn't recognise the file type, or can't view | 119 | ;; If the view command doesn't recognise the file type, or can't view |
| 117 | ;; it because you don't have the viewer, or can't view *any* of the | 120 | ;; it because you don't have the viewer, or can't view *any* of the |
| @@ -127,27 +130,27 @@ | |||
| 127 | ;; that might have escaped deletion if the user typed `C-g'. | 130 | ;; that might have escaped deletion if the user typed `C-g'. |
| 128 | ;; | 131 | ;; |
| 129 | ;; | 132 | ;; |
| 130 | ;; `C-c C-v C-a' (gnus-uu-toggle-asynchronous) toggles the | 133 | ;; `C-c C-v C-a' (`gnus-uu-toggle-asynchronous') toggles the |
| 131 | ;; gnus-uu-asynchronous variable. See below for explanation. | 134 | ;; `gnus-uu-asynchronous' variable. See below for explanation. |
| 132 | ;; | 135 | ;; |
| 133 | ;; `C-c C-v C-q' (gnus-uu-toggle-query) toggles the | 136 | ;; `C-c C-v C-q' (`gnus-uu-toggle-query') toggles the |
| 134 | ;; gnus-uu-ask-before-view variable. See below for explanation. | 137 | ;; `gnus-uu-ask-before-view' variable. See below for explanation. |
| 135 | ;; | 138 | ;; |
| 136 | ;; `C-c C-v C-p' (gnus-uu-toggle-always-ask) toggles the | 139 | ;; `C-c C-v C-p' (`gnus-uu-toggle-always-ask') toggles the |
| 137 | ;; gnus-uu-view-and-save variable. See below for explanation. | 140 | ;; `gnus-uu-view-and-save' variable. See below for explanation. |
| 138 | ;; | 141 | ;; |
| 139 | ;; `C-c C-v C-k' (gnus-uu-toggle-kill-carriage-return) toggles the | 142 | ;; `C-c C-v C-k' (`gnus-uu-toggle-kill-carriage-return') toggles the |
| 140 | ;; gnus-uu-kill-carriage-return variable. See below for explanation. | 143 | ;; `gnus-uu-kill-carriage-return' variable. See below for explanation. |
| 141 | ;; | 144 | ;; |
| 142 | ;; `C-c C-v C-i' (gnus-uu-toggle-interactive-view) toggles interactive | 145 | ;; `C-c C-v C-i' (`gnus-uu-toggle-interactive-view') toggles interactive |
| 143 | ;; mode. If it is turned on, gnus-uu won't view files immediately but | 146 | ;; mode. If it is turned on, gnus-uu won't view files immediately but |
| 144 | ;; give you a buffer with the default commands and files and lets you | 147 | ;; give you a buffer with the default commands and files and lets you |
| 145 | ;; edit the commands and execute them at leisure. | 148 | ;; edit the commands and execute them at leisure. |
| 146 | ;; | 149 | ;; |
| 147 | ;; `C-c C-v C-t' (gnus-uu-toggle-any-variable) is an interface to the | 150 | ;; `C-c C-v C-t' (`gnus-uu-toggle-any-variable') is an interface to the |
| 148 | ;; five toggle commands listed above. | 151 | ;; five toggle commands listed above. |
| 149 | ;; | 152 | ;; |
| 150 | ;; gnus-uu-toggle-correct-stripped-articles toggles whether to check | 153 | ;; `gnus-uu-toggle-correct-stripped-articles' toggles whether to check |
| 151 | ;; and correct uuencoded articles that may have had trailing spaces | 154 | ;; and correct uuencoded articles that may have had trailing spaces |
| 152 | ;; stripped by mailers. | 155 | ;; stripped by mailers. |
| 153 | ;; | 156 | ;; |
| @@ -186,7 +189,7 @@ | |||
| 186 | ;; | 189 | ;; |
| 187 | ;; in your .emacs file. | 190 | ;; in your .emacs file. |
| 188 | ;; | 191 | ;; |
| 189 | ;; There's a similar variable called 'gnus-uu-user-archive-rules' | 192 | ;; There's a similar variable called `gnus-uu-user-archive-rules' |
| 190 | ;; which gives a list of unarcers to use when looking inside archives | 193 | ;; which gives a list of unarcers to use when looking inside archives |
| 191 | ;; for files to display. | 194 | ;; for files to display. |
| 192 | ;; | 195 | ;; |
| @@ -228,7 +231,7 @@ | |||
| 228 | ;; | 231 | ;; |
| 229 | ;; If you want gnus-uu to ignore the default file rules when viewing, | 232 | ;; If you want gnus-uu to ignore the default file rules when viewing, |
| 230 | ;; for instance if there's several file types that you can't view, set | 233 | ;; for instance if there's several file types that you can't view, set |
| 231 | ;; `gnus-uu-ignore-default-view-rules' to `t'. There's a similar | 234 | ;; `gnus-uu-ignore-default-view-rules' to t. There's a similar |
| 232 | ;; variable to disable the default unarchive rule list, | 235 | ;; variable to disable the default unarchive rule list, |
| 233 | ;; `gnus-uu-ignore-default-archive-rules'. | 236 | ;; `gnus-uu-ignore-default-archive-rules'. |
| 234 | ;; | 237 | ;; |
| @@ -278,8 +281,13 @@ | |||
| 278 | ;; translated into "dir-file". Added a function for fixing stripped | 281 | ;; translated into "dir-file". Added a function for fixing stripped |
| 279 | ;; uucode articles. Added binhex save. | 282 | ;; uucode articles. Added binhex save. |
| 280 | ;; | 283 | ;; |
| 284 | ;; v2.5: First version copyrighted by FSF. Changed lots of | ||
| 285 | ;; documentation strings. | ||
| 281 | ;; | 286 | ;; |
| 282 | ;; Keymap overview: | 287 | ;; v2.5.1: Added uuencode/posting code to post binary files. |
| 288 | ;; | ||
| 289 | ;; | ||
| 290 | ;; Default keymap overview: | ||
| 283 | ;; | 291 | ;; |
| 284 | ;; All commands start with `C-c C-v'. The difference is in the third | 292 | ;; All commands start with `C-c C-v'. The difference is in the third |
| 285 | ;; keystroke. All view commands are `C-LETTER'. All save commands are | 293 | ;; keystroke. All view commands are `C-LETTER'. All save commands are |
| @@ -321,6 +329,7 @@ | |||
| 321 | ;;; Code: | 329 | ;;; Code: |
| 322 | 330 | ||
| 323 | (require 'gnus) | 331 | (require 'gnus) |
| 332 | (require 'gnuspost) | ||
| 324 | 333 | ||
| 325 | ;; Binding of keys to the gnus-uu functions. | 334 | ;; Binding of keys to the gnus-uu functions. |
| 326 | 335 | ||
| @@ -366,9 +375,138 @@ | |||
| 366 | ;(load "rnewspost") | 375 | ;(load "rnewspost") |
| 367 | ;(define-key news-reply-mode-map "\C-c\C-v" 'gnus-uu-uuencode-and-post) | 376 | ;(define-key news-reply-mode-map "\C-c\C-v" 'gnus-uu-uuencode-and-post) |
| 368 | 377 | ||
| 378 | ;; Dummy function gnus-uu | ||
| 379 | |||
| 380 | (defun gnus-uu () | ||
| 381 | "gnus-uu is a package for uudecoding and viewing articles. | ||
| 382 | |||
| 383 | By default, all gnus-uu keystrokes begin with `C-c C-v'. | ||
| 384 | |||
| 385 | There four decoding commands categories: | ||
| 386 | All commands for viewing are `C-c C-v C-LETTER'. | ||
| 387 | All commands for saving are `C-c C-v LETTER'. | ||
| 388 | All commands for marked viewing are `C-c C-v C-M-LETTER'. | ||
| 389 | All commands for marked saving are `C-c C-v M-LETTER'. | ||
| 390 | |||
| 391 | \\<gnus-summary-mode-map>\\[gnus-uu-decode-and-view]\tDecode and view articles | ||
| 392 | \\[gnus-uu-decode-and-save]\tDecode and save articles | ||
| 393 | \\[gnus-uu-shar-and-view]\tUnshar and view articles | ||
| 394 | \\[gnus-uu-shar-and-save]\tUnshar and save articles | ||
| 395 | \\[gnus-uu-multi-decode-and-view]\tChoose a decoding method, decode and view articles | ||
| 396 | \\[gnus-uu-multi-decode-and-save]\tChoose a decoding method, decode and save articles | ||
| 397 | |||
| 398 | \\[gnus-uu-decode-and-show-in-buffer]\tDecode the current article and view the result in a buffer | ||
| 399 | \\[gnus-uu-edit-begin-line]\tEdit the 'begin' line of an uuencoded article | ||
| 400 | |||
| 401 | \\[gnus-uu-decode-and-save-all-unread-articles]\tDecode and save all unread articles | ||
| 402 | \\[gnus-uu-decode-and-save-all-articles]\tDecode and save all articles | ||
| 403 | \\[gnus-uu-decode-and-save-all-unread-articles-and-mark]\tDecode and save all unread articles and catch up | ||
| 404 | \\[gnus-uu-decode-and-save-all-articles-and-mark]\tDecode and save all articles and catch up | ||
| 405 | |||
| 406 | \\[gnus-uu-mark-article]\tMark the current article for decoding | ||
| 407 | \\[gnus-uu-unmark-article]\tUnmark the current article | ||
| 408 | \\[gnus-uu-unmark-all-articles]\tUnmark all articles | ||
| 409 | \\[gnus-uu-mark-by-regexp]\tMark articles for decoding by regexp | ||
| 410 | \\[gnus-uu-marked-decode-and-view]\tDecode and view marked articles | ||
| 411 | \\[gnus-uu-marked-decode-and-save]\tDecode and save marked articles | ||
| 412 | \\[gnus-uu-marked-shar-and-view]\tUnshar and view marked articles | ||
| 413 | \\[gnus-uu-marked-shar-and-save]\tUnshar and save marked articles | ||
| 414 | \\[gnus-uu-marked-multi-decode-and-view]\tChoose decoding method, decode and view marked articles | ||
| 415 | \\[gnus-uu-marked-multi-decode-and-save]\tChoose decoding method, decode and save marked articles | ||
| 416 | |||
| 417 | \\[gnus-uu-toggle-asynchronous]\tToggle asynchronous viewing mode | ||
| 418 | \\[gnus-uu-toggle-query]\tToggle whether to ask before viewing a file | ||
| 419 | \\[gnus-uu-toggle-always-ask]\tToggle whether to ask to save a file after viewing | ||
| 420 | \\[gnus-uu-toggle-kill-carriage-return]\tToggle whether to strip trailing carriage returns | ||
| 421 | \\[gnus-uu-toggle-interactive-view]\tToggle whether to use interactive viewing mode | ||
| 422 | \\[gnus-uu-toggle-any-variable]\tToggle any of the things above | ||
| 423 | |||
| 424 | User configurable variables: | ||
| 425 | |||
| 426 | Rule Variables | ||
| 427 | |||
| 428 | gnus-uu uses \"rule\" variables to decide how to view a file. All | ||
| 429 | these variables are of the form | ||
| 430 | |||
| 431 | (list '(regexp1 command2) | ||
| 432 | '(regexp2 command2) | ||
| 433 | ...) | ||
| 434 | |||
| 435 | `gnus-uu-user-view-rules' | ||
| 436 | This variable is consulted first when viewing files. If you wish | ||
| 437 | to use, for instance, sox to convert an .au sound file, you could | ||
| 438 | say something like: | ||
| 439 | |||
| 440 | (setq gnus-uu-user-view-rules | ||
| 441 | (list '(\"\\\\.au$\" \"sox %s -t .aiff > /dev/audio\"))) | ||
| 442 | |||
| 443 | `gnus-uu-user-view-rules-end' | ||
| 444 | This variable is consulted if gnus-uu couldn't make any matches | ||
| 445 | from the user and default view rules. | ||
| 446 | |||
| 447 | `gnus-uu-user-interactive-view-rules' | ||
| 448 | This is the variable used instead of `gnus-uu-user-view-rules' | ||
| 449 | when in interactive mode. | ||
| 450 | |||
| 451 | `gnus-uu-user-interactive-view-rules-end' | ||
| 452 | This variable is used instead of `gnus-uu-user-view-rules-end' | ||
| 453 | when in interactive mode. | ||
| 454 | |||
| 455 | `gnus-uu-user-archive-rules` | ||
| 456 | This variable can be used to say what comamnds should be used to | ||
| 457 | unpack archives. | ||
| 458 | |||
| 459 | |||
| 460 | Other Variables | ||
| 461 | |||
| 462 | `gnus-uu-tmp-dir' | ||
| 463 | Where gnus-uu does its work. | ||
| 464 | |||
| 465 | `gnus-uu-do-not-unpack-archives' | ||
| 466 | Non-nil means that gnus-uu won't peek inside archives looking for | ||
| 467 | files to dispay. | ||
| 468 | |||
| 469 | `gnus-uu-view-and-save' | ||
| 470 | Non-nil means that the user will always be asked to save a file | ||
| 471 | after viewing it. | ||
| 472 | |||
| 473 | `gnus-uu-asynchronous' | ||
| 474 | Non-nil means that files will be viewed asynchronously. | ||
| 475 | |||
| 476 | `gnus-uu-ask-before-view' | ||
| 477 | Non-nil means that gnus-uu will ask you before viewing each file | ||
| 478 | |||
| 479 | `gnus-uu-ignore-default-view-rules' | ||
| 480 | Non-nil means that gnus-uu will ignore the default viewing rules. | ||
| 481 | |||
| 482 | `gnus-uu-ignore-default-archive-rules' | ||
| 483 | Non-nil means that gnus-uu will ignore the default archive | ||
| 484 | unpacking commands. | ||
| 485 | |||
| 486 | `gnus-uu-kill-carriage-return' | ||
| 487 | Non-nil means that gnus-uu will strip all carriage returns from | ||
| 488 | articles. | ||
| 489 | |||
| 490 | `gnus-uu-unmark-articles-not-decoded' | ||
| 491 | Non-nil means that gnus-uu will mark articles that were | ||
| 492 | unsuccessfully decoded as unread. | ||
| 493 | |||
| 494 | `gnus-uu-output-window-height' | ||
| 495 | This variable says how tall the output buffer window is to be | ||
| 496 | when using interactive view mode. | ||
| 497 | |||
| 498 | `gnus-uu-correct-stripped-uucode' | ||
| 499 | Non-nil means that gnus-uu will *try* to fix uuencoded files that | ||
| 500 | have had traling spaces deleted. | ||
| 501 | |||
| 502 | `gnus-uu-use-interactive-view' | ||
| 503 | Non-nil means that gnus-uu will use interactive viewing mode." | ||
| 504 | (interactive) | ||
| 505 | ) | ||
| 506 | |||
| 369 | ;; Default viewing action rules | 507 | ;; Default viewing action rules |
| 370 | 508 | ||
| 371 | (defconst gnus-uu-default-view-rules | 509 | (defvar gnus-uu-default-view-rules |
| 372 | (list | 510 | (list |
| 373 | '("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "xv") | 511 | '("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "xv") |
| 374 | '("\\.tga$" "tgatoppm %s | xv -") | 512 | '("\\.tga$" "tgatoppm %s | xv -") |
| @@ -386,12 +524,9 @@ | |||
| 386 | '("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\)$" | 524 | '("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\)$" |
| 387 | "gnus-uu-archive")) | 525 | "gnus-uu-archive")) |
| 388 | 526 | ||
| 389 | 527 | "Default actions to be taken when the user asks to view a file. | |
| 390 | "This constant is a list that gives the default actions to be taken | 528 | To change the behaviour, you can either edit this variable or set |
| 391 | when the user asks to view a file. To change the behaviour, you can | 529 | `gnus-uu-user-view-rules' to something useful. |
| 392 | either edit this constant or set 'gnus-uu-user-view-rules' to | ||
| 393 | something useful. To add a default \"end\" rule, edit the | ||
| 394 | 'gnus-uu-user-view-rules-end' variable. | ||
| 395 | 530 | ||
| 396 | For example: | 531 | For example: |
| 397 | 532 | ||
| @@ -400,40 +535,60 @@ following in your .emacs file | |||
| 400 | 535 | ||
| 401 | (setq gnus-uu-user-view-rules (list '(\"jpg$\\\\|gif$\" \"xli\"))) | 536 | (setq gnus-uu-user-view-rules (list '(\"jpg$\\\\|gif$\" \"xli\"))) |
| 402 | 537 | ||
| 403 | Both these variables are lists of lists of strings, where the first | 538 | Both these variables are lists of lists with two string elements. The |
| 404 | string is a regular expression. If the file name matches this regular | 539 | first string is a regular expression. If the file name matches this |
| 405 | expression, the command in the second string is fed the file. | 540 | regular expression, the command in the second string is executed with |
| 541 | the file as an argument. | ||
| 406 | 542 | ||
| 407 | If the command string contains \"%s\", the file name will be inserted | 543 | If the command string contains \"%s\", the file name will be inserted |
| 408 | at that point in the command string. If there's no \"%s\" in the | 544 | at that point in the command string. If there's no \"%s\" in the |
| 409 | command string, the file name will be appended to the command before | 545 | command string, the file name will be appended to the command string |
| 410 | executing. ") | 546 | before executing. |
| 547 | |||
| 548 | There are several user variables to tailor the behaviour of gnus-uu to | ||
| 549 | your needs. First we have `gnus-uu-user-view-rules', which is the | ||
| 550 | variable gnus-uu first consults when trying to decide how to view a | ||
| 551 | file. If this variable contains no matches, gnus-uu examines the | ||
| 552 | default rule vaiable provided in this package. If gnus-uu finds no | ||
| 553 | match here, it uses `gnus-uu-user-view-rules-end' to try to make a | ||
| 554 | match. | ||
| 555 | |||
| 556 | Unless, of course, you are using the interactive view mode. Then | ||
| 557 | `gnus-uu-user-interactive-view-rules' and | ||
| 558 | `gnus-uu-user-interactive-view-rules-end' will be used instead.") | ||
| 411 | 559 | ||
| 412 | (defvar gnus-uu-user-view-rules nil | 560 | (defvar gnus-uu-user-view-rules nil |
| 413 | "User variable. See explanation of the 'gnus-uu-default-view-rules' for | 561 | "Variable detailing what actions are to be taken to view a file. |
| 562 | See the documentation on the `gnus-uu-default-view-rules' variable for | ||
| 414 | details.") | 563 | details.") |
| 415 | 564 | ||
| 416 | (defvar gnus-uu-user-view-rules-end nil | 565 | (defvar gnus-uu-user-view-rules-end nil |
| 417 | "The user may use this variable to provide default viewing rules.") | 566 | "Variable saying what actions are to be taken if no rule matched the file name. |
| 567 | See the documentation on the `gnus-uu-default-view-rules' variable for | ||
| 568 | details.") | ||
| 418 | 569 | ||
| 419 | (defvar gnus-uu-user-interactive-view-rules nil | 570 | (defvar gnus-uu-user-interactive-view-rules nil |
| 420 | "If this variable is set and interactive mode is to be used, this | 571 | "Variable detailing what actions are to be taken to view a file when using interactive mode. |
| 421 | variable will be used instead of gnus-uu-user-view-rules.") | 572 | See the documentation on the `gnus-uu-default-view-rules' variable for |
| 573 | details.") | ||
| 422 | 574 | ||
| 423 | (defvar gnus-uu-user-interactive-view-rules-end nil | 575 | (defvar gnus-uu-user-interactive-view-rules-end nil |
| 424 | "If this variable is set and interactive mode is to be used, this | 576 | "Variable saying what actions are to be taken if no rule matched the file name when using interactive mode. |
| 425 | variable will be used instead of gnus-uu-user-view-rules-end.") | 577 | See the documentation on the `gnus-uu-default-view-rules' variable for |
| 578 | details.") | ||
| 426 | 579 | ||
| 427 | (defconst gnus-uu-default-interactive-view-rules-begin | 580 | (defvar gnus-uu-default-interactive-view-rules-begin |
| 428 | (list | 581 | (list |
| 429 | '("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed s/ //g") | 582 | '("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed s/ |
| 430 | '("\\.pas$" "cat %s | sed s/ //g") | 583 | //g") |
| 584 | '("\\.pas$" "cat %s | sed s/ | ||
| 585 | //g") | ||
| 431 | )) | 586 | )) |
| 432 | 587 | ||
| 433 | 588 | ||
| 434 | ;; Default unpacking commands | 589 | ;; Default unpacking commands |
| 435 | 590 | ||
| 436 | (defconst gnus-uu-default-archive-rules | 591 | (defvar gnus-uu-default-archive-rules |
| 437 | (list '("\\.tar$" "tar xf") | 592 | (list '("\\.tar$" "tar xf") |
| 438 | '("\\.zip$" "unzip") | 593 | '("\\.zip$" "unzip") |
| 439 | '("\\.ar$" "ar x") | 594 | '("\\.ar$" "ar x") |
| @@ -443,82 +598,82 @@ variable will be used instead of gnus-uu-user-view-rules-end.") | |||
| 443 | '("\\.Z$" "uncompress") | 598 | '("\\.Z$" "uncompress") |
| 444 | '("\\.gz$" "gunzip") | 599 | '("\\.gz$" "gunzip") |
| 445 | '("\\.arc$" "arc -x")) | 600 | '("\\.arc$" "arc -x")) |
| 446 | "*") | 601 | ) |
| 447 | (defvar gnus-uu-user-archive-rules nil) | 602 | |
| 603 | (defvar gnus-uu-user-archive-rules nil | ||
| 604 | "A list that can be set to override the default archive unpacking commands. | ||
| 605 | To use, for instance, 'untar' to unpack tar files and 'zip -x' to | ||
| 606 | unpack zip files, say the following: | ||
| 607 | (setq gnus-uu-user-archive-rules | ||
| 608 | (list '(\"\\\\.tar$\" \"untar\") | ||
| 609 | '(\"\\\\.zip$\" \"zip -x\")))" | ||
| 610 | ) | ||
| 448 | 611 | ||
| 449 | 612 | ||
| 450 | ;; Various variables users may set | 613 | ;; Various variables users may set |
| 451 | 614 | ||
| 452 | (defvar gnus-uu-tmp-dir "/tmp/" | 615 | (defvar gnus-uu-tmp-dir "/tmp/" |
| 453 | "Variable saying where gnus-uu is to do its work. Default is \"/tmp/\".") | 616 | "Variable saying where gnus-uu is to do its work. |
| 617 | Default is \"/tmp/\".") | ||
| 454 | 618 | ||
| 455 | (defvar gnus-uu-do-not-unpack-archives nil | 619 | (defvar gnus-uu-do-not-unpack-archives nil |
| 456 | "Set this variable if you don't want gnus-uu to look inside | 620 | "Non-nil means that gnus-uu won't peek inside archives looking for files to dispay. |
| 457 | archives for files to display. Default is `nil'.") | 621 | Default is nil.") |
| 458 | |||
| 459 | (defvar gnus-uu-do-not-unpack-archives nil | ||
| 460 | "Set this variable if you don't want gnus-uu to look inside | ||
| 461 | archives for files to display. Default is `nil'.") | ||
| 462 | 622 | ||
| 463 | (defvar gnus-uu-view-and-save nil | 623 | (defvar gnus-uu-view-and-save nil |
| 464 | "Set this variable if you want to be asked if you want to save the | 624 | "Non-nil means that the user will always be asked to save a file after viewing it. |
| 465 | file after viewing. If this variable is nil, which is the default, | 625 | If the variable is nil, the suer will only be asked to save if the |
| 466 | gnus-uu won't offer to save a file if viewing is successful. Default | 626 | viewing is unsuccessful. Default is nil.") |
| 467 | is `nil'.") | ||
| 468 | 627 | ||
| 469 | (defvar gnus-uu-asynchronous nil | 628 | (defvar gnus-uu-asynchronous nil |
| 470 | "Set this variable to `t' if you don't want gnus-uu to wait until | 629 | "Non-nil means that files will be viewed asynchronously. |
| 471 | the viewing command has ended before returning control to emacs. | 630 | Default is nil.") |
| 472 | Default is `nil'.") | ||
| 473 | 631 | ||
| 474 | (defvar gnus-uu-ask-before-view nil | 632 | (defvar gnus-uu-ask-before-view nil |
| 475 | "Set this variable to `t' if you want gnus-uu to ask you before | 633 | "Non-nil means that gnus-uu will ask you before viewing each file. |
| 476 | viewing every file. Useful when `gnus-uu-asynchronous' is set. Default | 634 | Especially useful when `gnus-uu-asynchronous' is set. Default is |
| 477 | is `nil'.") | 635 | nil.") |
| 478 | 636 | ||
| 479 | (defvar gnus-uu-ignore-default-view-rules nil | 637 | (defvar gnus-uu-ignore-default-view-rules nil |
| 480 | "Set this variable if you want gnus-uu to ignore the default viewing | 638 | "Non-nil means that gnus-uu will ignore the default viewing rules. |
| 481 | rules and just use the rules given in gnus-uu-user-view-rules. Default | 639 | Only the user viewing rules will be consulted. Default is nil.") |
| 482 | is `nil'.") | ||
| 483 | 640 | ||
| 484 | (defvar gnus-uu-ignore-default-archive-rules nil | 641 | (defvar gnus-uu-ignore-default-archive-rules nil |
| 485 | "Set this variable if you want gnus-uu to ignore the default archive | 642 | "Non-nil means that gnus-uu will ignore the default archive unpacking commands. |
| 486 | unpacking commands and just use the rules given in | 643 | Only the user unpacking commands will be consulted. Default is nil.") |
| 487 | gnus-uu-user-archive-rules. Default is `nil'.") | ||
| 488 | 644 | ||
| 489 | (defvar gnus-uu-kill-carriage-return t | 645 | (defvar gnus-uu-kill-carriage-return t |
| 490 | "Set this variable if you want to remove all carriage returns from | 646 | "Non-nil means that gnus-uu will strip all carriage returns from articles. |
| 491 | the mail articles. Default is `t'.") | 647 | Default is t.") |
| 492 | 648 | ||
| 493 | (defvar gnus-uu-unmark-articles-not-decoded nil | 649 | (defvar gnus-uu-unmark-articles-not-decoded nil |
| 494 | "If this variable is set, artciles that are unsuccessfully decoded | 650 | "Non-nil means that gnus-uu will mark articles that were unsuccessfully decoded as unread. |
| 495 | are marked as unread. Default is `nil'.") | 651 | Default is nil.") |
| 496 | 652 | ||
| 497 | (defvar gnus-uu-output-window-height 20 | 653 | (defvar gnus-uu-output-window-height 20 |
| 498 | "This variable says how hight the output buffer window is to be when | 654 | "This variable says how tall the output buffer window is to be when using interactive view mode. |
| 499 | using interactive view mode. Change it at your convenience. Default is 20.") | 655 | Change it at your convenience. Default is 20.") |
| 500 | 656 | ||
| 501 | (defvar gnus-uu-correct-stripped-uucode nil | 657 | (defvar gnus-uu-correct-stripped-uucode nil |
| 502 | "If this variable is set, gnus-uu will try to correct uuencoded files that | 658 | "Non-nil means that gnus-uu will *try* to fix uuencoded files that have had traling spaces deleted. |
| 503 | have had trailing spaces stripped by nosy mail saoftware. Default is `nil'.") | 659 | Default is nil.") |
| 504 | 660 | ||
| 505 | (defvar gnus-uu-use-interactive-view nil | 661 | (defvar gnus-uu-use-interactive-view nil |
| 506 | "If this variable is set, gnus-uu will create a special buffer where | 662 | "Non-nil means that gnus-uu will use interactive viewing mode. |
| 507 | the user may choose interactively which files to view and how. Default | 663 | Gnus-uu will create a special buffer where the user may choose |
| 508 | is `nil'.") | 664 | interactively which files to view and how. Default is nil.") |
| 509 | 665 | ||
| 510 | 666 | ||
| 511 | ;; Internal variables | 667 | ;; Internal variables |
| 512 | 668 | ||
| 513 | (defconst gnus-uu-begin-string "^begin[ \t]+[0-7][0-7][0-7][ \t]+\\(.*\\)$" | 669 | (defconst gnus-uu-begin-string "^begin[ \t]+[0-7][0-7][0-7][ \t]+\\(.*\\)$") |
| 514 | "*") | ||
| 515 | (defconst gnus-uu-end-string "^end[ \t]*$") | 670 | (defconst gnus-uu-end-string "^end[ \t]*$") |
| 516 | (defconst gnus-uu-body-line | 671 | (defconst gnus-uu-body-line |
| 517 | "^M.............................................................?$" "*") | 672 | "^M.............................................................?$") |
| 518 | (defconst gnus-uu-shar-begin-string "^#! */bin/sh" "*") | 673 | (defconst gnus-uu-shar-begin-string "^#! */bin/sh") |
| 519 | 674 | ||
| 520 | (defvar gnus-uu-shar-file-name nil "*") | 675 | (defvar gnus-uu-shar-file-name nil) |
| 521 | (defconst gnus-uu-shar-name-marker "begin [0-7][0-7][0-7][ \t]+\\(\\(\\w\\|\\.\\)*\\b\\)" "*") | 676 | (defconst gnus-uu-shar-name-marker "begin [0-7][0-7][0-7][ \t]+\\(\\(\\w\\|\\.\\)*\\b\\)") |
| 522 | (defvar gnus-uu-shar-directory nil) | 677 | (defvar gnus-uu-shar-directory nil) |
| 523 | 678 | ||
| 524 | (defvar gnus-uu-file-name nil) | 679 | (defvar gnus-uu-file-name nil) |
| @@ -532,6 +687,7 @@ is `nil'.") | |||
| 532 | (defconst gnus-uu-output-buffer-name "*Gnus UU Output*") | 687 | (defconst gnus-uu-output-buffer-name "*Gnus UU Output*") |
| 533 | (defconst gnus-uu-result-buffer "*Gnus UU Result Buffer*") | 688 | (defconst gnus-uu-result-buffer "*Gnus UU Result Buffer*") |
| 534 | 689 | ||
| 690 | (defconst gnus-uu-error-during-unarching nil) | ||
| 535 | 691 | ||
| 536 | ;; Interactive functions | 692 | ;; Interactive functions |
| 537 | 693 | ||
| @@ -539,25 +695,27 @@ is `nil'.") | |||
| 539 | 695 | ||
| 540 | (defun gnus-uu-decode-and-view () | 696 | (defun gnus-uu-decode-and-view () |
| 541 | "UUdecodes and 'views' (if possible) the resulting file. | 697 | "UUdecodes and 'views' (if possible) the resulting file. |
| 542 | 'Viewing' can be any action at all, as defined in the | 698 | 'Viewing' can be any action at all, as defined in the |
| 543 | 'gnus-uu-file-action-list' variable. Running 'xv' on gifs and | 699 | `gnus-uu-file-action-list' variable. Running 'xv' on gifs and 'cat |
| 544 | 'play' on au files are popular actions. If the file can't be viewed, | 700 | >/dev/audio' on au files are popular actions. If the file can't be |
| 545 | the user is asked if she would like to save the file instead." | 701 | viewed, the user is asked if she would like to save the file instead." |
| 546 | (interactive) | 702 | (interactive) |
| 547 | (gnus-uu-decode-and-view-or-save t nil)) | 703 | (gnus-uu-decode-and-view-or-save t nil)) |
| 548 | 704 | ||
| 549 | (defun gnus-uu-decode-and-save () | 705 | (defun gnus-uu-decode-and-save () |
| 550 | "uudecodes and saves the resulting file." | 706 | "Decodes and saves the resulting file." |
| 551 | (interactive) | 707 | (interactive) |
| 552 | (gnus-uu-decode-and-view-or-save nil nil)) | 708 | (gnus-uu-decode-and-view-or-save nil nil)) |
| 553 | 709 | ||
| 554 | (defun gnus-uu-marked-decode-and-view () | 710 | (defun gnus-uu-marked-decode-and-view () |
| 555 | "The marked equivalent to gnus-uu-decode-and-view." | 711 | "Decodes and views articles marked. |
| 712 | The marked equivalent to `gnus-uu-decode-and-view'." | ||
| 556 | (interactive) | 713 | (interactive) |
| 557 | (gnus-uu-decode-and-view-or-save t t)) | 714 | (gnus-uu-decode-and-view-or-save t t)) |
| 558 | 715 | ||
| 559 | (defun gnus-uu-marked-decode-and-save () | 716 | (defun gnus-uu-marked-decode-and-save () |
| 560 | "The marked equivalent to gnus-uu-decode-and-save." | 717 | "Decodes and saves articles marked. |
| 718 | The marked equivalent to `gnus-uu-decode-and-save'." | ||
| 561 | (interactive) | 719 | (interactive) |
| 562 | (gnus-uu-decode-and-view-or-save nil t)) | 720 | (gnus-uu-decode-and-view-or-save nil t)) |
| 563 | 721 | ||
| @@ -565,22 +723,26 @@ the user is asked if she would like to save the file instead." | |||
| 565 | ;; Unshar and view | 723 | ;; Unshar and view |
| 566 | 724 | ||
| 567 | (defun gnus-uu-shar-and-view () | 725 | (defun gnus-uu-shar-and-view () |
| 568 | "Does the same as gnus-uu-decode-and-view for shar files." | 726 | "Unshars and views articles. |
| 727 | The shar equivalent of `gnus-uu-decode-and-view'." | ||
| 569 | (interactive) | 728 | (interactive) |
| 570 | (gnus-uu-unshar-and-view-or-save t nil)) | 729 | (gnus-uu-unshar-and-view-or-save t nil)) |
| 571 | 730 | ||
| 572 | (defun gnus-uu-shar-and-save () | 731 | (defun gnus-uu-shar-and-save () |
| 573 | "Does the same as gnus-uu-decode-and-save for shar files." | 732 | "Unshars and saves files. |
| 733 | The shar equivalent to `gnus-uu-decode-and-save'." | ||
| 574 | (interactive) | 734 | (interactive) |
| 575 | (gnus-uu-unshar-and-view-or-save nil nil)) | 735 | (gnus-uu-unshar-and-view-or-save nil nil)) |
| 576 | 736 | ||
| 577 | (defun gnus-uu-marked-shar-and-view () | 737 | (defun gnus-uu-marked-shar-and-view () |
| 578 | "The marked equivalent to gnus-uu-shar-and-view." | 738 | "Unshars and views articles marked. |
| 739 | The marked equivalent to `gnus-uu-shar-and-view'." | ||
| 579 | (interactive) | 740 | (interactive) |
| 580 | (gnus-uu-unshar-and-view-or-save t t)) | 741 | (gnus-uu-unshar-and-view-or-save t t)) |
| 581 | 742 | ||
| 582 | (defun gnus-uu-marked-shar-and-save () | 743 | (defun gnus-uu-marked-shar-and-save () |
| 583 | "The marked equivalent to gnus-uu-shar-and-save." | 744 | "Unshars and saves articles marked. |
| 745 | The marked equivalent to `gnus-uu-shar-and-save'." | ||
| 584 | (interactive) | 746 | (interactive) |
| 585 | (gnus-uu-unshar-and-view-or-save nil t)) | 747 | (gnus-uu-unshar-and-view-or-save nil t)) |
| 586 | 748 | ||
| @@ -588,7 +750,9 @@ the user is asked if she would like to save the file instead." | |||
| 588 | ;; Decode and show in buffer | 750 | ;; Decode and show in buffer |
| 589 | 751 | ||
| 590 | (defun gnus-uu-decode-and-show-in-buffer () | 752 | (defun gnus-uu-decode-and-show-in-buffer () |
| 591 | "uudecodes the current article and displays the result in a buffer." | 753 | "Uudecodes the current article and displays the result in a buffer. |
| 754 | Might be useful if someone has, for instance, some text uuencoded in | ||
| 755 | their sigs. (Stranger things have happened.)" | ||
| 592 | (interactive) | 756 | (interactive) |
| 593 | (let ((uu-buffer (get-buffer-create gnus-uu-output-buffer-name)) | 757 | (let ((uu-buffer (get-buffer-create gnus-uu-output-buffer-name)) |
| 594 | list-of-articles file-name) | 758 | list-of-articles file-name) |
| @@ -625,8 +789,7 @@ the user is asked if she would like to save the file instead." | |||
| 625 | (message "gnus-uu will now view without asking first"))) | 789 | (message "gnus-uu will now view without asking first"))) |
| 626 | 790 | ||
| 627 | (defun gnus-uu-toggle-always-ask () | 791 | (defun gnus-uu-toggle-always-ask () |
| 628 | "This function toggles whether to ask saving a file even after successful | 792 | "This function toggles whether to always ask to save a file after viewing." |
| 629 | viewing." | ||
| 630 | (interactive) | 793 | (interactive) |
| 631 | (if (setq gnus-uu-view-and-save (not gnus-uu-view-and-save)) | 794 | (if (setq gnus-uu-view-and-save (not gnus-uu-view-and-save)) |
| 632 | (message "gnus-uu will now ask to save the file after viewing") | 795 | (message "gnus-uu will now ask to save the file after viewing") |
| @@ -708,26 +871,32 @@ viewing." | |||
| 708 | ;; Multi functions | 871 | ;; Multi functions |
| 709 | 872 | ||
| 710 | (defun gnus-uu-multi-decode-and-view () | 873 | (defun gnus-uu-multi-decode-and-view () |
| 711 | "This function lets the user decide what method to use for decoding. | 874 | "Choose a method of decoding and then decode and view. |
| 712 | Other than that, it's equivalent to the other decode-and-view functions." | 875 | This function lets the user decide what method to use for decoding. |
| 876 | Other than that, it's equivalent to the other decode-and-view | ||
| 877 | functions." | ||
| 713 | (interactive) | 878 | (interactive) |
| 714 | (gnus-uu-multi-decode-and-view-or-save t nil)) | 879 | (gnus-uu-multi-decode-and-view-or-save t nil)) |
| 715 | 880 | ||
| 716 | (defun gnus-uu-multi-decode-and-save () | 881 | (defun gnus-uu-multi-decode-and-save () |
| 717 | "This function lets the user decide what method to use for decoding. | 882 | "Choose a method of decoding and then decode and save. |
| 718 | Other than that, it's equivalent to the other decode-and-save functions." | 883 | This function lets the user decide what method to use for decoding. |
| 884 | Other than that, it's equivalent to the other decode-and-save | ||
| 885 | functions." | ||
| 719 | (interactive) | 886 | (interactive) |
| 720 | (gnus-uu-multi-decode-and-view-or-save nil nil)) | 887 | (gnus-uu-multi-decode-and-view-or-save nil nil)) |
| 721 | 888 | ||
| 722 | (defun gnus-uu-marked-multi-decode-and-view () | 889 | (defun gnus-uu-marked-multi-decode-and-view () |
| 723 | "This function lets the user decide what method to use for decoding. | 890 | "Choose a method of decoding and then decode and view the marked articles. |
| 891 | This function lets the user decide what method to use for decoding. | ||
| 724 | Other than that, it's equivalent to the other marked decode-and-view | 892 | Other than that, it's equivalent to the other marked decode-and-view |
| 725 | functions." | 893 | functions." |
| 726 | (interactive) | 894 | (interactive) |
| 727 | (gnus-uu-multi-decode-and-view-or-save t t)) | 895 | (gnus-uu-multi-decode-and-view-or-save t t)) |
| 728 | 896 | ||
| 729 | (defun gnus-uu-marked-multi-decode-and-save () | 897 | (defun gnus-uu-marked-multi-decode-and-save () |
| 730 | "This function lets the user decide what method to use for decoding. | 898 | "Choose a method of decoding and then decode and save the marked articles. |
| 899 | This function lets the user decide what method to use for decoding. | ||
| 731 | Other than that, it's equivalent to the other marked decode-and-save | 900 | Other than that, it's equivalent to the other marked decode-and-save |
| 732 | functions." | 901 | functions." |
| 733 | (interactive) | 902 | (interactive) |
| @@ -737,7 +906,8 @@ functions." | |||
| 737 | (let (decode-type) | 906 | (let (decode-type) |
| 738 | (message "(u)udecode, (s)har, s(a)ve, (b)inhex: ") | 907 | (message "(u)udecode, (s)har, s(a)ve, (b)inhex: ") |
| 739 | (setq decode-type (read-char)) | 908 | (setq decode-type (read-char)) |
| 740 | (if (= decode-type ? ) (setq decode-type ?u)) | 909 | (if (= decode-type ? |
| 910 | ) (setq decode-type ?u)) | ||
| 741 | (if (= decode-type ?u) | 911 | (if (= decode-type ?u) |
| 742 | (gnus-uu-decode-and-view-or-save view marked) | 912 | (gnus-uu-decode-and-view-or-save view marked) |
| 743 | (if (= decode-type ?s) | 913 | (if (= decode-type ?s) |
| @@ -752,63 +922,22 @@ functions." | |||
| 752 | 922 | ||
| 753 | ;; uuencode and post | 923 | ;; uuencode and post |
| 754 | 924 | ||
| 755 | (defun gnus-uu-news-inews () | 925 | (defconst gnus-uu-uuencode-post-length 90) |
| 756 | "Send a news message using inews." | 926 | |
| 757 | (interactive) | 927 | (defun gnus-uu-post () |
| 758 | (let* (newsgroups subject | ||
| 759 | (case-fold-search nil)) | ||
| 760 | (save-excursion | ||
| 761 | (save-restriction | ||
| 762 | (goto-char (point-min)) | ||
| 763 | (search-forward (concat "\n" mail-header-separator "\n")) | ||
| 764 | (narrow-to-region (point-min) (point)) | ||
| 765 | (setq newsgroups (mail-fetch-field "newsgroups") | ||
| 766 | subject (mail-fetch-field "subject"))) | ||
| 767 | (widen) | ||
| 768 | (goto-char (point-min)) | ||
| 769 | ; (run-hooks 'news-inews-hook) | ||
| 770 | (goto-char (point-min)) | ||
| 771 | (search-forward (concat "\n" mail-header-separator "\n")) | ||
| 772 | (replace-match "\n\n") | ||
| 773 | (goto-char (point-max)) | ||
| 774 | ;; require a newline at the end for inews to append .signature to | ||
| 775 | (or (= (preceding-char) ?\n) | ||
| 776 | (insert ?\n)) | ||
| 777 | (message "Posting to USENET...") | ||
| 778 | (call-process-region (point-min) (point-max) | ||
| 779 | news-inews-program nil 0 nil | ||
| 780 | "-h") ; take all header lines! | ||
| 781 | ;@@ setting of subject and newsgroups still needed? | ||
| 782 | ;"-t" subject | ||
| 783 | ;"-n" newsgroups | ||
| 784 | (message "Posting to USENET... done") | ||
| 785 | (goto-char (point-min)) ;restore internal header separator | ||
| 786 | (search-forward "\n\n") | ||
| 787 | (replace-match (concat "\n" mail-header-separator "\n"))))) | ||
| 788 | |||
| 789 | (autoload 'news-inews "rnewspost") | ||
| 790 | |||
| 791 | (defun gnus-uu-post-buffer (&optional first) | ||
| 792 | (append-to-file 1 (point-max) "/tmp/gnusuutull") | ||
| 793 | ; (if first | ||
| 794 | ; (news-inews) | ||
| 795 | ; (gnus-uu-news-inews)) | ||
| 796 | (message "posted")) | ||
| 797 | |||
| 798 | (defconst gnus-uu-uuencode-post-length 20) | ||
| 799 | |||
| 800 | (defun gnus-uu-uuencode-and-post () | ||
| 801 | (interactive) | 928 | (interactive) |
| 802 | (let (file uubuf sendbuf short-file length parts header i end beg | 929 | (let ((uuencode-buffer-name "*uuencode buffer*") |
| 803 | beg-line minlen) | 930 | (send-buffer-name "*uuencode send buffer*") |
| 931 | (top-string "[ cut here %s (%s %d/%d) %s gnus-uu ]") | ||
| 932 | file uubuf short-file length parts header i end beg | ||
| 933 | beg-line minlen buf post-buf whole-len) | ||
| 804 | (setq file (read-file-name | 934 | (setq file (read-file-name |
| 805 | "What file do you want to uuencode and post? " "~/Unrd.jpg")) | 935 | "What file do you want to uuencode and post? " "~/Unrd.jpg")) |
| 806 | (if (not (file-exists-p file)) | 936 | (if (not (file-exists-p file)) |
| 807 | (message "%s: No such file" file) | 937 | (message "%s: No such file" file) |
| 808 | (save-excursion | 938 | (save-excursion |
| 809 | (setq uubuf (get-buffer-create "*uuencode buffer*")) | 939 | (setq post-buf (current-buffer)) |
| 810 | (setq sendbuf (get-buffer-create "*uuencode send buffer*")) | 940 | (set-buffer (setq uubuf (get-buffer-create uuencode-buffer-name))) |
| 811 | (set-buffer uubuf) | ||
| 812 | (erase-buffer) | 941 | (erase-buffer) |
| 813 | (if (string-match "^~/" file) | 942 | (if (string-match "^~/" file) |
| 814 | (setq file (concat "$HOME" (substring file 1)))) | 943 | (setq file (concat "$HOME" (substring file 1)))) |
| @@ -836,21 +965,32 @@ functions." | |||
| 836 | (progn | 965 | (progn |
| 837 | (end-of-line) | 966 | (end-of-line) |
| 838 | (insert (format " (0/%d)" parts)))) | 967 | (insert (format " (0/%d)" parts)))) |
| 839 | (gnus-uu-post-buffer t) | 968 | ; (save-excursion |
| 969 | ; (set-buffer (get-buffer-create "*tull")) | ||
| 970 | ; (erase-buffer) | ||
| 971 | ; (goto-char (point-max)) | ||
| 972 | ; (insert-buffer send-buffer-name)) | ||
| 973 | (gnus-inews-news) | ||
| 974 | |||
| 840 | (save-excursion | 975 | (save-excursion |
| 841 | (set-buffer sendbuf) | ||
| 842 | (setq i 1) | 976 | (setq i 1) |
| 843 | (setq beg 1) | 977 | (setq beg 1) |
| 844 | (while (not (> i parts)) | 978 | (while (not (> i parts)) |
| 845 | (set-buffer sendbuf) | 979 | (set-buffer (get-buffer-create send-buffer-name)) |
| 846 | (erase-buffer) | 980 | (erase-buffer) |
| 847 | (insert header) | 981 | (insert header) |
| 848 | (insert "\n") | 982 | (insert "\n") |
| 849 | (setq minlen (/ (- 62 (length (format " (%d/%d) " i parts))) 2)) | 983 | (setq whole-len |
| 850 | (setq beg-line (format "[ cut here %s (%d/%d) %s gnus-uu ]\n" | 984 | (- 62 (length (format top-string "" short-file i parts "")))) |
| 851 | (make-string (- minlen 11) ?-) i parts | 985 | (setq minlen (/ whole-len 2)) |
| 852 | (make-string (- minlen 10) ?-))) | 986 | (setq |
| 987 | beg-line | ||
| 988 | (format top-string | ||
| 989 | (make-string minlen ?-) | ||
| 990 | short-file i parts | ||
| 991 | (make-string (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-))) | ||
| 853 | (insert beg-line) | 992 | (insert beg-line) |
| 993 | (insert "\n") | ||
| 854 | (goto-char 1) | 994 | (goto-char 1) |
| 855 | (if (re-search-forward "^Subject: " nil t) | 995 | (if (re-search-forward "^Subject: " nil t) |
| 856 | (progn | 996 | (progn |
| @@ -866,10 +1006,19 @@ functions." | |||
| 866 | (setq end (point))) | 1006 | (setq end (point))) |
| 867 | (insert-buffer-substring uubuf beg end) | 1007 | (insert-buffer-substring uubuf beg end) |
| 868 | (insert beg-line) | 1008 | (insert beg-line) |
| 1009 | (insert "\n") | ||
| 869 | (setq beg end) | 1010 | (setq beg end) |
| 870 | (setq i (1+ i)) | 1011 | (setq i (1+ i)) |
| 871 | (gnus-uu-post-buffer))) | 1012 | ; (save-excursion |
| 872 | ))) | 1013 | ; (set-buffer (get-buffer-create "*tull")) |
| 1014 | ; (goto-char (point-max)) | ||
| 1015 | ; (insert-buffer send-buffer-name)) | ||
| 1016 | (gnus-inews-news) | ||
| 1017 | )) | ||
| 1018 | (and (setq buf (get-buffer send-buffer-name)) | ||
| 1019 | (kill-buffer buf)) | ||
| 1020 | (and (setq buf (get-buffer uuencode-buffer-name)) | ||
| 1021 | (kill-buffer buf))))) | ||
| 873 | 1022 | ||
| 874 | 1023 | ||
| 875 | 1024 | ||
| @@ -877,29 +1026,33 @@ functions." | |||
| 877 | 1026 | ||
| 878 | (defconst gnus-uu-rest-of-articles nil) | 1027 | (defconst gnus-uu-rest-of-articles nil) |
| 879 | (defconst gnus-uu-do-sloppy-uudecode nil) | 1028 | (defconst gnus-uu-do-sloppy-uudecode nil) |
| 880 | (defvar gnus-uu-current-save-dir nil "*") | 1029 | (defvar gnus-uu-current-save-dir nil) |
| 881 | 1030 | ||
| 882 | (defun gnus-uu-decode-and-save-all-unread-articles () | 1031 | (defun gnus-uu-decode-and-save-all-unread-articles () |
| 883 | "This function reads all unread articles in the current group and | 1032 | "Try to decode all unread articles and saves the result. |
| 884 | sees whether it can uudecode the articles. The user will be prompted | 1033 | This function reads all unread articles in the current group and sees |
| 885 | for an directory to put the resulting (if any) files." | 1034 | whether it can uudecode the articles. The user will be prompted for an |
| 1035 | directory to put the resulting (if any) files." | ||
| 886 | (interactive) | 1036 | (interactive) |
| 887 | (gnus-uu-decode-and-save-articles t t)) | 1037 | (gnus-uu-decode-and-save-articles t t)) |
| 888 | 1038 | ||
| 889 | (defun gnus-uu-decode-and-save-all-articles () | 1039 | (defun gnus-uu-decode-and-save-all-articles () |
| 890 | "Does the same as gnus-uu-decode-and-save-all-unread-articles, except | 1040 | "Try to decode all articles and saves the result. |
| 1041 | Does the same as `gnus-uu-decode-and-save-all-unread-articles', except | ||
| 891 | that it grabs all articles visible, unread or not." | 1042 | that it grabs all articles visible, unread or not." |
| 892 | (interactive) | 1043 | (interactive) |
| 893 | (gnus-uu-decode-and-save-articles nil t)) | 1044 | (gnus-uu-decode-and-save-articles nil t)) |
| 894 | 1045 | ||
| 895 | (defun gnus-uu-decode-and-save-all-unread-articles-and-mark () | 1046 | (defun gnus-uu-decode-and-save-all-unread-articles-and-mark () |
| 896 | "Does the same as gnus-uu-decode-and-save-all-unread-articles, except that | 1047 | "Try to decode all unread articles and saves the result and marks everything as read. |
| 1048 | Does the same as `gnus-uu-decode-and-save-all-unread-articles', except that | ||
| 897 | it marks everything as read, even if it couldn't decode the articles." | 1049 | it marks everything as read, even if it couldn't decode the articles." |
| 898 | (interactive) | 1050 | (interactive) |
| 899 | (gnus-uu-decode-and-save-articles t nil)) | 1051 | (gnus-uu-decode-and-save-articles t nil)) |
| 900 | 1052 | ||
| 901 | (defun gnus-uu-decode-and-save-all-articles-and-mark () | 1053 | (defun gnus-uu-decode-and-save-all-articles-and-mark () |
| 902 | "Does the same as gnus-uu-decode-and-save-all-articles, except that | 1054 | "Try to decode all articles and saves the result and marks everything as read. |
| 1055 | Does the same as `gnus-uu-decode-and-save-all-articles', except that | ||
| 903 | it marks everything as read, even if it couldn't decode the articles." | 1056 | it marks everything as read, even if it couldn't decode the articles." |
| 904 | (interactive) | 1057 | (interactive) |
| 905 | (gnus-uu-decode-and-save-articles nil nil)) | 1058 | (gnus-uu-decode-and-save-articles nil nil)) |
| @@ -949,15 +1102,18 @@ it marks everything as read, even if it couldn't decode the articles." | |||
| 949 | 1102 | ||
| 950 | (gnus-uu-summary-next-subject) | 1103 | (gnus-uu-summary-next-subject) |
| 951 | 1104 | ||
| 952 | (if (and gnus-uu-use-interactive-view view decoded) | 1105 | (if gnus-uu-error-during-unarching |
| 953 | (gnus-uu-do-interactive)) | 1106 | (gnus-uu-clean-up) |
| 1107 | (if (and gnus-uu-use-interactive-view view decoded) | ||
| 1108 | (gnus-uu-do-interactive))) | ||
| 954 | 1109 | ||
| 955 | (if (or (not gnus-uu-use-interactive-view) (not decoded)) | 1110 | (if (or (not gnus-uu-use-interactive-view) (not decoded)) |
| 956 | (gnus-uu-clean-up)))) | 1111 | (gnus-uu-clean-up)))) |
| 957 | 1112 | ||
| 1113 | |||
| 1114 | ; Unshars and views/saves marked/unmarked articles. | ||
| 958 | 1115 | ||
| 959 | (defun gnus-uu-unshar-and-view-or-save (view marked) | 1116 | (defun gnus-uu-unshar-and-view-or-save (view marked) |
| 960 | "Unshars and views/saves marked/unmarked articles." | ||
| 961 | (gnus-uu-initialize) | 1117 | (gnus-uu-initialize) |
| 962 | (let (tar-file files decoded) | 1118 | (let (tar-file files decoded) |
| 963 | (save-excursion | 1119 | (save-excursion |
| @@ -1019,8 +1175,7 @@ it marks everything as read, even if it couldn't decode the articles." | |||
| 1019 | gnus-newsgroup-name))) | 1175 | gnus-newsgroup-name))) |
| 1020 | (gnus-uu-add-file gnus-uu-saved-article-name) | 1176 | (gnus-uu-add-file gnus-uu-saved-article-name) |
| 1021 | (if (gnus-uu-grab-articles list-of-articles 'gnus-uu-save-article) | 1177 | (if (gnus-uu-grab-articles list-of-articles 'gnus-uu-save-article) |
| 1022 | (gnus-uu-save-file gnus-uu-saved-article-name)) | 1178 | (gnus-uu-save-file gnus-uu-saved-article-name)))))) |
| 1023 | )))) | ||
| 1024 | 1179 | ||
| 1025 | 1180 | ||
| 1026 | (defun gnus-uu-save-article (buffer in-state) | 1181 | (defun gnus-uu-save-article (buffer in-state) |
| @@ -1049,7 +1204,6 @@ it marks everything as read, even if it couldn't decode the articles." | |||
| 1049 | (setq list-of-articles (gnus-uu-get-list-of-articles)) | 1204 | (setq list-of-articles (gnus-uu-get-list-of-articles)) |
| 1050 | (setq list-of-articles (reverse gnus-uu-marked-article-list)) | 1205 | (setq list-of-articles (reverse gnus-uu-marked-article-list)) |
| 1051 | (setq gnus-uu-marked-article-list nil)) | 1206 | (setq gnus-uu-marked-article-list nil)) |
| 1052 | ' (setq gn-dummy-l list-of-articles) | ||
| 1053 | (if (not list-of-articles) | 1207 | (if (not list-of-articles) |
| 1054 | (progn | 1208 | (progn |
| 1055 | (message "No list of articles") | 1209 | (message "No list of articles") |
| @@ -1061,8 +1215,7 @@ it marks everything as read, even if it couldn't decode the articles." | |||
| 1061 | gnus-newsgroup-name))) | 1215 | gnus-newsgroup-name))) |
| 1062 | (gnus-uu-add-file gnus-uu-binhex-article-name) | 1216 | (gnus-uu-add-file gnus-uu-binhex-article-name) |
| 1063 | (if (gnus-uu-grab-articles list-of-articles 'gnus-uu-binhex-article) | 1217 | (if (gnus-uu-grab-articles list-of-articles 'gnus-uu-binhex-article) |
| 1064 | (gnus-uu-save-file gnus-uu-binhex-article-name)) | 1218 | (gnus-uu-save-file gnus-uu-binhex-article-name)))))) |
| 1065 | )))) | ||
| 1066 | 1219 | ||
| 1067 | 1220 | ||
| 1068 | (defun gnus-uu-binhex-article (buffer in-state) | 1221 | (defun gnus-uu-binhex-article (buffer in-state) |
| @@ -1094,21 +1247,22 @@ it marks everything as read, even if it couldn't decode the articles." | |||
| 1094 | 1247 | ||
| 1095 | ;; Internal view commands | 1248 | ;; Internal view commands |
| 1096 | 1249 | ||
| 1097 | (defun gnus-uu-view-file (file-name &optional dont-ask) | 1250 | ; This function takes two parameters. The first is name of the file to |
| 1098 | "This function takes two parameters. The first is name of the file to be | 1251 | ; be viewed. `gnus-uu-view-file' will look for an action associated |
| 1099 | viewed. gnus-uu-view-file will look for an action associated with the file | 1252 | ; with the file type of the file. If it finds an appropriate action, |
| 1100 | type of the file. If it finds an appropriate action, the file will be | 1253 | ; the file will be attempted displayed. |
| 1101 | attempted displayed. | 1254 | ; |
| 1255 | ; The second parameter specifies if the user is to be asked whether to | ||
| 1256 | ; save the file if viewing is unsuccessful. t means "do not ask." | ||
| 1257 | ; | ||
| 1258 | ; Note that the file given will be deleted by this function, one way | ||
| 1259 | ; or another. If `gnus-uu-asynchronous' is set, it won't be deleted | ||
| 1260 | ; right away, but sometime later. If the user is offered to save the | ||
| 1261 | ; file, it'll be moved to wherever the user wants it. | ||
| 1262 | |||
| 1263 | ; `gnus-uu-view-file' returns t if viewing is successful. | ||
| 1102 | 1264 | ||
| 1103 | The second parameter specifies if the user is to be asked whether to | 1265 | (defun gnus-uu-view-file (file-name &optional dont-ask) |
| 1104 | save the file if viewing is unsuccessful. `t' means 'do not ask.' | ||
| 1105 | |||
| 1106 | Note that the file given will be deleted by this function, one way or | ||
| 1107 | another. If `gnus-uu-asynchronous' is set, it won't be deleted right | ||
| 1108 | away, but sometime later. If the user is offered to save the file, it'll | ||
| 1109 | be moved to wherever the user wants it. | ||
| 1110 | |||
| 1111 | gnus-uu-view-file returns `t' if viewing is successful." | ||
| 1112 | (let (action did-view | 1266 | (let (action did-view |
| 1113 | (didnt-want t) | 1267 | (didnt-want t) |
| 1114 | (do-view t)) | 1268 | (do-view t)) |
| @@ -1160,13 +1314,16 @@ gnus-uu-view-file returns `t' if viewing is successful." | |||
| 1160 | (if (and | 1314 | (if (and |
| 1161 | didnt-want | 1315 | didnt-want |
| 1162 | (or (not action) | 1316 | (or (not action) |
| 1163 | (and (string= action "gnus-uu-archive") (not did-view)))) | 1317 | (and (string= action "gnus-uu-archive") |
| 1318 | (not did-view)))) | ||
| 1164 | (progn | 1319 | (progn |
| 1165 | (message (format "Could find no rule for %s" file-name)) | 1320 | (message |
| 1321 | (format "Could find no rule for %s" file-name)) | ||
| 1166 | (sit-for 2))) | 1322 | (sit-for 2))) |
| 1167 | (and (or (not did-view) gnus-uu-view-and-save) | 1323 | (and (or (not did-view) gnus-uu-view-and-save) |
| 1168 | (y-or-n-p | 1324 | (y-or-n-p |
| 1169 | (format "Do you want to save the file %s? " file-name)) | 1325 | (format "Do you want to save the file %s? " |
| 1326 | file-name)) | ||
| 1170 | (gnus-uu-save-file file-name)))) | 1327 | (gnus-uu-save-file file-name)))) |
| 1171 | 1328 | ||
| 1172 | (if (and (file-exists-p file-name) | 1329 | (if (and (file-exists-p file-name) |
| @@ -1179,17 +1336,16 @@ gnus-uu-view-file returns `t' if viewing is successful." | |||
| 1179 | did-view)) | 1336 | did-view)) |
| 1180 | 1337 | ||
| 1181 | 1338 | ||
| 1339 | ; `gnus-uu-call-synchronous' takes two parameters: The name of the | ||
| 1340 | ; file to be displayed and the command to display it with. Returns t | ||
| 1341 | ; on success and nil if the file couldn't be displayed. | ||
| 1342 | |||
| 1182 | (defun gnus-uu-call-synchronous (file-name action) | 1343 | (defun gnus-uu-call-synchronous (file-name action) |
| 1183 | "Takes two parameters: The name of the file to be displayed and | ||
| 1184 | the command to display it with. Returns `t' on success and `nil' if | ||
| 1185 | the file couldn't be displayed." | ||
| 1186 | (let (did-view command) | 1344 | (let (did-view command) |
| 1187 | (save-excursion | 1345 | (save-excursion |
| 1188 | (set-buffer (get-buffer-create gnus-uu-output-buffer-name)) | 1346 | (set-buffer (get-buffer-create gnus-uu-output-buffer-name)) |
| 1189 | (erase-buffer) | 1347 | (erase-buffer) |
| 1190 | (if (string-match "%s" action) | 1348 | (setq command (gnus-uu-command action file-name)) |
| 1191 | (setq command (format action (concat "'" file-name "'"))) | ||
| 1192 | (setq command (concat action " " (concat "'" file-name "'")))) | ||
| 1193 | (message (format "Viewing with '%s'" command)) | 1349 | (message (format "Viewing with '%s'" command)) |
| 1194 | (if (not (= 0 (call-process "sh" nil t nil "-c" command))) | 1350 | (if (not (= 0 (call-process "sh" nil t nil "-c" command))) |
| 1195 | (progn | 1351 | (progn |
| @@ -1202,14 +1358,14 @@ the file couldn't be displayed." | |||
| 1202 | (setq did-view t))) | 1358 | (setq did-view t))) |
| 1203 | did-view)) | 1359 | did-view)) |
| 1204 | 1360 | ||
| 1361 | ; `gnus-uu-call-asyncronous' takes two parameters: The name of the | ||
| 1362 | ; file to be displayed and the command to display it with. Since the | ||
| 1363 | ; view command is executed asynchronously, it's kinda hard to decide | ||
| 1364 | ; whether the command succeded or not, so this function always returns | ||
| 1365 | ; t. It also adds "; rm -f file-name" to the end of the execution | ||
| 1366 | ; string, so the file will be removed after viewing has ended. | ||
| 1205 | 1367 | ||
| 1206 | (defun gnus-uu-call-asynchronous (file-name action) | 1368 | (defun gnus-uu-call-asynchronous (file-name action) |
| 1207 | "Takes two parameters: The name of the file to be displayed and | ||
| 1208 | the command to display it with. Since the view command is executed | ||
| 1209 | asynchronously, it's kinda hard to decide whether the command succeded | ||
| 1210 | or not, so this function always returns `t'. It also adds \"; rm -f | ||
| 1211 | file-name\" to the end of the execution string, so the file will be | ||
| 1212 | removed after viewing has ended." | ||
| 1213 | (let (command file tmp-file start) | 1369 | (let (command file tmp-file start) |
| 1214 | (while (string-match "/" file-name start) | 1370 | (while (string-match "/" file-name start) |
| 1215 | (setq start (1+ (match-beginning 0)))) | 1371 | (setq start (1+ (match-beginning 0)))) |
| @@ -1220,23 +1376,21 @@ removed after viewing has ended." | |||
| 1220 | (rename-file file-name tmp-file t) | 1376 | (rename-file file-name tmp-file t) |
| 1221 | (setq file-name tmp-file)) | 1377 | (setq file-name tmp-file)) |
| 1222 | 1378 | ||
| 1223 | (if (string-match "%s" action) | 1379 | (setq command (gnus-uu-command action file-name)) |
| 1224 | (setq command (format action file-name)) | ||
| 1225 | (setq command (concat action " " file-name))) | ||
| 1226 | (setq command (format "%s ; rm -f %s" command file-name)) | 1380 | (setq command (format "%s ; rm -f %s" command file-name)) |
| 1227 | (message (format "Viewing with %s" command)) | 1381 | (message (format "Viewing with %s" command)) |
| 1228 | (start-process "gnus-uu-view" | 1382 | (start-process "gnus-uu-view" nil "sh" "-c" command) |
| 1229 | nil "sh" "-c" command) | ||
| 1230 | t)) | 1383 | t)) |
| 1231 | 1384 | ||
| 1232 | 1385 | ||
| 1386 | ; `gnus-uu-decode-and-strip' does all the main work. It finds out what | ||
| 1387 | ; articles to grab, grabs them, strips the result and decodes. If any | ||
| 1388 | ; of these operations fail, it returns nil, t otherwise. If shar is | ||
| 1389 | ; t, it will pass this on to `gnus-uu-grab-articles', which will | ||
| 1390 | ; (probably) unshar the articles. If use-marked is non-nil, it won't | ||
| 1391 | ; try to find articles, but use the marked list. | ||
| 1392 | |||
| 1233 | (defun gnus-uu-decode-and-strip (&optional shar use-marked) | 1393 | (defun gnus-uu-decode-and-strip (&optional shar use-marked) |
| 1234 | "This function does all the main work. It finds out what articles | ||
| 1235 | to grab, grabs them, strips the result and decodes. If any of | ||
| 1236 | these operations fail, it returns `nil', `t' otherwise. | ||
| 1237 | If shar is `t', it will pass this on to gnus-uu-grab-articles | ||
| 1238 | who will (probably) unshar the articles. If use-marked | ||
| 1239 | is non-nil, it won't try to find articles, but use the marked list." | ||
| 1240 | (let (list-of-articles) | 1394 | (let (list-of-articles) |
| 1241 | (save-excursion | 1395 | (save-excursion |
| 1242 | 1396 | ||
| @@ -1254,15 +1408,16 @@ is non-nil, it won't try to find articles, but use the marked list." | |||
| 1254 | 'gnus-uu-uustrip-article-as)))))) | 1408 | 'gnus-uu-uustrip-article-as)))))) |
| 1255 | 1409 | ||
| 1256 | 1410 | ||
| 1411 | ; Takes a string and puts a \ in front of every special character; | ||
| 1412 | ; ignores any leading "version numbers" thingies that they use in the | ||
| 1413 | ; comp.binaries groups, and either replaces anything that looks like | ||
| 1414 | ; "2/3" with "[0-9]+/[0-9]+" or, if it can't find something like that, | ||
| 1415 | ; replaces the last two numbers with "[0-9]+". This, in my experience, | ||
| 1416 | ; should get most postings of a series." | ||
| 1417 | |||
| 1257 | (defun gnus-uu-reginize-string (string) | 1418 | (defun gnus-uu-reginize-string (string) |
| 1258 | "Takes a string and puts a \\ in front of every special character; | ||
| 1259 | ignores any leading \"version numbers\" | ||
| 1260 | thingies that they use in the comp.binaries groups, and either replaces | ||
| 1261 | anything that looks like \"2/3\" with \"[0-9]+/[0-9]+\" or, if it can't find | ||
| 1262 | something like that, replaces the last two numbers with \"[0-9]+\". This, | ||
| 1263 | in my experience, should get most postings of a series." | ||
| 1264 | (let ((count 2) | 1419 | (let ((count 2) |
| 1265 | (vernum "v[0-9][0-9][a-z][0-9]+:") | 1420 | (vernum "v[0-9]+[a-z][0-9]+:") |
| 1266 | reg beg) | 1421 | reg beg) |
| 1267 | (save-excursion | 1422 | (save-excursion |
| 1268 | (set-buffer (get-buffer-create gnus-uu-output-buffer-name)) | 1423 | (set-buffer (get-buffer-create gnus-uu-output-buffer-name)) |
| @@ -1302,9 +1457,10 @@ in my experience, should get most postings of a series." | |||
| 1302 | (buffer-substring 1 (point-max))))) | 1457 | (buffer-substring 1 (point-max))))) |
| 1303 | 1458 | ||
| 1304 | 1459 | ||
| 1460 | ; Finds all articles that matches the regular expression given. | ||
| 1461 | ; Returns the resulting list. | ||
| 1462 | |||
| 1305 | (defun gnus-uu-get-list-of-articles (&optional subject mark-articles only-unread) | 1463 | (defun gnus-uu-get-list-of-articles (&optional subject mark-articles only-unread) |
| 1306 | "Finds all articles that matches the regular expression given. | ||
| 1307 | Returns the resulting list." | ||
| 1308 | (let (beg end reg-subject list-of-subjects list-of-numbers art-num) | 1464 | (let (beg end reg-subject list-of-subjects list-of-numbers art-num) |
| 1309 | (save-excursion | 1465 | (save-excursion |
| 1310 | 1466 | ||
| @@ -1369,12 +1525,13 @@ Returns the resulting list." | |||
| 1369 | list-of-numbers))) | 1525 | list-of-numbers))) |
| 1370 | 1526 | ||
| 1371 | 1527 | ||
| 1528 | ; Takes a list of strings and "expands" all numbers in all the | ||
| 1529 | ; strings. That is, this function makes all numbers equal length by | ||
| 1530 | ; prepending lots of zeroes before each number. This is to ease later | ||
| 1531 | ; sorting to find out what sequence the articles are supposed to be | ||
| 1532 | ; decoded in. Returns the list of expanded strings. | ||
| 1533 | |||
| 1372 | (defun gnus-uu-expand-numbers (string-list) | 1534 | (defun gnus-uu-expand-numbers (string-list) |
| 1373 | "Takes a list of strings and \"expands\" all numbers in all the strings. | ||
| 1374 | That is, this function makes all numbers equal length by prepending lots | ||
| 1375 | of zeroes before each number. This is to ease later sorting to find out | ||
| 1376 | what sequence the articles are supposed to be decoded in. Returns the list | ||
| 1377 | of expanded strings." | ||
| 1378 | (let (string out-list pos num) | 1535 | (let (string out-list pos num) |
| 1379 | (save-excursion | 1536 | (save-excursion |
| 1380 | (set-buffer (get-buffer-create gnus-uu-output-buffer-name)) | 1537 | (set-buffer (get-buffer-create gnus-uu-output-buffer-name)) |
| @@ -1403,36 +1560,37 @@ of expanded strings." | |||
| 1403 | out-list)) | 1560 | out-list)) |
| 1404 | 1561 | ||
| 1405 | 1562 | ||
| 1563 | ; Used in a sort for finding out what string is bigger, but ignoring | ||
| 1564 | ; everything before the subject part. | ||
| 1565 | |||
| 1406 | (defun gnus-uu-string< (string1 string2) | 1566 | (defun gnus-uu-string< (string1 string2) |
| 1407 | "Used in a sort for finding out what string is bigger, but ignoring | ||
| 1408 | everything before the subject part." | ||
| 1409 | (string< (substring string1 (string-match "\\] " string1)) | 1567 | (string< (substring string1 (string-match "\\] " string1)) |
| 1410 | (substring string2 (string-match "\\] " string2)))) | 1568 | (substring string2 (string-match "\\] " string2)))) |
| 1411 | 1569 | ||
| 1412 | 1570 | ||
| 1413 | ;; gnus-uu-grab-article | 1571 | ;; gnus-uu-grab-article |
| 1414 | ;; | 1572 | ; |
| 1415 | ;; This is the general multi-article treatment function. | 1573 | ; This is the general multi-article treatment function. It takes a |
| 1416 | ;; It takes a list of articles to be grabbed and a function | 1574 | ; list of articles to be grabbed and a function to apply to each |
| 1417 | ;; to apply to each article. It puts the result in | 1575 | ; article. It puts the result in `gnus-uu-result-buffer'. |
| 1418 | ;; gnus-uu-result-buffer. | 1576 | ; |
| 1419 | ;; | 1577 | ; The function to be called should take two parameters. The first is |
| 1420 | ;; The function to be called should take two parameters. | 1578 | ; the buffer that has the article that should be treated. The function |
| 1421 | ;; The first is the buffer that has the article that should | 1579 | ; should leave the result in this buffer as well. This result is then |
| 1422 | ;; be treated. The function should leave the result in this | 1580 | ; appended on to the `gnus-uu-result-buffer'. |
| 1423 | ;; buffer as well. This result is then appended on to the | 1581 | ; |
| 1424 | ;; gnus-uu-result-buffer. | 1582 | ; The second parameter is the state of the list of articles, and can |
| 1425 | ;; The second parameter is the state of the list of articles, | 1583 | ; have three values: 'start, 'middle and 'end. |
| 1426 | ;; and can have three values: 'start, 'middle and 'end. | 1584 | ; |
| 1427 | ;; The function can have several return values. | 1585 | ; The function can have several return values: |
| 1428 | ;; 'error if there was an error while treating. | 1586 | ; 'error if there was an error while treating. |
| 1429 | ;; 'end if the last article has been sighted. | 1587 | ; 'end if the last article has been sighted. |
| 1430 | ;; 'begin-and-end if the article is both the beginning and | 1588 | ; 'begin-and-end if the article is both the beginning and |
| 1431 | ;; the end. All these three return values results in | 1589 | ; the end. All these three return values results in |
| 1432 | ;; gnus-uu-grab-articles stopping traversing of the list | 1590 | ; `gnus-uu-grab-articles' stopping traversing of the list |
| 1433 | ;; of articles. | 1591 | ; of articles. |
| 1434 | ;; 'middle if the article is a "middle" article. | 1592 | ; 'middle if the article is a "middle" article. |
| 1435 | ;; 'ok if everything is ok. | 1593 | ; 'ok if everything is ok. |
| 1436 | 1594 | ||
| 1437 | (defvar gnus-uu-has-been-grabbed nil) | 1595 | (defvar gnus-uu-has-been-grabbed nil) |
| 1438 | 1596 | ||
| @@ -1449,17 +1607,17 @@ everything before the subject part." | |||
| 1449 | (gnus-summary-mark-as-unread (car gnus-uu-has-been-grabbed) t) | 1607 | (gnus-summary-mark-as-unread (car gnus-uu-has-been-grabbed) t) |
| 1450 | (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed))) | 1608 | (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed))) |
| 1451 | (if dont-unmark-last-article | 1609 | (if dont-unmark-last-article |
| 1452 | (setq gnus-uu-has-been-grabbed (list art))) | 1610 | (setq gnus-uu-has-been-grabbed (list art)))))) |
| 1453 | ))) | ||
| 1454 | 1611 | ||
| 1455 | 1612 | ||
| 1456 | (defun gnus-uu-grab-articles (list-of-articles process-function) | 1613 | ; This function takes a list of articles and a function to apply to |
| 1457 | "This function takes a list of articles and a function to apply | 1614 | ; each article grabbed. The result of the function is appended on to |
| 1458 | to each article grabbed. The result of the function is appended | 1615 | ; `gnus-uu-result-buffer'. |
| 1459 | on to gnus-uu-result-buffer. | 1616 | ; |
| 1617 | ; This function returns t if the grabbing and the process-function | ||
| 1618 | ; has been successful and nil otherwise." | ||
| 1460 | 1619 | ||
| 1461 | This function returns `t' if the grabbing and the process-function | 1620 | (defun gnus-uu-grab-articles (list-of-articles process-function) |
| 1462 | has been successful and `nil' otherwise." | ||
| 1463 | (let ((result-buffer (get-buffer-create gnus-uu-result-buffer)) | 1621 | (let ((result-buffer (get-buffer-create gnus-uu-result-buffer)) |
| 1464 | (state 'first) | 1622 | (state 'first) |
| 1465 | (process-state 'ok) | 1623 | (process-state 'ok) |
| @@ -1555,14 +1713,17 @@ has been successful and `nil' otherwise." | |||
| 1555 | 1713 | ||
| 1556 | (if gnus-uu-kill-carriage-return | 1714 | (if gnus-uu-kill-carriage-return |
| 1557 | (progn | 1715 | (progn |
| 1558 | (while (search-forward " " nil t) | 1716 | (while (search-forward " |
| 1717 | " nil t) | ||
| 1559 | (delete-backward-char 1)) | 1718 | (delete-backward-char 1)) |
| 1560 | (goto-char 1))) | 1719 | (goto-char 1))) |
| 1561 | 1720 | ||
| 1562 | (if (not (re-search-forward | 1721 | (if (not (re-search-forward gnus-uu-begin-string nil t)) |
| 1563 | (concat gnus-uu-begin-string "\\|" gnus-uu-body-line) nil t)) | 1722 | (if (not (re-search-forward gnus-uu-body-line nil t)) |
| 1564 | (setq state 'wrong-type) | 1723 | (setq state 'wrong-type))) |
| 1565 | 1724 | ||
| 1725 | (if (eq state 'wrong-type) | ||
| 1726 | () | ||
| 1566 | (beginning-of-line) | 1727 | (beginning-of-line) |
| 1567 | (setq start-char (point)) | 1728 | (setq start-char (point)) |
| 1568 | 1729 | ||
| @@ -1573,12 +1734,13 @@ has been successful and `nil' otherwise." | |||
| 1573 | (while (re-search-forward "/" name-end t) | 1734 | (while (re-search-forward "/" name-end t) |
| 1574 | (replace-match "-")) | 1735 | (replace-match "-")) |
| 1575 | (setq gnus-uu-file-name (buffer-substring name-beg name-end)) | 1736 | (setq gnus-uu-file-name (buffer-substring name-beg name-end)) |
| 1576 | (setq pst (process-status | 1737 | (and gnus-uu-uudecode-process |
| 1577 | (or gnus-uu-uudecode-process "nevair"))) | 1738 | (setq pst (process-status |
| 1578 | (if (or (eq pst 'stop) (eq pst 'run)) | 1739 | (or gnus-uu-uudecode-process "nevair"))) |
| 1579 | (progn | 1740 | (if (or (eq pst 'stop) (eq pst 'run)) |
| 1580 | (delete-process gnus-uu-uudecode-process) | 1741 | (progn |
| 1581 | (gnus-uu-unmark-list-of-grabbed t))) | 1742 | (delete-process gnus-uu-uudecode-process) |
| 1743 | (gnus-uu-unmark-list-of-grabbed t)))) | ||
| 1582 | (setq gnus-uu-uudecode-process | 1744 | (setq gnus-uu-uudecode-process |
| 1583 | (start-process | 1745 | (start-process |
| 1584 | "*uudecode*" | 1746 | "*uudecode*" |
| @@ -1592,33 +1754,53 @@ has been successful and `nil' otherwise." | |||
| 1592 | (setq state 'middle)) | 1754 | (setq state 'middle)) |
| 1593 | 1755 | ||
| 1594 | (goto-char (point-max)) | 1756 | (goto-char (point-max)) |
| 1757 | |||
| 1595 | (re-search-backward | 1758 | (re-search-backward |
| 1596 | (concat gnus-uu-body-line "\\|" gnus-uu-end-string) nil t) | 1759 | (concat gnus-uu-body-line "\\|" gnus-uu-end-string) nil t) |
| 1760 | (beginning-of-line) | ||
| 1761 | |||
| 1597 | (if (looking-at gnus-uu-end-string) | 1762 | (if (looking-at gnus-uu-end-string) |
| 1598 | (if (eq state 'begin) | 1763 | (if (eq state 'begin) |
| 1599 | (setq state 'begin-and-end) | 1764 | (setq state 'begin-and-end) |
| 1600 | (setq state 'end))) | 1765 | (setq state 'end))) |
| 1601 | (forward-line 1) | 1766 | (forward-line 1) |
| 1602 | 1767 | ||
| 1603 | (setq pst (process-status (or gnus-uu-uudecode-process "nevair"))) | 1768 | ; (message "Ja: %s" state)(sit-for 0)(sleep-for 2) |
| 1604 | (if (or (eq pst 'run) (eq pst 'stop)) | 1769 | |
| 1605 | (progn | 1770 | (and gnus-uu-uudecode-process |
| 1606 | (gnus-uu-check-correct-stripped-uucode start-char (point)) | 1771 | (setq pst (process-status (or gnus-uu-uudecode-process "nevair"))) |
| 1607 | (condition-case err | 1772 | (if (or (eq pst 'run) (eq pst 'stop)) |
| 1608 | (process-send-region gnus-uu-uudecode-process start-char | 1773 | (progn |
| 1609 | (point)) | 1774 | (if gnus-uu-correct-stripped-uucode |
| 1610 | (error | 1775 | (progn |
| 1611 | (progn | 1776 | (gnus-uu-check-correct-stripped-uucode |
| 1612 | (setq state 'wrong-type) | 1777 | start-char (point)) |
| 1613 | (delete-process gnus-uu-uudecode-process))))) | 1778 | (goto-char (point-max)) |
| 1614 | (setq state 'wrong-type))) | 1779 | (re-search-backward |
| 1780 | (concat gnus-uu-body-line "\\|" gnus-uu-end-string) | ||
| 1781 | nil t) | ||
| 1782 | (forward-line 1))) | ||
| 1783 | (condition-case err | ||
| 1784 | (process-send-region gnus-uu-uudecode-process | ||
| 1785 | start-char (point)) | ||
| 1786 | (error | ||
| 1787 | (progn | ||
| 1788 | (message "Her var en uuerror") | ||
| 1789 | (sleep-for 2) | ||
| 1790 | (setq state 'wrong-type) | ||
| 1791 | (delete-process gnus-uu-uudecode-process))))) | ||
| 1792 | (setq state 'wrong-type))) | ||
| 1793 | (if (not gnus-uu-uudecode-process) | ||
| 1794 | (setq state 'wrong-type))) | ||
| 1795 | |||
| 1615 | (setq buffer-read-only buf-state)) | 1796 | (setq buffer-read-only buf-state)) |
| 1616 | state)) | 1797 | state)) |
| 1617 | 1798 | ||
| 1618 | 1799 | ||
| 1800 | ; This function is used by `gnus-uu-grab-articles' to treat | ||
| 1801 | ; a shared article. | ||
| 1802 | |||
| 1619 | (defun gnus-uu-unshar-article (process-buffer in-state) | 1803 | (defun gnus-uu-unshar-article (process-buffer in-state) |
| 1620 | "This function is used by gnus-uu-grab-articles to treat | ||
| 1621 | a shared article." | ||
| 1622 | (let ((state 'ok) | 1804 | (let ((state 'ok) |
| 1623 | start-char) | 1805 | start-char) |
| 1624 | (save-excursion | 1806 | (save-excursion |
| @@ -1635,8 +1817,9 @@ a shared article." | |||
| 1635 | state)) | 1817 | state)) |
| 1636 | 1818 | ||
| 1637 | 1819 | ||
| 1820 | ; Returns the name of what the shar file is going to unpack. | ||
| 1821 | |||
| 1638 | (defun gnus-uu-find-name-in-shar () | 1822 | (defun gnus-uu-find-name-in-shar () |
| 1639 | "Returns the name of what the shar file is going to unpack." | ||
| 1640 | (let ((oldpoint (point)) | 1823 | (let ((oldpoint (point)) |
| 1641 | res) | 1824 | res) |
| 1642 | (goto-char 1) | 1825 | (goto-char 1) |
| @@ -1646,8 +1829,9 @@ a shared article." | |||
| 1646 | res)) | 1829 | res)) |
| 1647 | 1830 | ||
| 1648 | 1831 | ||
| 1832 | ; Returns the article number of the given subject. | ||
| 1833 | |||
| 1649 | (defun gnus-uu-article-number (subject) | 1834 | (defun gnus-uu-article-number (subject) |
| 1650 | "Returns the article number of the given subject." | ||
| 1651 | (let (end) | 1835 | (let (end) |
| 1652 | (string-match "[0-9]+[^0-9]" subject 1) | 1836 | (string-match "[0-9]+[^0-9]" subject 1) |
| 1653 | (setq end (match-end 0)) | 1837 | (setq end (match-end 0)) |
| @@ -1655,9 +1839,10 @@ a shared article." | |||
| 1655 | (substring subject (string-match "[0-9]" subject 1) end)))) | 1839 | (substring subject (string-match "[0-9]" subject 1) end)))) |
| 1656 | 1840 | ||
| 1657 | 1841 | ||
| 1842 | ; UUdecodes everything in the buffer and returns the name of the | ||
| 1843 | ; resulting file. | ||
| 1844 | |||
| 1658 | (defun gnus-uu-decode (directory) | 1845 | (defun gnus-uu-decode (directory) |
| 1659 | "UUdecodes everything in the buffer and returns the name of the resulting | ||
| 1660 | file." | ||
| 1661 | (let ((command (concat "cd " directory " ; uudecode")) | 1846 | (let ((command (concat "cd " directory " ; uudecode")) |
| 1662 | file-name) | 1847 | file-name) |
| 1663 | (save-excursion | 1848 | (save-excursion |
| @@ -1669,10 +1854,11 @@ file." | |||
| 1669 | file-name))) | 1854 | file-name))) |
| 1670 | 1855 | ||
| 1671 | 1856 | ||
| 1857 | ; `gnus-uu-choose-action' chooses what action to perform given the name | ||
| 1858 | ; and `gnus-uu-file-action-list'. Returns either nil if no action is | ||
| 1859 | ; found, or the name of the command to run if such a rule is found. | ||
| 1860 | |||
| 1672 | (defun gnus-uu-choose-action (file-name file-action-list) | 1861 | (defun gnus-uu-choose-action (file-name file-action-list) |
| 1673 | "Chooses what action to perform given the name and gnus-uu-file-action-list. | ||
| 1674 | Returns either nil if no action is found, or the name of the command | ||
| 1675 | to run if such a rule is found." | ||
| 1676 | (let ((action-list (copy-sequence file-action-list)) | 1862 | (let ((action-list (copy-sequence file-action-list)) |
| 1677 | rule action) | 1863 | rule action) |
| 1678 | (while (not (or (eq action-list ()) action)) | 1864 | (while (not (or (eq action-list ()) action)) |
| @@ -1683,8 +1869,9 @@ to run if such a rule is found." | |||
| 1683 | action)) | 1869 | action)) |
| 1684 | 1870 | ||
| 1685 | 1871 | ||
| 1872 | ; Moves the file from the tmp directory to where the user wants it. | ||
| 1873 | |||
| 1686 | (defun gnus-uu-save-file (from-file-name &optional default-dir ignore-existing) | 1874 | (defun gnus-uu-save-file (from-file-name &optional default-dir ignore-existing) |
| 1687 | "Moves the file from the tmp directory to where the user wants it." | ||
| 1688 | (let (dir file-name command) | 1875 | (let (dir file-name command) |
| 1689 | (string-match "/[^/]*$" from-file-name) | 1876 | (string-match "/[^/]*$" from-file-name) |
| 1690 | (setq file-name (substring from-file-name (1+ (match-beginning 0)))) | 1877 | (setq file-name (substring from-file-name (1+ (match-beginning 0)))) |
| @@ -1726,13 +1913,13 @@ to run if such a rule is found." | |||
| 1726 | (setq gnus-uu-current-save-dir (concat dir "/")))) | 1913 | (setq gnus-uu-current-save-dir (concat dir "/")))) |
| 1727 | 1914 | ||
| 1728 | 1915 | ||
| 1916 | ; Unpacks an archive and views all the files in it. Returns t if | ||
| 1917 | ; viewing one or more files is successful. | ||
| 1918 | |||
| 1729 | (defun gnus-uu-treat-archive (file-name) | 1919 | (defun gnus-uu-treat-archive (file-name) |
| 1730 | "Unpacks an archive and views all the files in it. Returns `t' if | ||
| 1731 | viewing one or more files is successful." | ||
| 1732 | (let ((arc-dir (make-temp-name | 1920 | (let ((arc-dir (make-temp-name |
| 1733 | (concat gnus-uu-tmp-dir "gnusuu"))) | 1921 | (concat gnus-uu-tmp-dir "gnusuu"))) |
| 1734 | action command files file did-view short-file-name | 1922 | action command files file did-view short-file-name) |
| 1735 | error-during-unarching) | ||
| 1736 | (setq action (gnus-uu-choose-action | 1923 | (setq action (gnus-uu-choose-action |
| 1737 | file-name (append gnus-uu-user-archive-rules | 1924 | file-name (append gnus-uu-user-archive-rules |
| 1738 | (if gnus-uu-ignore-default-archive-rules | 1925 | (if gnus-uu-ignore-default-archive-rules |
| @@ -1743,14 +1930,14 @@ viewing one or more files is successful." | |||
| 1743 | (sit-for 2)) | 1930 | (sit-for 2)) |
| 1744 | (string-match "/[^/]*$" file-name) | 1931 | (string-match "/[^/]*$" file-name) |
| 1745 | (setq short-file-name (substring file-name (1+ (match-beginning 0)))) | 1932 | (setq short-file-name (substring file-name (1+ (match-beginning 0)))) |
| 1746 | (setq command (format "%s %s %s ; cd %s ; %s %s " | 1933 | (setq command (format "%s %s %s ; cd %s ; %s " |
| 1747 | (if (or (string= action "uncompress") | 1934 | (if (or (string= action "uncompress") |
| 1748 | (string= action "gunzip")) | 1935 | (string= action "gunzip")) |
| 1749 | "cp" | 1936 | "cp" |
| 1750 | "mv") | 1937 | "mv") |
| 1751 | file-name arc-dir | 1938 | (gnus-uu-command "" file-name) arc-dir |
| 1752 | arc-dir | 1939 | arc-dir |
| 1753 | action short-file-name)) | 1940 | (gnus-uu-command action short-file-name))) |
| 1754 | 1941 | ||
| 1755 | (make-directory arc-dir) | 1942 | (make-directory arc-dir) |
| 1756 | (gnus-uu-add-file arc-dir) | 1943 | (gnus-uu-add-file arc-dir) |
| @@ -1760,21 +1947,21 @@ viewing one or more files is successful." | |||
| 1760 | (erase-buffer)) | 1947 | (erase-buffer)) |
| 1761 | 1948 | ||
| 1762 | (message (format "Unpacking with %s..." action)) | 1949 | (message (format "Unpacking with %s..." action)) |
| 1950 | (sleep-for 1) | ||
| 1763 | 1951 | ||
| 1764 | (if (= 0 (call-process "sh" nil | 1952 | (if (= 0 (call-process "sh" nil |
| 1765 | (get-buffer-create gnus-uu-output-buffer-name) | 1953 | (get-buffer-create gnus-uu-output-buffer-name) |
| 1766 | nil "-c" command)) | 1954 | nil "-c" command)) |
| 1767 | (message "") | 1955 | (message "") |
| 1768 | (message "Error during unpacking of archive") | 1956 | (message "Error during unpacking of archive") |
| 1769 | (sit-for 2) | 1957 | (sit-for 0) (sleep-for 2) |
| 1770 | (sit-for 2) | 1958 | (setq gnus-uu-error-during-unarching t)) |
| 1771 | (setq error-during-unarching t)) | ||
| 1772 | 1959 | ||
| 1773 | (if (not (or (string= action "uncompress") | 1960 | (if (not (or (string= action "uncompress") |
| 1774 | (string= action "gunzip"))) | 1961 | (string= action "gunzip"))) |
| 1775 | (call-process "sh" nil (get-buffer gnus-uu-output-buffer-name) | 1962 | (call-process "sh" nil (get-buffer gnus-uu-output-buffer-name) |
| 1776 | nil "-c" (format "mv %s/%s %s" | 1963 | nil "-c" (format "mv %s %s" |
| 1777 | arc-dir short-file-name | 1964 | (gnus-uu-command "" (concat arc-dir "/" short-file-name)) |
| 1778 | gnus-uu-tmp-dir))) | 1965 | gnus-uu-tmp-dir))) |
| 1779 | (gnus-uu-add-file (concat gnus-uu-tmp-dir short-file-name)) | 1966 | (gnus-uu-add-file (concat gnus-uu-tmp-dir short-file-name)) |
| 1780 | 1967 | ||
| @@ -1789,9 +1976,10 @@ viewing one or more files is successful." | |||
| 1789 | did-view)) | 1976 | did-view)) |
| 1790 | 1977 | ||
| 1791 | 1978 | ||
| 1979 | ; Tries to view all the files in the given directory. Returns t if | ||
| 1980 | ; viewing one or more files is successful. | ||
| 1981 | |||
| 1792 | (defun gnus-uu-show-directory (dir &optional dont-delete-files) | 1982 | (defun gnus-uu-show-directory (dir &optional dont-delete-files) |
| 1793 | "Tries to view all the files in the given directory. Returns `t' if | ||
| 1794 | viewing one or more files is successful." | ||
| 1795 | (let (files file did-view) | 1983 | (let (files file did-view) |
| 1796 | (setq files (directory-files dir t)) | 1984 | (setq files (directory-files dir t)) |
| 1797 | (setq gnus-uu-generated-file-list | 1985 | (setq gnus-uu-generated-file-list |
| @@ -1868,7 +2056,7 @@ viewing one or more files is successful." | |||
| 1868 | (setq gnus-uu-marked-article-list ()))) | 2056 | (setq gnus-uu-marked-article-list ()))) |
| 1869 | 2057 | ||
| 1870 | (defun gnus-uu-mark-by-regexp () | 2058 | (defun gnus-uu-mark-by-regexp () |
| 1871 | "Asks for a regular expression and marks all articles that match for later decoding." | 2059 | "Asks for a regular expression and marks all articles that match." |
| 1872 | (interactive) | 2060 | (interactive) |
| 1873 | (let (exp) | 2061 | (let (exp) |
| 1874 | (setq exp (read-from-minibuffer "Enter regular expression: ")) | 2062 | (setq exp (read-from-minibuffer "Enter regular expression: ")) |
| @@ -1884,23 +2072,35 @@ viewing one or more files is successful." | |||
| 1884 | (if (not gnus-uu-correct-stripped-uucode) | 2072 | (if (not gnus-uu-correct-stripped-uucode) |
| 1885 | () | 2073 | () |
| 1886 | (goto-char start) | 2074 | (goto-char start) |
| 1887 | (while (< (point) end) | 2075 | |
| 1888 | (if (looking-at (concat gnus-uu-begin-string "\\|" gnus-uu-end-string)) | 2076 | (if (re-search-forward " \\|`" end t) |
| 1889 | () | 2077 | (progn |
| 1890 | (if (not found) | 2078 | (goto-char start) |
| 2079 | (while (not (eobp)) | ||
| 1891 | (progn | 2080 | (progn |
| 1892 | (beginning-of-line) | 2081 | (if (looking-at "\n") (replace-match "")) |
| 1893 | (setq beg (point)) | 2082 | (forward-line 1)))) |
| 1894 | (end-of-line) | 2083 | |
| 1895 | (setq length (- (point) beg)))) | 2084 | (while (not (eobp)) |
| 1896 | (beginning-of-line) | 2085 | (if (looking-at (concat gnus-uu-begin-string "\\|" |
| 1897 | (setq beg (point)) | 2086 | gnus-uu-end-string)) |
| 1898 | (end-of-line) | 2087 | () |
| 1899 | (if (not (= length (- (point) beg))) | 2088 | (if (not found) |
| 1900 | (insert (make-string (- length (- (point) beg))) ? ))) | 2089 | (progn |
| 1901 | (forward-line 1))))) | 2090 | (beginning-of-line) |
| 2091 | (setq beg (point)) | ||
| 2092 | (end-of-line) | ||
| 2093 | (setq length (- (point) beg)))) | ||
| 2094 | (setq found t) | ||
| 2095 | (beginning-of-line) | ||
| 2096 | (setq beg (point)) | ||
| 2097 | (end-of-line) | ||
| 2098 | (if (not (= length (- (point) beg))) | ||
| 2099 | (insert (make-string (- length (- (point) beg)) ? )))) | ||
| 2100 | (forward-line 1)))))) | ||
| 1902 | 2101 | ||
| 1903 | (defun gnus-uu-initialize () | 2102 | (defun gnus-uu-initialize () |
| 2103 | (setq gnus-uu-error-during-unarching nil) | ||
| 1904 | (if (not gnus-uu-use-interactive-view) | 2104 | (if (not gnus-uu-use-interactive-view) |
| 1905 | () | 2105 | () |
| 1906 | (save-excursion | 2106 | (save-excursion |
| @@ -1915,13 +2115,15 @@ viewing one or more files is successful." | |||
| 1915 | ")))) | 2115 | ")))) |
| 1916 | 2116 | ||
| 1917 | 2117 | ||
| 2118 | ; Kills the temporary uu buffers, kills any processes, etc. | ||
| 2119 | |||
| 1918 | (defun gnus-uu-clean-up () | 2120 | (defun gnus-uu-clean-up () |
| 1919 | "Kills the temporary uu buffers." | ||
| 1920 | (let (buf pst) | 2121 | (let (buf pst) |
| 1921 | (setq gnus-uu-do-sloppy-uudecode nil) | 2122 | (setq gnus-uu-do-sloppy-uudecode nil) |
| 1922 | (setq pst (process-status (or gnus-uu-uudecode-process "nevair"))) | 2123 | (and gnus-uu-uudecode-process |
| 1923 | (if (or (eq pst 'stop) (eq pst 'run)) | 2124 | (setq pst (process-status (or gnus-uu-uudecode-process "nevair"))) |
| 1924 | (delete-process gnus-uu-uudecode-process)) | 2125 | (if (or (eq pst 'stop) (eq pst 'run)) |
| 2126 | (delete-process gnus-uu-uudecode-process))) | ||
| 1925 | (and (not gnus-uu-asynchronous) | 2127 | (and (not gnus-uu-asynchronous) |
| 1926 | (setq buf (get-buffer gnus-uu-output-buffer-name)) | 2128 | (setq buf (get-buffer gnus-uu-output-buffer-name)) |
| 1927 | (kill-buffer buf)) | 2129 | (kill-buffer buf)) |
| @@ -1929,9 +2131,11 @@ viewing one or more files is successful." | |||
| 1929 | (kill-buffer buf)))) | 2131 | (kill-buffer buf)))) |
| 1930 | 2132 | ||
| 1931 | 2133 | ||
| 2134 | ; `gnus-uu-check-for-generated-files' deletes any generated files that | ||
| 2135 | ; hasn't been deleted, if, for instance, the user terminated decoding | ||
| 2136 | ; with `C-g'. | ||
| 2137 | |||
| 1932 | (defun gnus-uu-check-for-generated-files () | 2138 | (defun gnus-uu-check-for-generated-files () |
| 1933 | "Deletes any generated files that hasn't been deleted, if, for | ||
| 1934 | instance, the user terminated decoding with `C-g'." | ||
| 1935 | (let (file) | 2139 | (let (file) |
| 1936 | (while gnus-uu-generated-file-list | 2140 | (while gnus-uu-generated-file-list |
| 1937 | (setq file (car gnus-uu-generated-file-list)) | 2141 | (setq file (car gnus-uu-generated-file-list)) |
| @@ -1944,10 +2148,15 @@ instance, the user terminated decoding with `C-g'." | |||
| 1944 | (delete-file file)))))))) | 2148 | (delete-file file)))))))) |
| 1945 | 2149 | ||
| 1946 | 2150 | ||
| 2151 | ; Add a file to be checked (and deleted if it still exists upon | ||
| 2152 | ; exiting the newsgroup) to a list | ||
| 1947 | (defun gnus-uu-add-file (file) | 2153 | (defun gnus-uu-add-file (file) |
| 1948 | (setq gnus-uu-generated-file-list | 2154 | (setq gnus-uu-generated-file-list |
| 1949 | (cons file gnus-uu-generated-file-list))) | 2155 | (cons file gnus-uu-generated-file-list))) |
| 1950 | 2156 | ||
| 2157 | |||
| 2158 | ; Go to the next unread subject. If there is no further unread | ||
| 2159 | ; subjects, go to the last subject in the buffer. | ||
| 1951 | (defun gnus-uu-summary-next-subject () | 2160 | (defun gnus-uu-summary-next-subject () |
| 1952 | (if (not (gnus-summary-search-forward t)) | 2161 | (if (not (gnus-summary-search-forward t)) |
| 1953 | (progn | 2162 | (progn |
| @@ -1960,6 +2169,21 @@ instance, the user terminated decoding with `C-g'." | |||
| 1960 | (sit-for 0) | 2169 | (sit-for 0) |
| 1961 | (gnus-summary-recenter)) | 2170 | (gnus-summary-recenter)) |
| 1962 | 2171 | ||
| 2172 | ; Inputs an action and a file and returns a full command, putting | ||
| 2173 | ; ticks round the file name and escaping any ticks in the file name. | ||
| 2174 | (defun gnus-uu-command (action file) | ||
| 2175 | (let ((ofile "")) | ||
| 2176 | (while (string-match "`\\|\"\\|\\$\\|\\\\" file) | ||
| 2177 | (progn | ||
| 2178 | (setq ofile | ||
| 2179 | (concat ofile (substring file 0 (match-beginning 0)) "\\" | ||
| 2180 | (substring file (match-beginning 0) (match-end 0)))) | ||
| 2181 | (setq file (substring file (1+ (match-beginning 0)))))) | ||
| 2182 | (setq ofile (concat "\"" ofile file "\"")) | ||
| 2183 | (if (string-match "%s" action) | ||
| 2184 | (format action ofile) | ||
| 2185 | (concat action " " ofile)))) | ||
| 2186 | |||
| 1963 | 2187 | ||
| 1964 | ;; Initializing | 2188 | ;; Initializing |
| 1965 | 2189 | ||
| @@ -1999,14 +2223,12 @@ instance, the user terminated decoding with `C-g'." | |||
| 1999 | (setq gnus-uu-interactive-file-list | 2223 | (setq gnus-uu-interactive-file-list |
| 2000 | (cons file gnus-uu-interactive-file-list)) | 2224 | (cons file gnus-uu-interactive-file-list)) |
| 2001 | (set-buffer (get-buffer gnus-uu-interactive-buffer-name)) | 2225 | (set-buffer (get-buffer gnus-uu-interactive-buffer-name)) |
| 2002 | (if (string-match "%s" action) | 2226 | (setq command (gnus-uu-command action file)) |
| 2003 | (setq command (format action (concat "'" file "'"))) | ||
| 2004 | (setq command (concat action " " (concat "'" file "'")))) | ||
| 2005 | |||
| 2006 | (insert (format "%s\n" command))))) | 2227 | (insert (format "%s\n" command))))) |
| 2007 | 2228 | ||
| 2008 | 2229 | ||
| 2009 | (defun gnus-uu-interactive-execute () | 2230 | (defun gnus-uu-interactive-execute () |
| 2231 | "Executes the command on the current line in interactive mode." | ||
| 2010 | (interactive) | 2232 | (interactive) |
| 2011 | (let (beg out-buf command) | 2233 | (let (beg out-buf command) |
| 2012 | (beginning-of-line) | 2234 | (beginning-of-line) |
| @@ -2028,7 +2250,7 @@ instance, the user terminated decoding with `C-g'." | |||
| 2028 | 2250 | ||
| 2029 | 2251 | ||
| 2030 | (defun gnus-uu-interactive-end () | 2252 | (defun gnus-uu-interactive-end () |
| 2031 | "This function ends interactive view mode and returns to summary mode." | 2253 | "This function exits interactive view mode and returns to summary mode." |
| 2032 | (interactive) | 2254 | (interactive) |
| 2033 | (let (buf) | 2255 | (let (buf) |
| 2034 | (delete-window gnus-uu-output-window) | 2256 | (delete-window gnus-uu-output-window) |
| @@ -2056,6 +2278,7 @@ instance, the user terminated decoding with `C-g'." | |||
| 2056 | 2278 | ||
| 2057 | 2279 | ||
| 2058 | (defun gnus-uu-interactive-save-original-file () | 2280 | (defun gnus-uu-interactive-save-original-file () |
| 2281 | "Saves the file from whence the file on the current line came from." | ||
| 2059 | (interactive) | 2282 | (interactive) |
| 2060 | (let (file) | 2283 | (let (file) |
| 2061 | (if (file-exists-p | 2284 | (if (file-exists-p |
| @@ -2066,7 +2289,7 @@ instance, the user terminated decoding with `C-g'." | |||
| 2066 | 2289 | ||
| 2067 | 2290 | ||
| 2068 | (defun gnus-uu-interactive-save-current-file-silent () | 2291 | (defun gnus-uu-interactive-save-current-file-silent () |
| 2069 | "hei" | 2292 | "Saves the file referred to on the current line in the current directory." |
| 2070 | (interactive) | 2293 | (interactive) |
| 2071 | (gnus-uu-interactive-save-current-file t)) | 2294 | (gnus-uu-interactive-save-current-file t)) |
| 2072 | 2295 | ||
| @@ -2094,7 +2317,7 @@ instance, the user terminated decoding with `C-g'." | |||
| 2094 | 2317 | ||
| 2095 | 2318 | ||
| 2096 | (defun gnus-uu-interactive-save-all-files () | 2319 | (defun gnus-uu-interactive-save-all-files () |
| 2097 | "Saves all files referred to on the current line." | 2320 | "Saves all files referred to in the interactive buffer." |
| 2098 | (interactive) | 2321 | (interactive) |
| 2099 | (let (dir) | 2322 | (let (dir) |
| 2100 | (goto-char 1) | 2323 | (goto-char 1) |
| @@ -2105,15 +2328,14 @@ instance, the user terminated decoding with `C-g'." | |||
| 2105 | (defun gnus-uu-mode () | 2328 | (defun gnus-uu-mode () |
| 2106 | "Major mode for editing view commands in gnus-uu. | 2329 | "Major mode for editing view commands in gnus-uu. |
| 2107 | 2330 | ||
| 2108 | |||
| 2109 | Commands: | 2331 | Commands: |
| 2110 | Return, C-c C-v, C-c C-x Execute the current command | 2332 | \\<gnus-uu-mode-map>Return, C-c C-v, C-c C-x Execute the current command |
| 2111 | C-c C-c End interactive mode | 2333 | \\[gnus-uu-interactive-end] End interactive mode |
| 2112 | C-c s Save the current file | 2334 | \\[gnus-uu-interactive-save-current-file] Save the current file |
| 2113 | C-c C-s Save the current file without asking | 2335 | \\[gnus-uu-interactive-save-current-file-silent] Save the current file without asking |
| 2114 | where to put it | 2336 | where to put it |
| 2115 | C-c C-a Save all files | 2337 | \\[gnus-uu-interactive-save-all-files] Save all files |
| 2116 | C-c C-o Save the original file: If the files | 2338 | \\[gnus-uu-interactive-save-original-file] Save the original file: If the files |
| 2117 | originated in an archive, the archive | 2339 | originated in an archive, the archive |
| 2118 | file is saved. | 2340 | file is saved. |
| 2119 | " | 2341 | " |