gnus-uu.el 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154
  1. ;;; gnus-uu.el --- extract (uu)encoded files in Gnus
  2. ;; Copyright (C) 1985-1987, 1993-1998, 2000-2012
  3. ;; Free Software Foundation, Inc.
  4. ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
  5. ;; Created: 2 Oct 1993
  6. ;; Keyword: news
  7. ;; This file is part of GNU Emacs.
  8. ;; GNU Emacs is free software: you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation, either version 3 of the License, or
  11. ;; (at your option) any later version.
  12. ;; GNU Emacs is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;; GNU General Public License for more details.
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  18. ;;; Commentary:
  19. ;;; Code:
  20. (eval-when-compile (require 'cl))
  21. (require 'gnus)
  22. (require 'gnus-art)
  23. (require 'message)
  24. (require 'gnus-msg)
  25. (require 'mm-decode)
  26. (require 'yenc)
  27. (defgroup gnus-extract nil
  28. "Extracting encoded files."
  29. :prefix "gnus-uu-"
  30. :group 'gnus)
  31. (defgroup gnus-extract-view nil
  32. "Viewing extracted files."
  33. :group 'gnus-extract)
  34. (defgroup gnus-extract-archive nil
  35. "Extracting encoded archives."
  36. :group 'gnus-extract)
  37. (defgroup gnus-extract-post nil
  38. "Extracting encoded archives."
  39. :prefix "gnus-uu-post"
  40. :group 'gnus-extract)
  41. ;; Default viewing action rules
  42. (defcustom gnus-uu-default-view-rules
  43. '(("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed 's/\r$//'")
  44. ("\\.pas$" "cat %s | sed 's/\r$//'")
  45. ("\\.[1-9]$" "groff -mandoc -Tascii %s | sed s/\b.//g")
  46. ("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "display")
  47. ("\\.tga$" "tgatoppm %s | ee -")
  48. ("\\.\\(wav\\|aiff\\|hcom\\|u[blw]\\|s[bfw]\\|voc\\|smp\\)$"
  49. "sox -v .5 %s -t .au -u - > /dev/audio")
  50. ("\\.au$" "cat %s > /dev/audio")
  51. ("\\.midi?$" "playmidi -f")
  52. ("\\.mod$" "str32")
  53. ("\\.ps$" "ghostview")
  54. ("\\.dvi$" "xdvi")
  55. ("\\.html$" "xmosaic")
  56. ("\\.mpe?g$" "mpeg_play")
  57. ("\\.\\(flc\\|fli\\|rle\\|iff\\|pfx\\|avi\\|sme\\|rpza\\|dl\\|qt\\|rsrc\\|mov\\)$" "xanim")
  58. ("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\|lha\\)$"
  59. "gnus-uu-archive"))
  60. "*Default actions to be taken when the user asks to view a file.
  61. To change the behavior, you can either edit this variable or set
  62. `gnus-uu-user-view-rules' to something useful.
  63. For example:
  64. To make gnus-uu use 'xli' to display JPEG and GIF files, put the
  65. following in your .emacs file:
  66. (setq gnus-uu-user-view-rules '((\"jpg$\\\\|gif$\" \"xli\")))
  67. Both these variables are lists of lists with two string elements. The
  68. first string is a regular expression. If the file name matches this
  69. regular expression, the command in the second string is executed with
  70. the file as an argument.
  71. If the command string contains \"%s\", the file name will be inserted
  72. at that point in the command string. If there's no \"%s\" in the
  73. command string, the file name will be appended to the command string
  74. before executing.
  75. There are several user variables to tailor the behavior of gnus-uu to
  76. your needs. First we have `gnus-uu-user-view-rules', which is the
  77. variable gnus-uu first consults when trying to decide how to view a
  78. file. If this variable contains no matches, gnus-uu examines the
  79. default rule variable provided in this package. If gnus-uu finds no
  80. match here, it uses `gnus-uu-user-view-rules-end' to try to make a
  81. match."
  82. :group 'gnus-extract-view
  83. :type '(repeat (group regexp (string :tag "Command"))))
  84. (defcustom gnus-uu-user-view-rules nil
  85. "What actions are to be taken to view a file.
  86. See the documentation on the `gnus-uu-default-view-rules' variable for
  87. details."
  88. :group 'gnus-extract-view
  89. :type '(repeat (group regexp (string :tag "Command"))))
  90. (defcustom gnus-uu-user-view-rules-end
  91. '(("" "file"))
  92. "*What actions are to be taken if no rule matched the file name.
  93. See the documentation on the `gnus-uu-default-view-rules' variable for
  94. details."
  95. :group 'gnus-extract-view
  96. :type '(repeat (group regexp (string :tag "Command"))))
  97. ;; Default unpacking commands
  98. (defcustom gnus-uu-default-archive-rules
  99. '(("\\.tar$" "tar xf")
  100. ("\\.zip$" "unzip -o")
  101. ("\\.ar$" "ar x")
  102. ("\\.arj$" "unarj x")
  103. ("\\.zoo$" "zoo -e")
  104. ("\\.\\(lzh\\|lha\\)$" "lha x")
  105. ("\\.Z$" "uncompress")
  106. ("\\.gz$" "gunzip")
  107. ("\\.arc$" "arc -x"))
  108. "*See `gnus-uu-user-archive-rules'."
  109. :group 'gnus-extract-archive
  110. :type '(repeat (group regexp (string :tag "Command"))))
  111. (defvar gnus-uu-destructive-archivers
  112. (list "uncompress" "gunzip"))
  113. (defcustom gnus-uu-user-archive-rules nil
  114. "A list that can be set to override the default archive unpacking commands.
  115. To use, for instance, 'untar' to unpack tar files and 'zip -x' to
  116. unpack zip files, say the following:
  117. (setq gnus-uu-user-archive-rules
  118. '((\"\\\\.tar$\" \"untar\")
  119. (\"\\\\.zip$\" \"zip -x\")))"
  120. :group 'gnus-extract-archive
  121. :type '(repeat (group regexp (string :tag "Command"))))
  122. (defcustom gnus-uu-ignore-files-by-name nil
  123. "*A regular expression saying what files should not be viewed based on name.
  124. If, for instance, you want gnus-uu to ignore all .au and .wav files,
  125. you could say something like
  126. (setq gnus-uu-ignore-files-by-name \"\\\\.au$\\\\|\\\\.wav$\")
  127. Note that this variable can be used in conjunction with the
  128. `gnus-uu-ignore-files-by-type' variable."
  129. :group 'gnus-extract
  130. :type '(choice (const :tag "off" nil)
  131. (regexp :format "%v")))
  132. (defcustom gnus-uu-ignore-files-by-type nil
  133. "*A regular expression saying what files that shouldn't be viewed, based on MIME file type.
  134. If, for instance, you want gnus-uu to ignore all audio files and all mpegs,
  135. you could say something like
  136. (setq gnus-uu-ignore-files-by-type \"audio/\\\\|video/mpeg\")
  137. Note that this variable can be used in conjunction with the
  138. `gnus-uu-ignore-files-by-name' variable."
  139. :group 'gnus-extract
  140. :type '(choice (const :tag "off" nil)
  141. (regexp :format "%v")))
  142. ;; Pseudo-MIME support
  143. (defconst gnus-uu-ext-to-mime-list
  144. '(("\\.gif$" "image/gif")
  145. ("\\.jpe?g$" "image/jpeg")
  146. ("\\.tiff?$" "image/tiff")
  147. ("\\.xwd$" "image/xwd")
  148. ("\\.pbm$" "image/pbm")
  149. ("\\.pgm$" "image/pgm")
  150. ("\\.ppm$" "image/ppm")
  151. ("\\.xbm$" "image/xbm")
  152. ("\\.pcx$" "image/pcx")
  153. ("\\.tga$" "image/tga")
  154. ("\\.ps$" "image/postscript")
  155. ("\\.fli$" "video/fli")
  156. ("\\.wav$" "audio/wav")
  157. ("\\.aiff$" "audio/aiff")
  158. ("\\.hcom$" "audio/hcom")
  159. ("\\.voc$" "audio/voc")
  160. ("\\.smp$" "audio/smp")
  161. ("\\.mod$" "audio/mod")
  162. ("\\.dvi$" "image/dvi")
  163. ("\\.mpe?g$" "video/mpeg")
  164. ("\\.au$" "audio/basic")
  165. ("\\.\\(te?xt\\|doc\\|c\\|h\\)$" "text/plain")
  166. ("\\.\\(c\\|h\\)$" "text/source")
  167. ("read.*me" "text/plain")
  168. ("\\.html$" "text/html")
  169. ("\\.bat$" "text/bat")
  170. ("\\.[1-6]$" "text/man")
  171. ("\\.flc$" "video/flc")
  172. ("\\.rle$" "video/rle")
  173. ("\\.pfx$" "video/pfx")
  174. ("\\.avi$" "video/avi")
  175. ("\\.sme$" "video/sme")
  176. ("\\.rpza$" "video/prza")
  177. ("\\.dl$" "video/dl")
  178. ("\\.qt$" "video/qt")
  179. ("\\.rsrc$" "video/rsrc")
  180. ("\\..*$" "unknown/unknown")))
  181. ;; Various variables users may set
  182. (defcustom gnus-uu-tmp-dir
  183. (cond ((fboundp 'temp-directory) (temp-directory))
  184. ((boundp 'temporary-file-directory) temporary-file-directory)
  185. ("/tmp/"))
  186. "*Variable saying where gnus-uu is to do its work.
  187. Default is \"/tmp/\"."
  188. :group 'gnus-extract
  189. :type 'directory)
  190. (defcustom gnus-uu-do-not-unpack-archives nil
  191. "*Non-nil means that gnus-uu won't peek inside archives looking for files to display.
  192. Default is nil."
  193. :group 'gnus-extract-archive
  194. :type 'boolean)
  195. (defcustom gnus-uu-ignore-default-view-rules nil
  196. "*Non-nil means that gnus-uu will ignore the default viewing rules.
  197. Only the user viewing rules will be consulted. Default is nil."
  198. :group 'gnus-extract-view
  199. :type 'boolean)
  200. (defcustom gnus-uu-grabbed-file-functions nil
  201. "Functions run on each file after successful decoding.
  202. They will be called with the name of the file as the argument.
  203. Likely functions you can use in this list are `gnus-uu-grab-view'
  204. and `gnus-uu-grab-move'."
  205. :group 'gnus-extract
  206. :options '(gnus-uu-grab-view gnus-uu-grab-move)
  207. :type 'hook)
  208. (defcustom gnus-uu-ignore-default-archive-rules nil
  209. "*Non-nil means that gnus-uu will ignore the default archive unpacking commands.
  210. Only the user unpacking commands will be consulted. Default is nil."
  211. :group 'gnus-extract-archive
  212. :type 'boolean)
  213. (defcustom gnus-uu-kill-carriage-return t
  214. "*Non-nil means that gnus-uu will strip all carriage returns from articles.
  215. Default is t."
  216. :group 'gnus-extract
  217. :type 'boolean)
  218. (defcustom gnus-uu-view-with-metamail nil
  219. "*Non-nil means that files will be viewed with metamail.
  220. The gnus-uu viewing functions will be ignored and gnus-uu will try
  221. to guess at a content-type based on file name suffixes. Default
  222. it nil."
  223. :group 'gnus-extract
  224. :type 'boolean)
  225. (defcustom gnus-uu-unmark-articles-not-decoded nil
  226. "*Non-nil means that gnus-uu will mark articles that were unsuccessfully decoded as unread.
  227. Default is nil."
  228. :group 'gnus-extract
  229. :type 'boolean)
  230. (defcustom gnus-uu-correct-stripped-uucode nil
  231. "*Non-nil means that gnus-uu will *try* to fix uuencoded files that have had trailing spaces deleted.
  232. Default is nil."
  233. :group 'gnus-extract
  234. :type 'boolean)
  235. (defcustom gnus-uu-save-in-digest nil
  236. "*Non-nil means that gnus-uu, when asked to save without decoding, will save in digests.
  237. If this variable is nil, gnus-uu will just save everything in a
  238. file without any embellishments. The digesting almost conforms to RFC1153 -
  239. no easy way to specify any meaningful volume and issue numbers were found,
  240. so I simply dropped them."
  241. :group 'gnus-extract
  242. :type 'boolean)
  243. (defcustom gnus-uu-pre-uudecode-hook nil
  244. "Hook run before sending a message to uudecode."
  245. :group 'gnus-extract
  246. :type 'hook)
  247. (defcustom gnus-uu-digest-headers
  248. '("^Date:" "^From:" "^To:" "^Cc:" "^Subject:" "^Message-ID:" "^Keywords:"
  249. "^Summary:" "^References:" "^Content-Type:" "^Content-Transfer-Encoding:"
  250. "^MIME-Version:" "^Content-Disposition:" "^Content-Description:"
  251. "^Content-ID:")
  252. "*List of regexps to match headers included in digested messages.
  253. The headers will be included in the sequence they are matched. If nil
  254. include all headers."
  255. :group 'gnus-extract
  256. :type '(repeat regexp))
  257. (defcustom gnus-uu-save-separate-articles nil
  258. "*Non-nil means that gnus-uu will save articles in separate files."
  259. :group 'gnus-extract
  260. :type 'boolean)
  261. (defcustom gnus-uu-be-dangerous 'ask
  262. "*Specifies what to do if unusual situations arise during decoding.
  263. If nil, be as conservative as possible. If t, ignore things that
  264. didn't work, and overwrite existing files. Otherwise, ask each time."
  265. :group 'gnus-extract
  266. :type '(choice (const :tag "conservative" nil)
  267. (const :tag "ask" ask)
  268. (const :tag "liberal" t)))
  269. ;; Internal variables
  270. (defvar gnus-uu-saved-article-name nil)
  271. (defvar gnus-uu-begin-string "^begin[ \t]+0?[0-7][0-7][0-7][ \t]+\\(.*\\)$")
  272. (defvar gnus-uu-end-string "^end[ \t]*$")
  273. (defvar gnus-uu-body-line "^M")
  274. (let ((i 61))
  275. (while (> (setq i (1- i)) 0)
  276. (setq gnus-uu-body-line (concat gnus-uu-body-line "[^a-z]")))
  277. (setq gnus-uu-body-line (concat gnus-uu-body-line ".?$")))
  278. ;"^M.............................................................?$"
  279. (defvar gnus-uu-shar-begin-string "^#! */bin/sh")
  280. (defvar gnus-uu-shar-name-marker
  281. "begin 0?[0-7][0-7][0-7][ \t]+\\(\\(\\w\\|[.\\:]\\)*\\b\\)")
  282. (defvar gnus-uu-postscript-begin-string "^%!PS-")
  283. (defvar gnus-uu-postscript-end-string "^%%EOF$")
  284. (defvar gnus-uu-file-name nil)
  285. (defvar gnus-uu-uudecode-process nil)
  286. (defvar gnus-uu-binhex-article-name nil)
  287. (defvar gnus-uu-yenc-article-name nil)
  288. (defvar gnus-uu-work-dir nil)
  289. (defvar gnus-uu-output-buffer-name " *Gnus UU Output*")
  290. (defvar gnus-uu-default-dir gnus-article-save-directory)
  291. (defvar gnus-uu-digest-from-subject nil)
  292. (defvar gnus-uu-digest-buffer nil)
  293. ;; Commands.
  294. (defun gnus-uu-decode-uu (&optional n)
  295. "Uudecodes the current article."
  296. (interactive "P")
  297. (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n))
  298. (defun gnus-uu-decode-uu-and-save (n dir)
  299. "Decodes and saves the resulting file."
  300. (interactive
  301. (list current-prefix-arg
  302. (file-name-as-directory
  303. (read-directory-name "Uudecode and save in dir: "
  304. gnus-uu-default-dir
  305. gnus-uu-default-dir t))))
  306. (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n dir nil nil t))
  307. (defun gnus-uu-decode-unshar (&optional n)
  308. "Unshars the current article."
  309. (interactive "P")
  310. (gnus-uu-decode-with-method 'gnus-uu-unshar-article n nil nil 'scan t))
  311. (defun gnus-uu-decode-unshar-and-save (n dir)
  312. "Unshars and saves the current article."
  313. (interactive
  314. (list current-prefix-arg
  315. (file-name-as-directory
  316. (read-directory-name "Unshar and save in dir: "
  317. gnus-uu-default-dir
  318. gnus-uu-default-dir t))))
  319. (gnus-uu-decode-with-method 'gnus-uu-unshar-article n dir nil 'scan t))
  320. (defun gnus-uu-decode-save (n file)
  321. "Saves the current article."
  322. (interactive
  323. (list current-prefix-arg
  324. (if gnus-uu-save-separate-articles
  325. (read-directory-name
  326. "Save articles in dir: " gnus-uu-default-dir gnus-uu-default-dir)
  327. (read-file-name
  328. "Save article in file: " gnus-uu-default-dir gnus-uu-default-dir))))
  329. (setq gnus-uu-saved-article-name file)
  330. (gnus-uu-decode-with-method 'gnus-uu-save-article n nil t))
  331. (defun gnus-uu-decode-binhex (n dir)
  332. "Unbinhexes the current article."
  333. (interactive
  334. (list current-prefix-arg
  335. (file-name-as-directory
  336. (read-directory-name "Unbinhex and save in dir: "
  337. gnus-uu-default-dir
  338. gnus-uu-default-dir))))
  339. (setq gnus-uu-binhex-article-name
  340. (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
  341. (gnus-uu-decode-with-method 'gnus-uu-binhex-article n dir))
  342. (defun gnus-uu-decode-yenc (n dir)
  343. "Decode the yEnc-encoded current article."
  344. (interactive
  345. (list current-prefix-arg
  346. (file-name-as-directory
  347. (read-directory-name "yEnc decode and save in dir: "
  348. gnus-uu-default-dir
  349. gnus-uu-default-dir))))
  350. (setq gnus-uu-yenc-article-name nil)
  351. (gnus-uu-decode-with-method 'gnus-uu-yenc-article n dir nil t))
  352. (defun gnus-uu-decode-uu-view (&optional n)
  353. "Uudecodes and views the current article."
  354. (interactive "P")
  355. (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
  356. (gnus-uu-decode-uu n)))
  357. (defun gnus-uu-decode-uu-and-save-view (n dir)
  358. "Decodes, views and saves the resulting file."
  359. (interactive
  360. (list current-prefix-arg
  361. (read-file-name "Uudecode, view and save in dir: "
  362. gnus-uu-default-dir
  363. gnus-uu-default-dir t)))
  364. (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
  365. (gnus-uu-decode-uu-and-save n dir)))
  366. (defun gnus-uu-decode-unshar-view (&optional n)
  367. "Unshars and views the current article."
  368. (interactive "P")
  369. (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
  370. (gnus-uu-decode-unshar n)))
  371. (defun gnus-uu-decode-unshar-and-save-view (n dir)
  372. "Unshars and saves the current article."
  373. (interactive
  374. (list current-prefix-arg
  375. (read-file-name "Unshar, view and save in dir: "
  376. gnus-uu-default-dir
  377. gnus-uu-default-dir t)))
  378. (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
  379. (gnus-uu-decode-unshar-and-save n dir)))
  380. (defun gnus-uu-decode-save-view (n file)
  381. "Saves and views the current article."
  382. (interactive
  383. (list current-prefix-arg
  384. (if gnus-uu-save-separate-articles
  385. (read-directory-name "Save articles in dir: "
  386. gnus-uu-default-dir gnus-uu-default-dir)
  387. (read-file-name "Save articles in file: "
  388. gnus-uu-default-dir gnus-uu-default-dir))))
  389. (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
  390. (gnus-uu-decode-save n file)))
  391. (defun gnus-uu-decode-binhex-view (n file)
  392. "Unbinhexes and views the current article."
  393. (interactive
  394. (list current-prefix-arg
  395. (read-file-name "Unbinhex, view and save in dir: "
  396. gnus-uu-default-dir gnus-uu-default-dir)))
  397. (setq gnus-uu-binhex-article-name
  398. (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
  399. (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
  400. (gnus-uu-decode-binhex n file)))
  401. ;; Digest and forward articles
  402. (defun gnus-uu-digest-mail-forward (&optional n post)
  403. "Digests and forwards all articles in this series."
  404. (interactive "P")
  405. (let ((gnus-uu-save-in-digest t)
  406. (file (mm-make-temp-file (nnheader-concat gnus-uu-tmp-dir "forward")))
  407. (message-forward-as-mime message-forward-as-mime)
  408. (mail-parse-charset gnus-newsgroup-charset)
  409. (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
  410. gnus-uu-digest-buffer subject from)
  411. (if (and n (not (numberp n)))
  412. (setq message-forward-as-mime (not message-forward-as-mime)
  413. n nil))
  414. (let ((gnus-article-reply (gnus-summary-work-articles n)))
  415. (when (and (not n)
  416. (= (length gnus-article-reply) 1))
  417. ;; The case where neither a number of articles nor a region is
  418. ;; specified.
  419. (gnus-summary-top-thread)
  420. (setq gnus-article-reply (nreverse (gnus-uu-find-articles-matching))))
  421. (gnus-setup-message 'forward
  422. (setq gnus-uu-digest-from-subject nil)
  423. (setq gnus-uu-digest-buffer
  424. (gnus-get-buffer-create " *gnus-uu-forward*"))
  425. ;; Specify articles to be forwarded. Note that they should be
  426. ;; reversed; see `gnus-uu-get-list-of-articles'.
  427. (let ((gnus-newsgroup-processable (reverse gnus-article-reply)))
  428. (gnus-uu-decode-save n file)
  429. (setq gnus-article-reply gnus-newsgroup-processable))
  430. ;; Restore the value of `gnus-newsgroup-processable' to which
  431. ;; it should be set when it is not `let'-bound.
  432. (setq gnus-newsgroup-processable (reverse gnus-article-reply))
  433. (switch-to-buffer gnus-uu-digest-buffer)
  434. (let ((fs gnus-uu-digest-from-subject))
  435. (when fs
  436. (setq from (caar fs)
  437. subject (gnus-simplify-subject-fuzzy (cdar fs))
  438. fs (cdr fs))
  439. (while (and fs (or from subject))
  440. (when from
  441. (unless (string= from (caar fs))
  442. (setq from nil)))
  443. (when subject
  444. (unless (string= (gnus-simplify-subject-fuzzy (cdar fs))
  445. subject)
  446. (setq subject nil)))
  447. (setq fs (cdr fs))))
  448. (unless subject
  449. (setq subject "Digested Articles"))
  450. (unless from
  451. (setq from
  452. (if (gnus-news-group-p gnus-newsgroup-name)
  453. gnus-newsgroup-name
  454. "Various"))))
  455. (goto-char (point-min))
  456. (when (re-search-forward "^Subject: ")
  457. (delete-region (point) (point-at-eol))
  458. (insert subject))
  459. (goto-char (point-min))
  460. (when (re-search-forward "^From:")
  461. (delete-region (point) (point-at-eol))
  462. (insert " " from))
  463. (let ((message-forward-decoded-p t))
  464. (message-forward post t))))
  465. (setq gnus-uu-digest-from-subject nil)))
  466. (defun gnus-uu-digest-post-forward (&optional n)
  467. "Digest and forward to a newsgroup."
  468. (interactive "P")
  469. (gnus-uu-digest-mail-forward n t))
  470. ;; Process marking.
  471. (defun gnus-message-process-mark (unmarkp new-marked)
  472. (let ((old (- (length gnus-newsgroup-processable) (length new-marked))))
  473. (gnus-message 6 "%d mark%s %s%s"
  474. (length new-marked)
  475. (if (= (length new-marked) 1) "" "s")
  476. (if unmarkp "removed" "added")
  477. (cond
  478. ((and (zerop old)
  479. (not unmarkp))
  480. "")
  481. (unmarkp
  482. (format ", %d remain marked"
  483. (length gnus-newsgroup-processable)))
  484. (t
  485. (format ", %d already marked" old))))))
  486. (defun gnus-new-processable (unmarkp articles)
  487. (if unmarkp
  488. (gnus-intersection gnus-newsgroup-processable articles)
  489. (gnus-set-difference articles gnus-newsgroup-processable)))
  490. (defun gnus-uu-mark-by-regexp (regexp &optional unmark)
  491. "Set the process mark on articles whose subjects match REGEXP.
  492. When called interactively, prompt for REGEXP.
  493. Optional UNMARK non-nil means unmark instead of mark."
  494. (interactive "sMark (regexp): \nP")
  495. (save-excursion
  496. (let* ((articles (gnus-uu-find-articles-matching regexp))
  497. (new-marked (gnus-new-processable unmark articles)))
  498. (while articles
  499. (if unmark
  500. (gnus-summary-remove-process-mark (pop articles))
  501. (gnus-summary-set-process-mark (pop articles))))
  502. (gnus-message-process-mark unmark new-marked)))
  503. (gnus-summary-position-point))
  504. (defun gnus-uu-unmark-by-regexp (regexp)
  505. "Remove the process mark from articles whose subjects match REGEXP.
  506. When called interactively, prompt for REGEXP."
  507. (interactive "sUnmark (regexp): ")
  508. (gnus-uu-mark-by-regexp regexp t))
  509. (defun gnus-uu-mark-series (&optional silent)
  510. "Mark the current series with the process mark."
  511. (interactive)
  512. (let* ((articles (gnus-uu-find-articles-matching))
  513. (l (length articles)))
  514. (while articles
  515. (gnus-summary-set-process-mark (car articles))
  516. (setq articles (cdr articles)))
  517. (unless silent
  518. (gnus-message 6 "Marked %d articles" l))
  519. (gnus-summary-position-point)
  520. l))
  521. (defun gnus-uu-mark-region (beg end &optional unmark)
  522. "Set the process mark on all articles between point and mark."
  523. (interactive "r")
  524. (save-excursion
  525. (goto-char beg)
  526. (while (< (point) end)
  527. (if unmark
  528. (gnus-summary-remove-process-mark (gnus-summary-article-number))
  529. (gnus-summary-set-process-mark (gnus-summary-article-number)))
  530. (forward-line 1)))
  531. (gnus-summary-position-point))
  532. (defun gnus-uu-unmark-region (beg end)
  533. "Remove the process mark from all articles between point and mark."
  534. (interactive "r")
  535. (gnus-uu-mark-region beg end t))
  536. (defun gnus-uu-mark-buffer ()
  537. "Set the process mark on all articles in the buffer."
  538. (interactive)
  539. (gnus-uu-mark-region (point-min) (point-max)))
  540. (defun gnus-uu-unmark-buffer ()
  541. "Remove the process mark on all articles in the buffer."
  542. (interactive)
  543. (gnus-uu-mark-region (point-min) (point-max) t))
  544. (defun gnus-uu-mark-thread ()
  545. "Marks all articles downwards in this thread."
  546. (interactive)
  547. (gnus-save-hidden-threads
  548. (let ((level (gnus-summary-thread-level)))
  549. (while (and (gnus-summary-set-process-mark
  550. (gnus-summary-article-number))
  551. (zerop (gnus-summary-next-subject 1 nil t))
  552. (> (gnus-summary-thread-level) level)))))
  553. (gnus-summary-position-point))
  554. (defun gnus-uu-unmark-thread ()
  555. "Unmarks all articles downwards in this thread."
  556. (interactive)
  557. (let ((level (gnus-summary-thread-level)))
  558. (while (and (gnus-summary-remove-process-mark
  559. (gnus-summary-article-number))
  560. (zerop (gnus-summary-next-subject 1))
  561. (> (gnus-summary-thread-level) level))))
  562. (gnus-summary-position-point))
  563. (defun gnus-uu-invert-processable ()
  564. "Invert the list of process-marked articles."
  565. (interactive)
  566. (let ((data gnus-newsgroup-data)
  567. number)
  568. (save-excursion
  569. (while data
  570. (if (memq (setq number (gnus-data-number (pop data)))
  571. gnus-newsgroup-processable)
  572. (gnus-summary-remove-process-mark number)
  573. (gnus-summary-set-process-mark number)))))
  574. (gnus-summary-position-point))
  575. (defun gnus-uu-mark-over (&optional score)
  576. "Mark all articles with a score over SCORE (the prefix)."
  577. (interactive "P")
  578. (let ((score (or score gnus-summary-default-score 0))
  579. (data gnus-newsgroup-data))
  580. (save-excursion
  581. (while data
  582. (when (> (or (cdr (assq (gnus-data-number (car data))
  583. gnus-newsgroup-scored))
  584. gnus-summary-default-score 0)
  585. score)
  586. (gnus-summary-set-process-mark (caar data)))
  587. (setq data (cdr data))))
  588. (gnus-summary-position-point)))
  589. (defun gnus-uu-mark-sparse ()
  590. "Mark all series that have some articles marked."
  591. (interactive)
  592. (let ((marked (nreverse gnus-newsgroup-processable))
  593. subject articles total headers)
  594. (unless marked
  595. (error "No articles marked with the process mark"))
  596. (setq gnus-newsgroup-processable nil)
  597. (save-excursion
  598. (while marked
  599. (and (vectorp (setq headers
  600. (gnus-summary-article-header (car marked))))
  601. (setq subject (mail-header-subject headers)
  602. articles (gnus-uu-find-articles-matching
  603. (gnus-uu-reginize-string subject))
  604. total (nconc total articles)))
  605. (while articles
  606. (gnus-summary-set-process-mark (car articles))
  607. (setcdr marked (delq (car articles) (cdr marked)))
  608. (setq articles (cdr articles)))
  609. (setq marked (cdr marked)))
  610. (setq gnus-newsgroup-processable (nreverse total)))
  611. (gnus-summary-position-point)))
  612. (defun gnus-uu-mark-all ()
  613. "Mark all articles in \"series\" order."
  614. (interactive)
  615. (setq gnus-newsgroup-processable nil)
  616. (save-excursion
  617. (let ((data gnus-newsgroup-data)
  618. (count 0)
  619. number)
  620. (while data
  621. (when (and (not (memq (setq number (gnus-data-number (car data)))
  622. gnus-newsgroup-processable))
  623. (vectorp (gnus-data-header (car data))))
  624. (gnus-summary-goto-subject number)
  625. (setq count (+ count (gnus-uu-mark-series t))))
  626. (setq data (cdr data)))
  627. (gnus-message 6 "Marked %d articles" count)))
  628. (gnus-summary-position-point))
  629. ;; All PostScript functions written by Erik Selberg <speed@cs.washington.edu>.
  630. (defun gnus-uu-decode-postscript (&optional n)
  631. "Gets PostScript of the current article."
  632. (interactive "P")
  633. (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article n))
  634. (defun gnus-uu-decode-postscript-view (&optional n)
  635. "Gets and views the current article."
  636. (interactive "P")
  637. (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
  638. (gnus-uu-decode-postscript n)))
  639. (defun gnus-uu-decode-postscript-and-save (n dir)
  640. "Extracts PostScript and saves the current article."
  641. (interactive
  642. (list current-prefix-arg
  643. (file-name-as-directory
  644. (read-directory-name "Save in dir: "
  645. gnus-uu-default-dir
  646. gnus-uu-default-dir t))))
  647. (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article
  648. n dir nil nil t))
  649. (defun gnus-uu-decode-postscript-and-save-view (n dir)
  650. "Decodes, views and saves the resulting file."
  651. (interactive
  652. (list current-prefix-arg
  653. (read-file-name "Where do you want to save the file(s)? "
  654. gnus-uu-default-dir
  655. gnus-uu-default-dir t)))
  656. (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
  657. (gnus-uu-decode-postscript-and-save n dir)))
  658. ;; Internal functions.
  659. (defun gnus-uu-decode-with-method (method n &optional save not-insert
  660. scan cdir)
  661. (gnus-uu-initialize scan)
  662. (when save
  663. (setq gnus-uu-default-dir save))
  664. ;; Create the directory we save to.
  665. (when (and scan cdir save
  666. (not (file-exists-p save)))
  667. (make-directory save t))
  668. (let ((articles (gnus-uu-get-list-of-articles n))
  669. files)
  670. (setq files (gnus-uu-grab-articles articles method t))
  671. (let ((gnus-current-article (car articles)))
  672. (when scan
  673. (setq files (gnus-uu-scan-directory gnus-uu-work-dir))))
  674. (when save
  675. (gnus-uu-save-files files save))
  676. (when (eq gnus-uu-do-not-unpack-archives nil)
  677. (setq files (gnus-uu-unpack-files files)))
  678. (setq files (nreverse (gnus-uu-get-actions files)))
  679. (or not-insert (not gnus-insert-pseudo-articles)
  680. (gnus-summary-insert-pseudos files save))))
  681. (defun gnus-uu-scan-directory (dir &optional rec)
  682. "Return a list of all files under DIR."
  683. (let ((files (directory-files dir t))
  684. out file)
  685. (while (setq file (pop files))
  686. (unless (member (file-name-nondirectory file) '("." ".."))
  687. (push (list (cons 'name file)
  688. (cons 'article gnus-current-article))
  689. out)
  690. (when (file-directory-p file)
  691. (setq out (nconc (gnus-uu-scan-directory file t) out)))))
  692. (if rec
  693. out
  694. (nreverse out))))
  695. (defun gnus-uu-save-files (files dir)
  696. "Save FILES in DIR."
  697. (let ((len (length files))
  698. (reg (concat "^" (regexp-quote gnus-uu-work-dir)))
  699. to-file file fromdir)
  700. (while (setq file (cdr (assq 'name (pop files))))
  701. (when (file-exists-p file)
  702. (string-match reg file)
  703. (setq fromdir (substring file (match-end 0)))
  704. (if (file-directory-p file)
  705. (gnus-make-directory (concat dir fromdir))
  706. (setq to-file (concat dir fromdir))
  707. (when (or (not (file-exists-p to-file))
  708. (eq gnus-uu-be-dangerous t)
  709. (and gnus-uu-be-dangerous
  710. (gnus-y-or-n-p (format "%s exists; overwrite? "
  711. to-file))))
  712. (copy-file file to-file t t)))))
  713. (gnus-message 5 "Saved %d file%s" len (if (= len 1) "" "s"))))
  714. ;; Functions for saving and possibly digesting articles without
  715. ;; any decoding.
  716. ;; Function called by gnus-uu-grab-articles to treat each article.
  717. (defun gnus-uu-save-article (buffer in-state)
  718. (cond
  719. (gnus-uu-save-separate-articles
  720. (with-current-buffer buffer
  721. (let ((coding-system-for-write mm-text-coding-system))
  722. (gnus-write-buffer
  723. (concat gnus-uu-saved-article-name gnus-current-article)))
  724. (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
  725. ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
  726. 'begin 'end))
  727. ((eq in-state 'last) (list 'end))
  728. (t (list 'middle)))))
  729. ((not gnus-uu-save-in-digest)
  730. (with-current-buffer buffer
  731. (write-region (point-min) (point-max) gnus-uu-saved-article-name t)
  732. (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
  733. ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
  734. 'begin 'end))
  735. ((eq in-state 'last) (list 'end))
  736. (t (list 'middle)))))
  737. (t
  738. (let ((header (gnus-summary-article-header)))
  739. (push (cons (mail-header-from header)
  740. (mail-header-subject header))
  741. gnus-uu-digest-from-subject))
  742. (let ((name (file-name-nondirectory gnus-uu-saved-article-name))
  743. beg subj headers headline sorthead body end-string state)
  744. (if (or (eq in-state 'first)
  745. (eq in-state 'first-and-last))
  746. (progn
  747. (setq state (list 'begin))
  748. (with-current-buffer (gnus-get-buffer-create "*gnus-uu-body*")
  749. (erase-buffer))
  750. (with-current-buffer (gnus-get-buffer-create "*gnus-uu-pre*")
  751. (erase-buffer)
  752. (insert (format
  753. "Date: %s\nFrom: %s\nSubject: %s Digest\n\n"
  754. (message-make-date) name name))
  755. (when (and message-forward-as-mime gnus-uu-digest-buffer)
  756. (insert
  757. "<#mml type=message/rfc822>\nSubject: Topics\n\n<#/mml>\n")
  758. (forward-line -1))
  759. (insert "Topics:\n")))
  760. (when (not (eq in-state 'end))
  761. (setq state (list 'middle))))
  762. (with-current-buffer "*gnus-uu-body*"
  763. (goto-char (setq beg (point-max)))
  764. (save-excursion
  765. (save-restriction
  766. (set-buffer buffer)
  767. (let (buffer-read-only)
  768. (set-text-properties (point-min) (point-max) nil)
  769. ;; These two are necessary for XEmacs 19.12 fascism.
  770. (put-text-property (point-min) (point-max) 'invisible nil)
  771. (put-text-property (point-min) (point-max) 'intangible nil))
  772. (when (and message-forward-as-mime
  773. message-forward-show-mml
  774. gnus-uu-digest-buffer)
  775. (mm-enable-multibyte)
  776. (mime-to-mml))
  777. (goto-char (point-min))
  778. (search-forward "\n\n")
  779. (unless (and message-forward-as-mime gnus-uu-digest-buffer)
  780. ;; Quote all 30-dash lines.
  781. (save-excursion
  782. (while (re-search-forward "^-" nil t)
  783. (beginning-of-line)
  784. (delete-char 1)
  785. (insert "- "))))
  786. (setq body (buffer-substring (1- (point)) (point-max)))
  787. (narrow-to-region (point-min) (point))
  788. (if (not (setq headers gnus-uu-digest-headers))
  789. (setq sorthead (buffer-string))
  790. (while headers
  791. (setq headline (car headers))
  792. (setq headers (cdr headers))
  793. (goto-char (point-min))
  794. (while (re-search-forward headline nil t)
  795. (setq sorthead
  796. (concat sorthead
  797. (buffer-substring
  798. (match-beginning 0)
  799. (or (and (re-search-forward "^[^ \t]" nil t)
  800. (1- (point)))
  801. (progn (forward-line 1) (point)))))))))
  802. (widen)))
  803. (if (and message-forward-as-mime gnus-uu-digest-buffer)
  804. (if message-forward-show-mml
  805. (progn
  806. (insert "\n<#mml type=message/rfc822>\n")
  807. (insert sorthead) (goto-char (point-max))
  808. (insert body) (goto-char (point-max))
  809. (insert "\n<#/mml>\n"))
  810. (let ((buf (mml-generate-new-buffer " *mml*")))
  811. (with-current-buffer buf
  812. (insert sorthead)
  813. (goto-char (point-min))
  814. (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
  815. (setq subj (buffer-substring (match-beginning 1)
  816. (match-end 1))))
  817. (goto-char (point-max))
  818. (insert body))
  819. (insert "\n<#part type=message/rfc822"
  820. " buffer=\"" (buffer-name buf) "\">\n")))
  821. (insert sorthead) (goto-char (point-max))
  822. (insert body) (goto-char (point-max))
  823. (insert (concat "\n" (make-string 30 ?-) "\n\n")))
  824. (goto-char beg)
  825. (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
  826. (setq subj (buffer-substring (match-beginning 1) (match-end 1))))
  827. (when subj
  828. (with-current-buffer "*gnus-uu-pre*"
  829. (insert (format " %s\n" subj)))))
  830. (when (or (eq in-state 'last)
  831. (eq in-state 'first-and-last))
  832. (if (and message-forward-as-mime gnus-uu-digest-buffer)
  833. (with-current-buffer gnus-uu-digest-buffer
  834. (erase-buffer)
  835. (insert-buffer-substring "*gnus-uu-pre*")
  836. (goto-char (point-max))
  837. (insert-buffer-substring "*gnus-uu-body*"))
  838. (with-current-buffer "*gnus-uu-pre*"
  839. (insert (format "\n\n%s\n\n" (make-string 70 ?-)))
  840. (if gnus-uu-digest-buffer
  841. (with-current-buffer gnus-uu-digest-buffer
  842. (erase-buffer)
  843. (insert-buffer-substring "*gnus-uu-pre*"))
  844. (let ((coding-system-for-write mm-text-coding-system))
  845. (gnus-write-buffer gnus-uu-saved-article-name))))
  846. (with-current-buffer "*gnus-uu-body*"
  847. (goto-char (point-max))
  848. (insert
  849. (concat (setq end-string (format "End of %s Digest" name))
  850. "\n"))
  851. (insert (concat (make-string (length end-string) ?*) "\n"))
  852. (if gnus-uu-digest-buffer
  853. (with-current-buffer gnus-uu-digest-buffer
  854. (goto-char (point-max))
  855. (insert-buffer-substring "*gnus-uu-body*"))
  856. (let ((coding-system-for-write mm-text-coding-system)
  857. (file-name-coding-system nnmail-pathname-coding-system))
  858. (write-region
  859. (point-min) (point-max) gnus-uu-saved-article-name t)))))
  860. (gnus-kill-buffer "*gnus-uu-pre*")
  861. (gnus-kill-buffer "*gnus-uu-body*")
  862. (push 'end state))
  863. (if (memq 'begin state)
  864. (cons gnus-uu-saved-article-name state)
  865. state)))))
  866. ;; Binhex treatment - not very advanced.
  867. (defvar gnus-uu-binhex-body-line
  868. "^[^:]...............................................................$")
  869. (defvar gnus-uu-binhex-begin-line
  870. "^:...............................................................$")
  871. (defvar gnus-uu-binhex-end-line
  872. ":$")
  873. (defun gnus-uu-binhex-article (buffer in-state)
  874. (let (state start-char)
  875. (with-current-buffer buffer
  876. (widen)
  877. (goto-char (point-min))
  878. (when (not (re-search-forward gnus-uu-binhex-begin-line nil t))
  879. (when (not (re-search-forward gnus-uu-binhex-body-line nil t))
  880. (setq state (list 'wrong-type))))
  881. (if (memq 'wrong-type state)
  882. ()
  883. (beginning-of-line)
  884. (setq start-char (point))
  885. (if (looking-at gnus-uu-binhex-begin-line)
  886. (progn
  887. (setq state (list 'begin))
  888. (write-region (point-min) (point-min)
  889. gnus-uu-binhex-article-name))
  890. (setq state (list 'middle)))
  891. (goto-char (point-max))
  892. (re-search-backward (concat gnus-uu-binhex-body-line "\\|"
  893. gnus-uu-binhex-end-line)
  894. nil t)
  895. (when (looking-at gnus-uu-binhex-end-line)
  896. (setq state (if (memq 'begin state)
  897. (cons 'end state)
  898. (list 'end))))
  899. (beginning-of-line)
  900. (forward-line 1)
  901. (when (file-exists-p gnus-uu-binhex-article-name)
  902. (mm-append-to-file start-char (point) gnus-uu-binhex-article-name))))
  903. (if (memq 'begin state)
  904. (cons gnus-uu-binhex-article-name state)
  905. state)))
  906. ;; yEnc
  907. (defun gnus-uu-yenc-article (buffer in-state)
  908. (with-current-buffer gnus-original-article-buffer
  909. (widen)
  910. (let ((file-name (yenc-extract-filename))
  911. state start-char)
  912. (when (not file-name)
  913. (setq state (list 'wrong-type)))
  914. (if (memq 'wrong-type state)
  915. ()
  916. (when (yenc-first-part-p)
  917. (setq gnus-uu-yenc-article-name
  918. (expand-file-name file-name gnus-uu-work-dir))
  919. (push 'begin state))
  920. (when (yenc-last-part-p)
  921. (push 'end state))
  922. (unless state
  923. (push 'middle state))
  924. (mm-with-unibyte-buffer
  925. (insert-buffer-substring gnus-original-article-buffer)
  926. (yenc-decode-region (point-min) (point-max))
  927. (when (and (member 'begin state)
  928. (file-exists-p gnus-uu-yenc-article-name))
  929. (delete-file gnus-uu-yenc-article-name))
  930. (mm-append-to-file (point-min) (point-max)
  931. gnus-uu-yenc-article-name)))
  932. (if (memq 'begin state)
  933. (cons file-name state)
  934. state))))
  935. ;; PostScript
  936. (defun gnus-uu-decode-postscript-article (process-buffer in-state)
  937. (let ((state (list 'ok))
  938. start-char end-char file-name)
  939. (with-current-buffer process-buffer
  940. (goto-char (point-min))
  941. (if (not (re-search-forward gnus-uu-postscript-begin-string nil t))
  942. (setq state (list 'wrong-type))
  943. (beginning-of-line)
  944. (setq start-char (point))
  945. (if (not (re-search-forward gnus-uu-postscript-end-string nil t))
  946. (setq state (list 'wrong-type))
  947. (setq end-char (point))
  948. (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
  949. (insert-buffer-substring process-buffer start-char end-char)
  950. (setq file-name (concat gnus-uu-work-dir
  951. (cdr gnus-article-current) ".ps"))
  952. (write-region (point-min) (point-max) file-name)
  953. (setq state (list file-name 'begin 'end)))))
  954. state))
  955. ;; Find actions.
  956. (defun gnus-uu-get-actions (files)
  957. (let ((ofiles files)
  958. action name)
  959. (while files
  960. (setq name (cdr (assq 'name (car files))))
  961. (and
  962. (setq action (gnus-uu-get-action name))
  963. (setcar files (nconc (list (if (string= action "gnus-uu-archive")
  964. (cons 'action "file")
  965. (cons 'action action))
  966. (cons 'execute (gnus-uu-command
  967. action name)))
  968. (car files))))
  969. (setq files (cdr files)))
  970. ofiles))
  971. (defun gnus-uu-get-action (file-name)
  972. (let (action)
  973. (setq action
  974. (gnus-uu-choose-action
  975. file-name
  976. (append
  977. gnus-uu-user-view-rules
  978. (if gnus-uu-ignore-default-view-rules
  979. nil
  980. gnus-uu-default-view-rules)
  981. gnus-uu-user-view-rules-end)))
  982. (when (and (not (string= (or action "") "gnus-uu-archive"))
  983. gnus-uu-view-with-metamail)
  984. (when (setq action
  985. (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list))
  986. (setq action (format "metamail -d -b -c \"%s\"" action))))
  987. action))
  988. ;; Functions for treating subjects and collecting series.
  989. (defun gnus-uu-reginize-string (string)
  990. ;; Takes a string and puts a \ in front of every special character;
  991. ;; replaces the last thing that looks like "2/3" with "[0-9]+/3"
  992. ;; or, if it can't find something like that, tries "2 of 3", then
  993. ;; finally just replaces the next to last number with "[0-9]+".
  994. (with-current-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name)
  995. (buffer-disable-undo)
  996. (erase-buffer)
  997. (insert (regexp-quote string))
  998. (setq case-fold-search nil)
  999. (end-of-line)
  1000. (if (re-search-backward "\\([^0-9]\\)[0-9]+/\\([0-9]+\\)" nil t)
  1001. (replace-match "\\1[0-9]+/\\2")
  1002. (end-of-line)
  1003. (if (re-search-backward "\\([^0-9]\\)[0-9]+[ \t]*of[ \t]*\\([0-9]+\\)"
  1004. nil t)
  1005. (replace-match "\\1[0-9]+ of \\2")
  1006. (end-of-line)
  1007. (if (re-search-backward "\\([^0-9]\\)[0-9]+\\([^0-9]+\\)[0-9]+"
  1008. nil t)
  1009. (replace-match "\\1[0-9]+\\2[0-9]+" t nil nil nil))))
  1010. (goto-char (point-min))
  1011. (while (re-search-forward "[ \t]+" nil t)
  1012. (replace-match "[ \t]+" t t))
  1013. (buffer-string)))
  1014. (defun gnus-uu-get-list-of-articles (n)
  1015. ;; If N is non-nil, the article numbers of the N next articles
  1016. ;; will be returned.
  1017. ;; If any articles have been marked as processable, they will be
  1018. ;; returned.
  1019. ;; Failing that, articles that have subjects that are part of the
  1020. ;; same "series" as the current will be returned.
  1021. (let (articles)
  1022. (cond
  1023. (n
  1024. (setq n (prefix-numeric-value n))
  1025. (let ((backward (< n 0))
  1026. (n (abs n)))
  1027. (save-excursion
  1028. (while (and (> n 0)
  1029. (push (gnus-summary-article-number)
  1030. articles)
  1031. (gnus-summary-search-forward nil nil backward))
  1032. (setq n (1- n))))
  1033. (nreverse articles)))
  1034. (gnus-newsgroup-processable
  1035. (reverse gnus-newsgroup-processable))
  1036. (t
  1037. (gnus-uu-find-articles-matching)))))
  1038. (defun gnus-uu-string< (l1 l2)
  1039. (string< (car l1) (car l2)))
  1040. (defun gnus-uu-find-articles-matching
  1041. (&optional subject only-unread do-not-translate)
  1042. ;; Finds all articles that matches the regexp SUBJECT. If it is
  1043. ;; nil, the current article name will be used. If ONLY-UNREAD is
  1044. ;; non-nil, only unread articles are chosen. If DO-NOT-TRANSLATE is
  1045. ;; non-nil, article names are not equalized before sorting.
  1046. (let ((subject (or subject
  1047. (gnus-uu-reginize-string (gnus-summary-article-subject))))
  1048. list-of-subjects)
  1049. (save-excursion
  1050. (when subject
  1051. ;; Collect all subjects matching subject.
  1052. (let ((case-fold-search t)
  1053. (data gnus-newsgroup-data)
  1054. subj mark d)
  1055. (while data
  1056. (setq d (pop data))
  1057. (and (not (gnus-data-pseudo-p d))
  1058. (or (not only-unread)
  1059. (= (setq mark (gnus-data-mark d))
  1060. gnus-unread-mark)
  1061. (= mark gnus-ticked-mark)
  1062. (= mark gnus-dormant-mark))
  1063. (setq subj (mail-header-subject (gnus-data-header d)))
  1064. (string-match subject subj)
  1065. (push (cons subj (gnus-data-number d))
  1066. list-of-subjects))))
  1067. ;; Expand numbers, sort, and return the list of article
  1068. ;; numbers.
  1069. (mapcar 'cdr
  1070. (sort (gnus-uu-expand-numbers
  1071. list-of-subjects
  1072. (not do-not-translate))
  1073. 'gnus-uu-string<))))))
  1074. (defun gnus-uu-expand-numbers (string-list &optional translate)
  1075. ;; Takes a list of strings and "expands" all numbers in all the
  1076. ;; strings. That is, this function makes all numbers equal length by
  1077. ;; prepending lots of zeroes before each number. This is to ease later
  1078. ;; sorting to find out what sequence the articles are supposed to be
  1079. ;; decoded in. Returns the list of expanded strings.
  1080. (let ((out-list string-list)
  1081. string)
  1082. (with-current-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name)
  1083. (buffer-disable-undo)
  1084. (while string-list
  1085. (erase-buffer)
  1086. (insert (caar string-list))
  1087. ;; Translate multiple spaces to one space.
  1088. (goto-char (point-min))
  1089. (while (re-search-forward "[ \t]+" nil t)
  1090. (replace-match " "))
  1091. ;; Translate all characters to "a".
  1092. (goto-char (point-min))
  1093. (when translate
  1094. (while (re-search-forward "[A-Za-z]" nil t)
  1095. (replace-match "a" t t)))
  1096. ;; Expand numbers.
  1097. (goto-char (point-min))
  1098. (while (re-search-forward "[0-9]+" nil t)
  1099. (ignore-errors
  1100. (replace-match
  1101. (format "%06d"
  1102. (string-to-number (buffer-substring
  1103. (match-beginning 0) (match-end 0)))))))
  1104. (setq string (buffer-substring (point-min) (point-max)))
  1105. (setcar (car string-list) string)
  1106. (setq string-list (cdr string-list))))
  1107. out-list))
  1108. ;; `gnus-uu-grab-articles' is the general multi-article treatment
  1109. ;; function. It takes a list of articles to be grabbed and a function
  1110. ;; to apply to each article.
  1111. ;;
  1112. ;; The function to be called should take two parameters. The first
  1113. ;; parameter is the article buffer. The function should leave the
  1114. ;; result, if any, in this buffer. Most treatment functions will just
  1115. ;; generate files...
  1116. ;;
  1117. ;; The second parameter is the state of the list of articles, and can
  1118. ;; have four values: `first', `middle', `last' and `first-and-last'.
  1119. ;;
  1120. ;; The function should return a list. The list may contain the
  1121. ;; following symbols:
  1122. ;; `error' if an error occurred
  1123. ;; `begin' if the beginning of an encoded file has been received
  1124. ;; If the list returned contains a `begin', the first element of
  1125. ;; the list *must* be a string with the file name of the decoded
  1126. ;; file.
  1127. ;; `end' if the end of an encoded file has been received
  1128. ;; `middle' if the article was a body part of an encoded file
  1129. ;; `wrong-type' if the article was not a part of an encoded file
  1130. ;; `ok', which can be used everything is ok
  1131. (defvar gnus-uu-has-been-grabbed nil)
  1132. (defun gnus-uu-unmark-list-of-grabbed (&optional dont-unmark-last-article)
  1133. (let (art)
  1134. (if (not (and gnus-uu-has-been-grabbed
  1135. gnus-uu-unmark-articles-not-decoded))
  1136. ()
  1137. (when dont-unmark-last-article
  1138. (setq art (car gnus-uu-has-been-grabbed))
  1139. (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
  1140. (while gnus-uu-has-been-grabbed
  1141. (gnus-summary-tick-article (car gnus-uu-has-been-grabbed) t)
  1142. (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
  1143. (when dont-unmark-last-article
  1144. (setq gnus-uu-has-been-grabbed (list art))))))
  1145. ;; This function takes a list of articles and a function to apply to
  1146. ;; each article grabbed.
  1147. ;;
  1148. ;; This function returns a list of files decoded if the grabbing and
  1149. ;; the process-function has been successful and nil otherwise.
  1150. (defun gnus-uu-grab-articles (articles process-function
  1151. &optional sloppy limit no-errors)
  1152. (require 'gnus-async)
  1153. (let ((state 'first)
  1154. (gnus-asynchronous nil)
  1155. (gnus-inhibit-treatment t)
  1156. has-been-begin article result-file result-files process-state
  1157. gnus-summary-display-article-function
  1158. gnus-article-prepare-hook gnus-display-mime-function
  1159. article-series files)
  1160. (while (and articles
  1161. (not (memq 'error process-state))
  1162. (or sloppy
  1163. (not (memq 'end process-state))))
  1164. (setq article (pop articles))
  1165. (when (vectorp (gnus-summary-article-header article))
  1166. (push article article-series)
  1167. (unless articles
  1168. (if (eq state 'first)
  1169. (setq state 'first-and-last)
  1170. (setq state 'last)))
  1171. (let ((part (gnus-uu-part-number article)))
  1172. (gnus-message 6 "Getting article %d%s..."
  1173. article (if (string= part "") "" (concat ", " part))))
  1174. (gnus-summary-display-article article)
  1175. ;; Push the article to the processing function.
  1176. (with-current-buffer gnus-original-article-buffer
  1177. (let ((buffer-read-only nil))
  1178. (with-current-buffer gnus-summary-buffer
  1179. (setq process-state
  1180. (funcall process-function
  1181. gnus-original-article-buffer state)))))
  1182. (gnus-summary-remove-process-mark article)
  1183. ;; If this is the beginning of a decoded file, we push it
  1184. ;; on to a list.
  1185. (when (or (memq 'begin process-state)
  1186. (and (or (eq state 'first)
  1187. (eq state 'first-and-last))
  1188. (memq 'ok process-state)))
  1189. (when has-been-begin
  1190. ;; If there is a `result-file' here, that means that the
  1191. ;; file was unsuccessfully decoded, so we delete it.
  1192. (when (and result-file
  1193. (file-exists-p result-file)
  1194. (not gnus-uu-be-dangerous)
  1195. (or (eq gnus-uu-be-dangerous t)
  1196. (gnus-y-or-n-p
  1197. (format "Delete unsuccessfully decoded file %s? "
  1198. result-file))))
  1199. (delete-file result-file)))
  1200. (when (memq 'begin process-state)
  1201. (setq result-file (car process-state)))
  1202. (setq has-been-begin t))
  1203. ;; Check whether we have decoded one complete file.
  1204. (when (memq 'end process-state)
  1205. (setq article-series nil)
  1206. (setq has-been-begin nil)
  1207. (if (stringp result-file)
  1208. (setq files (list result-file))
  1209. (setq files result-file))
  1210. (setq result-file (car files))
  1211. (while files
  1212. (push (list (cons 'name (pop files))
  1213. (cons 'article article))
  1214. result-files))
  1215. ;; Allow user-defined functions to be run on this file.
  1216. (when gnus-uu-grabbed-file-functions
  1217. (let ((funcs gnus-uu-grabbed-file-functions))
  1218. (unless (listp funcs)
  1219. (setq funcs (list funcs)))
  1220. (while funcs
  1221. (funcall (pop funcs) result-file))))
  1222. (setq result-file nil)
  1223. ;; Check whether we have decoded enough articles.
  1224. (and limit (= (length result-files) limit)
  1225. (setq articles nil)))
  1226. ;; If this is the last article to be decoded, and
  1227. ;; we still haven't reached the end, then we delete
  1228. ;; the partially decoded file.
  1229. (and (or (eq state 'last) (eq state 'first-and-last))
  1230. (not (memq 'end process-state))
  1231. result-file
  1232. (file-exists-p result-file)
  1233. (not gnus-uu-be-dangerous)
  1234. (or (eq gnus-uu-be-dangerous t)
  1235. (gnus-y-or-n-p
  1236. (format "Delete incomplete file %s? " result-file)))
  1237. (delete-file result-file))
  1238. ;; If this was a file of the wrong sort, then
  1239. (when (and (or (memq 'wrong-type process-state)
  1240. (memq 'error process-state))
  1241. gnus-uu-unmark-articles-not-decoded)
  1242. (gnus-summary-tick-article article t))
  1243. ;; Set the new series state.
  1244. (if (and (not has-been-begin)
  1245. (not sloppy)
  1246. (or (memq 'end process-state)
  1247. (memq 'middle process-state)))
  1248. (progn
  1249. (setq process-state (list 'error))
  1250. (gnus-message 2 "No begin part at the beginning")
  1251. (sleep-for 2))
  1252. (setq state 'middle))))
  1253. ;; When there are no result-files, then something must be wrong.
  1254. (if result-files
  1255. (message "")
  1256. (cond
  1257. ((not has-been-begin)
  1258. (gnus-message 2 "Wrong type file"))
  1259. ((memq 'error process-state)
  1260. (gnus-message 2 "An error occurred during decoding"))
  1261. ((not (or (memq 'ok process-state)
  1262. (memq 'end process-state)))
  1263. (gnus-message 2 "End of articles reached before end of file")))
  1264. ;; Make unsuccessfully decoded articles unread.
  1265. (when gnus-uu-unmark-articles-not-decoded
  1266. (while article-series
  1267. (gnus-summary-tick-article (pop article-series) t))))
  1268. ;; The original article buffer is hosed, shoot it down.
  1269. (gnus-kill-buffer gnus-original-article-buffer)
  1270. (setq gnus-current-article nil)
  1271. result-files))
  1272. (defun gnus-uu-grab-view (file)
  1273. "View FILE using the gnus-uu methods."
  1274. (let ((action (gnus-uu-get-action file)))
  1275. (gnus-execute-command
  1276. (if (string-match "%" action)
  1277. (format action file)
  1278. (concat action " " file))
  1279. (eq gnus-view-pseudos 'not-confirm))))
  1280. (defun gnus-uu-grab-move (file)
  1281. "Move FILE to somewhere."
  1282. (when gnus-uu-default-dir
  1283. (let ((to-file (concat (file-name-as-directory gnus-uu-default-dir)
  1284. (file-name-nondirectory file))))
  1285. (rename-file file to-file)
  1286. (unless (file-exists-p file)
  1287. (make-symbolic-link to-file file)))))
  1288. (defun gnus-uu-part-number (article)
  1289. (let* ((header (gnus-summary-article-header article))
  1290. (subject (and header (mail-header-subject header)))
  1291. (part nil))
  1292. (if subject
  1293. (while (string-match "[0-9]+/[0-9]+\\|[0-9]+[ \t]+of[ \t]+[0-9]+"
  1294. subject)
  1295. (setq part (match-string 0 subject))
  1296. (setq subject (substring subject (match-end 0)))))
  1297. (or part
  1298. (while (string-match "[0-9]+[^0-9]+[0-9]+" subject)
  1299. (setq part (match-string 0 subject))
  1300. (setq subject (substring subject (match-end 0)))))
  1301. (or part "")))
  1302. (defun gnus-uu-uudecode-sentinel (process event)
  1303. (delete-process (get-process process)))
  1304. (defun gnus-uu-uustrip-article (process-buffer in-state)
  1305. ;; Uudecodes a file asynchronously.
  1306. (with-current-buffer process-buffer
  1307. (let ((state (list 'wrong-type))
  1308. process-connection-type case-fold-search buffer-read-only
  1309. files start-char)
  1310. (goto-char (point-min))
  1311. ;; Deal with ^M at the end of the lines.
  1312. (when gnus-uu-kill-carriage-return
  1313. (save-excursion
  1314. (while (search-forward "\r" nil t)
  1315. (delete-char -1))))
  1316. (while (or (re-search-forward gnus-uu-begin-string nil t)
  1317. (re-search-forward gnus-uu-body-line nil t))
  1318. (setq state (list 'ok))
  1319. ;; Ok, we are at the first uucoded line.
  1320. (beginning-of-line)
  1321. (setq start-char (point))
  1322. (if (not (looking-at gnus-uu-begin-string))
  1323. (setq state (list 'middle))
  1324. ;; This is the beginning of a uuencoded article.
  1325. ;; We replace certain characters that could make things messy.
  1326. (setq gnus-uu-file-name
  1327. (gnus-map-function
  1328. mm-file-name-rewrite-functions
  1329. (file-name-nondirectory (match-string 1))))
  1330. (replace-match (concat "begin 644 " gnus-uu-file-name) t t)
  1331. ;; Remove any non gnus-uu-body-line right after start.
  1332. (forward-line 1)
  1333. (while (and (not (eobp))
  1334. (not (looking-at gnus-uu-body-line)))
  1335. (gnus-delete-line))
  1336. ;; If a process is running, we kill it.
  1337. (when (and gnus-uu-uudecode-process
  1338. (memq (process-status gnus-uu-uudecode-process)
  1339. '(run stop)))
  1340. (delete-process gnus-uu-uudecode-process)
  1341. (gnus-uu-unmark-list-of-grabbed t))
  1342. ;; Start a new uudecoding process.
  1343. (let ((cdir default-directory))
  1344. (unwind-protect
  1345. (progn
  1346. (cd gnus-uu-work-dir)
  1347. (setq gnus-uu-uudecode-process
  1348. (start-process
  1349. "*uudecode*"
  1350. (gnus-get-buffer-create gnus-uu-output-buffer-name)
  1351. shell-file-name shell-command-switch
  1352. (format "cd %s %s uudecode" gnus-uu-work-dir
  1353. gnus-shell-command-separator))))
  1354. (cd cdir)))
  1355. (set-process-sentinel
  1356. gnus-uu-uudecode-process 'gnus-uu-uudecode-sentinel)
  1357. (setq state (list 'begin))
  1358. (push (concat gnus-uu-work-dir gnus-uu-file-name) files))
  1359. ;; We look for the end of the thing to be decoded.
  1360. (if (re-search-forward gnus-uu-end-string nil t)
  1361. (push 'end state)
  1362. (goto-char (point-max))
  1363. (re-search-backward gnus-uu-body-line nil t))
  1364. (forward-line 1)
  1365. (when gnus-uu-uudecode-process
  1366. (when (memq (process-status gnus-uu-uudecode-process) '(run stop))
  1367. ;; Try to correct mishandled uucode.
  1368. (when gnus-uu-correct-stripped-uucode
  1369. (gnus-uu-check-correct-stripped-uucode start-char (point)))
  1370. (gnus-run-hooks 'gnus-uu-pre-uudecode-hook)
  1371. ;; Send the text to the process.
  1372. (condition-case nil
  1373. (process-send-region
  1374. gnus-uu-uudecode-process start-char (point))
  1375. (error
  1376. (progn
  1377. (delete-process gnus-uu-uudecode-process)
  1378. (gnus-message 2 "gnus-uu: Couldn't uudecode")
  1379. (setq state (list 'wrong-type)))))
  1380. (if (memq 'end state)
  1381. (progn
  1382. ;; Send an EOF, just in case.
  1383. (ignore-errors
  1384. (process-send-eof gnus-uu-uudecode-process))
  1385. (while (memq (process-status gnus-uu-uudecode-process)
  1386. '(open run))
  1387. (accept-process-output gnus-uu-uudecode-process 1)))
  1388. (when (or (not gnus-uu-uudecode-process)
  1389. (not (memq (process-status gnus-uu-uudecode-process)
  1390. '(run stop))))
  1391. (setq state (list 'wrong-type)))))))
  1392. (if (memq 'begin state)
  1393. (cons (if (= (length files) 1) (car files) files) state)
  1394. state))))
  1395. (defvar gnus-uu-unshar-warning
  1396. "*** WARNING ***
  1397. Shell archives are an archaic method of bundling files for distribution
  1398. across computer networks. During the unpacking process, arbitrary commands
  1399. are executed on your system, and all kinds of nasty things can happen.
  1400. Please examine the archive very carefully before you instruct Emacs to
  1401. unpack it. You can browse the archive buffer using \\[scroll-other-window].
  1402. If you are unsure what to do, please answer \"no\"."
  1403. "Text of warning message displayed by `gnus-uu-unshar-article'.
  1404. Make sure that this text consists only of few text lines. Otherwise,
  1405. Gnus might fail to display all of it.")
  1406. ;; This function is used by `gnus-uu-grab-articles' to treat
  1407. ;; a shared article.
  1408. (defun gnus-uu-unshar-article (process-buffer in-state)
  1409. (let ((state (list 'ok))
  1410. start-char)
  1411. (with-current-buffer process-buffer
  1412. (goto-char (point-min))
  1413. (if (not (re-search-forward gnus-uu-shar-begin-string nil t))
  1414. (setq state (list 'wrong-type))
  1415. (save-window-excursion
  1416. (save-excursion
  1417. (switch-to-buffer (current-buffer))
  1418. (delete-other-windows)
  1419. (let ((buffer (get-buffer-create (generate-new-buffer-name
  1420. "*Warning*"))))
  1421. (unless
  1422. (unwind-protect
  1423. (with-current-buffer buffer
  1424. (insert (substitute-command-keys
  1425. gnus-uu-unshar-warning))
  1426. (goto-char (point-min))
  1427. (display-buffer buffer)
  1428. (yes-or-no-p "This is a shell archive, unshar it? "))
  1429. (kill-buffer buffer))
  1430. (setq state (list 'error))))))
  1431. (unless (memq 'error state)
  1432. (beginning-of-line)
  1433. (setq start-char (point))
  1434. (call-process-region
  1435. start-char (point-max) shell-file-name nil
  1436. (gnus-get-buffer-create gnus-uu-output-buffer-name) nil
  1437. shell-command-switch
  1438. (concat "cd " gnus-uu-work-dir " "
  1439. gnus-shell-command-separator " sh")))))
  1440. state))
  1441. ;; Returns the name of what the shar file is going to unpack.
  1442. (defun gnus-uu-find-name-in-shar ()
  1443. (let ((oldpoint (point))
  1444. res)
  1445. (goto-char (point-min))
  1446. (when (re-search-forward gnus-uu-shar-name-marker nil t)
  1447. (setq res (buffer-substring (match-beginning 1) (match-end 1))))
  1448. (goto-char oldpoint)
  1449. res))
  1450. ;; `gnus-uu-choose-action' chooses what action to perform given the name
  1451. ;; and `gnus-uu-file-action-list'. Returns either nil if no action is
  1452. ;; found, or the name of the command to run if such a rule is found.
  1453. (defun gnus-uu-choose-action (file-name file-action-list &optional no-ignore)
  1454. (let ((action-list (copy-sequence file-action-list))
  1455. (case-fold-search t)
  1456. rule action)
  1457. (and
  1458. (unless no-ignore
  1459. (and (not
  1460. (and gnus-uu-ignore-files-by-name
  1461. (string-match gnus-uu-ignore-files-by-name file-name)))
  1462. (not
  1463. (and gnus-uu-ignore-files-by-type
  1464. (string-match gnus-uu-ignore-files-by-type
  1465. (or (gnus-uu-choose-action
  1466. file-name gnus-uu-ext-to-mime-list t)
  1467. ""))))))
  1468. (while (not (or (eq action-list ()) action))
  1469. (setq rule (car action-list))
  1470. (setq action-list (cdr action-list))
  1471. (when (string-match (car rule) file-name)
  1472. (setq action (cadr rule)))))
  1473. action))
  1474. (defun gnus-uu-treat-archive (file-path)
  1475. ;; Unpacks an archive. Returns t if unpacking is successful.
  1476. (let ((did-unpack t)
  1477. action command dir)
  1478. (setq action (gnus-uu-choose-action
  1479. file-path (append gnus-uu-user-archive-rules
  1480. (if gnus-uu-ignore-default-archive-rules
  1481. nil
  1482. gnus-uu-default-archive-rules))))
  1483. (when (not action)
  1484. (error "No unpackers for the file %s" file-path))
  1485. (string-match "/[^/]*$" file-path)
  1486. (setq dir (substring file-path 0 (match-beginning 0)))
  1487. (when (member action gnus-uu-destructive-archivers)
  1488. (copy-file file-path (concat file-path "~") t))
  1489. (setq command (format "cd %s ; %s" dir (gnus-uu-command action file-path)))
  1490. (with-current-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name)
  1491. (erase-buffer))
  1492. (gnus-message 5 "Unpacking: %s..." (gnus-uu-command action file-path))
  1493. (if (eq 0 (call-process shell-file-name nil
  1494. (gnus-get-buffer-create gnus-uu-output-buffer-name)
  1495. nil shell-command-switch command))
  1496. (message "")
  1497. (gnus-message 2 "Error during unpacking of archive")
  1498. (setq did-unpack nil))
  1499. (when (member action gnus-uu-destructive-archivers)
  1500. (rename-file (concat file-path "~") file-path t))
  1501. did-unpack))
  1502. (defun gnus-uu-dir-files (dir)
  1503. (let ((dirs (directory-files dir t "[^/][^\\.][^\\.]?$"))
  1504. files file)
  1505. (while dirs
  1506. (if (file-directory-p (setq file (car dirs)))
  1507. (setq files (append files (gnus-uu-dir-files file)))
  1508. (push file files))
  1509. (setq dirs (cdr dirs)))
  1510. files))
  1511. (defun gnus-uu-unpack-files (files &optional ignore)
  1512. ;; Go through FILES and look for files to unpack.
  1513. (let* ((totfiles (gnus-uu-ls-r gnus-uu-work-dir))
  1514. (ofiles files)
  1515. file did-unpack)
  1516. (while files
  1517. (setq file (cdr (assq 'name (car files))))
  1518. (when (and (not (member file ignore))
  1519. (equal (gnus-uu-get-action (file-name-nondirectory file))
  1520. "gnus-uu-archive"))
  1521. (push file did-unpack)
  1522. (unless (gnus-uu-treat-archive file)
  1523. (gnus-message 2 "Error during unpacking of %s" file))
  1524. (let* ((newfiles (gnus-uu-ls-r gnus-uu-work-dir))
  1525. (nfiles newfiles))
  1526. (while nfiles
  1527. (unless (member (car nfiles) totfiles)
  1528. (push (list (cons 'name (car nfiles))
  1529. (cons 'original file))
  1530. ofiles))
  1531. (setq nfiles (cdr nfiles)))
  1532. (setq totfiles newfiles)))
  1533. (setq files (cdr files)))
  1534. (if did-unpack
  1535. (gnus-uu-unpack-files ofiles (append did-unpack ignore))
  1536. ofiles)))
  1537. (defun gnus-uu-ls-r (dir)
  1538. (let* ((files (gnus-uu-directory-files dir t))
  1539. (ofiles files))
  1540. (while files
  1541. (when (file-directory-p (car files))
  1542. (setq ofiles (delete (car files) ofiles))
  1543. (setq ofiles (append ofiles (gnus-uu-ls-r (car files)))))
  1544. (setq files (cdr files)))
  1545. ofiles))
  1546. ;; Various stuff
  1547. (defun gnus-uu-directory-files (dir &optional full)
  1548. (let (files out file)
  1549. (setq files (directory-files dir full))
  1550. (while files
  1551. (setq file (car files))
  1552. (setq files (cdr files))
  1553. (unless (member (file-name-nondirectory file) '("." ".."))
  1554. (push file out)))
  1555. (setq out (nreverse out))
  1556. out))
  1557. (defun gnus-uu-check-correct-stripped-uucode (start end)
  1558. (save-excursion
  1559. (let (found beg length)
  1560. (unless gnus-uu-correct-stripped-uucode
  1561. (goto-char start)
  1562. (if (re-search-forward " \\|`" end t)
  1563. (progn
  1564. (goto-char start)
  1565. (while (not (eobp))
  1566. (progn
  1567. (when (looking-at "\n")
  1568. (replace-match ""))
  1569. (forward-line 1))))
  1570. (while (not (eobp))
  1571. (unless (looking-at (concat gnus-uu-begin-string "\\|"
  1572. gnus-uu-end-string))
  1573. (when (not found)
  1574. (setq length (- (point-at-eol) (point-at-bol))))
  1575. (setq found t)
  1576. (beginning-of-line)
  1577. (setq beg (point))
  1578. (end-of-line)
  1579. (unless (= length (- (point) beg))
  1580. (insert (make-string (- length (- (point) beg)) ? ))))
  1581. (forward-line 1)))))))
  1582. (defvar gnus-uu-tmp-alist nil)
  1583. (defun gnus-uu-initialize (&optional scan)
  1584. (let (entry)
  1585. (if (and (not scan)
  1586. (when (setq entry (assoc gnus-newsgroup-name gnus-uu-tmp-alist))
  1587. (if (file-exists-p (cdr entry))
  1588. (setq gnus-uu-work-dir (cdr entry))
  1589. (setq gnus-uu-tmp-alist (delq entry gnus-uu-tmp-alist))
  1590. nil)))
  1591. t
  1592. (setq gnus-uu-tmp-dir (file-name-as-directory
  1593. (expand-file-name gnus-uu-tmp-dir)))
  1594. (if (not (file-directory-p gnus-uu-tmp-dir))
  1595. (error "Temp directory %s doesn't exist" gnus-uu-tmp-dir)
  1596. (when (not (file-writable-p gnus-uu-tmp-dir))
  1597. (error "Temp directory %s can't be written to"
  1598. gnus-uu-tmp-dir)))
  1599. (setq gnus-uu-work-dir
  1600. (mm-make-temp-file (concat gnus-uu-tmp-dir "gnus") 'dir))
  1601. (gnus-set-file-modes gnus-uu-work-dir 448)
  1602. (setq gnus-uu-work-dir (file-name-as-directory gnus-uu-work-dir))
  1603. (push (cons gnus-newsgroup-name gnus-uu-work-dir)
  1604. gnus-uu-tmp-alist))))
  1605. ;; Kills the temporary uu buffers, kills any processes, etc.
  1606. (defun gnus-uu-clean-up ()
  1607. (let (buf)
  1608. (and gnus-uu-uudecode-process
  1609. (memq (process-status (or gnus-uu-uudecode-process "nevair"))
  1610. '(stop run))
  1611. (delete-process gnus-uu-uudecode-process))
  1612. (when (setq buf (get-buffer gnus-uu-output-buffer-name))
  1613. (kill-buffer buf))))
  1614. ;; Inputs an action and a filename and returns a full command, making sure
  1615. ;; that the filename will be treated as a single argument when the shell
  1616. ;; executes the command.
  1617. (defun gnus-uu-command (action file)
  1618. (let ((quoted-file (shell-quote-argument file)))
  1619. (if (string-match "%s" action)
  1620. (format action quoted-file)
  1621. (concat action " " quoted-file))))
  1622. (defun gnus-uu-delete-work-dir (&optional dir)
  1623. "Delete recursively all files and directories under `gnus-uu-work-dir'."
  1624. (if dir
  1625. (gnus-message 7 "Deleting directory %s..." dir)
  1626. (setq dir gnus-uu-work-dir))
  1627. (when (and dir
  1628. (file-exists-p dir))
  1629. (let ((files (directory-files dir t nil t))
  1630. file)
  1631. (while (setq file (pop files))
  1632. (unless (member (file-name-nondirectory file) '("." ".."))
  1633. (if (file-directory-p file)
  1634. (gnus-uu-delete-work-dir file)
  1635. (gnus-message 9 "Deleting file %s..." file)
  1636. (condition-case err
  1637. (delete-file file)
  1638. (error (gnus-message 3 "Deleting file %s failed... %s" file err))))))
  1639. (condition-case err
  1640. (delete-directory dir)
  1641. (error (gnus-message 3 "Deleting directory %s failed... %s" file err))))
  1642. (gnus-message 7 "")))
  1643. ;; Initializing
  1644. (add-hook 'gnus-exit-group-hook 'gnus-uu-clean-up)
  1645. (add-hook 'gnus-exit-group-hook 'gnus-uu-delete-work-dir)
  1646. ;;;
  1647. ;;; uuencoded posting
  1648. ;;;
  1649. ;; Any function that is to be used as and encoding method will take two
  1650. ;; parameters: PATH-NAME and FILE-NAME. (E.g. "/home/gaga/spiral.jpg"
  1651. ;; and "spiral.jpg", respectively.) The function should return nil if
  1652. ;; the encoding wasn't successful.
  1653. (defcustom gnus-uu-post-encode-method 'gnus-uu-post-encode-uuencode
  1654. "Function used for encoding binary files.
  1655. There are three functions supplied with gnus-uu for encoding files:
  1656. `gnus-uu-post-encode-uuencode', which does straight uuencoding;
  1657. `gnus-uu-post-encode-mime', which encodes with base64 and adds MIME
  1658. headers; and `gnus-uu-post-encode-mime-uuencode', which encodes with
  1659. uuencode and adds MIME headers."
  1660. :group 'gnus-extract-post
  1661. :type '(radio (function-item gnus-uu-post-encode-uuencode)
  1662. (function-item gnus-uu-post-encode-mime)
  1663. (function-item gnus-uu-post-encode-mime-uuencode)
  1664. (function :tag "Other")))
  1665. (defcustom gnus-uu-post-include-before-composing nil
  1666. "Non-nil means that gnus-uu will ask for a file to encode before you compose the article.
  1667. If this variable is t, you can either include an encoded file with
  1668. \\[gnus-uu-post-insert-binary-in-article] or have one included for you when you post the article."
  1669. :group 'gnus-extract-post
  1670. :type 'boolean)
  1671. (defcustom gnus-uu-post-length 990
  1672. "Maximum length of an article.
  1673. The encoded file will be split into how many articles it takes to
  1674. post the entire file."
  1675. :group 'gnus-extract-post
  1676. :type 'integer)
  1677. (defcustom gnus-uu-post-threaded nil
  1678. "Non-nil means that gnus-uu will post the encoded file in a thread.
  1679. This may not be smart, as no other decoder I have seen are able to
  1680. follow threads when collecting uuencoded articles. (Well, I have seen
  1681. one package that does that - gnus-uu, but somehow, I don't think that
  1682. counts...) The default is nil."
  1683. :group 'gnus-extract-post
  1684. :type 'boolean)
  1685. (defcustom gnus-uu-post-separate-description t
  1686. "Non-nil means that the description will be posted in a separate article.
  1687. The first article will typically be numbered (0/x). If this variable
  1688. is nil, the description the user enters will be included at the
  1689. beginning of the first article, which will be numbered (1/x). Default
  1690. is t."
  1691. :group 'gnus-extract-post
  1692. :type 'boolean)
  1693. (defvar gnus-uu-post-binary-separator "--binary follows this line--")
  1694. (defvar gnus-uu-post-message-id nil)
  1695. (defvar gnus-uu-post-inserted-file-name nil)
  1696. (defvar gnus-uu-winconf-post-news nil)
  1697. (defun gnus-uu-post-news ()
  1698. "Compose an article and post an encoded file."
  1699. (interactive)
  1700. (setq gnus-uu-post-inserted-file-name nil)
  1701. (setq gnus-uu-winconf-post-news (current-window-configuration))
  1702. (gnus-summary-post-news)
  1703. (let ((map (make-sparse-keymap)))
  1704. (set-keymap-parent map (current-local-map))
  1705. (use-local-map map))
  1706. ;;(local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
  1707. (local-set-key "\C-c\C-c" 'gnus-uu-post-news-inews)
  1708. (local-set-key "\C-c\C-s" 'gnus-uu-post-news-inews)
  1709. (local-set-key "\C-c\C-i" 'gnus-uu-post-insert-binary-in-article)
  1710. (when gnus-uu-post-include-before-composing
  1711. (save-excursion (setq gnus-uu-post-inserted-file-name
  1712. (gnus-uu-post-insert-binary)))))
  1713. (defun gnus-uu-post-insert-binary-in-article ()
  1714. "Inserts an encoded file in the buffer.
  1715. The user will be asked for a file name."
  1716. (interactive)
  1717. (save-excursion
  1718. (setq gnus-uu-post-inserted-file-name (gnus-uu-post-insert-binary))))
  1719. ;; Encodes with uuencode and substitutes all spaces with backticks.
  1720. (defun gnus-uu-post-encode-uuencode (path file-name)
  1721. (when (gnus-uu-post-encode-file "uuencode" path file-name)
  1722. (goto-char (point-min))
  1723. (forward-line 1)
  1724. (while (search-forward " " nil t)
  1725. (replace-match "`"))
  1726. t))
  1727. ;; Encodes with uuencode and adds MIME headers.
  1728. (defun gnus-uu-post-encode-mime-uuencode (path file-name)
  1729. (when (gnus-uu-post-encode-uuencode path file-name)
  1730. (gnus-uu-post-make-mime file-name "x-uue")
  1731. t))
  1732. ;; Encodes with base64 and adds MIME headers
  1733. (defun gnus-uu-post-encode-mime (path file-name)
  1734. (when (eq 0 (call-process shell-file-name nil t nil shell-command-switch
  1735. (format "%s %s -o %s" "mmencode" path file-name)))
  1736. (gnus-uu-post-make-mime file-name "base64")
  1737. t))
  1738. ;; Adds MIME headers.
  1739. (defun gnus-uu-post-make-mime (file-name encoding)
  1740. (goto-char (point-min))
  1741. (insert (format "Content-Type: %s; name=\"%s\"\n"
  1742. (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list)
  1743. file-name))
  1744. (insert (format "Content-Transfer-Encoding: %s\n\n" encoding))
  1745. (save-restriction
  1746. (set-buffer gnus-message-buffer)
  1747. (goto-char (point-min))
  1748. (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
  1749. (forward-line -1)
  1750. (narrow-to-region (point-min) (point))
  1751. (unless (mail-fetch-field "mime-version")
  1752. (widen)
  1753. (insert "MIME-Version: 1.0\n"))
  1754. (widen)))
  1755. ;; Encodes a file PATH with COMMAND, leaving the result in the
  1756. ;; current buffer.
  1757. (defun gnus-uu-post-encode-file (command path file-name)
  1758. (eq 0 (call-process shell-file-name nil t nil shell-command-switch
  1759. (format "%s %s %s" command path file-name))))
  1760. (defun gnus-uu-post-news-inews ()
  1761. "Posts the composed news article and encoded file.
  1762. If no file has been included, the user will be asked for a file."
  1763. (interactive)
  1764. (let (file-name)
  1765. (if gnus-uu-post-inserted-file-name
  1766. (setq file-name gnus-uu-post-inserted-file-name)
  1767. (setq file-name (gnus-uu-post-insert-binary)))
  1768. (gnus-uu-post-encoded file-name gnus-uu-post-threaded))
  1769. (setq gnus-uu-post-inserted-file-name nil)
  1770. (when gnus-uu-winconf-post-news
  1771. (set-window-configuration gnus-uu-winconf-post-news)))
  1772. ;; Asks for a file to encode, encodes it and inserts the result in
  1773. ;; the current buffer. Returns the file name the user gave.
  1774. (defun gnus-uu-post-insert-binary ()
  1775. (let ((uuencode-buffer-name "*uuencode buffer*")
  1776. file-path uubuf file-name)
  1777. (setq file-path (read-file-name
  1778. "What file do you want to encode? "))
  1779. (when (not (file-exists-p file-path))
  1780. (error "%s: No such file" file-path))
  1781. (goto-char (point-max))
  1782. (insert (format "\n%s\n" gnus-uu-post-binary-separator))
  1783. ;; #### Unix-specific?
  1784. (when (string-match "^~/" file-path)
  1785. (setq file-path (concat "$HOME" (substring file-path 1))))
  1786. ;; #### Unix-specific?
  1787. (if (string-match "/[^/]*$" file-path)
  1788. (setq file-name (substring file-path (1+ (match-beginning 0))))
  1789. (setq file-name file-path))
  1790. (unwind-protect
  1791. (if (with-current-buffer
  1792. (setq uubuf (gnus-get-buffer-create uuencode-buffer-name))
  1793. (erase-buffer)
  1794. (funcall gnus-uu-post-encode-method file-path file-name))
  1795. (insert-buffer-substring uubuf)
  1796. (error "Encoding unsuccessful"))
  1797. (kill-buffer uubuf))
  1798. file-name))
  1799. ;; Posts the article and all of the encoded file.
  1800. (defun gnus-uu-post-encoded (file-name &optional threaded)
  1801. (let ((send-buffer-name "*uuencode send buffer*")
  1802. (encoded-buffer-name "*encoded buffer*")
  1803. (top-string "[ cut here %s (%s %d/%d) %s gnus-uu ]")
  1804. (separator (concat mail-header-separator "\n\n"))
  1805. uubuf length parts header i end beg
  1806. beg-line minlen post-buf whole-len beg-binary end-binary)
  1807. (setq post-buf (current-buffer))
  1808. (goto-char (point-min))
  1809. (when (not (re-search-forward
  1810. (if gnus-uu-post-separate-description
  1811. (concat "^" (regexp-quote gnus-uu-post-binary-separator)
  1812. "$")
  1813. (concat "^" (regexp-quote mail-header-separator) "$"))
  1814. nil t))
  1815. (error "Internal error: No binary/header separator"))
  1816. (beginning-of-line)
  1817. (forward-line 1)
  1818. (setq beg-binary (point))
  1819. (setq end-binary (point-max))
  1820. (with-current-buffer
  1821. (setq uubuf (gnus-get-buffer-create encoded-buffer-name))
  1822. (erase-buffer)
  1823. (insert-buffer-substring post-buf beg-binary end-binary)
  1824. (goto-char (point-min))
  1825. (setq length (count-lines (point-min) (point-max)))
  1826. (setq parts (/ length gnus-uu-post-length))
  1827. (unless (< (% length gnus-uu-post-length) 4)
  1828. (incf parts)))
  1829. (when gnus-uu-post-separate-description
  1830. (forward-line -1))
  1831. (delete-region (point) (point-max))
  1832. (goto-char (point-min))
  1833. (re-search-forward
  1834. (concat "^" (regexp-quote mail-header-separator) "$") nil t)
  1835. (setq header (buffer-substring (point-min) (point-at-bol)))
  1836. (goto-char (point-min))
  1837. (when gnus-uu-post-separate-description
  1838. (when (re-search-forward "^Subject: " nil t)
  1839. (end-of-line)
  1840. (insert (format " (0/%d)" parts)))
  1841. (save-excursion
  1842. (message-send))
  1843. (setq gnus-uu-post-message-id (message-fetch-field "message-id")))
  1844. (save-excursion
  1845. (setq i 1)
  1846. (setq beg 1)
  1847. (while (not (> i parts))
  1848. (set-buffer (gnus-get-buffer-create send-buffer-name))
  1849. (erase-buffer)
  1850. (insert header)
  1851. (when (and threaded gnus-uu-post-message-id)
  1852. (insert "References: " gnus-uu-post-message-id "\n"))
  1853. (insert separator)
  1854. (setq whole-len
  1855. (- 62 (length (format top-string "" file-name i parts ""))))
  1856. (when (> 1 (setq minlen (/ whole-len 2)))
  1857. (setq minlen 1))
  1858. (setq
  1859. beg-line
  1860. (format top-string
  1861. (make-string minlen ?-)
  1862. file-name i parts
  1863. (make-string
  1864. (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-)))
  1865. (goto-char (point-min))
  1866. (when (re-search-forward "^Subject: " nil t)
  1867. (end-of-line)
  1868. (insert (format " (%d/%d)" i parts)))
  1869. (goto-char (point-max))
  1870. (with-current-buffer uubuf
  1871. (goto-char beg)
  1872. (if (= i parts)
  1873. (goto-char (point-max))
  1874. (forward-line gnus-uu-post-length))
  1875. (when (and (= (1+ i) parts) (< (count-lines (point) (point-max)) 4))
  1876. (forward-line -4))
  1877. (setq end (point)))
  1878. (insert-buffer-substring uubuf beg end)
  1879. (insert beg-line "\n")
  1880. (setq beg end)
  1881. (incf i)
  1882. (goto-char (point-min))
  1883. (re-search-forward
  1884. (concat "^" (regexp-quote mail-header-separator) "$") nil t)
  1885. (beginning-of-line)
  1886. (forward-line 2)
  1887. (when (re-search-forward
  1888. (concat "^" (regexp-quote gnus-uu-post-binary-separator) "$")
  1889. nil t)
  1890. (replace-match "")
  1891. (forward-line 1))
  1892. (insert beg-line)
  1893. (insert "\n")
  1894. (let (message-sent-message-via)
  1895. (save-excursion
  1896. (message-send))
  1897. (setq gnus-uu-post-message-id
  1898. (concat (message-fetch-field "references") " "
  1899. (message-fetch-field "message-id"))))))
  1900. (gnus-kill-buffer send-buffer-name)
  1901. (gnus-kill-buffer encoded-buffer-name)
  1902. (when (not gnus-uu-post-separate-description)
  1903. (set-buffer-modified-p nil)
  1904. (bury-buffer))))
  1905. (provide 'gnus-uu)
  1906. ;;; gnus-uu.el ends here