home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / a / atav11.zip / ATAVACHR.EL next >
Text File  |  1993-01-29  |  54KB  |  1,319 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;
  3. ;;                       An interface to the astro/math/physics preprint
  4. ;; Atavachron.el -\|/-   archives from within emacs giving the user 
  5. ;;                       commands to get, store, and process papers get
  6. ;;                       figures with ease.
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8. ;; Author          : Jim Hetrick
  9. ;; Created On      : Fri Jan 22 21:52:41 1993
  10. ;; Last Modified By: Jim Hetrick
  11. ;; Last Modified On: Thu Jan 28 21:23:05 1993
  12. ;; Update Count    : 7
  13. ;; Status          : Unknown, Use with caution!
  14. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  15. ;;  --- RCS ---
  16. ;; $Id: atavachron.el,v 1.2 1993/01/29 10:54:08 hetrick Exp $
  17. ;; $Log: atavachron.el,v $
  18. ;; Revision 1.2  1993/01/29  10:54:08  hetrick
  19. ;; Fixed spurious "X" in atv-Xinit-loc-dirs
  20. ;; shell-paper: append "/" to atv-shell-dir if needed
  21. ;;
  22. ;; Revision 1.1.1.1  1993/01/22  23:48:51  hetrick
  23. ;; shell-paper: asks for directory (default: atv-download-dir)
  24. ;; slice-and-dice: (atv-init-loc-dirs) + \\(.ps \\| .eps\\)
  25. ;;    bug: doesn't find right name for PS files < 20 lines
  26. ;;
  27. ;; Revision 1.1  1993/01/13  21:50:46  hetrick
  28. ;; Initial revision
  29. ;;
  30. ;; $Locker:  $
  31. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  32. ;; LCD Archive Entry:
  33. ;; Atavachron|James E. Hetrick|hetrick@phys.uva.nl|
  34. ;; An interface system to the astro/math/physics preprint archives|
  35. ;; 13-1-93|$Revision: 1.2 $|~/interfaces/atavachron.tar.Z|
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. ;;;
  38. ;;; Copyright (C) 1992, 1993  James E. Hetrick 
  39. ;;; 
  40. ;;; This program is free software; you can redistribute it and/or modify
  41. ;;; it under the terms of the GNU General Public License as published by
  42. ;;; the Free Software Foundation.
  43. ;;;
  44. ;;; This program is distributed in the hope that it will be useful,
  45. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  46. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  47. ;;; GNU General Public License for more details.
  48. ;;;
  49. ;;; A copy of the GNU General Public License can be obtained from
  50. ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
  51. ;;; 02139, USA.
  52. ;;;
  53. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  54. ;
  55. ; =======              The Atavachron         -\|/-       =========
  56. ;
  57. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  58. ;
  59. ; The Atavachron is a system for interacting with the preprint
  60. ; archives from within emacs. It gives the user a simple set of commands
  61. ; which can be called from the mini-buffer (M-x) to get, store, and list
  62. ; and process papers. It can be loaded into to your .emacs file
  63. ; by including one of these lines therein:
  64. ;
  65. ;  (load-file '"atavachron.el")     or
  66. ;  (load-library '"atavachron")     if you put it in your emacs load path.
  67. ;
  68. ; You might also want to byte-compile it.
  69. ;
  70. ; The atavachron's commands are listed here and described 
  71. ; below (-Functions-):
  72. ;
  73. ;    get-paper               : get paper above point
  74. ;    get-paper-from-data     : prompt for paper-archive/number
  75. ;    store-paper             : store directly to disk
  76. ;    store-paper-from-data   : as above, from paper data
  77. ;    process-paper           : process locally stored paper
  78. ;    slice-and-dice          : remove appended PostScript files
  79. ;    shell-paper             : shell region below #!/bin/ 
  80. ;    get-listing-from-data   : get monthly title listing
  81. ;    store-listing-from-data : store listing
  82. ;    get-abstract            : get abstract
  83. ;    get-abstract-from-data  : prompt for number, get abstract
  84. ;    interesting             : append abstract to atv-interesting-file
  85. ;    atavachron-mail         : report bugs with internal variable dump
  86. ;
  87. ; Please go through the -Configuration- and -Batteries Not Included- 
  88. ; sections (see manual or below) and set things appropriately for your 
  89. ; system. Note that the documentation here is meant to be somewhat 
  90. ; pedagogical for users new to emacs.
  91. ;
  92. ; If you find bugs, please report them; this is very easy with the
  93. ; function "atavachron-mail". You can also use this function for other
  94. ; correspondence as well... :-)
  95. ;
  96. ; Thanks very much to Paul Ginsparg, Greg Kilcup, Marcus Speh,
  97. ; and Bas de Bakker for many suggestions and beta tests.
  98. ;
  99. ; _____________________________________________________________
  100. ; James E. Hetrick            Institute for Theoretical Physics
  101. ; hetrick@phys.uva.nl                    -\|/-
  102. ;
  103. ; University of Amsterdam
  104. ; Valckenierstraat 65, 1018 XE Amsterdam
  105. ; Telephone: +31 20 525 5772     Fax: +31 20 525 5788
  106. ; _____________________________________________________________
  107. ;
  108. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  109. ;
  110. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  111. ;
  112. ;  The Atavachron:        -Configuration-              -\|/-
  113. ;
  114. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  115. ;
  116. ; Sample .emacs: (see manual or defvars below)
  117. ; --------------------.emacs-------------------------------
  118. ;
  119. ;@example
  120. ; ====================.emacs stuff ========================
  121. ;
  122. ;(load-library '"ange-ftp")  ;see ange-ftp docs for more details
  123. ;(setq ange-ftp-generate-anonymous-password t) ; sends email address
  124. ;                                              ; for password
  125. ;(load-library '"zcat")
  126. ;(load-library '"atavachron")
  127. ;
  128. ;(setq atv-main-ftp-site "/anonymous\@@babbage.sissa.it:") ;Europeans
  129. ;;(setq atv-main-ftp-site "/anonymous\@@xxx.lanl.gov:")  ;N+S Americans
  130. ;
  131. ;(setq atv-download-dir "~/tex/preprints/")   ;default download directory 
  132. ;(setq atv-uufiles-dir "~/tex/preprints/")    ;default place for uu output
  133. ;(setq atv-prompt-filename t)              ;prompt to rename paper locally
  134. ;(setq atv-interesting-file "~/interesting.atv") ;file for interesting abs.
  135. ;(setq atv-auto-tex-paper nil)     ;run tex on paper grabbed automatically
  136. ;(setq atv-auto-tex-command 'TeX-buffer)        ;command to run on buffer
  137. ;(setq atv-no-csh nil)                     ;set to t if you don't have csh
  138. ;
  139. ; ==========================================================
  140. ;@end example
  141. ;........................................................................
  142. ;
  143. ;       =================
  144. (defvar atv-main-ftp-site "/anonymous\@babbage\.sissa\.it:"  
  145. ;       =================
  146. "Your main archive. Papers on hep-lat, alg-geom, etc. are
  147. automatically gotten from their respective archives, while branches
  148. not supported at xxx.lanl.gov, such as cond-mat, are retrieved from
  149. babbage.sissa.it. In your .emacs file put:
  150.  
  151.  setq atv-main-ftp-site \"/anonymous\@babbage\.sissa\.it:\" for  Europeans
  152.      or                                                    (others chose)
  153.  setq atv-main-ftp-site \"/anonymous\@xxx\.lanl\.gov:\"  for  N+S Americans
  154. ")
  155. ;.........................................................................
  156. ;       ================
  157. (defvar atv-download-dir "~/tex/preprints/"
  158. ;       ================
  159. "This is your local download workspace: If you have branch
  160. directories  hep-th, hep-lat, astro-ph, etc. below atv-download-dir,
  161. papers, when saved, will automatically be put there, sorted by
  162. branch. For example, your atv-download-dir is set to \"~/tex/preprints/\"
  163. and you have the subdirs \"~/tex/preprints/hep-th/\" and
  164. \"~/tex/preprints/cond-mat/\". Then getting hep-th/91120013 will put the 
  165. file in tex/preprints/hep-th/. Getting cond-mat/920106 will put it in 
  166. tex/preprints/cond-mat/. If these subdirs do not exist below 
  167. tex/preprints/, both papers would be put in tex/preprints/.
  168.  
  169. Put this directory in your TEXINPUTS environment variable also!
  170. Then tex can get at your newly grabbed files.")
  171. ;..........................................................................
  172. ;
  173. ;       ===============
  174. (defvar atv-uufiles-dir atv-download-dir
  175. ;       ===============
  176. "This is where uufiles (figures) will be unpacked. It should 
  177. usually be the same as atv-download-dir, unless you have a good
  178. reason to put the figs elsewhere [your dvi->ps processor can't 
  179. get at them in atv-download-dir, for instance. (in which case you
  180. should get dvips)]. If it's the same as atv-download-dir, it will
  181. adjust itself to the subdirectory structure following atv-download-dir.")
  182. ;..........................................................................
  183. ;
  184. ;       ===================
  185. (defvar atv-prompt-filename t         ; prompt to rename paper locally
  186. ;       ===================           ; t = true, nil = false
  187. "This one toggles prompting for a name of the grabbed paper or 
  188. listing. When t, you are prompted to name the incoming archive
  189. file which is then appended with .tex. Hitting return at the prompt will
  190. accept the default given in parenthesis.
  191.  
  192. Example: the point is located in the abstract or listing 
  193. of Witten's paper hep-th/9204083. If atv-prompt-filename is t, 
  194. Doing M-x get-paper, asks:
  195.  
  196. \"Local name for paper? [.tex appended] (9204083): \"
  197.  
  198. Typing \"witten\", renames this paper as witten.tex. Simply hitting 
  199. [return], preserves it's archive name as 9204083.tex")
  200. ;...........................................................................
  201. ;       ====================
  202. (defvar atv-interesting-file "~/interesting\.atv"  ; file for interesting
  203. ;       ====================                      ; abstracts.
  204. "Default file to which abstracts stored with \"interesting\" function 
  205. are appended.")
  206. ;...........................................................................
  207. ;
  208. ;       ==================
  209. (defvar atv-auto-tex-paper nil 
  210.     "If t, run tex on grabbed paper automatically.")
  211. (defvar atv-auto-tex-command 'TeX-buffer
  212. ;       ====================
  213. "Setting \"atv-auto-tex-paper\" to t, automatically starts the tex
  214. processor in \"atv-auto-tex-command\" on the paper once it's loaded
  215. into a local buffer, provided no shell command signal is found. The
  216. function pointed to here is then a hook for custom processing of
  217. the grabbed paper.")
  218. ;...........................................................................
  219. ;
  220. ;       ==========
  221. (defvar atv-no-csh nil 
  222. ;       ==========
  223. "Set to t if you don't have csh. No guarantees...")
  224. ;...........................................................................
  225. ;
  226. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  227. ;
  228. ;  The Atavachron:      -Batteries not included-           -\|/-
  229. ;
  230. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  231. ;
  232. ; Other files and packages needed or recommended:
  233. ;
  234. ;         ange-ftp.el  (not included)   --- [needed]
  235. ;         zcat.el   (included at end)   --- [needed for month+ old papers] 
  236. ;        .netrc    (see below)          --- [highly recommended]
  237. ;        .dvipsrc  (see below)          --- [highly recommended]
  238. ;
  239. ;.....................................................................
  240. ;
  241. ; >>>  ange-ftp.el      (available from prep.ai.mit.edu)
  242. ; atavachron.el requires Andy Norman's, essential, ftp interface 
  243. ; ange-ftp.el to do the remote file teleportation. If you don't have
  244. ; this loaded in your .emacs file,...! (check locally if you have
  245. ; it, or download it from prep.ai.mit.edu)
  246. ;
  247. ;.....................................................................
  248. ;
  249. ; >>>  zcat.el          (Included in distribution)
  250. ;
  251. ; Another file needed is Graham Gough's zcat.el which uncompresses
  252. ; .Z files on the fly. This makes loading older papers which are
  253. ; compressed at the archive transparent. Since it's short it is included 
  254. ; with the Atavachron package.
  255. ;
  256. ;.....................................................................
  257. ;
  258. ; >>>  .netrc           (write your own, see example: "---.netrc---")
  259. ;
  260. ; Ange-ftp will work much smoother if you keep a .netrc file in your 
  261. ; home directory, thus bypassing the need to send the "anonymous" login
  262. ; and email address when ftping into the archive. Simply clip out the
  263. ; following and name it ~/.netrc (don't forget to take out the ;'s
  264. ; and put your email address in for you@where.you.are).
  265. ;
  266. ; ---------------------------.netrc---------------------------
  267. ;machine ftp.scri.fsu.edu login anonymous password you@where.you.are
  268. ;machine xxx.lanl.gov login anonymous password you@where.you.are
  269. ;machine babbage.sissa.it login anonymous password you@where.you.are
  270. ;machine publications.math.duke.edu login anonymous password you@@where.you.are
  271. ;machine alcom-p.cwru.edu login anonymous password you@@where.you.are
  272. ; ------------------------------------------------------------
  273. ;
  274. ; Furthermore, it must be a protected file. Run: "chmod go-rwx .netrc"
  275. ; on it once created.
  276. ;
  277. ;.....................................................................
  278. ;
  279. ; >>>  .dvipsrc        (write your own, see example: "---.dvipsrc---")
  280. ;
  281. ; Finally, if you use dvips as your .dvi->.ps processor, put your
  282. ; atv-uufiles-dir (see -Configuration-) in its path by keeping
  283. ; a ~/.dvipsrc file with the following lines:
  284. ;
  285. ; --------------------------.dvipsrc--------------------------
  286. ;S ~/tex/preprints:
  287. ;H ~/tex/preprints:
  288. ;W "reading your .dvipsrc file"
  289. ; ------------------------------------------------------------
  290. ;
  291. ; Having atv-uufiles-dir both in your dvips path and your TEXINPUTS 
  292. ; environment variable allows allows dvi and tex to access your 
  293. ; figure files. The trailing :'s above add the default paths.
  294. ;
  295. ; For more info, see your man pages on tex and dvips or your system 
  296. ; administrator, whichever is friendlier.
  297. ;
  298. ;.....................................................................
  299. ;
  300. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  301. ;
  302. ;  The Atavachron:    -Functions-                    -\|/-
  303. ;
  304. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  305. ;
  306. ;    get-paper
  307. ;    get-paper-from-data
  308. ;
  309. ; When reading a daily abstract listing in emacs, either in one of the 
  310. ; mail readers or just as a file, placing the point (cursor) anywhere 
  311. ; in the abstract of choice and typing:  
  312. ;
  313. ;      (M-x)  get-paper    
  314. ;
  315. ; automatically opens an ftp channel to the right archive (via ange-ftp),
  316. ; transfers the paper, uncompresses it if necessary (via zcat.el), 
  317. ; and loads it into a tex-mode buffer. Once in the local buffer, the paper
  318. ; is ready for processing via the usual tex-mode facilities, C-c C-b for 
  319. ; (la)texing, C-c C-p for printing, or any other local tex or auc-tex 
  320. ; features, such as previewing.
  321. ;
  322. ; If the Atavachron finds the PostScript printer signal %! it will try 
  323. ; to extricate the tex file and the appended PostScript figures,
  324. ; by slicing them off into appropriate files. Of course, it saves the
  325. ; whole file first as "localname.tpl", before hacking away under 
  326. ; prompting. [see * Slice-and-dice]
  327. ;
  328. ; If it finds shell commands beginning with ^#!.*/bin/ it will shell out 
  329. ; the region from there to the end, producing a report "localname.rpt" 
  330. ; buffer of any shell output. This is handy to see what was just unpacked 
  331. ; in your download directory. If it finds a .tex file in this report, 
  332. ; it is loaded in tex-mode.
  333. ;
  334. ; Similarly atavachron will try to unpack a .tar.Z file if the archived
  335. ; preprint turns out to be in this form.
  336. ;
  337. ; * Multiple files: *
  338. ;
  339. ; With the advent of the Paul Ginsparg's "uufiles" function (available
  340. ; in the macros) to package figures, data files, and other auxiliary 
  341. ; files, the occurance of "all-in-one" papers will hopefully deminish. 
  342. ;
  343. ; If the Atavachron finds multiple (sequentially numbered) files at the 
  344. ; archive, it will first try process these as uuencoded figure files 
  345. ; (as produced by uufiles). If they are true uufiles, they are unpacked 
  346. ; and a report "localname.rpt" is shown. The paper (papernum.1) is then 
  347. ; loaded in tex-mode.
  348. ;
  349. ; If the mutiple files are not uufiles, they are each gotten to a buffer,
  350. ; with sequential integer extensions "localname.n". A *Buffer List* is 
  351. ; produced from which they can be acted upon.   
  352. ;
  353. ; Note that the buffer(s) containing the paper are marked as changed
  354. ; so that you will be prompted to save it if you try to delete it.
  355. ;
  356. ; Similarly, get-paper-from-data, prompts the user for a preprint
  357. ; number of the form: hep-lat/9211003, then goes away and loads this
  358. ; preprint, performing the above steps.
  359. ;  
  360. ;.....................................................................
  361. ;
  362. ;    store-paper
  363. ;    store-paper-from-data
  364. ;
  365. ; Store-paper, and store-paper-from-data, work like get-paper and 
  366. ; get-paper-from-data resp. for input data, but the paper is stored 
  367. ; directly in the user's default download directory (set below in 
  368. ; -Configuration-), for later processing with [* "process-paper"]. 
  369. ; This is convenient when reading the abstracts remotely (on
  370. ; the weekend from home, say) when one wants to save processing and
  371. ; printing the tex file for later, or so that the file can be further
  372. ; downloaded via modem.
  373. ;
  374. ;.....................................................................
  375. ;
  376. ;    process-paper
  377. ;    slice-and-dice
  378. ;    shell-paper
  379. ;
  380. ; "process-paper" performs the steps described in [* get-paper] for
  381. ; unpacking, shelling, and uudecoding the stored paper as if it was
  382. ; just "gotten" from the archive.
  383. ;
  384. ; "slice-and-dice" is the function called by "get-paper" and 
  385. ; "process-paper" when they find appended PostScript. It goes to 
  386. ; the beginning of the buffer and trys to cut off PostScript
  387. ; figures one by one. It's provided as a standalone function as
  388. ; a utility.
  389. ;
  390. ; "shell-paper" extracts the region below "^#!.*/bin/" to the file
  391. ; "buffer-name", then runs "sh buffer-name". The echoed output
  392. ; of this shell is collected and shown in the buffer "localname.rpt". 
  393. ;.....................................................................
  394. ;
  395. ;    get-listing-from-data
  396. ;    store-listing-from-data
  397. ;    get-abstract
  398. ;    get-abstract-from-data
  399. ;
  400. ; Get-listing-from-data and store-listing-from-data work the same way,
  401. ; except on title listings. They prompt the user for the listing
  402. ; in the usual format: hep-th/9204, then "get" (to a buffer),
  403. ; or "store" (to a file) the given month's listing. 
  404. ;
  405. ; Note that if the listing is gotten with get-listing-from-data into
  406. ; a buffer, then "get-paper" will work in that buffer as in the daily
  407. ; abstract list. Simply put the cursor on the paper of interest (AFTER
  408. ; the line beginning with "Paper:" and type M-x get-paper. 
  409. ;
  410. ; Get-abstract(-from-data) are the equivalent functions for abstracts,
  411. ; and are useful to read the abstract of a title gotten with 
  412. ; get-listing-from-data, etc.
  413. ;.....................................................................
  414. ;
  415. ;    interesting
  416. ; The point of "interesting" is to save having to 'save' the
  417. ; whole mail file which caontains an interesting abstract. 
  418. ; "interesting" will prompt for a filename (offering atv-interesting-file
  419. ; as the default), then append the paper and abstract of choice (in
  420. ; which the point is located) to that file. Papers thus saved can
  421. ; be gotten with "get-paper" in the usual way.
  422. ;
  423. ;.....................................................................
  424. ;
  425. ;    atavachron-mail
  426. ;
  427. ; This handy function allows you to easily send a bug report, 
  428. ; comment, or question to the author. It opens a mail buffer
  429. ; addressed to me and dumps a few current variables which will be 
  430. ; useful reconstructing the situation if you wish to report a bug.
  431. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  432. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  433. ;
  434. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  435. ;    The Atavachron:    -End of Source File Documentation-     -\|/-    
  436. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  437.  
  438.  
  439. (provide 'atavachron)
  440. (require 'ange-ftp)
  441.  
  442. (setq atv-A "NONE") (setq atv-C "NONE") (setq atv-E "NONE") 
  443. (setq atv-bogus-uu "NONE") (setq atv-branch "NONE") 
  444. (setq atv-buf-height "NONE") (setq atv-chpd-figs "NONE") 
  445. (setq atv-dir "NONE") (setq atv-dirs-eq "NONE")
  446. (setq atv-dot-2 "NONE") (setq atv-dot-Z "NONE") 
  447. (setq atv-dot-ind "NONE") (setq atv-dot-tar "NONE") 
  448. (setq atv-fig-name "NONE") (setq atv-fig-name-guess "NONE")
  449. (setq atv-file-complet "NONE") (setq atv-first-file "NONE") 
  450. (setq atv-ftp-site "NONE") (setq atv-i "NONE") (setq atv-ii "NONE")
  451. (setq atv-loc-fullname "NONE") (setq atv-loc-name "NONE") 
  452. (setq atv-more-figs "NONE") (setq atv-multi-1 "NONE") 
  453. (setq atv-n "NONE") (setq atv-n-files "NONE") (setq atv-name "NONE")
  454. (setq atv-name-stub "NONE") (setq atv-nth "NONE") 
  455. (setq atv-org-buf-name "NONE") (setq atv-paperno "NONE") 
  456. (setq atv-proc-stub "NONE") (setq atv-remote-complet "NONE") 
  457. (setq atv-remote-ith "NONE") (setq atv-shell-dir "NONE")
  458. (setq atv-shelled-tex "NONE") (setq atv-shelled-tex-n "NONE") 
  459. (setq atv-sh-command "NONE") (setq atv-slash "NONE") 
  460. (setq atv-uuget-no "NONE") (setq atv-whole-data "NONE") 
  461. (setq atv-yymm "NONE")
  462.  
  463.  
  464. (defun atv-make-stub (atv-stub-full)
  465.    (if (string-match "\\." atv-stub-full)
  466.       (progn 
  467.      (setq atv-dot-ind (match-beginning 0))
  468.          (setq atv-name-stub (substring atv-stub-full 0 atv-dot-ind)))
  469.          (setq atv-name-stub atv-stub-full)))
  470.  
  471. (defun atv-get-name (atv-get-name-prompt atv-get-default atv-get-name-suffix)
  472.    (setq atv-name (read-string atv-get-name-prompt))
  473.    (if (not (string= atv-name ""))
  474.        (setq atv-loc-name (concat atv-name atv-get-name-suffix)) 
  475.        (setq atv-loc-name (concat atv-get-default atv-get-name-suffix)))
  476.    (atv-make-stub atv-loc-name)
  477.    (setq atv-name ""))
  478.  
  479. (defun atv-shrink-to-fit ()
  480.    (interactive)
  481.    (goto-char (point-max))
  482.    (setq atv-buf-height (count-lines (window-start) (point)))
  483.    (if (< atv-buf-height (window-height))
  484.       (if (> atv-buf-height window-min-height)
  485.          (shrink-window (- (window-height) atv-buf-height 1))
  486.      (shrink-window (- (window-height) window-min-height))))
  487.    (goto-char (point-min)))
  488.  
  489. (defun atv-var-to-string (atv-trans-var)
  490.   (cond
  491.      ((stringp atv-trans-var) (format atv-trans-var))
  492.      ((integerp atv-trans-var) (int-to-string atv-trans-var))
  493.      ((if (eq atv-trans-var t) (format "t")))
  494.      ((if (eq atv-trans-var nil) (format "nil")))))
  495.  
  496. (defun interesting ()
  497.     (interactive)
  498.     (save-excursion
  499.       (re-search-backward "^Paper.*: ")
  500.       (previous-line 2)
  501.       (set-mark (point))
  502.       (forward-line 2)
  503.       (if (re-search-forward "\\\\\\\\")
  504.          (if (re-search-forward "\\\\\\\\") (sit-for 0 1)))
  505.       (exchange-point-and-mark)
  506.     (atv-get-name (concat "Append to? (" atv-interesting-file "): ")
  507.          atv-interesting-file "")
  508.     (append-to-file (mark) (point) atv-loc-name)))
  509.  
  510. (defun atv-extract-data-from-buffer ()
  511.     (re-search-backward "^Paper.*: ")
  512.     (re-search-forward ": ")
  513.     (setq atv-A (point))
  514.     (re-search-forward "/")
  515.     (setq atv-branch (buffer-substring atv-A (point)))
  516.     (setq atv-ftp-site atv-main-ftp-site)
  517.     (setq atv-ftp-site (cond 
  518.               ((string= "hep-lat/" atv-branch)
  519.                "/anonymous\@ftp\.scri\.fsu\.edu:")
  520.           ((string= "alg-geom/" atv-branch)
  521.            "/anonymous@publications\.math\.duke\.edu:")
  522.           ((string= "lc-om/" atv-branch)
  523.            "/anonymous\@alcom-p\.cwru\.edu:")
  524.               ((or (string= "astro-ph/" atv-branch)
  525.                    (string= "cond-mat/" atv-branch)
  526.                    (string= "funct-an/" atv-branch)
  527.                    (string= "math-ph/" atv-branch))
  528.            "/anonymous\@babbage\.sissa\.it:")
  529.               (atv-ftp-site))) 
  530.     (setq atv-A (point))
  531.     (forward-char 4)
  532.     (setq atv-yymm (buffer-substring atv-A (point)))
  533.     (end-of-line)
  534.     (setq atv-paperno (buffer-substring atv-A (point)))
  535.     (setq atv-dir (concat atv-ftp-site atv-branch "papers/" atv-yymm "/")))
  536.  
  537. (defun atv-ask-bozo-for-data (atv-listing)
  538.    (if (eq atv-listing t)
  539.       (setq atv-whole-data (read-string
  540.          "Enter branch/yymm [ex: hep-lat/9211]: ")) 
  541.       (setq atv-whole-data (read-string
  542.              "Enter paper number [format: cond-mat/9211003]: ")))
  543.    (string-match "/" atv-whole-data)
  544.    (setq atv-slash (match-beginning 0))
  545.    (setq atv-branch (substring atv-whole-data 0 (+ atv-slash 1))) 
  546.    (setq atv-ftp-site atv-main-ftp-site)
  547.    (setq atv-ftp-site (cond 
  548.               ((string= "hep-lat/" atv-branch)
  549.                "/anonymous\@ftp\.scri\.fsu\.edu:")
  550.           ((string= "alg-geom/" atv-branch)
  551.            "/anonymous@publications\.math\.duke\.edu:")
  552.           ((string= "lc-om/" atv-branch)
  553.            "/anonymous\@alcom-p\.cwru\.edu:")
  554.               ((or (string= "astro-ph/" atv-branch)
  555.                    (string= "cond-mat/" atv-branch)
  556.                    (string= "funct-an/" atv-branch)
  557.                    (string= "math-ph/" atv-branch))
  558.            "/anonymous\@babbage\.sissa\.it:")
  559.               (atv-ftp-site)))
  560.     (setq atv-yymm (substring atv-whole-data (+ atv-slash 1) (+ atv-slash 5)))
  561.     (setq atv-paperno (substring atv-whole-data (+ atv-slash 1)))
  562.     (if (eq atv-listing t)
  563.       (setq atv-dir (concat atv-ftp-site atv-branch "listings/")) 
  564.       (setq atv-dir (concat atv-ftp-site atv-branch "papers/" atv-yymm "/"))))
  565.  
  566. (defun atv-init-loc-dirs ()
  567. ; *** append "/"
  568.       (if (not (string= (substring atv-download-dir -1) "/"))
  569.      (setq atv-download-dir (concat atv-download-dir "/")))
  570.       (if (not (string= (substring atv-uufiles-dir -1) "/"))
  571.      (setq atv-uufiles-dir (concat atv-uufiles-dir "/")))
  572. ; *** atv-download-dir =? atv-uufiles-dir
  573.       (if (string= atv-download-dir atv-uufiles-dir)
  574.      (setq atv-dirs-eq t))
  575. ; *** Check existence of atv-download-dir
  576.       (if (not (file-directory-p atv-download-dir))
  577.          (progn 
  578.        (message (concat 
  579.               "Default download dir: " 
  580.       atv-download-dir " doesn't exist! ...I'm setting it to: ~/"))
  581.        (sit-for 3 1)
  582.        (setq atv-download-dir "~/")))
  583. ; *** Check for branches below local atv-download-dir
  584.       (setq atv-download-dir 
  585.           (cond ((file-directory-p (concat atv-download-dir atv-branch))
  586.                    (concat atv-download-dir atv-branch))
  587.                 (atv-download-dir)))
  588.       (if (eq atv-dirs-eq t) (setq atv-uufiles-dir atv-download-dir)))
  589.  
  590. (defun atv-chop-figs ()
  591.   (message "Entering slice and dice mode...")
  592.   (sit-for 1 1)
  593.   (atv-init-loc-dirs)
  594.   (setq atv-org-buf-name (buffer-name (current-buffer)))
  595.   (set-visited-file-name (concat atv-download-dir atv-name-stub "\.tpl"))
  596.   (save-buffer)
  597.   (message (concat "Whole original is saved in: " atv-download-dir 
  598.        (buffer-name (current-buffer))))
  599.   (sit-for 2 1)
  600.   (save-excursion 
  601.     (switch-to-buffer (concat atv-name-stub "\.figs"))
  602.     (set-visited-file-name (concat atv-download-dir atv-name-stub "\.figs"))
  603.     (insert-string (concat
  604. " * -\\|/- The Atavachron  (1.1) * \n"
  605. "Below are the PostScript figures extracted from: " atv-name-stub "\.tex\n"
  606. "-----------------------------------------------\n")))
  607.   (beginning-of-line)
  608.   (setq atv-E (point))
  609.   (end-of-line)
  610.   (setq atv-chpd-figs 0)
  611.   (setq atv-more-figs t)
  612.   (while (eq atv-more-figs t)
  613.     (progn 
  614.       (beginning-of-line)
  615.       (setq atv-C (point))
  616.       (previous-line 20)
  617.       (if (re-search-forward "\\([-a-zA-Z0-9\_]+\\(\\.ps\\|\\.eps\\)\\)"
  618.                  atv-C t nil)
  619.        (setq atv-fig-name-guess 
  620.          (buffer-substring (match-beginning 1) (match-end 1)))
  621.        (setq atv-fig-name-guess "* NONE FOUND *"))
  622.       (goto-char atv-C)
  623.       (set-mark (point))
  624.       (end-of-line)
  625.       (if (re-search-forward "^\%\!" nil t nil)
  626.      (beginning-of-line)
  627.      (progn (goto-char (point-max)) (setq atv-more-figs nil)))
  628.       (exchange-point-and-mark)
  629.       (setq atv-fig-name (read-string (concat
  630.      "Name of figure file below this point? ("
  631.      atv-fig-name-guess "): ")))
  632.       (if (string= atv-fig-name "")
  633.      (setq atv-fig-name atv-fig-name-guess))
  634.       (exchange-point-and-mark)
  635.       (write-region (mark) (point) (concat atv-uufiles-dir atv-fig-name))
  636.       (message (concat "Extracted " atv-fig-name))
  637.       (save-excursion
  638.     (switch-to-buffer (concat atv-name-stub "\.figs"))
  639.     (goto-char (point-max))
  640.     (insert-string (concat atv-fig-name "\n")))
  641.       (sit-for 2 1)
  642.       (setq atv-chpd-figs (1+ atv-chpd-figs))
  643.       (end-of-line)))
  644.     (pop-to-buffer (concat atv-name-stub "\.figs"))
  645.     (save-buffer)
  646.     (atv-shrink-to-fit)
  647.     (pop-to-buffer (concat atv-name-stub "\.tpl"))
  648.     (message (concat "Surgery complete: " 
  649.              atv-chpd-figs " figure(s) removed.   Good Luck..."))
  650.     (sit-for 2 1)
  651.     (goto-char atv-E)
  652.     (set-mark (point))
  653.     (kill-region (mark) (point-max))
  654.     (goto-char (point-min))
  655.     (rename-buffer atv-org-buf-name))
  656.  
  657. (defun slice-and-dice ()
  658.   (interactive)
  659.   (goto-char (point-min))
  660.   (re-search-forward "^\%\!" nil t nil)
  661.   (atv-chop-figs))
  662.  
  663. (defun atv-type-check (atv-type-dir atv-type-name)
  664.       (atv-init-loc-dirs)
  665. ; *** find all remote files matching paper name in type-dir
  666.       (setq atv-remote-complet 
  667.         (file-name-all-completions atv-type-name atv-type-dir))
  668. ; *** remove abstract and check file completion list for types:
  669.       (setq atv-i 0)
  670.       (setq atv-dot-Z nil)
  671.       (setq atv-dot-2 nil)
  672.       (setq atv-dot-tar nil)
  673.       (setq atv-file-complet (make-list 0 ""))
  674.       (while (< atv-i (length atv-remote-complet))
  675.          (progn 
  676.         (setq atv-remote-ith (elt atv-remote-complet atv-i))
  677.             (if (or (< (length atv-remote-ith) 4)
  678.                     (not (string= (substring atv-remote-ith -4 nil)
  679.                                "\.abs")))
  680.            (progn
  681.                  (setq atv-file-complet
  682.                       (cons atv-remote-ith atv-file-complet))
  683.          (if (and (not atv-dot-Z) 
  684.              (string-match "\.Z" atv-remote-ith))
  685.                 (setq atv-dot-Z t))
  686.          (if (and (not atv-dot-2) 
  687.              (string-match (concat atv-type-name "\.2") atv-remote-ith))
  688.                 (setq atv-dot-2 t))
  689.          (if (and (not atv-dot-tar) 
  690.              (string-match (concat atv-type-name "\.tar\.Z") 
  691.                                              atv-remote-ith))
  692.                 (setq atv-dot-tar t))))
  693.             (setq atv-i (1+ atv-i))))
  694.       (setq atv-n-files (length atv-file-complet))
  695.       (setq atv-first-file (elt atv-file-complet 0)))
  696.  
  697. (defun atv-proc-unique (atv-u-dir atv-u-name atv-u-loc atv-listing)
  698. ;---Setup local file:---
  699.             (atv-make-stub atv-u-name)
  700.             (if (and (eq atv-prompt-filename t) (not (eq atv-u-loc t)))
  701.                (atv-get-name 
  702.                   (concat "Local name for paper? [.tex appended] (" 
  703.               atv-name-stub "): ") atv-name-stub "\.tex")
  704.               (setq atv-loc-name (concat atv-name-stub "\.tex")))
  705. ;---Get remote:---
  706.             (find-file-other-window (concat atv-u-dir atv-first-file))
  707.             (if (not (string= atv-loc-name (buffer-name (current-buffer))))
  708.                (rename-buffer atv-loc-name))
  709.             (if (string= (substring atv-loc-name -2 nil) "\.Z")
  710.                 (rename-buffer 
  711.                    (substring atv-loc-name 0 
  712.                   (- (length atv-loc-name) 2))))
  713.         (set-visited-file-name (concat atv-download-dir 
  714.                        (buffer-name (current-buffer)))) 
  715. ;---Have a peek:---
  716.             (if (not (eq atv-listing t)) 
  717.               (progn
  718.                 (cond 
  719. ;    ---#!/bin/shell ouch! (--> atv-shell-out-buf)
  720.                   ((and (goto-char (point-min))
  721.                      (re-search-forward "^\#\!.*/bin" nil t nil))
  722.              (progn
  723.                        (if (y-or-n-p 
  724.              "Primary file contains shell commands. Unpack? ")
  725.               (progn
  726.                 (atv-shell-out-buf atv-download-dir 
  727.                          (concat atv-name-stub "\.sh")
  728.                          atv-name-stub t)
  729.                 (goto-char (point-min))
  730.                 (next-line 3)
  731.                 (setq atv-shelled-tex-n 0)
  732.                 (while (re-search-forward 
  733.                  "\\([-a-zA-Z0-9\_]+\\.tex\\)" nil t nil)
  734.                    (progn
  735.                                    (setq atv-shelled-tex
  736.                     (buffer-substring (match-beginning 1) 
  737.                               (match-end 1)))
  738.                  (setq atv-shelled-tex-n 
  739.                                      (1+ atv-shelled-tex-n))))
  740.                    (if (eq atv-shelled-tex-n 1)
  741.                  (find-file-other-window
  742.                     (concat atv-download-dir atv-shelled-tex)))
  743.                                (if (eq atv-shelled-tex-n 1)
  744.                      (progn 
  745.                    (message (concat
  746.              "Can't find any tex file in shell echo output: " 
  747.              atv-name-stub "\.rpt"))
  748.                    (sit-for 3 1)
  749.                    (message (concat
  750.                  "Check file: " 
  751.                  atv-name-stub "\.sh  manually"))))))))
  752. ;---Appended PostScript: chop chop (--> atv-chop-figs)
  753.                   ((and (goto-char (point-min))
  754.                      (re-search-forward "^\%\!" nil t nil))
  755.                        (progn 
  756.              (message 
  757.    "Looks like there are appended PostScript figures...")
  758.              (sit-for 2 1)
  759.              (if (y-or-n-p 
  760.    "Shall I surgically remove the figures? ")
  761.                 (progn
  762.                    (atv-chop-figs)
  763.                    (tex-mode)
  764.                    (if (eq atv-auto-tex-paper t) 
  765.                    (funcall atv-auto-tex-command)))
  766.                 (message "I understand..."))))
  767. ;---Regular old fashioned paper:---
  768.                   (t (progn
  769.                      (tex-mode)
  770.                      (if (eq atv-auto-tex-paper t) 
  771.             (funcall atv-auto-tex-command))))))))
  772.  
  773. (defun shell-paper ()
  774.    (interactive)
  775.    (atv-init-loc-dirs)
  776.    (setq atv-name (read-string 
  777.            (concat "Directory for shell operation? (" atv-download-dir
  778.                    "): ")))
  779.    (if (not (string= atv-name ""))
  780.        (setq atv-shell-dir atv-name) 
  781.        (setq atv-shell-dir atv-download-dir))
  782.    (if (not (string= (substring atv-shell-dir -1) "/"))
  783.        (setq atv-shell-dir (concat atv-shell-dir "/")))
  784.    (atv-make-stub (buffer-name (current-buffer)))
  785.    (atv-shell-out-buf atv-shell-dir (buffer-name (current-buffer))
  786.              atv-name-stub t))
  787.  
  788. (defun atv-shell-out-buf (atv-sh-dir atv-sh-file atv-sh-rpt atv-show-rpt)
  789.    (goto-char (point-min))
  790.    (if (re-search-forward "^\#\![ \t]*\\(.*/bin/.*\\)$" nil t)
  791.       (progn
  792.         (setq atv-sh-command (buffer-substring (match-beginning 1)
  793.                            (match-end 1)))
  794.     (beginning-of-line)
  795.         (if (and (eq atv-no-csh t) (search-forward "bin/csh"))
  796.            (progn                  ;  takes #!/bin/csh
  797.               (backward-char 3)    ;      --->  #!/bin/sh
  798.           (delete-char 1)      ;  for those lacking csh
  799.               (beginning-of-line)
  800.               (setq atv-sh-command "/bin/sh")))
  801.         (write-region (point) (point-max) (concat atv-sh-dir atv-sh-file))
  802.         (message "Executing shell script...")
  803.         (shell-command (concat "cd " atv-sh-dir "; "
  804.                          atv-sh-command " " atv-sh-file))
  805.         (set-buffer-modified-p nil)
  806.         (bury-buffer)))
  807.         (pop-to-buffer "*Shell Command Output*")
  808.         (rename-buffer (concat atv-sh-rpt "\.rpt"))
  809.         (goto-char (point-min))
  810.         (insert-string (concat
  811. " * -\\|/- The Atavachron  (1.1) * \n"
  812. "This is the output of: " atv-sh-command " " atv-sh-dir atv-sh-file "\n"
  813. "Below should be a manifest of the enclosed files (or shell output):\n"
  814. "------------------------------------------------------------------\n"))
  815.         (set-visited-file-name (concat atv-sh-dir 
  816.                    (buffer-name (current-buffer)))) 
  817.     (atv-shrink-to-fit)
  818.         (if (not (eq atv-show-rpt t))
  819.        (progn 
  820.               (save-buffer)
  821.               (kill-buffer (current-buffer))
  822.               (delete-window))))
  823.  
  824. (defun atv-get-and-store (atv-s-dir atv-s-name atv-s-listing)  
  825. ; *** assumes previous call to atv-type-check
  826.     (if (and (eq atv-prompt-filename t) (not (eq atv-s-listing t)))
  827.        (atv-get-name 
  828.           (concat "Local name for paper? (" atv-paperno 
  829.           "): ") atv-paperno "") 
  830.        (setq atv-loc-name atv-paperno))
  831.     (cond 
  832. ;--- check that something matched paper number at archive
  833.       ((not (stringp atv-first-file))
  834.          (message (concat "No files match: " atv-s-dir atv-s-name)))
  835.  
  836. ;--- unique: (plain or .Z)
  837.       ((and (eq atv-n-files 1) (not (eq atv-dot-tar t)))
  838.         (if (eq atv-dot-Z t)
  839.        (progn
  840.              (copy-file (concat atv-s-dir atv-first-file) 
  841.               (concat atv-download-dir atv-loc-name "\.Z") 1)
  842.          (message (concat "Copied " atv-download-dir atv-loc-name "\.Z")))
  843.        (progn
  844.          (copy-file (concat atv-s-dir atv-first-file) 
  845.               (concat atv-download-dir atv-loc-name) 1)
  846.          (message (concat "Copied " atv-download-dir atv-loc-name)))))
  847. ;--- unique: tarred remote
  848.          ((eq atv-dot-tar t)
  849.        (progn
  850.              (copy-file (concat atv-s-dir atv-first-file) 
  851.               (concat atv-download-dir atv-loc-name "\.tar\.Z") 1)
  852.          (message (concat "Copied " atv-loc-name "\.tar\.Z"))))
  853. ;--- uufigs (.2,...)
  854.    ((eq atv-dot-2 t)
  855.      (progn
  856.     (setq atv-n 1)
  857.     (setq atv-uuget-no 0)
  858.     (while (<= atv-n atv-n-files)
  859.       (progn
  860.         (setq atv-ii 0)
  861.         (while (< atv-ii atv-n-files)
  862.           (progn
  863. ;    >--- file matches "atv-s-name.n"
  864.         (if (string-match
  865.              (concat atv-s-name "\." (int-to-string atv-n))
  866.                   (elt atv-file-complet atv-ii))
  867.            (progn
  868.              (if (eq atv-dot-Z t)
  869.             (copy-file (concat atv-s-dir atv-s-name "\." 
  870.                        (int-to-string atv-n) "\.Z")
  871.                            (concat atv-download-dir atv-loc-name "\." 
  872.                        (int-to-string atv-n) "\.Z") 1)
  873.                 (copy-file (concat atv-s-dir atv-s-name "\." 
  874.                        (int-to-string atv-n))
  875.                        (concat atv-download-dir atv-loc-name "\." 
  876.                        (int-to-string atv-n)) 1))
  877.           (setq atv-uuget-no (1+ atv-uuget-no))))
  878.                   (setq atv-ii (1+ atv-ii))))
  879.            (setq atv-n (1+ atv-n))))
  880.      (message (concat "Copied " atv-uuget-no " files."))))
  881.  
  882. ;--- distributed in more than 2 files (!?!)
  883.          ((and (> atv-n-files 2) (not (eq atv-dot-2 t)))
  884.             (if (y-or-n-p (concat 
  885.                  "Paper distributed in " 
  886.                   (int-to-string atv-n-files) 
  887.                  " files without integer suffices!  Continue? "))
  888.             (progn
  889.            (message 
  890.              "Copying--- (archive filenames are preserved since I'm confused)")
  891.                (sit-for 3 1)
  892.            (setq atv-i 0)
  893.                (while (< atv-i atv-n-files)
  894.          (setq atv-nth (elt atv-file-complet atv-i))
  895.          (message (concat "Copying: " atv-nth))
  896.          (sit-for 1 1)
  897.          (setq atv-i (1+ atv-i))
  898.          (copy-file (concat atv-dir atv-nth) 
  899.                    (concat atv-download-dir atv-nth))))))
  900.        (t (message 
  901.    "BOGUS!: Can't decide what to do... (report bug with atavachron-mail)")))
  902.     (if (not (eq atv-s-listing t))
  903.        (progn (sit-for 2 1)
  904.        (message (concat "Use \"process-paper\" on \"" atv-loc-name
  905.              "\" at your convenience..."))))) 
  906.  
  907.  
  908. (defun atv-untar (atv-t-dir atv-t-file atv-t-stub atv-t-suffix atv-tarview)
  909. ;            untar:   dir,  file,  name stub, add "suffix",   |
  910. ;                                                 if t keep output in view
  911.    (message "Untarring...")
  912.    (shell-command (concat "cd " atv-t-dir "; "
  913.           "zcat " atv-t-file " | tar -xvf -"))
  914.    (pop-to-buffer "*Shell Command Output*")
  915.    (rename-buffer (concat atv-t-stub atv-t-suffix))
  916.    (goto-char (point-min))
  917.    (insert-string (concat
  918. " * -\\|/- The Atavachron  (1.1) * \n"
  919. "This is the output of: zcat " atv-t-dir atv-t-file " | tar -xvf - \n"
  920. "Below should be a manifest of the enclosed files:\n"
  921. "------------------------------------------------\n"))
  922.    (set-visited-file-name (concat atv-t-dir 
  923.                    (buffer-name (current-buffer)))) 
  924.    (save-buffer)
  925.    (atv-shrink-to-fit)
  926.    (if (not (eq atv-tarview t))
  927.       (progn
  928.     (kill-buffer (current-buffer))
  929.     (delete-window))))
  930.  
  931. (defun atv-get-and-proc (atv-g-dir atv-g-name atv-g-loc atv-listing)
  932. ;--- assumes call to atv-type-check to set atv-n-files, etc.
  933. ; *** GET file:
  934. ;               * unique:
  935. ;        - tarred? 
  936. ;               * distributed:
  937. ;        - uufigs (.2,...)
  938. ;        - other (?!)
  939.  
  940.     (atv-make-stub atv-g-name)
  941.     (cond 
  942. ;--- check that something matched paper number at archive
  943.       ((not (stringp atv-first-file))
  944.          (message (concat "No files match: " atv-g-dir atv-g-name)))
  945.  
  946. ;--- unique: readable (plain or .Z)
  947.       ((and (eq atv-n-files 1) (not (eq atv-dot-tar t))) 
  948.            (atv-proc-unique atv-g-dir atv-g-name atv-g-loc atv-listing))
  949.  
  950.  
  951. ;--- unique: tarred remote
  952.          ((and (eq atv-n-files 1) (eq atv-dot-tar t))
  953.       (if (not (eq atv-g-loc t))
  954.        (progn
  955.               (message
  956.                 (concat "Paper is archived: " atv-first-file))
  957.           (sit-for 1 1)
  958.               (if (eq atv-prompt-filename t)
  959.                 (atv-get-name 
  960.            (concat "Rename incoming tarfile? [.tar.Z appended] (" 
  961.                atv-g-name "): ") atv-g-name "\.tar\.Z") 
  962.         (setq atv-loc-name atv-first-file))
  963.           (setq atv-loc-fullname (concat atv-download-dir atv-loc-name))
  964.           (message "Copying...")
  965.               (copy-file (concat atv-g-dir atv-first-file) atv-loc-fullname 1)
  966.           (message (concat "Copied " atv-loc-fullname))
  967.           (if (y-or-n-p "Unpack tarfile now? ")
  968.                (atv-untar atv-download-dir atv-loc-name atv-name-stub "\.rpt" t)
  969.            (message (concat "Use \"process-paper\" on \"" atv-name-stub
  970.                 "\" at your convenience..."))))
  971.        (progn
  972.          (message (concat 
  973.                "File is tarred: " atv-g-name ".tar.Z; Unpacking..."))
  974.          (sit-for 2 1)
  975.          (atv-untar atv-g-dir (concat atv-g-name "\.tar\.Z")
  976.                atv-g-name "\.rpt" t))))
  977.  
  978. ; Distributed: Figures (atv-paperno.2, or more)
  979.  
  980.    ((eq atv-dot-2 t)
  981.      (progn
  982.        (message (concat 
  983.  "Paper distributed in " atv-n-files " files."))
  984.        (sit-for 2 1)
  985.        (if (and (eq atv-prompt-filename t) (not (eq atv-g-loc t)))
  986.           (atv-get-name 
  987.              (concat "Local name for files? [.tex or .n appended] (" 
  988.               atv-name-stub "): ") atv-name-stub "")
  989.           (setq atv-loc-name atv-name-stub))
  990.        (message "Checking for uu-encoded figures or files...")
  991.        (sit-for 2 1)
  992.        (setq atv-n 2)
  993.        (setq atv-uuget-no 0)
  994.        (setq atv-bogus-uu nil)
  995.        (while (<= atv-n atv-n-files)
  996.       (progn
  997.         (setq atv-ii 0)
  998.         (while (< atv-ii atv-n-files)
  999.           (progn
  1000. ;  --- file matches "atv-g-name.n"
  1001.         (if (string-match
  1002.              (concat atv-g-name "\." (int-to-string atv-n))
  1003.                   (elt atv-file-complet atv-ii))
  1004.            (progn
  1005.              (if (eq atv-dot-Z t)
  1006.             (find-file (concat atv-g-dir atv-g-name "\." 
  1007.                        (int-to-string atv-n) "\.Z"))
  1008.                 (find-file (concat atv-g-dir atv-g-name "\." 
  1009.                        (int-to-string atv-n))))
  1010.           (setq atv-uuget-no (1+ atv-uuget-no))
  1011.  
  1012. ; --- process suspected uufile:
  1013.         (goto-char (point-min))
  1014.       (if (search-forward "file created by csh script  uufiles" nil t)
  1015.          (progn
  1016.                 (if (not (string= 
  1017.                  (concat atv-name-stub  "\." (int-to-string atv-n))
  1018.          (buffer-name (current-buffer))))
  1019.                    (rename-buffer (concat atv-name-stub "\." 
  1020.                        (int-to-string atv-n))))
  1021.         (set-visited-file-name (concat atv-uufiles-dir 
  1022.                        (buffer-name (current-buffer)))) 
  1023.             (previous-line 1)
  1024.         (beginning-of-line)
  1025.         (if (looking-at "#!/bin/csh -f.*")
  1026.             (progn
  1027.               (message "unpacking uufile...")
  1028.               (if (eq atv-no-csh t)
  1029.                          (progn                 ;  takes #!/bin/csh
  1030.                (forward-char 7)     ;      --->  #!/bin/sh
  1031.                (delete-char 1)      ;  for those lacking csh
  1032.                (beginning-of-line)))
  1033.               (write-region (point) (point-max) 
  1034.                 (concat atv-uufiles-dir atv-loc-name 
  1035.                     "\." (int-to-string atv-n)))
  1036.               (shell-command (concat "cd " atv-uufiles-dir "; "
  1037.                          "sh " atv-loc-name "\."  (int-to-string atv-n)))
  1038.                       (set-buffer-modified-p nil)
  1039.               (bury-buffer)))
  1040.         (pop-to-buffer "*Shell Command Output*")
  1041.         (rename-buffer (concat atv-loc-name 
  1042.                        (int-to-string atv-n) "\.rpt"))
  1043.         (goto-char (point-min))
  1044.         (insert-string (concat
  1045. " * -\\|/- The Atavachron  (1.1) * \n"
  1046. "This is the output of: sh " atv-branch atv-paperno "\." 
  1047. (int-to-string atv-n) "\n"
  1048. "Below should be a manifest of the enclosed files:\n"
  1049. "------------------------------------------------\n"))
  1050.         (set-visited-file-name (concat atv-uufiles-dir 
  1051.                        (buffer-name (current-buffer)))) 
  1052.         (save-buffer)
  1053.                 (atv-shrink-to-fit))
  1054.  
  1055.              (progn
  1056.                 (message (concat atv-loc-name "\." (int-to-string atv-n)
  1057.        " is not a uufile;  Please process by hand."))
  1058.                 (sit-for 3 1)
  1059.                 (setq atv-bogus-uu t)
  1060.                 (if (not (string= 
  1061.           (concat atv-loc-name "\." (int-to-string atv-n))
  1062.               (buffer-name (current-buffer))))
  1063.                   (rename-buffer 
  1064.                         (concat atv-loc-name "\." (int-to-string atv-n))))
  1065.         (set-visited-file-name (concat atv-uufiles-dir 
  1066.                        (buffer-name (current-buffer))))))))
  1067.        (setq atv-ii (1+ atv-ii))))
  1068.      (setq atv-n (1+ atv-n))))
  1069. ; ---- and finally the paper: paperno.1
  1070.                 (if (not (eq atv-bogus-uu t))
  1071.                    (progn
  1072.                       (message "Figures processed, getting paper...")
  1073.                       (setq atv-multi-1 "\.tex"))
  1074.                    (setq atv-multi-1 "\.1"))
  1075.                 (if (eq atv-dot-Z t)
  1076.                   (find-file-other-window (concat atv-g-dir atv-g-name "\.1\.Z"))
  1077.           (find-file-other-window (concat atv-g-dir atv-g-name "\.1")))
  1078.         (if (not (string= (concat atv-loc-name atv-multi-1) 
  1079.                                             (buffer-name (current-buffer))))
  1080.            (rename-buffer (concat atv-loc-name atv-multi-1)))
  1081.                 (if (and (> (length atv-loc-name) 1) 
  1082.                          (string= (substring atv-loc-name -2 nil) "\.Z"))
  1083.                    (rename-buffer 
  1084.                        (substring atv-loc-name 0 
  1085.                   (- (length atv-loc-name) 2))))
  1086.             (set-visited-file-name (concat atv-download-dir 
  1087.                       (buffer-name (current-buffer))))
  1088.                 (if (eq atv-bogus-uu t)
  1089.                    (progn
  1090.                       (list-buffers)
  1091.                       (atv-shrink-to-fit)
  1092.                       (sit-for 0)
  1093.                       (if (> atv-uuget-no 1)
  1094.                          (message (concat "Also fetched " 
  1095.                                 (int-to-string atv-uuget-no) 
  1096.                          " other unprocessed files;  see *Buffer List*"))
  1097.                          (message (concat "Also fetched: " atv-loc-name 
  1098.             "\.2  (see *Buffer List*);  please process files manually.")))
  1099.                       (sit-for 4 1))
  1100.                       (setq atv-bogus-uu nil))
  1101.                 (cond 
  1102.                   ((and (goto-char (point-min))
  1103.                      (re-search-forward "^\%\!" nil t nil))
  1104.                        (message (concat
  1105.                                 "Primary file contains PostScript! "
  1106.                                 "Try \"slice-and-dice\" [see documentation]")))
  1107.                   ((and (goto-char (point-min))
  1108.                  (re-search-forward "^\#\!.*/bin" nil t nil))
  1109.                        (message (concat 
  1110.                                 "Primary file contains shell commands! "
  1111.                                 "Try \"shell-paper\" [see documetation]")))
  1112.                   ((not (eq atv-bogus-uu t))
  1113.                      (progn
  1114.                        (tex-mode) 
  1115.                        (if (eq atv-auto-tex-paper t) 
  1116.                           (progn (sit-for 2 1) 
  1117.                             (funcall atv-auto-tex-command))))))))
  1118.  
  1119. ; ------------ distributed in non-integer .ext files (?)
  1120.          ((and (> atv-n-files 2) (not (eq atv-dot-2 t)))
  1121.             (if (y-or-n-p (concat 
  1122.                  "Paper distributed in " 
  1123.                   (int-to-string atv-n-files) 
  1124.                  " files without integer suffices!  Continue? "))
  1125.             (progn
  1126.            (message 
  1127.      "Copying--- (archive filenames are preserved since I'm a bit confused)")
  1128.                (sit-for 3 1)
  1129.            (setq atv-i 0)
  1130.                (while (< atv-i atv-n-files)
  1131.          (setq atv-nth (elt atv-file-complet atv-i))
  1132.          (message (concat "Copying: " atv-nth))
  1133.          (sit-for 1 1)
  1134.          (setq atv-i (1+ atv-i))
  1135.          (copy-file (concat atv-dir atv-nth) 
  1136.                    (concat atv-download-dir atv-nth))))))
  1137.        (t (message 
  1138.    "BOGUS!: Can't decide what to do... (report bug with atavachron-mail)")))) 
  1139.  
  1140. (defun get-paper ()
  1141. "--------- searches backward to the first occurance of the regexp
  1142. \"^Paper.*: \", and extracts the paper data from the buffer. This
  1143. paper is then gotten from the appropriate archive using ange-ftp.
  1144. tex-mode is loaded in the buffer, and the buffer and visited file
  1145. names are renamed appropriately."
  1146.    (interactive)
  1147.    (atv-extract-data-from-buffer)
  1148.    (atv-type-check atv-dir atv-paperno)
  1149.    (atv-get-and-proc atv-dir atv-paperno nil nil))
  1150.  
  1151. (defun process-paper ()
  1152. "------------- prompts for a local paper name (such as Smith, Jones-A,
  1153. or 9212001), and processes the file(s) exactly as would \"getting\"
  1154. them with *get-paper. Thus appended PostScript is extracted, uufiles
  1155. decoded, or tar files unpacked, depending on the paper format of the
  1156. stored files. Works only on papers stored in atv-download-dir."
  1157.   (interactive)
  1158.   (setq atv-proc-stub (read-string 
  1159.       "Name of stored paper? [without suffix]: "))
  1160.   (setq atv-name-stub atv-proc-stub)
  1161.   (atv-type-check atv-download-dir atv-proc-stub)
  1162.   (atv-get-and-proc atv-download-dir atv-proc-stub t nil))
  1163.  
  1164. (defun get-paper-from-data ()
  1165. "------------------- prompts the user for the paper data
  1166. in the usual form: hep-th/9204083
  1167. This paper is then gotten from the appropriate archive using
  1168. ange-ftp.  tex-mode is loaded in the buffer, and the buffer and
  1169. visited file names are renamed appropriately."
  1170.    (interactive)
  1171.    (atv-ask-bozo-for-data nil)
  1172.    (atv-type-check atv-dir atv-paperno)
  1173.    (atv-get-and-proc atv-dir atv-paperno nil nil))
  1174.  
  1175. (defun get-listing-from-data ()
  1176. "--------------------- gets a month's titles from input of the 
  1177. form: hep-th/9204. Once this listing is loaded, get-paper can be 
  1178. run on any paper, provided the point (cursor) is below the line
  1179. beginning with \"Paper\""
  1180.    (interactive)
  1181.    (atv-ask-bozo-for-data t)
  1182.    (atv-type-check atv-dir atv-paperno)
  1183.    (atv-get-and-proc atv-dir atv-paperno nil t))
  1184.  
  1185. (defun store-paper ()
  1186. "----------- searches backward to the first occurance of the regexp
  1187. \"^Paper.*: \", and extracts the paper data from the buffer. This
  1188. paper is then gotten from the appropriate archive using ange-ftp.
  1189. The paper is stored in the directory given by atv-download-dir, or
  1190. the appropriate subdir (hep-th, hep-lat, etc.) if it exists."
  1191.    (interactive)
  1192.    (atv-extract-data-from-buffer)
  1193.    (atv-type-check atv-dir atv-paperno)
  1194.    (atv-get-and-store atv-dir atv-paperno nil))
  1195.  
  1196. (defun store-paper-from-data ()
  1197. "--------------------- prompts the user for the paper data
  1198. in the usual form: hep-th/9204083
  1199. This paper is then gotten from the appropriate archive using
  1200. ange-ftp. The paper is stored in the directory given by atv-download-dir, 
  1201. or the appropriate subdir (hep-th, hep-lat, etc.) if it exists." 
  1202.    (interactive)
  1203.    (atv-ask-bozo-for-data nil)
  1204.    (atv-type-check atv-dir atv-paperno)
  1205.    (atv-get-and-store atv-dir atv-paperno nil))
  1206.  
  1207. (defun store-listing-from-data () 
  1208. "----------------------- gets a month's titles from input of 
  1209. the form: hep-th/9204, and stores it in atv-download-dir."
  1210.    (interactive) 
  1211.    (atv-ask-bozo-for-data t)
  1212.    (atv-type-check atv-dir atv-paperno)
  1213.    (atv-get-and-store atv-dir atv-paperno t))
  1214.  
  1215. (defun get-abstract () 
  1216. "--------- searches backward to the first occurance of the regexp
  1217. \"^Paper.*: \", and extracts the paper data from the buffer.
  1218. This paper's abstract is then gotten to a separate window."
  1219.    (interactive) 
  1220.    (atv-extract-data-from-buffer)
  1221.    (find-file-other-window (concat atv-dir atv-paperno "\.abs")))
  1222.  
  1223. (defun get-abstract-from-data () 
  1224. "----------------------- gets a paper's abstract from input of 
  1225. the form: hep-lat/9212005."
  1226.    (interactive) 
  1227.    (atv-ask-bozo-for-data nil)
  1228.    (find-file-other-window (concat atv-dir atv-paperno "\.abs")))
  1229.  
  1230. (defun atavachron-mail ()
  1231. "------------- opens a *Mail* buffer addressed to the author of 
  1232. atavachron.el (Jim Hetrick, hetrick@phys.uva.nl), dumps some environment 
  1233. variables and current atv- variables for reconstructing bugs, and leaves
  1234. the point after \"User comments:\", for entering correspondence."
  1235.   (interactive)
  1236.   (mail nil "hetrick@phys\.uva\.nl" "Atavachron-* report")
  1237.   (goto-char (point-max))
  1238.   (insert-string (concat 
  1239. "
  1240.  * -\\|/- The Atavachron (v1.1) *  == Automatic System Report ==
  1241.  
  1242.  User Comments:
  1243.  
  1244.  
  1245.  
  1246.  
  1247. ................................................................
  1248.  >  user: " (user-full-name) "
  1249.  >  machine: " (system-name) "
  1250.  >  system type: " (symbol-name (symbol-value 'system-type)) "
  1251.  >  emacs version: " (emacs-version) "
  1252.  >  environment: 
  1253.     - TERM: " (or (getenv "TERM") "") "
  1254.     - SHELL: " (or (getenv "SHELL") "") "
  1255.     - TEXINPUTS: " (or (getenv "TEXINPUTS") (getenv "TEX_INPUTS") "") "
  1256.  >  main archive: " atv-main-ftp-site "
  1257.  >  most recent paper:
  1258.     - site:   " atv-ftp-site  "
  1259.     - branch: " atv-branch "
  1260.     - number: " atv-paperno "
  1261.     - full: " atv-paperno "
  1262.  >  local download dir: " atv-download-dir "
  1263.  >  local paper name: " atv-loc-name "
  1264.  >  Internal:
  1265. (atv-var-to-string atv-A) "::"
  1266. (atv-var-to-string atv-C) "::"
  1267. (atv-var-to-string atv-E) "::"
  1268. (atv-var-to-string atv-bogus-uu) "::\n"
  1269. (atv-var-to-string atv-branch) "::"
  1270. (atv-var-to-string atv-buf-height) "::"
  1271. (atv-var-to-string atv-chpd-figs) "::"
  1272. (atv-var-to-string atv-dir) "::\n"
  1273. (atv-var-to-string atv-dirs-eq) "::"
  1274. (atv-var-to-string atv-dot-2) "::"
  1275. (atv-var-to-string atv-dot-Z) "::"
  1276. (atv-var-to-string atv-dot-ind) "::\n"
  1277. (atv-var-to-string atv-dot-tar) "::"
  1278. (atv-var-to-string atv-fig-name) "::"
  1279. (atv-var-to-string atv-fig-name-guess) "::"
  1280. (atv-var-to-string atv-file-complet) "::\n"
  1281. (atv-var-to-string atv-first-file) "::"
  1282. (atv-var-to-string atv-ftp-site) "::"
  1283. (atv-var-to-string atv-i) "::"
  1284. (atv-var-to-string atv-ii) "::\n"
  1285. (atv-var-to-string atv-loc-fullname) "::"
  1286. (atv-var-to-string atv-loc-name) "::"
  1287. (atv-var-to-string atv-more-figs) "::"
  1288. (atv-var-to-string atv-multi-1) "::\n"
  1289. (atv-var-to-string atv-n) "::"
  1290. (atv-var-to-string atv-n-files) "::"
  1291. (atv-var-to-string atv-name) "::"
  1292. (atv-var-to-string atv-name-stub) "::\n"
  1293. (atv-var-to-string atv-nth) "::"
  1294. (atv-var-to-string atv-org-buf-name) "::"
  1295. (atv-var-to-string atv-paperno) "::"
  1296. (atv-var-to-string atv-proc-stub) "::\n"
  1297. (atv-var-to-string atv-remote-complet) "::"
  1298. (atv-var-to-string atv-remote-ith) "::"
  1299. (atv-var-to-string atv-shell-dir) "::"
  1300. (atv-var-to-string atv-shelled-tex) "::\n"
  1301. (atv-var-to-string atv-shelled-tex-n) "::"
  1302. (atv-var-to-string atv-sh-command) "::"
  1303. (atv-var-to-string atv-shelled-tex-n) "::"
  1304. (atv-var-to-string atv-slash) "::\n"
  1305. (atv-var-to-string atv-uuget-no) "::"
  1306. (atv-var-to-string atv-whole-data) "::"
  1307. (atv-var-to-string atv-yymm) "::"
  1308. ))
  1309. (goto-char (point-min))
  1310. (search-forward "User comments")
  1311. (next-line 2)
  1312. (insert-string "       "))
  1313.