home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume38 / annote / part01 next >
Text File  |  1993-06-20  |  76KB  |  1,834 lines

  1. Newsgroups: comp.sources.misc
  2. From: arrouye@cosmos.imag.fr (Yves Arrouye)
  3. Subject: v38i005: annote - BibTeX styles supporting annotations, v1.5.1, Part01/04
  4. Message-ID: <csm-v38i005=annote.135536@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: d1fc33bb7d38c818c596af8f26976d65
  6. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  7. Organization: IMAG Institute, University of Grenoble
  8. Date: Thu, 17 Jun 1993 18:55:55 GMT
  9. Approved: kent@sparky.imd.sterling.com
  10.  
  11. Submitted-by: arrouye@cosmos.imag.fr (Yves Arrouye)
  12. Posting-number: Volume 38, Issue 5
  13. Archive-name: annote/part01
  14. Environment: LaTex
  15. Supersedes: annote: Volume 37, Issue 57-59
  16.  
  17. This is version 1.5.1 of the `annote' package for BibTeX styles supporting 
  18. annotations.
  19.  
  20. The package is intended to facilitate the use of annotated bibliographies
  21. by enabling one to modify ``normal'' BibTeX styles in order to support
  22. an `annote' field (like is available in Bibcard). The advantages of
  23. this package over existing annotated bibliographies are twofold: users can
  24. easily customize the annotation layout, and existing BibTeX styles can
  25. be automatically modified in order to support the `annote' package.
  26.  
  27. Styles for BibTeX may be developped using the conventions of this
  28. package, or existing style files may be converted to these
  29. conventions. Automatic conversion of the files is available through
  30. two interactive Emacs functions.
  31.   
  32. The `annotated' BibTeX styles support listing the bibliographies in
  33. annotated or non-annotated forms without any further modifications;
  34. instead, the user can include a style file defining his preferred
  35. layout of annotations and use it on her bibliography. This layout is
  36. easily modified by using a simple LaTeX \renewcommand.
  37.  
  38. This release contains the `annote' package and some example BibTeX
  39. styles, including the ones bundled with the LaTeX distribution (i.e.
  40. `plain.bst', `alpha.bst', `unsrt.bst' and `abbrv.bst'); these BibTeX
  41. styles were all modified to support `annote', some by hand when
  42. annotebib.el wasn't wrote, the other with annotebib.el.
  43.  
  44. Simple documentation is in the `annote.README' file.
  45.  
  46. Yves Arrouye <arrouye@imag.imag.fr>
  47. June, 1993
  48. ---------------
  49. #! /bin/sh
  50. # This is a shell archive.  Remove anything before this line, then unpack
  51. # it by saving it into a file and typing "sh file".  To overwrite existing
  52. # files, type "sh file -c".  You can also feed this as standard input via
  53. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  54. # will see the following message at the end:
  55. #        "End of shell archive."
  56. # Contents:  NEWS ANNOUNCE README IDEAS ChangeLog annotebib.add
  57. #   Makefile sample.tex sample.bib compile-annote.el annotebib.el
  58. #   annote.sty commentaire.sty
  59. # Wrapped by arrouye@cosmos on Tue Jun  8 13:47:06 1993
  60. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  61. if test -f 'NEWS' -a "${1}" != "-c" ; then 
  62.   echo shar: Will not clobber existing file \"'NEWS'\"
  63. else
  64. echo shar: Extracting \"'NEWS'\" \(1272 characters\)
  65. sed "s/^X//" >'NEWS' <<'END_OF_FILE'
  66. XThis file documents changes between distributions of annotebib.
  67. X
  68. XVersion 1.5  Second post (patch). This release is the first really
  69. X         "stable" version of annotebib (it contains big
  70. X         changes/improvements, but future patches will not be as
  71. X         big as this one).
  72. X
  73. X           Support for multiple annotation fields. This was
  74. X             possible in the BibTeX styles, but no automated supported
  75. X             was provided in the Emacs Lisp package.
  76. X               Functions to remove annotation fields from an annotated
  77. X             style (in a buffer or a file).
  78. X           Support to write a LaTeX style.
  79. X               Functions to automate the modification (annotation or
  80. X             unannotation) of a bunch of BibTeX styles, and to write
  81. X             the associated LaTeX style files.
  82. X           Much better error handling, better default values,
  83. X             confirmation asked for overwriting or other potentially
  84. X             dangerous things.
  85. X           For some functions (annote-make-*, annote-*file*),
  86. X         errors triggered by called functions are summarized in the
  87. X             annote-errors variable after execution (actually, it is a
  88. X         quick hack that will be improved in a future release).
  89. X
  90. XVersion 1.0  Initial post.
  91. X
  92. X
  93. XYves Arrouye
  94. Xarrouye@imag.imag.fr
  95. END_OF_FILE
  96. if test 1272 -ne `wc -c <'NEWS'`; then
  97.     echo shar: \"'NEWS'\" unpacked with wrong size!
  98. fi
  99. # end of 'NEWS'
  100. fi
  101. if test -f 'ANNOUNCE' -a "${1}" != "-c" ; then 
  102.   echo shar: Will not clobber existing file \"'ANNOUNCE'\"
  103. else
  104. echo shar: Extracting \"'ANNOUNCE'\" \(1767 characters\)
  105. sed "s/^X//" >'ANNOUNCE' <<'END_OF_FILE'
  106. XAnnouncing the v1.5 `annote' package for BibTeX styles supporting annotations
  107. X-----------------------------------------------------------------------------
  108. X
  109. XThe package is intended to facilitate the use of annotated bibliographies
  110. Xby enabling one to modify ``normal'' BibTeX styles in order to support
  111. Xan `annote' field (like is available in Bibcard). The advantages of
  112. Xthis package over existing annotated bibliographies are twofold: users can
  113. Xeasily customize the annotation layout, and existing BibTeX styles can
  114. Xbe automatically modified in order to support the `annote' package.
  115. X
  116. XStyles for BibTeX may be developped using the conventions of this
  117. Xpackage, or existing style files may be converted to these
  118. Xconventions.
  119. X  An Emacs Lisp package is distributed to help making changes to the
  120. XBibTeX styles (add or remove annotation fields) and to generate
  121. Xappropriate LaTeX styles in order to print the annotations.
  122. X  Releases past v1.0 have support for more than one annotation field
  123. Xin a BibTeX style.
  124. X  
  125. XThe `annotated' BibTeX styles support listing the bibliographies in
  126. Xannotated or non-annotated forms without any further modifications;
  127. Xinstead, the user can include a style file defining his preferred
  128. Xlayout for a given annotation field and use it on her bibliography.
  129. XThis layout is easily modified by using a simple LaTeX \renewcommand.
  130. X
  131. XThis release contains the `annote' package and some example BibTeX
  132. Xstyles, including the ones bundled with the LaTeX distribution (i.e.
  133. X`plain.bst', `alpha.bst', `unsrt.bst' and `abbrv.bst'); these BibTeX
  134. Xstyles were all modified to support `annote', some by hand when
  135. Xannotebib.el wasn't wrote, the other with annotebib.el.
  136. X
  137. XSimple documentation is in the `README' file.
  138. X
  139. XYves Arrouye <arrouye@imag.imag.fr>
  140. XMay, 1993
  141. END_OF_FILE
  142. if test 1767 -ne `wc -c <'ANNOUNCE'`; then
  143.     echo shar: \"'ANNOUNCE'\" unpacked with wrong size!
  144. fi
  145. # end of 'ANNOUNCE'
  146. fi
  147. if test -f 'README' -a "${1}" != "-c" ; then 
  148.   echo shar: Will not clobber existing file \"'README'\"
  149. else
  150. echo shar: Extracting \"'README'\" \(1868 characters\)
  151. sed "s/^X//" >'README' <<'END_OF_FILE'
  152. XThis is the ``annote'' package, which provides a simple and convenient
  153. Xway to add support for annotated bibliographies to LaTeX.
  154. X
  155. XThis package provides you with:
  156. X
  157. X  1. A generic way to add annotation capacities to your BibTeX styles.
  158. X
  159. X  2. An automated way of modifying your existing files.
  160. X
  161. X  3. A style of annotations which can be redefined by the user.
  162. X
  163. X
  164. XTo make the package work, one has to make the following steps:
  165. X
  166. X  1. Change the .bst files to add support for annotation. This is done
  167. X     by adding the annote field in the ENTRY list, adding the
  168. X     format.annote function to the style file, and changing the
  169. X     fin.entry (or the corresponding entry-closing function) by adding
  170. X     a call to format.annote at the end of the function, followed by a
  171. X     write$ call.
  172. X       See the "annotebib.add" file for the source of the modifications.
  173. X
  174. X     * This step can be automated on most bibliography styles with the
  175. X     use of the `annotebib.el' functions. It is the preferred (and
  176. X     painless) way to make such modifications.
  177. X
  178. X  2. Install "annote.sty" in one of your LaTeX directories (one which
  179. X     is listed in the TEXINPUTS environment variable).
  180. X
  181. X  3. Use it! Just add annote to your \documentstyle options when you
  182. X     need it, or define the annote environment in your document, or
  183. X     make that definition (the one you prefer, of course) a new .sty
  184. X     file...
  185. X
  186. X       For example, to have annotations printed as quotations in
  187. X     emphasized typeface, just say
  188. X
  189. X      \newenvironment{annote}{\begin{quotation}\em}{\end{quotation}}
  190. X
  191. X     in your document, before the \bibliography statement.
  192. X
  193. X  NOTE. The modifications here use the "annote" field of the .bib
  194. X        file, which can be easily edited with BibCard (menu "View",
  195. X        item "Annotation..."), but one can easily change that field.
  196. X
  197. X
  198. XYves Arrouye (arrouye@imag.imag.fr)
  199. XMay 12, 1993
  200. X
  201. END_OF_FILE
  202. if test 1868 -ne `wc -c <'README'`; then
  203.     echo shar: \"'README'\" unpacked with wrong size!
  204. fi
  205. # end of 'README'
  206. fi
  207. if test -f 'IDEAS' -a "${1}" != "-c" ; then 
  208.   echo shar: Will not clobber existing file \"'IDEAS'\"
  209. else
  210. echo shar: Extracting \"'IDEAS'\" \(728 characters\)
  211. sed "s/^X//" >'IDEAS' <<'END_OF_FILE'
  212. XThis file is intended to hold ideas for future enhancements of the
  213. X`annote' package. If you have such ideas, please complete this file
  214. Xand email it to the author, Yves Arrouye <arrouye@imag.imag.fr>
  215. X
  216. X1. Make an elaborated \cite command which takes an optional parameter
  217. X   saying if we really want the annotation. This may be used in a
  218. X   bibliography where related items (with similar annotations) are
  219. X   \cite'd, but we do want only one annotation to appear.
  220. X
  221. X2. In the Elisp package, use programmed completion to let the user
  222. X   choose the values between all the field names in the user variable
  223. X   annote-default-annote-fields. Then, instead of inserting the
  224. X   contents of the variable, let the user play with completion.
  225. X
  226. END_OF_FILE
  227. if test 728 -ne `wc -c <'IDEAS'`; then
  228.     echo shar: \"'IDEAS'\" unpacked with wrong size!
  229. fi
  230. # end of 'IDEAS'
  231. fi
  232. if test -f 'ChangeLog' -a "${1}" != "-c" ; then 
  233.   echo shar: Will not clobber existing file \"'ChangeLog'\"
  234. else
  235. echo shar: Extracting \"'ChangeLog'\" \(6480 characters\)
  236. sed "s/^X//" >'ChangeLog' <<'END_OF_FILE'
  237. XTue Jun  8 13:34:56 1993  Yves.Arrouye  (arrouye@cosmos)
  238. X
  239. X    * Makefile: added a target to build the supplied sample file.
  240. X
  241. X    * annotebib.el: Revision 1.5.1
  242. X    Fixed a bug which cause interactively-called functions annote-file
  243. X    and unannote-file to take the filename of the current buffer if no
  244. X    savefile was given, instead of the name of the original file.
  245. X      Added backup support with the annote-backup-* variables.
  246. X    (annote-internal-ab): Fixed a typo which caused an error from
  247. X    BibTeX, complaining about an undefined p function.
  248. X    (annote-internal-of): Now expand the filenames.
  249. X    (annote-internal-ws): Id.
  250. X    
  251. X
  252. XWed May 19 10:49:26 1993  Yves.Arrouye  (arrouye@cosmos)
  253. X
  254. X    * annotebib.el: (Still 1.5)
  255. X    (annote-internal-ob): Same principle as for annote-internal-of,
  256. X    but for buffers. Is used by annote-buffer and annote-unannote-buffer.
  257. X    which were rewritten.
  258. X    (annote-buffer): See above.
  259. X    (annote-unannote-buffer): See above.
  260. X    (annote-accessible-BibTeX-styles): now takes three optional
  261. X    parameters, which are the path, path-sep and regexp.
  262. X    (annote-make-annotated): The file list may be a path (string) in a
  263. X    non-interactive-call.
  264. X    (annote-make-unannotated): Same as annote-make-annotate, except
  265. X    that it removes annotation fields. (The implementation is a copy
  266. X    of the first function with little change: it's bad).
  267. X    Made the file-list an optional argument in both functions.
  268. X    Improved errors in the *-make-* functions.
  269. X
  270. XTue May 18 11:48:16 1993  Yves Arrouye  (arrouye@chergui)
  271. X
  272. X        * annotebib.el: Revison 1.5.
  273. X    Better error handling so that when processing
  274. X    multiple files an error will not prevent processing the other.
  275. X    The function now return a summary of errors... All functions use
  276. X    the same construction, but code is duplicated. The functions are
  277. X    annote-buffer (and so annote-file), annote-unannote-buffer and
  278. X    annote-write-styles.
  279. X    (annote-internal-of): Used to work on files.
  280. X    (annote-unannote-file): New function for annotating a style file.
  281. X    Use annote-internal-of.
  282. X    (annote-file): Rewritten to use annote-internal-of (in fact,
  283. X    annote-internal-of is the body of the old annote-file function,
  284. X    without the interactive clause, and with a functional parameter).
  285. X    (annote-accessible-BibTeX-styles): give all accessible BibTeX
  286. X    styles, using the defaul BibTeX path, path separator, and style
  287. X    file extension. Use annote-directory-files-matching and
  288. X    annote-path-files-matching.
  289. X    * annotebib.el: Added two functions to help system managers
  290. X    convert a bunch of styles in a single command.
  291. X    (annote-make-annotated): Ask interactively for all BibTeX
  292. X    style files, the annotation fields, and annote the styles and
  293. X    generate the LaTeX styles.
  294. X    (annote-read-file-names): Ask for a list of files (much like
  295. X    read-file-name).
  296. X
  297. XMon May 17 16:27:14 1993  Yves Arrouye  (arrouye@mistral)
  298. X
  299. X    * annotebib.el: Revision 1.4, support for simultaneous entries,
  300. X    thus allowing the user to specify more than one field in a command.
  301. X    (annote-buffer): Simple use.
  302. X    (annote-file): Id. Calls annote-buffer so no problem here.
  303. X    (annote-write-styles): New name for the old annote-write-style
  304. X    function. The function does not ask for a file name anymore, but
  305. X    rather uses the annotation fields names and the
  306. X    annote-LaTeX-style-prefix and annote-LaTeX-style-suffix user
  307. X    variables to build the style file name.
  308. X    (annote-unnanote-buffer): Field name now defaults to the entire
  309. X    list of annotation fields found in the buffer. If called
  310. X    interactively, prompts with the last inserted field (i.e. the one
  311. X    just before the fin.entry FUNCTION).
  312. X
  313. X    * annotebib.add : Reflected the name change.
  314. X
  315. X    * annotebib.el: For more robustness, changed the
  316. X    `format.FIELD' name of the function to
  317. X    `annotebib.format.FIELD', and     used a search for that
  318. X    FUNCTION to build the list of annotation fields. The list should
  319. X    be good even if someone deleted the comments. But the comments are
  320. X    looked for before.
  321. X    Moved the `annotebib.format.' part of the name in the
  322. X    annote-func-prefix variable.
  323. X
  324. X    * annotebib.el: Revision 1.3, support for unannotating a file.
  325. X    (annote-unannote-buffer): New function to remove an annotation.
  326. X    annote-ask-interactively: New variable controlling wether to ask
  327. X    something interactively.
  328. X    (annote-write-file): Write a style file. Overwrites if wanted, or
  329. X    ask for confirmation if annote-ask-interactively is true;
  330. X    otherwise, fail when the file/buffer existed.
  331. X    (annote-buffer): Now one does not have to Undo! a change if the
  332. X    function fails while editing in-place.
  333. X
  334. XFri May 14 11:19:24 1993  Yves.Arrouye  (arrouye@cosmos)
  335. X
  336. X    * annotebib.el:
  337. X    (annnote-insert-style): If the buffer we are inserting in is
  338. X    currently visiting a file, and if this file's name ends in
  339. X    annote-LaTeX-style-extension, use the nondirectory part of the
  340. X    filename without the extension as the annotation field name.
  341. X    The code nows supplies default values for nil values or blank strings.
  342. X    (annote-buffer): Bhe annote field gets a default value if its nil
  343. X    or a blank string. For the filenames, however, you can save under
  344. X    a filename which is " " for example (not really good if you want
  345. X    to find it easily in a directory listing :-) 
  346. X
  347. XThu May 13 17:12:37 1993  Yves.Arrouye  (arrouye@cosmos)
  348. X
  349. X    * annotebib.el: Revision 1.2, support for multiple annotation fields.
  350. X    Added the annote-default-annote-field (defaulting to "annote") in
  351. X    the user variables list.
  352. X    (annote-buffer): Has now two optional arguments, the first one
  353. X    being the name of the annotation field (defaults to
  354. X    annote-default-annote-field), the second one being the in-place
  355. X    parameter. updated the documentation string, and added
  356. X    instructions for setup with autoload.
  357. X    Modified the comment saying that the style changed so that it
  358. X    includes the version of annotebib.el and the name of the
  359. X    annotation field.
  360. X    Issues a message if no modifications were necessary.
  361. X    Changed the return value when no changes are necessary.
  362. X    Tries to be smart enough so that it will not clobber the file with
  363. X    advertising that the style is now `annote'-compatible.
  364. X    (annote-file): If the file was already visited, saves it modified
  365. X    status, otherwise don't save unless success (i.e. modified).
  366. X    Do not destroy the buffer if it was here before the call to the
  367. X    function (it was not very smart ;-)
  368. X    make a copy of the buffer if visited but saved under another name.
  369. X    (annote-insert-style): new function to produce the text for a
  370. X    style file. Asks for annotation field name, and start and end of
  371. X    the environment. If called non-interactively, uses default from
  372. X    user variables.
  373. END_OF_FILE
  374. if test 6480 -ne `wc -c <'ChangeLog'`; then
  375.     echo shar: \"'ChangeLog'\" unpacked with wrong size!
  376. fi
  377. # end of 'ChangeLog'
  378. fi
  379. if test -f 'annotebib.add' -a "${1}" != "-c" ; then 
  380.   echo shar: Will not clobber existing file \"'annotebib.add'\"
  381. else
  382. echo shar: Extracting \"'annotebib.add'\" \(658 characters\)
  383. sed "s/^X//" >'annotebib.add' <<'END_OF_FILE'
  384. X% annotebib.add: what to add/change to a .bst file to support annotations
  385. X%
  386. X% Yves Arrouye (arrouye@imag.imag.fr)
  387. X%
  388. X% April 13, 1993
  389. X
  390. X% You have to add the following field to the ENTRY list (after the
  391. X% address field)
  392. X
  393. Xannote
  394. X
  395. X% This function has to be added to your .bst file
  396. X
  397. XFUNCTION {annotebib.format.annote}
  398. X{ annote empty$
  399. X    { "" }
  400. X        { "\ifx\annote\undefined\else\begin{annote} "
  401. X      annote
  402. X      * " \end{annote}\fi " *
  403. X    }
  404. X      if$
  405. X}
  406. X
  407. X% The fin.entry function is changed to call annotebib.format.annote just before
  408. X% the end (closing brace) of the function.
  409. X
  410. XFUNCTION {fin.entry}
  411. X{ add.period$
  412. X  write$
  413. X  newline$
  414. X  annotebib.format.annote write$
  415. X}
  416. END_OF_FILE
  417. if test 658 -ne `wc -c <'annotebib.add'`; then
  418.     echo shar: \"'annotebib.add'\" unpacked with wrong size!
  419. fi
  420. # end of 'annotebib.add'
  421. fi
  422. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  423.   echo shar: Will not clobber existing file \"'Makefile'\"
  424. else
  425. echo shar: Extracting \"'Makefile'\" \(1598 characters\)
  426. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  427. XBST = *.bst
  428. XSTY = *.sty
  429. X
  430. XBST2= abbrv.bst alpha.bst
  431. XBST3= plain.bst unsrt.bst apalike.bst
  432. XBST4= siam.bst fsiam.bst lsiam.bst
  433. X
  434. XOTH = NEWS ANNOUNCE README IDEAS ChangeLog annotebib.add Makefile sample.tex \
  435. X      sample.bib compile-annote.el
  436. XEL  = annotebib.el
  437. XELC = annotebib.elc
  438. XELP = $(EL) $(ELC)
  439. X
  440. XALL = $(OTH) $(STY) $(ELP) $(BST)
  441. X
  442. XBSTDIR = /usr/local/lib/tex/inputs
  443. XSTYDIR = /usr/local/lib/tex/inputs
  444. XOTHDIR = $(STYDIR)/documents
  445. XELPDIR = /usr/local/src/Gnu/Emacs18/local-lisp
  446. X
  447. XSHRDIR = NOT-DIST
  448. X
  449. XLATEX  = latex
  450. XBIBTEX = bibtex
  451. X
  452. Xsample: sample.dvi
  453. Xsample.dvi: sample.tex sample.bib
  454. X    $(LATEX) sample
  455. X    -$(BIBTEX) sample
  456. X    $(LATEX) sample
  457. X    $(LATEX) sample
  458. X
  459. Xshar: manifest shar1 shar2 shar3 shar4
  460. Xmanifest:
  461. X    @echo creating $(SHRDIR)/MANIFEST
  462. X    @echo 'Contents of the 4 archives of the `annote'"'"' package' \
  463. X          >$(SHRDIR)/MANIFEST
  464. X    @echo >>$(SHRDIR)/MANIFEST
  465. X    @echo "Archive 1: " $(OTH) $(ELP) $(STY) >>$(SHRDIR)/MANIFEST
  466. X    @echo "Archive 2: " $(BST2) >>$(SHRDIR)/MANIFEST
  467. X    @echo "Archive 3: " $(BST3) >>$(SHRDIR)/MANIFEST
  468. X    @echo "Archive 4: " $(BST4) >>$(SHRDIR)/MANIFEST
  469. X    @echo >>$(SHRDIR)/MANIFEST
  470. X
  471. Xshar1:
  472. X    shar $(OTH) $(EL) $(STY) >$(SHRDIR)/annote.shar.part1
  473. Xshar2:
  474. X    shar $(BST2) >$(SHRDIR)/annote.shar.part2
  475. Xshar3:
  476. X    shar $(BST3) >$(SHRDIR)/annote.shar.part3
  477. Xshar4:
  478. X    shar $(BST4) >$(SHRDIR)/annote.shar.part4
  479. X
  480. Xannotebib.elc: annotebib.el
  481. X    emacs -batch -l compile-annote.el
  482. X
  483. Xinstall: annotebib.elc
  484. X    install -c -m 664 $(BST) $(BSTDIR)
  485. X    install -c -m 664 $(STY) $(BSTDIR)
  486. X    install -c -m 664 $(ELP) $(ELPDIR)
  487. X    $(RM) -f $(ELC)
  488. X    for i in $(OTH); do install -c -m 664 $$i $(OTHDIR)/annote.$$i; done
  489. X
  490. END_OF_FILE
  491. if test 1598 -ne `wc -c <'Makefile'`; then
  492.     echo shar: \"'Makefile'\" unpacked with wrong size!
  493. fi
  494. # end of 'Makefile'
  495. fi
  496. if test -f 'sample.tex' -a "${1}" != "-c" ; then 
  497.   echo shar: Will not clobber existing file \"'sample.tex'\"
  498. else
  499. echo shar: Extracting \"'sample.tex'\" \(973 characters\)
  500. sed "s/^X//" >'sample.tex' <<'END_OF_FILE'
  501. X% sample.tex: a test for the `annote' package. Assume that you are
  502. X% using an annote-compatible `plain.bst' BibTeX style.
  503. X
  504. X% To format: latex sample
  505. X%            bibtex sample
  506. X%            latex sample
  507. X%            latex sample
  508. X
  509. X% Yves Arrouye
  510. X% May, 1993
  511. X
  512. X% The companion bibliography has two annotation fields in it:
  513. X% `commentaire' is in french, `annote' is in english. Not all entries
  514. X% have both fields...
  515. X
  516. X% Delete `commentaire' from the \documentstyle options if you don't
  517. X% want to have french commentaires in the bibliography.
  518. X
  519. X\documentstyle[a4,commentaire,refrench]{article}
  520. X%
  521. X\def\BibTeX-style{alpha}
  522. X%
  523. X\begin{document}
  524. X\section*{Testing the `annote' package with {\tt \BibTeX-style.bst}}
  525. X% Here is an annote environment, comment it to not look at the english
  526. X% annotations of the bibliography. 
  527. X\newenvironment{annote}{\begin{quote}\em [English here]\ }{\end{quote}}
  528. X% Cite all
  529. X\nocite{*}
  530. X\bibliography{sample}
  531. X\bibliographystyle{\BibTeX-style}
  532. X\end{document}
  533. END_OF_FILE
  534. if test 973 -ne `wc -c <'sample.tex'`; then
  535.     echo shar: \"'sample.tex'\" unpacked with wrong size!
  536. fi
  537. # end of 'sample.tex'
  538. fi
  539. if test -f 'sample.bib' -a "${1}" != "-c" ; then 
  540.   echo shar: Will not clobber existing file \"'sample.bib'\"
  541. else
  542. echo shar: Extracting \"'sample.bib'\" \(5672 characters\)
  543. sed "s/^X//" >'sample.bib' <<'END_OF_FILE'
  544. X
  545. X
  546. X@manual{gnu:lew90el,
  547. X   author = {Bil Lewis and Dan {LaLiberte} and {the GNU Manual Group}},
  548. X   address = {675 Mass Ave, Cambridge, MA 02139},
  549. X   edition = {1.03},
  550. X   month = dec,
  551. X   organization = {Free Software Foundation},
  552. X   title = {{GNU Emacs Lisp Reference Manual}},
  553. X   year = {1990},
  554. X   commentaire = {Manuel de r\'ef\'erence d'Elisp (pour Emacs Lisp), le Lisp sp\'ecialis\'e int\'egr\'e \`a
  555. XEmacs. Ce Lisp permet d'\'etendre facilement les fonctionnalit\'es d'Emacs, et dispose, outre les primitives Lisp ``classiques'', d'un tr\`es grand nombre de primitives sp\'ecialis\'ees dans la gestion de l'\'edition (insertion, destruction, recherche et remplacement de cha\^\i{}nes et d'expressions r\'eguli\`eres, gestion des modes et fen\^etres d'Emacs, etc\ldots{}), la manipulation de fichiers et la gestion de processus ``attach\'es'' \`a Emacs.},
  556. X   annote = {Reference Manual for Elisp (standing for Emacs Lisp), the specialized Emacs built-in Lisp. This Lisp allows one to easily extend Emacs' functionalities, and gives, besides the ``classical'' Lisp primitives, a lot of primitives specialized in editing tasks (insert, delete, search and replace of strings and regular expressions, modes and windows management etc\ldots{}), file management or ``attached'' processes management.}
  557. X}
  558. X
  559. X@manual{gnu:sta92em,
  560. X   author = {Richard M. Stallman},
  561. X   address = {675 Mass Ave, Cambridge, MA 02139},
  562. X   edition = {7},
  563. X   month = sep,
  564. X   note = {Emacs Version 18.58},
  565. X   organization = {Free Software Foundation},
  566. X   title = {{GNU Emacs Manual}},
  567. X   year = {1992},
  568. X   commentaire = {Emacs est un \'editeur de texte extr\^emement puissant, facilement extensible gr\^ace au
  569. XLisp sp\'ecialis\'e qui lui est int\'egr\'e et qui permet de reprogrammer enti\`erement
  570. Xles fonctionnalit\'es de l'\'editeur, ainsi que d'en ajouter de nouvelles.
  571. X\par 
  572. XIl est possible de trouver un ``mode'' Emacs pour faciliter \`a peu pr\`es n'importe quelle
  573. Xt\^ache d'\'edition, que ce soit de la saisie de texte dans un langage donn\'e ou
  574. Xl'interaction avec un logiciel complexe\ldots{}}
  575. X}
  576. X
  577. X@article{lng:lib91a,
  578. X   author = {Don Libes},
  579. X   journal = {Computing Systems},
  580. X   number = {2},
  581. X   pages = {99-125},
  582. X   title = {{expect: Scripts for Controlling Interactive Processes}},
  583. X   volume = {4},
  584. X   year = {1991},
  585. X   commentaire = {Le langage expect est bas\'e sur Tcl, auquel il ajoute la possibilit\'e de contr\^oler n'importe quel programme Unix, interactif ou non, sous forme de processus attach\'e au programme expect.
  586. X\par
  587. XComme Tcl, expect peut \^etre inclus dans une application, lui apportant alors de grandes facilit\'es d'extension.
  588. X\par 
  589. XCet article pr\'esente le langage en donnant un certain nombre de scripts utilis\'es dans des domaines vari\'es (administration syst\`eme, s\'ecurit\'e, jeux (!), communication,
  590. X\ldots{}).
  591. X}
  592. X}
  593. X
  594. X@techreport{lng:lib91b,
  595. X   author = {Don Libes},
  596. X   address = {Gaithesburg, MD},
  597. X   institution = {National Institute of Standards and Technology},
  598. X   number = {NIST IR 744-91},
  599. X   title = {{expect User Manual}},
  600. X   year = {1991},
  601. X   commentaire = {Le langage expect est bas\'e sur Tcl, auquel il ajoute la possibilit\'e de contr\^oler n'importe quel programme Unix, interactif ou non, sous forme de processus attach\'e au programme expect.
  602. X\par 
  603. XComme Tcl, expect peut \^etre inclus dans une application, lui apportant alors de grandes facilit\'es d'extension.
  604. X}
  605. X}
  606. X
  607. X@inproceedings{lng:ous90,
  608. X   author = {John Ousterhout},
  609. X   booktitle = {{Proceedings of the Winter 1990 USENIX Conference}},
  610. X   crossref = {prc:usenix90w},
  611. X   title = {{Tcl: An Embeddable Command Language}},
  612. X   year = {1990},
  613. X   commentaire = {Tcl est un langage destin\'e \`a \^etre inclus dans des applications afin de leur fournir un langage int\'egr\'e simple et puissant.
  614. X\par 
  615. XUne fois le langage ajout\'e \`a l'application, celle-ci fournit un certain nombre de points d'entr\'ee vers ses fonctionnalit\'es, qui peuvent alors \^etre utilis\'ees par un simple appel proc\'edural dans les programmes que l'utilisateur \'ecrit en Tcl.
  616. X\par 
  617. XTcl a \'et\'e utilis\'e dans beaucoup d'applications, dont un \'editeur de texte enti\`erement reconfigurable et programmable, Point, qui utilise Tcl et son extension pour X, Tk.}
  618. X}
  619. X
  620. X@inproceedings{lng:bir92,
  621. X   author = {J. J. Birchman and S. L. Tanimoto},
  622. X   title = {{An Implementation of the VIVA Visual Language on the NeXT Computer}},
  623. X   year = {1992},
  624. X   commentaire = {VIVA est un langage de programmation visuelle destin\'e au traitement d'image. Il utilise des ic\^ones pour repr\'esenter les op\'erateurs de traitement d'image, et des arcs orient\'es pour repr\'esenter le flot de donn\'es (images) entre les op\'erateurs.
  625. X\par 
  626. XLe syst\`eme est organis\'e en deux niveaux accompagn\'es d'un certain nombre de modules. Le niveaux sup\'erieur est la pr\'esentation de l'environnement de programmation \`a l'utilisateur, lui permettant de cr\'eer, modifier, sauver et ex\'ecuter ses programmes. Le niveau inf\'erieur est la structure interne du langage, qui g\`ere la programmation visuelle, le d\'eclenchement des op\'erateurs \`a l'arriv\'ee de nouvelles donn\`ees, et la gestion des ic\^ones (op\'erateurs).
  627. X\par 
  628. XVIVA propose un mod\`ele synchrone de flot de donn\'ees, dans un environnement ``pleinement vivant'', i.e. refl\'etant \`a tout moment l'\'etat du syst\`eme et les actions de l'utilisateur.
  629. X\par 
  630. XVIVA a \'et\'e d\'evelopp\'e pour faciliter l'apprentissage des techniques d'imagerie m\'edicale par des m\'edecins sans connaissances informatiques.}
  631. X}
  632. X
  633. X@proceedings{prc:usenix90w,
  634. X   address = {Washington, DC},
  635. X   month = jan,
  636. X   title = {{Proceedings of the Winter 1990 USENIX Conference}},
  637. X   year = {1990}
  638. X}
  639. END_OF_FILE
  640. if test 5672 -ne `wc -c <'sample.bib'`; then
  641.     echo shar: \"'sample.bib'\" unpacked with wrong size!
  642. fi
  643. # end of 'sample.bib'
  644. fi
  645. if test -f 'compile-annote.el' -a "${1}" != "-c" ; then 
  646.   echo shar: Will not clobber existing file \"'compile-annote.el'\"
  647. else
  648. echo shar: Extracting \"'compile-annote.el'\" \(70 characters\)
  649. sed "s/^X//" >'compile-annote.el' <<'END_OF_FILE'
  650. X;;; compile the annotebib.el file
  651. X
  652. X(byte-compile-file "annotebib.el")
  653. END_OF_FILE
  654. if test 70 -ne `wc -c <'compile-annote.el'`; then
  655.     echo shar: \"'compile-annote.el'\" unpacked with wrong size!
  656. fi
  657. # end of 'compile-annote.el'
  658. fi
  659. if test -f 'annotebib.el' -a "${1}" != "-c" ; then 
  660.   echo shar: Will not clobber existing file \"'annotebib.el'\"
  661. else
  662. echo shar: Extracting \"'annotebib.el'\" \(44921 characters\)
  663. sed "s/^X//" >'annotebib.el' <<'END_OF_FILE'
  664. X;;;; annotebib.el, v1.5.1
  665. X;;;;
  666. X;;;; Transform a bibliography style so that it is compatible with the
  667. X;;;; conventions used by my `annote' package.
  668. X;;;;
  669. X;;;; Version 1.5.1 corrects a bug in the annote.format.* functions: a
  670. X;;;; p (a mystyped C-p under emacs!) preceded the if$ at the end of
  671. X;;;; the functions, making BibTeX complains about such an undefined
  672. X;;;; function!
  673. X;;;;   It also correct a bug when reading the "Save file: " filenames:
  674. X;;;; if the answer was RET and the current buffer (in interactive use)
  675. X;;;; had a filename, then this filename was used to save instead of
  676. X;;;; the default save filename.
  677. X;;;;   Automatic backup of files is also supported. The default value
  678. X;;;; of annote-backup-files is nil (because most people use automatic
  679. X;;;; backup so there is no need fo the annote one), and the files
  680. X;;;; are backuped by adding the ".orig" suffix to the file name.
  681. X;;;;
  682. X;;;; Version 1.5 completes the package with annote-unannote-file and
  683. X;;;; annote-make-unannotated; I also made some rewriting and wrote
  684. X;;;; error handlers in functions iterating over multiple calls to basic
  685. X;;;; functions. New error handling/remembering. For functions handling
  686. X;;;; multiple operations, a summary of errors is available in the
  687. X;;;; annote-errors variable after completion.
  688. X;;;;
  689. X;;;; Version 1.4 supports multiple field names with a single command,
  690. X;;;; with every command except for annote-insert-style. It also adds
  691. X;;;; `bunch-processing' functions to the package.
  692. X;;;;
  693. X;;;; Version 1.3 has bug fixes, and new support for writing LaTeX and
  694. X;;;; (more useful!) unannotating a BibTeX style file.
  695. X;;;;
  696. X;;;; Version 1.2 supports multiple annotation fields, recognition of
  697. X;;;; already-annotated files, and new features (annote-insert-style,
  698. X;;;; and new user variables). The functions accept default values
  699. X;;;; taken from user variables (when called with blank or nil
  700. X;;;; variables or with prefix arguments).
  701. X;;;;   Started to use a ChangeLog, so the comments below (except for
  702. X;;;; autoloading) are not maintained now.
  703. X;;;;
  704. X;;;; Version 1.0 was very simple...
  705. X;;;;
  706. X;;;;
  707. X;;;; Yves Arrouye (arrouye@imag.imag.fr), May 1993 -- June 1993.
  708. X
  709. X(provide 'annotebib)
  710. X
  711. X;;;; Installation with autoload. Put the following lines in your
  712. X;;;; .emacs or site-init.el file, and uncomment them:
  713. X;;;;
  714. X;;;;   (autoload 'annote-buffer "annotebib"
  715. X;;;;     "Annote the bibliography style in the optionnaly specified
  716. X;;;;   buffer (or current if called interactively). The first argument
  717. X;;;;   (asked interactively for) is the list of annotation fields
  718. X;;;;   names. It defaults to the value of the user variable
  719. X;;;;   annote-default-annote-fields.  It may be a list or a string
  720. X;;;;   with multiple names.
  721. X;;;;
  722. X;;;;   The buffer is edited in place if the in-place argument is
  723. X;;;;   non-nil, or if a negative prefix argument is given. The default
  724. X;;;;   value for the annotation field(s) name(s) is taken from the
  725. X;;;;   annote-default-annote-fields if the given name is nil or blank,
  726. X;;;;   or if the function is called interactively with a numeric
  727. X;;;;   prefix argument which is not `-' nor nil.
  728. X;;;;
  729. X;;;;   The function does nothing if the buffer already supports (or
  730. X;;;;   looks like it does support) `annote' for the given field.
  731. X;;;;
  732. X;;;;   Return the success of the modification, or the list
  733. X;;;;   '(no-change-for \"<annote-fields>\") if already supporting
  734. X;;;;   `annote' for the given field.")
  735. X;;;;
  736. X;;;;   (autoload 'annote-unannote-buffer "annotebib"
  737. X;;;;     "Unannote the bibliography style in the optionnally specified
  738. X;;;;   buffer (or current if called interactively).  The first
  739. X;;;;   argument (asked interactively for) is the list of annotation
  740. X;;;;   fields names. It defaults to the list of all annotations names
  741. X;;;;   in the buffer. It may be a list or a string with multiple
  742. X;;;;   names.
  743. X;;;;
  744. X;;;;   The buffer is edited in place if the in-place argument is
  745. X;;;;   non-nil, or if a negative prefix argument is given. The default
  746. X;;;;   value for the annotation field(s) name(s) is taken from the
  747. X;;;;   annote-default-annote-fields if the given name is nil or blank,
  748. X;;;;   or if the function is called interactively with a numeric
  749. X;;;;   prefix argument which is not `-' nor nil.
  750. X;;;;
  751. X;;;;   The function does nothing if the buffer does not support (or
  752. X;;;;   looks like it does not support) `annote' for the given field.
  753. X;;;;
  754. X;;;;   Return the success of the modification, or the list
  755. X;;;;   '(no-change-for \"<annote-fields>\") if non supporting `annote'
  756. X;;;;   for the given field.")
  757. X;;;;
  758. X;;;;   (autoload 'annote-file "annotebib"
  759. X;;;;     "Annote a file. If called interactively, asks for an existing
  760. X;;;;   filename, for the name(s) of the annotation field(s), and then for
  761. X;;;;   the name of the annotated file. If this name is a directory,
  762. X;;;;   then the name of the file will be the filename of the original
  763. X;;;;   file in this directory, unless the directories are the same, in
  764. X;;;;   which case the original file will have the value of
  765. X;;;;   annote-savefile-prefix prefixed to it. If the buffer was
  766. X;;;;   already visited, it is not destroyed.
  767. X;;;;
  768. X;;;;   If a numeric prefix argument is given, or if the name of the
  769. X;;;;   annotation field is blank, the default value is taken from the
  770. X;;;;   annote-default-annote-fields user variable.
  771. X;;;;
  772. X;;;;   If annote-buffer fails on the loaded file, it is not saved.
  773. X;;;;   Return success as got from annote-buffer.")
  774. X;;;;
  775. X;;;;   (autoload 'annote-insert-style "annotebib"
  776. X;;;;     "Insert the text of a LaTeX style file for an environment
  777. X;;;;   used to display an annotation field.
  778. X;;;;
  779. X;;;;   Arguments are the name of the annotation field, and LaTeX code
  780. X;;;;   to start and end the environment. If the annotation field is
  781. X;;;;   not given or blank, the function will try to guess it from the
  782. X;;;;   name of the visited file if any. In other cases, and for the
  783. X;;;;   other arguments, default values from the user variables will be
  784. X;;;;   used.
  785. X;;;;
  786. X;;;;   If called interactively with a non-nil prefix argument, default
  787. X;;;;   values will be used.")
  788. X;;;;
  789. X;;;;   (autoload annote-write-styles "annotebib"
  790. X;;;;     "Write one or more files with the text of a LaTeX style file
  791. X;;;;   for an environment used to display an annotation field.
  792. X;;;;
  793. X;;;;    Arguments are the name(s) of the annotation field(s), and
  794. X;;;;   LaTeX code to start and end the environment. The names of the
  795. X;;;;   fields may be given as a list of strings or a single strings
  796. X;;;;   with multiple names in it.  If an argument is not given,
  797. X;;;;   default values from the user variables will be used.
  798. X;;;;
  799. X;;;;    The function writes a file for each environment, prefixing the
  800. X;;;;   contents of annote-LaTeX-style-prefix to the annotation field
  801. X;;;;   name, and adding the annote-LaTeX-style-suffix to it.
  802. X;;;;
  803. X;;;;   If called interactively with a non-nil prefix argument, default
  804. X;;;;   values will be used. If the last argument is non-nil or a
  805. X;;;;   negative prefix argument is given, an existing file will be
  806. X;;;;   overwritten; otherwise, no changes are made to the contents of
  807. X;;;;   that file.")
  808. X;;;;
  809. X;;;;   (autoload 'annote-make-annotated "annotebib"
  810. X;;;;     "Make a full annotated distribution. Gets the list of BibTeX
  811. X;;;;   files to annotate, the list of annotation fields. Annotate the
  812. X;;;;   BibTeX files and save them, then write the LaTeX style files
  813. X;;;;   (asking for confirmation depending on the value of the
  814. X;;;;   overwrite flag, see annote-write-styles.  Note that the style
  815. X;;;;   files will all define the same environment (if you want
  816. X;;;;   different environments, you will have to call annote-file
  817. X;;;;   followed by as much annote-write-styles as you want different
  818. X;;;;   environments, but this is not painful, really...).
  819. X;;;;
  820. X;;;;   When called interactively, the list of BibTeX files is asked
  821. X;;;;   for, and one ends it by answering RET to the prompt. If a
  822. X;;;;   prefix argument is given, it is used as in annote-write-styles
  823. X;;;;   for the default values and overwrite argument.
  824. X;;;;
  825. X;;;;   In a non-interactive call, the file list may be a string,
  826. X;;;;   which is assumed to be a path of directories in which to get
  827. X;;;;   the the BibTeX files.")
  828. X;;;;
  829. X;;;;   (autoload 'annote-make-unannotated "annotebib"
  830. X;;;;     "Unannote a list of files. Gets the list of BibTeX files to
  831. X;;;;   annotate, the list of annotation fields. Unannotate the BibTeX
  832. X;;;;   files and save them.
  833. X;;;;
  834. X;;;;   When called interactively, the list of BibTeX files is asked
  835. X;;;;   for, and one ends it by answering RET to the prompt. If the
  836. X;;;;   list is empty, it defaults to all accessible BibTeX style
  837. X;;;;   files.
  838. X;;;;
  839. X;;;;   In a non-interactive call, the file list may be a string, which
  840. X;;;;   is assumed to be a path of directories in which to get the the
  841. X;;;;   BibTeX files.")
  842. X
  843. X;;;; The functions follow the guidelines found in annotebib.add: they
  844. X;;;; look for the ENTRY declaration, add the `annote' field, then look
  845. X;;;; for the fin.entry FUNCTION and add the `annotebib.format.annote' FUNCTION
  846. X;;;; before it, then add a call to `annotebib.format.annote' at the end of
  847. X;;;; `fin.entry'.
  848. X;;;;
  849. X;;;; The modifications are done in a separate buffer by default, then
  850. X;;;; this buffer is copied into the original one. This means that the
  851. X;;;; modification is undoable by a single undo, and that in case of
  852. X;;;; errors the original file is not modified.
  853. X
  854. X;;;; If the transformation fails, you can either do it by hand
  855. X;;;; (following directions in annotebib.add), or modify the regular
  856. X;;;; expressions used to search for interesting information. The
  857. X;;;; latter approach is best for multiple style files written with the
  858. X;;;; same conventions/functions.
  859. X
  860. X
  861. X;;; Regexps for recognizing things which interest us.
  862. X
  863. X(defvar annote-entry-regexp "ENTRY[^{]*{"
  864. X  "*A regexp to find the ENTRY fields declaration. This regexp should
  865. Xmatch up to the opening brace af the ENTRY declaration.")
  866. X
  867. X(defvar annote-fin-entry-regexp "FUNCTION[ \t]*{[ \t]*fin.entry[ \t]*}[^{]*"
  868. X  "*A regexp to find the FUNCTION for ending entries. This regexp
  869. Xshould match up to but not including the opening brace of the
  870. Xfunction.")
  871. X
  872. X;;; Other customization
  873. X
  874. X(defvar annote-default-annote-fields "annote"
  875. X  "*The default fields containing annotations. Used if a nil or \"\"
  876. Xvalue is given to an annotation function. Fields must be recognized by
  877. Xthe annote-field-regexp regexp (other chars in the string are
  878. Xdelimiters between field names).")
  879. X
  880. X(defvar annote-func-prefix "annotebib.format."
  881. X  "*The prefix used to build the name of the formatting function for a
  882. Xgiven annotation field.")
  883. X
  884. X(defvar annote-unannote-func-prefix ()
  885. X  "Uncommented function, only for those who have understood the code
  886. Xand have a serious upgrade to do between two releases.")
  887. X
  888. X(defvar annote-field-regexp "[^ \t]+"
  889. X  "*A regexp to recognize a field name. Field names in a string must
  890. Xbe separated by characters matched by the negated regexp.")
  891. X
  892. X(defvar annote-savefile-prefix ""
  893. X  "*A string prefixed to a bibliography file name when saving it. An
  894. Xempty string means to replace the file if in the same directory.")
  895. X
  896. X(defvar annote-BibTeX-path (getenv "TEXINPUTS")
  897. X  "*The path used to find a BibTeX file. Elements of the path (i.e
  898. Xdirectories) are separated by annote-BibTeX-path-separator characters.")
  899. X
  900. X(defvar annote-BibTeX-path-separator ":"
  901. X  "*A single character which separates directories in the BibTeX path
  902. Xstring.")
  903. X
  904. X(defvar annote-BibTeX-style-extension ".bst"
  905. X  "*The default BibTeX style file extension. Must start with a dot.")
  906. X
  907. X(defvar annote-BibTeX-style-directory 'default-directory
  908. X  "*The default BibTeX style directory. Will be evaluated when a style
  909. Xfile name is asked for.")
  910. X
  911. X(defvar annote-backup-prefix ""
  912. X  "*A string prefixed to BibTeX style filenames when backuped.")
  913. X
  914. X(defvar annote-backup-suffix ".orig"
  915. X  "*A string suffixed to BibTeX style filenames when backuped.")
  916. X
  917. X(defvar annote-LaTeX-style-extension ".sty"
  918. X  "*The default LaTeX style file extension.")
  919. X
  920. X(defvar annote-LaTeX-style-suffix annote-LaTeX-style-extension
  921. X  "*A string suffixed to the name of an annotation field in order to
  922. Xbuild a LaTeX style file name. Usualyy it is a file suffix.")
  923. X
  924. X(defvar annote-LaTeX-style-prefix ""
  925. X  "*A string prefixed to the name of an annotation field in order to
  926. Xbuild a LaTeX style file name. Usually it is a directory prefix.")
  927. X
  928. X(defvar annote-backup-files t
  929. X  "*A non-nil value means to backup files when the new filename is the
  930. Xsame as the old one.")
  931. X
  932. X(defvar annote-ask-interactively t
  933. X  "*A non-nil value means that annote will ask interactively for
  934. Xfile overwriting.")
  935. X
  936. X(defvar annote-ask-confirmation t
  937. X  "*A non-nil value means that annote will ask for confirmation before
  938. Xdoing something on files you haven't expressely specified.")
  939. X
  940. X;;; Style file variables
  941. X
  942. X(defvar annote-default-env-start "\\begin{quote}"
  943. X  "*The start of the environment used to display the annotation field
  944. Xin the bibliography.")
  945. X
  946. X(defvar annote-default-env-end "\\end{quote}"
  947. X  "*The end of the environment used to display the annotation field
  948. Xin the bibliography.")
  949. X
  950. X;;; Private variables
  951. X
  952. X(setq annote-version-string "v1.5.1")
  953. X
  954. X;;; Set up a syntax table. The syntax entries are borrowed from a
  955. X;;; BibTeX mode, and the syntax entries for { and } were added for
  956. X;;; security (if the mode the file was in has redefined those chars)
  957. X
  958. X(if (or (not (boundp 'bibtex-mode-syntax-table))
  959. X    (null bibtex-mode-syntax-table))
  960. X    (progn
  961. X      (setq bibtex-mode-syntax-table (copy-syntax-table))
  962. X      (modify-syntax-entry ?\$ "$$  ")
  963. X      (modify-syntax-entry ?\% "<   ")
  964. X      (modify-syntax-entry ?\f ">   ")
  965. X      (modify-syntax-entry ?\n ">   ")
  966. X      (modify-syntax-entry ?'  "w   ")
  967. X      (modify-syntax-entry ?@  "w   ")
  968. X      (modify-syntax-entry ?{  "(}")
  969. X      (modify-syntax-entry ?}  "){")))
  970. X
  971. X(defun annote-prompt-concat (x y)
  972. X  (if (and x
  973. X       (not (and (stringp x)
  974. X             (string-match "^[ \t]*$" x))))
  975. X      (concat x y)
  976. X    x))
  977. X
  978. X;;; Build the formatting function name
  979. X
  980. X(defun annote-mk-func (f)
  981. X  (concat annote-func-prefix f))
  982. X
  983. X;;; Listify: if given a list, that list; if given a string, sublistify
  984. X;;; that string; otherwise return nil
  985. X
  986. X(defun annote-listify (thing &optional regexp)
  987. X  (cond
  988. X   ((listp thing) thing)
  989. X   ((stringp thing) (annote-sublistify thing
  990. X                       (if regexp regexp
  991. X                     annote-field-regexp)
  992. X                       0))))
  993. X
  994. X;;; Listify a string, i.e. return a list of substrings which match a
  995. X;;; given regular expression
  996. X
  997. X(defun annote-sublistify (str regexp start)
  998. X  (if (string-match regexp str start)
  999. X      (cons (substring str (match-beginning 0) (match-end 0))
  1000. X        (annote-sublistify str regexp (match-end 0)))))
  1001. X                           
  1002. X;;; Annotation of a bibliography in a buffer. This is the basic
  1003. X;;; annotation primitive.
  1004. X
  1005. X(defun annote-buffer (&optional annote-fields in-place buffer)
  1006. X  "Annote the bibliography style in the optionnaly specified buffer
  1007. X(or current if called interactively). The first argument (asked
  1008. Xinteractively for) is the list of annotation fields names. It defaults
  1009. Xto the value of the user variable annote-default-annote-fields.  It
  1010. Xmay be a list or a string with multiple names.
  1011. X
  1012. XThe buffer is edited in place if the in-place argument is non-nil, or
  1013. Xif a negative prefix argument is given. The default value for the
  1014. Xannotation field(s) name(s) is taken from the annote-default-annote-fields if
  1015. Xthe given name is nil or blank, or if the function is called
  1016. Xinteractively with a numeric prefix argument which is not `-' nor nil.
  1017. X
  1018. XThe function does nothing if the buffer already supports (or looks
  1019. Xlike it does support) `annote' for the given field.
  1020. X
  1021. XReturn the success of the modification, or the list '(no-change-for
  1022. X\"<annote-fields>\") if already supporting `annote' for the given
  1023. Xfield."
  1024. X  (interactive (list (if (or (not current-prefix-arg)
  1025. X                 (eq current-prefix-arg '-))
  1026. X             (read-string "Annotation field(s) name(s): "
  1027. X                      (annote-prompt-concat
  1028. X                                        annote-default-annote-fields
  1029. X                    " ")))
  1030. X             (< (prefix-numeric-value current-prefix-arg) 0)))
  1031. X  (if (or (null annote-fields)
  1032. X      (and (stringp annote-fields)
  1033. X           (string-match "^[ \t]*$" annote-fields)))
  1034. X      (setq annote-fields annote-default-annote-fields))
  1035. X  (annote-internal-ob annote-fields in-place buffer 'annote-internal-ab
  1036. X                      "Annotating"))
  1037. X
  1038. X(defun annote-internal-ob (annote-fields in-place buffer funct msg)
  1039. X  (let ((success nil) (ret) (err)
  1040. X    (old-syntax (syntax-table))
  1041. X    (tembuf (if (not in-place) (generate-new-buffer " annote temp"))))
  1042. X    (if (not buffer) (setq buffer (current-buffer)))
  1043. X    (unwind-protect
  1044. X    (save-excursion
  1045. X      (if tembuf
  1046. X          (progn
  1047. X        (set-buffer tembuf)
  1048. X        (erase-buffer)
  1049. X        (insert-buffer-substring buffer)))
  1050. X      (set-syntax-table bibtex-mode-syntax-table)
  1051. X
  1052. X      (setq annote-fields (annote-listify annote-fields
  1053. X                          annote-field-regexp))
  1054. X      (if (setq ret (buffer-file-name buffer))
  1055. X          (setq msg (concat msg " `" ret "'..."))
  1056. X        (setq msg (concat msg " \"" (buffer-name buffer) "\"...")))
  1057. X      (message msg)
  1058. X      (annote-clear-errors)
  1059. X      (while annote-fields
  1060. X            (condition-case therror
  1061. X            (if (setq ret
  1062. X              (funcall funct (car annote-fields) (interactive-p)))
  1063. X            (progn
  1064. X              (undo-boundary)
  1065. X              (setq success ret)))
  1066. X          (error (message (car (cdr therror)))
  1067. X             (annote-add-to-errors therror)
  1068. X             (setq err (concat err
  1069. X                       (if err ", " "")
  1070. X                       "`" (car annote-fields) "'"))
  1071. X             (if (interactive-p) (progn (beep) (sit-for 1)))))
  1072. X        (setq annote-fields (cdr annote-fields)))
  1073. X
  1074. X      (if (and tembuf (eq success t))
  1075. X          (progn
  1076. X        (set-buffer buffer)
  1077. X        (erase-buffer)
  1078. X        (insert-buffer-substring tembuf)))
  1079. X          (if err
  1080. X              (error (concat msg "done with errors for " err "."))
  1081. X            (message (concat msg "done."))))
  1082. X      (set-syntax-table old-syntax)
  1083. X      (if tembuf (kill-buffer tembuf)))
  1084. X    success))
  1085. X
  1086. X(defun annote-internal-ab (annote-fields inter)
  1087. X  (let ((success nil)
  1088. X    (rem))
  1089. X    (goto-char (point-min))
  1090. X    (if (search-forward (concat "FUNCTION {"
  1091. X                (annote-mk-func annote-fields) "}")
  1092. X            (point-max) t)
  1093. X    ;; Already supporting this field
  1094. X    (progn
  1095. X      (setq success (list 'no-change-for annote-fields))
  1096. X      (message "No change needed for field `%s'." annote-fields))
  1097. X      (goto-char (point-min))
  1098. X      (if (not (re-search-forward annote-entry-regexp (point-max) t))
  1099. X      (error "Cannot find ENTRY declaration.")
  1100. X    (setq rem (match-end 0))
  1101. X    (if (not (re-search-forward annote-fin-entry-regexp
  1102. X                    (point-max) t))
  1103. X        (error "Cannot find FUNCTION for ending entries.")
  1104. X      ;; found the fin.entry function
  1105. X      (setq success t)
  1106. X      (message "Adding annotation field `%s'." annote-fields)
  1107. X      (goto-char (1- (scan-lists (match-end 0) 1 0)))
  1108. X      (insert "  " (annote-mk-func annote-fields) " write$\n")
  1109. X      (goto-char (1- (match-beginning 0)))
  1110. X      (insert "\n\
  1111. XFUNCTION {" (annote-mk-func annote-fields) "}\n\
  1112. X{ " annote-fields " empty$\n\
  1113. X        { \"\" }\n\
  1114. X        { \"\\ifx\\" annote-fields "\\undefined\\else\\begin{"
  1115. X                        annote-fields "} \"\n\
  1116. X          " annote-fields "\n\
  1117. X          * \" \\end{" annote-fields "}\\fi \" *\n\
  1118. X        }\n\
  1119. X      if$\n\
  1120. X}\n")
  1121. X      (goto-char rem)
  1122. X      (insert " " annote-fields "\n   ")
  1123. X      (goto-char (point-min))
  1124. X      (insert "\
  1125. X% Style file modified on " (current-time-string) " with `annotebib.el' "
  1126. X                         annote-version-string "\n\
  1127. X%                     by " (user-full-name)
  1128. X" <" (user-real-login-name) "@" (system-name) ">\n\
  1129. X%                     to support the `" annote-fields "' annotation field.\n")
  1130. X      ;; try to be smart: if we find the advertising comment in
  1131. X      ;; the buffer we just have to add to the list of
  1132. X      ;; modifications, and not put all the stuff again
  1133. X      (if (not (search-forward "`annote'-compatible" (point-max) t))
  1134. X              (insert "\n\
  1135. X% This bibliography style was made `annote'-compatible by \"annotebib.el\".\n\
  1136. X% It can be used for both annotated and non-annotated bibliographies \
  1137. Xlisting\n\
  1138. X% (`annote' package by Yves Arrouye <arrouye@imag.imag.fr>).\n\n")))))
  1139. X  success))
  1140. X
  1141. X;;; Return the list of annotations defined in a buffer. The preferred
  1142. X;;; place to find the names is in the comments in the top lines of the
  1143. X;;; file. However, if (and only if) all these comments have been
  1144. X;;; deleted, then we try by looking at the FUNCTIONs.
  1145. X
  1146. X(defun annote-get-fields (&optional buffer)
  1147. X  (let ((fields))
  1148. X    (save-excursion
  1149. X      (if buffer (set-buffer buffer))
  1150. X      (goto-char (point-min))
  1151. X      (if (not (setq fields (annote-cmt-fields)))
  1152. X      (progn
  1153. X        (goto-char (point-max))
  1154. X        (setq fields (annote-fmt-fields)))))
  1155. X    fields))
  1156. X
  1157. X(defun annote-cmt-fields ()
  1158. X  (if (re-search-forward "`\\([^']+\\)' annotation field." (point-max) t)
  1159. X      (cons (buffer-substring (match-beginning 1) (match-end 1))
  1160. X        (annote-cmt-fields))))
  1161. X
  1162. X(defun annote-fmt-fields ()
  1163. X  (if (re-search-backward (concat "FUNCTION {" annote-func-prefix
  1164. X                  "\\([^}]+\\)}") (point-min) t)
  1165. X      (cons (buffer-substring (match-beginning 1) (match-end 1))
  1166. X        (annote-fmt-fields))))
  1167. X
  1168. X;;; Suppresses annotations from a buffer.
  1169. X
  1170. X(defun annote-unannote-buffer (&optional annote-fields in-place buffer)
  1171. X  "Unannote the bibliography style in the optionnally specified buffer
  1172. X(or current if called interactively).  The first argument (asked
  1173. Xinteractively for) is the list of annotation fields names. It defaults
  1174. Xto the list of all annotations names in the buffer. It may be a list
  1175. Xor a string with multiple names.
  1176. X
  1177. XThe buffer is edited in place if the in-place argument is non-nil, or
  1178. Xif a negative prefix argument is given. The default value for the
  1179. Xannotation field(s) name(s) is taken from the annote-default-annote-fields if
  1180. Xthe given name is nil or blank, or if the function is called
  1181. Xinteractively with a numeric prefix argument which is not `-' nor nil.
  1182. X
  1183. XThe function does nothing if the buffer does not support (or looks
  1184. Xlike it does not support) `annote' for the given field.
  1185. X
  1186. XReturn the success of the modification, or the list '(no-change-for
  1187. X\"<annote-fields>\") if non supporting `annote' for the given
  1188. Xfield."
  1189. X  (interactive (let ((field (car (annote-get-fields))))
  1190. X         (if field
  1191. X             (list (if (or (not current-prefix-arg)
  1192. X                   (eq current-prefix-arg '-))
  1193. X                   (read-string "Annotation field(s) name(s): "
  1194. X                        (annote-prompt-concat field
  1195. X                         " ")))
  1196. X               (< (prefix-numeric-value current-prefix-arg) 0)
  1197. X               nil)
  1198. X           (error "Unannotated buffer (or with other annote-func-prefix)."))))
  1199. X  (if (or (null annote-fields)
  1200. X      (and (stringp annote-fields)
  1201. X           (string-match "^[ \t]*$" annote-fields)))
  1202. X      (progn
  1203. X        (setq annote-fields (annote-get-fields buffer))
  1204. X        (if (interactive-p)
  1205. X            (progn (message "Annotation field(s) name(s): [ALL]") (sit-for 1)))))
  1206. X  (let ((annote-func-prefix (if annote-unannote-func-prefix
  1207. X                                annote-unannote-func-prefix
  1208. X                              annote-func-prefix)))
  1209. X    (annote-internal-ob annote-fields in-place buffer 'annote-internal-ub
  1210. X                        "Unannotating")))
  1211. X
  1212. X(defun annote-internal-ub (annote-fields inter)
  1213. X  (let ((sucess nil)
  1214. X    (temp))
  1215. X    (goto-char (point-min))
  1216. X    (if (not (search-forward (concat "\nFUNCTION {"
  1217. X                     (annote-mk-func annote-fields) "}")
  1218. X                 (point-max) t))
  1219. X    ;; We don't support this field
  1220. X    (progn
  1221. X      (setq success (list 'no-change-for annote-fields))
  1222. X      (message "No change needed for field `%s'." annote-fields))
  1223. X      ;; remember where the FUNCTION was
  1224. X      (setq temp (cons (match-beginning 0) (match-end 0)))
  1225. X      ;; delete the field from the ENTRY list
  1226. X      (goto-char (point-min))
  1227. X      (if (not (re-search-forward (concat annote-entry-regexp
  1228. X                      "[^}]*\\( " annote-fields
  1229. X                      "\n   \\)")
  1230. X                  (point-max) t))
  1231. X      (error (concat "Cannot find ENTRY declaration for field `"
  1232. X             annote-fields "'."))
  1233. X    (delete-region (match-beginning 1) (match-end 1)))
  1234. X      ;; delete the FUNCTION
  1235. X      (search-forward (concat "\nFUNCTION {"
  1236. X                  (annote-mk-func annote-fields) "}")
  1237. X              (point-max) t)
  1238. X      (goto-char (match-end 0))
  1239. X      (delete-region (match-beginning 0)
  1240. X             (1+ (scan-lists (match-end 0) 1 0)))
  1241. X      ;; and delete the call to that function too
  1242. X      (while (re-search-forward (concat "^[ \t]*"
  1243. X                    (annote-mk-func annote-fields) ".*\n")
  1244. X                (point-max) t)
  1245. X    (delete-region (match-beginning 0) (match-end 0)))
  1246. X      (setq success t)
  1247. X      (message "Removing annotation field `%s'." annote-fields)
  1248. X      (goto-char (point-min))
  1249. X      (if (re-search-forward (concat "`" annote-fields
  1250. X                     "' annotation field.\n")
  1251. X                 (point-max) t)
  1252. X      (let ((end (point)))
  1253. X        (if (re-search-backward "^% Style file modified" (point-min) t)
  1254. X        (delete-region (match-beginning 0) end))))
  1255. X      ;; try to be smart: if this was the last annotation found in
  1256. X      ;; the buffer we have to delete the advertising comment.
  1257. X      (goto-char (point-min))
  1258. X      (if (not (re-search-forward "^% Style file modified" (point-max) t))
  1259. X      (if (re-search-forward "\n%.*`annote'-compatible"
  1260. X                 (point-max) t)
  1261. X          (progn
  1262. X        (end-of-line 4)
  1263. X        (delete-region (match-beginning 0) (1+ (point)))))))
  1264. X    success))
  1265. X
  1266. X;;; Annotation of a file.
  1267. X;;;
  1268. X;;; If and savefile is nil or "", then the original file is modified.
  1269. X
  1270. X(defun annote-file (origfile &optional annote-fields savefile)
  1271. X  "Annote a file. If called interactively, asks for an existing
  1272. Xfilename, for the name(s) of the annotation field(s), and then for the name
  1273. Xof the annotated file. If this name is a directory, then the name of
  1274. Xthe file will be the filename of the original file in this directory,
  1275. Xunless the directories are the same, in which case the original file
  1276. Xwill have the value of annote-savefile-prefix prefixed to it. If the
  1277. Xbuffer was already visited, it is not destroyed.
  1278. X
  1279. XIf a numeric prefix argument is given, or if the name of the
  1280. Xannotation field is blank, the default value is taken from the
  1281. Xannote-default-annote-fields user variable.
  1282. X
  1283. XIf annote-buffer fails on the loaded file, it is not saved. Return
  1284. Xsuccess as got from annote-buffer."
  1285. X  (interactive (list (read-file-name "Bib file: " default-directory
  1286. X                     (eval annote-BibTeX-style-directory) t)
  1287. X             (if (not current-prefix-arg)
  1288. X             (read-string "Annotation field(s) name(s): "
  1289. X                      (annote-prompt-concat
  1290. X                         annote-default-annote-fields
  1291. X                     " ")))
  1292. X             (read-file-name "Save file: " default-directory
  1293. X                     default-directory)))
  1294. X  (annote-internal-of origfile annote-fields savefile 'annote-buffer))
  1295. X
  1296. X(defun annote-unannote-file (origfile &optional annote-fields savefile)
  1297. X  "Unannote a file. If called interactively, asks for an existing
  1298. Xfilename, for the name(s) of the annotation field(s), and then for the name
  1299. Xof the unannotated file. If this name is a directory, then the name of
  1300. Xthe file will be the filename of the original file in this directory,
  1301. Xunless the directories are the same, in which case the original file
  1302. Xwill have the value of annote-savefile-prefix prefixed to it. If the
  1303. Xbuffer was already visited, it is not destroyed.
  1304. X
  1305. XIf a numeric prefix argument is given, or if the name of the
  1306. Xannotation field is blank, the default value is taken from the
  1307. Xannote-default-annote-fields user variable.
  1308. X
  1309. XIf annote-buffer fails on the loaded file, it is not saved. Return
  1310. Xsuccess as got from annote-unannote-buffer."
  1311. X  (interactive (list (read-file-name "Bib file: " default-directory
  1312. X                     (eval annote-BibTeX-style-directory) t)
  1313. X             (if (not current-prefix-arg)
  1314. X             (read-string "Annotation field(s) name(s): "
  1315. X                      (annote-prompt-concat
  1316. X                         annote-default-annote-fields
  1317. X                     " ")))
  1318. X             (read-file-name "Save file: " default-directory
  1319. X                     default-directory)))
  1320. X  (annote-internal-of origfile annote-fields savefile 'annote-unannote-buffer))
  1321. X
  1322. X(defun annote-internal-of (origfile annote-fields savefile funct)
  1323. X  (setq origfile (expand-file-name origfile))
  1324. X  (if (file-directory-p origfile)
  1325. X      (error (concat "File `" origfile "' is a directory!")))
  1326. X  (if (or (null savefile)
  1327. X      (string-equal savefile ""))
  1328. X      (setq savefile (file-name-directory origfile)))
  1329. X  (if (string-match ".+\\(/+\\)$" savefile)
  1330. X      (setq savefile (substring savefile 0 (match-beginning 1))))
  1331. X  (if (file-directory-p savefile)
  1332. X      ;; the savefile is a directory
  1333. X      (progn
  1334. X    (setq savefile (concat savefile "/"))
  1335. X    (setq savefile
  1336. X          (concat savefile
  1337. X              (if (string-equal (file-name-directory origfile)
  1338. X                    savefile)
  1339. X              ;; same directory: append the contents of
  1340. X              ;; the annote-savefile-prefix variable
  1341. X              annote-savefile-prefix)
  1342. X              (file-name-nondirectory origfile)))))
  1343. X  (setq savefile (expand-file-name savefile))
  1344. X  ;; now do the real job: load the file, modify it, and save it
  1345. X  (if (not (file-readable-p origfile))
  1346. X      (error (concat "Wouldn't read `" origfile "'"))
  1347. X    (if (not (file-writable-p savefile))
  1348. X    (error (concat "Wouldn't write `" savefile "'"))))
  1349. X  (let ((success nil)
  1350. X    (was-here (get-file-buffer origfile))
  1351. X    (tembuf)
  1352. X    (modified))
  1353. X    (setq modified (if was-here (buffer-modified-p was-here))
  1354. X      tembuf (if was-here
  1355. X             (if (string-equal origfile savefile)
  1356. X             was-here
  1357. X               (let ((buf (generate-new-buffer " annote temp")))
  1358. X             (set-buffer buf)
  1359. X             (insert-buffer-substring was-here)
  1360. X             (setq was-here nil)
  1361. X             buf))
  1362. X           (find-file-noselect origfile)))
  1363. X    (if (or (null annote-fields)
  1364. X        (and (stringp annote-fields)
  1365. X         (string-match "^[ \t]*$" annote-fields)))
  1366. X    (progn
  1367. X      (setq annote-fields (annote-get-fields tembuf))
  1368. X      (if (interactive-p)
  1369. X          (message "Annotation field(s) name(s): [ALL]"))))
  1370. X    (unwind-protect
  1371. X    (save-excursion
  1372. X      (if (and (string-equal savefile origfile)
  1373. X           annote-backup-files)
  1374. X          ;; save the original file as a backup
  1375. X          (copy-file origfile
  1376. X             (concat (file-name-directory origfile)
  1377. X                 annote-backup-prefix
  1378. X                 (file-name-nondirectory origfile)
  1379. X                 annote-backup-suffix)
  1380. X             t))
  1381. X      (set-buffer tembuf)
  1382. X      (set-visited-file-name savefile)
  1383. X      (set-buffer-modified-p nil)
  1384. X      (if (eq (setq success (funcall funct annote-fields t)) t)
  1385. X          (save-buffer)))
  1386. X      (if (not (eq success t))
  1387. X      ;; don't save, it's either a fail or a no-op
  1388. X      (progn
  1389. X        (set-buffer tembuf)
  1390. X        (set-buffer-modified-p nil))))
  1391. X    (save-excursion
  1392. X      (set-buffer tembuf)
  1393. X      (set-buffer-modified-p modified))
  1394. X    (if (not was-here)
  1395. X    (kill-buffer tembuf))
  1396. X    success))
  1397. X
  1398. X;;; Guess the name of the annotation field from a filename. If it is ending in
  1399. X;;; the contents of annote-LaTeX-style-extension, then the
  1400. X;;; nondirectory part without the extension will be used, otherwise it
  1401. X;;; defaults to the contents of the annote-default-annote-fields variable.
  1402. X
  1403. X(defun annote-get-field-from-filename (fname)
  1404. X  (if (and fname
  1405. X       (string-match (concat annote-LaTeX-style-extension "$")
  1406. X             (file-name-nondirectory fname)))
  1407. X      (substring
  1408. X       (file-name-nondirectory fname)
  1409. X       0
  1410. X       (match-beginning 0))
  1411. X    annote-default-annote-fields))
  1412. X
  1413. X;;; Set values of fields when needed
  1414. X
  1415. X(defun annote-mk-values (lst)
  1416. X  (mapcar '(lambda (f)
  1417. X         (let ((x (car f))
  1418. X           (y (cdr f)))
  1419. X           (if (or (null (eval x))
  1420. X               (and (stringp (eval x))
  1421. X                (string-match "^[ \t]*$" (eval x))))
  1422. X           (set x (eval y)))))
  1423. X      lst))
  1424. X  
  1425. X;;; Insert the text for an annotation style for a given field.
  1426. X
  1427. X(defun annote-insert-style (&optional annote-field env-start env-end)
  1428. X  "Insert the text of a LaTeX style file for an environment used to
  1429. Xdisplay an annotation field.
  1430. X
  1431. XArguments are the name of the annotation field, and LaTeX code to
  1432. Xstart and end the environment. If the annotation field is not given or
  1433. Xblank, the function will try to guess it from the name of the visited
  1434. Xfile if any. In other cases, and for the other arguments, default
  1435. Xvalues from the user variables will be used.
  1436. X
  1437. XIf called interactively with a non-nil prefix argument, default values
  1438. Xwill be used."
  1439. X  (interactive (if (not current-prefix-arg)
  1440. X           (list (read-string "Annotation field name: "
  1441. X                      (annote-get-field-from-filename
  1442. X                       (buffer-file-name)))
  1443. X             (read-string "Start of env: "
  1444. X                      annote-default-env-start)
  1445. X             (read-string "End of env: "
  1446. X                      annote-default-env-end))))
  1447. X  ;; Restore default values if they were garbaged during reading
  1448. X  (annote-mk-values
  1449. X   '((annote-field . (annote-get-field-from-filename (buffer-file-name)))
  1450. X     (env-start . annote-default-env-start)
  1451. X     (env-end . annote-default-env-end)))
  1452. X  (insert "% `"
  1453. X      annote-field ".sty' annotation style file for BibTeX/LaTeX\n\n\
  1454. X% Style file generated on " (current-time-string) " with `annotebib.el' "
  1455. X                         annote-version-string "\n\
  1456. X%                      by " (user-full-name)
  1457. X" <" (user-real-login-name) "@" (system-name) ">\n\
  1458. X%                      to support the `" annote-field "' annotation field.\n\n\
  1459. X% This style file must be used in conjunction with a BibTeX style file\n\
  1460. X% supporting the `annote' package by Yves Arrouye <arrouye@imag.imag.fr>.\n\n\
  1461. X\\newenvironment{" annote-field "}{%\n" env-start "%\n}{%\n" env-end "%\n}\n"))
  1462. X
  1463. X;;; Write a style file with the text for an annotation style for a
  1464. X;;; given field.
  1465. X
  1466. X(defun annote-write-styles (&optional annote-fields
  1467. X                      env-start env-end overwrite inter)
  1468. X  "Write one or more files with the text of a LaTeX style file for an
  1469. Xenvironment used to display an annotation field.
  1470. X
  1471. XArguments are the name(s) of the annotation field(s), and LaTeX code
  1472. Xto start and end the environment. The names of the fields may be given
  1473. Xas a list of strings or a single strings with multiple names in it.
  1474. XIf an argument is not given, default values from the user variables
  1475. Xwill be used.
  1476. X
  1477. XThe function writes a file for each environment, prefixing the
  1478. Xcontents of annote-LaTeX-style-prefix to the annotation field name,
  1479. Xand adding the annote-LaTeX-style-suffix to it.
  1480. X
  1481. XIf called interactively with a non-nil prefix argument, default values
  1482. Xwill be used. If the last argument is non-nil or a negative prefix
  1483. Xargument is given, an existing file will be overwritten; otherwise, no
  1484. Xchanges are made to the contents of that file."
  1485. X  (interactive (append
  1486. X        (if (not current-prefix-arg)
  1487. X            (list (read-string "Annotation field(s) name(s): "
  1488. X                       (annote-prompt-concat
  1489. X                    (annote-get-field-from-filename "")
  1490. X                    " "))
  1491. X              (read-string "Start of env: "
  1492. X                       annote-default-env-start)
  1493. X              (read-string "End of env: "
  1494. X                       annote-default-env-end))
  1495. X          '(nil nil nil))
  1496. X        (list (< (prefix-numeric-value current-prefix-arg) 0)
  1497. X              t)))
  1498. X  (let ((err))
  1499. X    ;; Restore default values if they were garbaged during reading
  1500. X    (annote-mk-values
  1501. X     '((annote-fields . (annote-get-field-from-filename ""))
  1502. X       (env-start . annote-default-env-start)
  1503. X       (env-end . annote-default-env-end)))
  1504. X    (save-excursion
  1505. X      (setq annote-fields (annote-listify annote-fields
  1506. X                      annote-field-regexp))
  1507. X      (annote-clear-errors)
  1508. X      (while annote-fields
  1509. X    (condition-case therror
  1510. X        (annote-internal-ws (car annote-fields)
  1511. X                (concat annote-LaTeX-style-prefix
  1512. X                    (car annote-fields)
  1513. X                    annote-LaTeX-style-suffix)
  1514. X                overwrite
  1515. X                inter)
  1516. X      (error (message (car (cdr therror)))
  1517. X         (annote-add-to-errors therror)
  1518. X         (setq err (concat err
  1519. X                   (if err ", " "")
  1520. X                   "`" (car annote-fields) "'"))
  1521. X         (if inter (progn (beep) (sit-for 1)))))
  1522. X    (undo-boundary)
  1523. X    (setq annote-fields (cdr annote-fields)))
  1524. X      (if err
  1525. X      (error (concat "Style writing...done with errors for " err "."))
  1526. X    (message "Style writing...done.")))))
  1527. X
  1528. X(defun annote-internal-ws (annote-field stylefile overwrite inter)
  1529. X  (let ((stybuf)
  1530. X    (was-here (get-file-buffer stylefile)))
  1531. X    (setq stybuf (if was-here
  1532. X             was-here
  1533. X           (find-file-noselect stylefile)))
  1534. X    (set-buffer stybuf)
  1535. X    (setq stylefile (expand-file-name stylefile))
  1536. X    (if (or was-here (file-exists-p stylefile))
  1537. X    ;; must have overwriting permission first
  1538. X    (if (and (not overwrite)
  1539. X         inter
  1540. X         annote-ask-interactively)
  1541. X        ;; ask for confirmation
  1542. X        (setq overwrite (yes-or-no-p (concat "Overwrite " stylefile
  1543. X                         "? "))))
  1544. X      (setq overwrite t))
  1545. X    (if (not overwrite)
  1546. X    (error "Wouldn't overwrite `%s'" stylefile)
  1547. X      ;; okay, now we can do what we want
  1548. X      (message "Write style `%s' for field `%s'." stylefile annote-field)
  1549. X      (if (and (file-exists-p stylefile)
  1550. X           annote-backup-files)
  1551. X      (copy-file stylefile
  1552. X             (concat (file-name-directory stylefile)
  1553. X                 annote-backup-prefix
  1554. X                 (file-name-nondirectory stylefile)
  1555. X                 annote-backup-suffix)
  1556. X             t))
  1557. X      (erase-buffer)
  1558. X      (annote-insert-style annote-field env-start env-end)
  1559. X      (save-buffer))
  1560. X    (if (not was-here) (kill-buffer stybuf))))
  1561. X
  1562. X;;; Ask interactively for a list of filenames, until the user type RET
  1563. X;;; as an answer to the prompt. Arguments are a prompt for the first
  1564. X;;; filename, an optional  prompt for other filenames (defaults to the first
  1565. X;;; prompt), an optional directory and an optional flag requiring
  1566. X;;; existence of the file.
  1567. X
  1568. X(defun annote-read-file-names (prompt &optional secprompt directory existing)
  1569. X  "Read a list of file names."
  1570. X  (let ((names)
  1571. X    (current))
  1572. X    (if (not secprompt) (setq secprompt prompt))
  1573. X    (setq current (read-file-name prompt directory "" existing))
  1574. X    (while (not (string-equal current ""))
  1575. X      (setq names (append names (list current))
  1576. X        directory (file-name-directory current)
  1577. X        current (read-file-name secprompt directory "" existing)))
  1578. X    names))
  1579. X
  1580. X;;; Making a full package of annotated bibliography styles, both
  1581. X;;; BibTeX and LaTeX.
  1582. X
  1583. X(defun annote-make-annotated (&optional file-list annote-fields
  1584. X                    env-start env-end overwrite)
  1585. X  "Make a full annotated distribution. Gets the list of BibTeX files
  1586. Xto annotate, the list of annotation fields. Annotate the BibTeX files
  1587. Xand save them, then write the LaTeX style files (asking for
  1588. Xconfirmation depending on the value of the overwrite flag, see
  1589. Xannote-write-styles.  Note that the style files will all define the
  1590. Xsame environment (if you want different environments, you will have to
  1591. Xcall annote-file followed by as much annote-write-styles as you want
  1592. Xdifferent environments, but this is not painful, really...).
  1593. X
  1594. XWhen called interactively, the list of BibTeX files is asked for, and
  1595. Xone ends it by answering RET to the prompt. If the list is empty, it
  1596. Xdefaults to all accessible BibTeX style files. If a prefix argument is
  1597. Xgiven, it is used as in annote-write-styles for the default values and
  1598. Xoverwrite argument.
  1599. X
  1600. XIn a non-interactive call, the file list may be a string, which is
  1601. Xassumed to be a path of directories in which to get the the BibTeX files."
  1602. X  (interactive (append
  1603. X        (list (annote-read-file-names
  1604. X               "BibTeX style: "
  1605. X               "Another style: "
  1606. X               (eval annote-BibTeX-style-directory)
  1607. X               t))
  1608. X        (if (not current-prefix-arg)
  1609. X            (list (read-string "Annotation field(s) name(s): "
  1610. X                       (annote-prompt-concat
  1611. X                    (annote-get-field-from-filename "")
  1612. X                    " "))
  1613. X              (read-string "Start of env: "
  1614. X                       annote-default-env-start)
  1615. X              (read-string "End of env: "
  1616. X                       annote-default-env-end))
  1617. X          '(nil nil nil))
  1618. X        (list (< (prefix-numeric-value current-prefix-arg) 0))))
  1619. X  (setq annote-fields (annote-listify annote-fields))
  1620. X  (let ((err) (errors))
  1621. X    ;; if no files, default to all BibTeX files
  1622. X    (if (null file-list)
  1623. X    (if (and (interactive-p) annote-ask-confirmation)
  1624. X        (if (yes-or-no-p "Really annote all accessible BibTeX styles? ")
  1625. X        (setq file-list (annote-accessible-BibTeX-styles))
  1626. X          (setq file-list nil))
  1627. X      (setq file-list (annote-accessible-BibTeX-styles)))
  1628. X      (if (stringp file-list)
  1629. X      ;; assume it is a path
  1630. X      (setq file-list (annote-accessible-BibTeX-styles file-list))))
  1631. X    (if file-list
  1632. X    (progn
  1633. X      (message "Annotating...")
  1634. X      ;; annote the BibTeX styles by iterating over filenames
  1635. X      (while file-list
  1636. X        (annote-clear-errors)
  1637. X        (condition-case therror
  1638. X        (if (and (interactive-p) annote-ask-interactively)
  1639. X            ;; ask if you really want this one
  1640. X            (if (y-or-n-p (concat "Really annote `"
  1641. X                      (car file-list) "'? "))
  1642. X            (annote-file (car file-list) annote-fields))
  1643. X          (annote-file (car file-list) annote-fields))
  1644. X          (error (message (car (cdr therror)))
  1645. X             (annote-add-to-errors therror)
  1646. X             (setq err (concat err
  1647. X                       (if err ", " "")
  1648. X                       "`" (car file-list) "'"))
  1649. X             (if (interactive-p) (progn (beep) (sit-for 1)))))
  1650. X        ;; save the errors
  1651. X        (setq errors (append errors annote-errors))
  1652. X        ;; next file
  1653. X        (setq file-list (cdr file-list)))
  1654. X      ;; now generate the LaTeX styles
  1655. X      (condition-case therror
  1656. X          (annote-write-styles annote-fields env-start env-end
  1657. X                   overwrite (interactive-p))
  1658. X        (error (if (null err)
  1659. X               (error (car (cdr therror)))
  1660. X             (message (car (cdr therror))) (beep) (sit-for 1))))
  1661. X      (annote-set-errors errors)
  1662. X      (if err
  1663. X          (error (concat "Annotating...done with errors for " err "."))
  1664. X        (message "Annotating...done."))))
  1665. X      (message "Annotating...nothing done.")
  1666. X      annote-errors))
  1667. X
  1668. X(defun annote-make-unannotated (&optional file-list annote-fields)
  1669. X  "Unannote a list of files. Gets the list of BibTeX files
  1670. Xto annotate, the list of annotation fields. Unannotate the BibTeX files
  1671. Xand save them.
  1672. X
  1673. XWhen called interactively, the list of BibTeX files is asked for, and
  1674. Xone ends it by answering RET to the prompt. If the list is empty, it
  1675. Xdefaults to all accessible BibTeX style files.
  1676. X
  1677. XIn a non-interactive call, the file list may be a string, which is
  1678. Xassumed to be a path of directories in which to get the the BibTeX files."
  1679. X  (interactive (list (annote-read-file-names
  1680. X              "BibTeX style: "
  1681. X              "Another style: "
  1682. X              (eval annote-BibTeX-style-directory)
  1683. X              t)
  1684. X             (if (not current-prefix-arg)
  1685. X             (read-string "Annotation field(s) name(s): "
  1686. X                      (annote-prompt-concat
  1687. X                       (annote-get-field-from-filename "")
  1688. X                       " ")))))
  1689. X  (setq annote-fields (annote-listify annote-fields))
  1690. X  (let ((err) (errors))
  1691. X    ;; if no files, default to all BibTeX files
  1692. X    (if (null file-list)
  1693. X    (if (and (interactive-p) annote-ask-confirmation)
  1694. X        (if (yes-or-no-p "Really unannote all accessible BibTeX styles? ")
  1695. X        (setq file-list (annote-accessible-BibTeX-styles))
  1696. X          (setq file-list nil))
  1697. X      (setq file-list (annote-accessible-BibTeX-styles)))
  1698. X      (if (stringp file-list)
  1699. X      ;; assume it is a path
  1700. X      (setq file-list (annote-accessible-BibTeX-styles file-list))))
  1701. X    (if file-list
  1702. X    (progn
  1703. X      (message "Unannotating...")
  1704. X      ;; unannote the BibTeX styles by iterating over filenames
  1705. X      (annote-clear-errors)
  1706. X      (while file-list
  1707. X        (annote-clear-errors)
  1708. X        (condition-case therror
  1709. X        (if (and (interactive-p) annote-ask-interactively)
  1710. X            ;; ask if you really want this one
  1711. X            (if (y-or-n-p (concat "Really unannote `"
  1712. X                      (car file-list) "'? "))
  1713. X            (annote-unannote-file (car file-list) annote-fields))
  1714. X          (annote-unannote-file (car file-list) annote-fields))
  1715. X          (error (message (car (cdr therror)))
  1716. X             (annote-add-to-errors therror)
  1717. X             (setq err (concat err
  1718. X                       (if err ", " "")
  1719. X                       "`" (car file-list) "'"))
  1720. X             (if (interactive-p) (progn (beep) (sit-for 1)))))
  1721. X        ;; save the errors
  1722. X        (setq errors (append errors annote-errors))
  1723. X        ;; next file
  1724. X        (setq file-list (cdr file-list)))
  1725. X      (if err
  1726. X          (error (concat "Unannotating...done with errors for " err "."))
  1727. X        (message "Unannotating...done.")))
  1728. X      (message "Unannotating...nothing done."))
  1729. X    (annote-set-errors errors)))
  1730. X
  1731. X;;; List of files matching a regexp in a directory.
  1732. X
  1733. X(defun annote-directory-files-matching (directory &optional regexp)
  1734. X  "Return the list of files matching the given regexp in the given directory."
  1735. X  (mapcar '(lambda (what)
  1736. X         (concat directory "/" what))
  1737. X      (if regexp
  1738. X          (apply 'append (mapcar '(lambda (name)
  1739. X                    (if (string-match regexp name)
  1740. X                        (list name)))
  1741. X                     (directory-files directory)))
  1742. X        (directory-files directory))))
  1743. X
  1744. X;;; List of files matching a regexp in a path of directories
  1745. X
  1746. X(defun annote-path-files-matching (path path-sep &optional regexp)
  1747. X  "Return all files matching the regexp in the given path, where path
  1748. Xelements are separated by the single-char string path-sep."
  1749. X  (apply 'append
  1750. X     (mapcar '(lambda (dir)
  1751. X            (annote-directory-files-matching dir regexp))
  1752. X         (annote-listify path (concat "[^]" path-sep "]+")))))
  1753. X
  1754. X;;; Specialization of annote-path-files-matching for BibTeX style files
  1755. X
  1756. X(defun annote-accessible-BibTeX-styles (&optional path path-sep regexp)
  1757. X  "Return a list of all accessible BibTeX styles."
  1758. X  (if (null path) (setq path annote-BibTeX-path))
  1759. X  (if (null path-sep) (setq path-sep annote-BibTeX-path-separator))
  1760. X  (if (null regexp) (setq regexp (concat "\\" annote-BibTeX-style-extension
  1761. X                     "$")))
  1762. X  (annote-path-files-matching path path-sep regexp))
  1763. X
  1764. X;;; Error-supporting functions
  1765. X
  1766. X(defun annote-set-errors (err)
  1767. X  (setq annote-errors err))
  1768. X
  1769. X(defun annote-clear-errors ()
  1770. X  (annote-set-errors nil))
  1771. X
  1772. X(defun annote-add-to-errors (err)
  1773. X  (setq annote-errors (append annote-errors (list (car (cdr err))))))
  1774. END_OF_FILE
  1775. if test 44921 -ne `wc -c <'annotebib.el'`; then
  1776.     echo shar: \"'annotebib.el'\" unpacked with wrong size!
  1777. fi
  1778. # end of 'annotebib.el'
  1779. fi
  1780. if test -f 'annote.sty' -a "${1}" != "-c" ; then 
  1781.   echo shar: Will not clobber existing file \"'annote.sty'\"
  1782. else
  1783. echo shar: Extracting \"'annote.sty'\" \(461 characters\)
  1784. sed "s/^X//" >'annote.sty' <<'END_OF_FILE'
  1785. X% `annote.sty' annotation style file for BibTeX/LaTeX
  1786. X
  1787. X% Style file generated on Tue Jun  8 12:32:12 1993 with `annotebib.el' v1.5.1
  1788. X%                      by Yves.Arrouye <arrouye@cosmos>
  1789. X%                      to support the `annote' annotation field.
  1790. X
  1791. X% This style file must be used in conjunction with a BibTeX style file
  1792. X% supporting the `annote' package by Yves Arrouye <arrouye@imag.imag.fr>.
  1793. X
  1794. X\newenvironment{annote}{%
  1795. X\begin{quote}%
  1796. X}{%
  1797. X\end{quote}%
  1798. X}
  1799. END_OF_FILE
  1800. if test 461 -ne `wc -c <'annote.sty'`; then
  1801.     echo shar: \"'annote.sty'\" unpacked with wrong size!
  1802. fi
  1803. # end of 'annote.sty'
  1804. fi
  1805. if test -f 'commentaire.sty' -a "${1}" != "-c" ; then 
  1806.   echo shar: Will not clobber existing file \"'commentaire.sty'\"
  1807. else
  1808. echo shar: Extracting \"'commentaire.sty'\" \(476 characters\)
  1809. sed "s/^X//" >'commentaire.sty' <<'END_OF_FILE'
  1810. X% `commentaire.sty' annotation style file for BibTeX/LaTeX
  1811. X
  1812. X% Style file generated on Tue Jun  8 12:32:11 1993 with `annotebib.el' v1.5.1
  1813. X%                      by Yves.Arrouye <arrouye@cosmos>
  1814. X%                      to support the `commentaire' annotation field.
  1815. X
  1816. X% This style file must be used in conjunction with a BibTeX style file
  1817. X% supporting the `annote' package by Yves Arrouye <arrouye@imag.imag.fr>.
  1818. X
  1819. X\newenvironment{commentaire}{%
  1820. X\begin{quote}%
  1821. X}{%
  1822. X\end{quote}%
  1823. X}
  1824. END_OF_FILE
  1825. if test 476 -ne `wc -c <'commentaire.sty'`; then
  1826.     echo shar: \"'commentaire.sty'\" unpacked with wrong size!
  1827. fi
  1828. # end of 'commentaire.sty'
  1829. fi
  1830. echo shar: End of shell archive.
  1831. exit 0
  1832.  
  1833. exit 0 # Just in case...
  1834.