~ubuntu-branches/ubuntu/oneiric/muse-el/oneiric

« back to all changes in this revision

Viewing changes to lisp/muse-latex.el

  • Committer: Bazaar Package Importer
  • Author(s): Michael W. Olson (GNU address)
  • Date: 2008-01-09 15:51:46 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080109155146-0wwzermvvzs9rqzo
Tags: 3.11-3ubuntu1
* Merge with with Debian unstable (LP: #137284). Remaining Ubuntu changes:
  - Keep manual.
  - Set Ubuntu MOTU to be Maintainer

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
;; Emacs Muse is free software; you can redistribute it and/or modify
8
8
;; it under the terms of the GNU General Public License as published
9
 
;; by the Free Software Foundation; either version 2, or (at your
 
9
;; by the Free Software Foundation; either version 3, or (at your
10
10
;; option) any later version.
11
11
 
12
12
;; Emacs Muse is distributed in the hope that it will be useful, but
95
95
  :type 'string
96
96
  :group 'muse-latex)
97
97
 
98
 
(defcustom muse-latex-footer "\n\\end{document}\n"
 
98
(defcustom muse-latex-footer "<lisp>(muse-latex-bibliography)</lisp>
 
99
\\end{document}\n"
99
100
  "Footer used for publishing LaTeX files.  This may be text or a filename."
100
101
  :type 'string
101
102
  :group 'muse-latex)
228
229
    (anchor          . "\\label{%s}")
229
230
    (emdash          . "---")
230
231
    (comment-begin   . "% ")
231
 
    (rule            . "\\bigskip")
 
232
    (rule            . "\\vspace{.5cm}\\hrule\\vspace{.5cm}")
232
233
    (no-break-space  . "~")
233
234
    (enddots         . "\\ldots{}")
234
235
    (dots            . "\\dots{}")
267
268
    (end-center      . "\n\\end{center}")
268
269
    (begin-quote     . "\\begin{quote}\n")
269
270
    (end-quote       . "\n\\end{quote}")
 
271
    (begin-cite     . "\\cite{")
 
272
    (begin-cite-author . "\\citet{")
 
273
    (begin-cite-year . "\\citet{")
 
274
    (end-cite        . "}")
270
275
    (begin-uli       . "\\begin{itemize}\n")
271
276
    (end-uli         . "\n\\end{itemize}")
272
277
    (begin-uli-item  . "\\item ")
489
494
          (replace-match "''")
490
495
          (setq open t))))))
491
496
 
 
497
(defun muse-latex-fixup-citations ()
 
498
  "Replace semicolons in multi-head citations with colons."
 
499
  (goto-char (point-min))
 
500
  (while (re-search-forward "\\\\cite.?{" nil t)
 
501
    (let ((start (point))
 
502
          (end (re-search-forward "}")))
 
503
      (save-restriction
 
504
        (narrow-to-region start end)
 
505
        (goto-char (point-min))
 
506
        (while (re-search-forward ";" nil t)
 
507
          (replace-match ","))))))
 
508
 
 
509
(defun muse-latex-fixup-headings ()
 
510
  "Remove footnotes in headings, since LaTeX does not permit them to exist.
 
511
 
 
512
This can happen if there is a link in a heading, because by
 
513
default Muse will add a footnote for each link."
 
514
  (goto-char (point-min))
 
515
  (while (re-search-forward "^\\\\section.?{" nil t)
 
516
    (save-restriction
 
517
      (narrow-to-region (match-beginning 0) (muse-line-end-position))
 
518
      (goto-char (point-min))
 
519
      (while (re-search-forward "\\\\footnote{[^}\n]+}" nil t)
 
520
        (replace-match ""))
 
521
      (forward-line 1))))
 
522
 
492
523
(defun muse-latex-munge-buffer ()
493
524
  (muse-latex-fixup-dquotes)
 
525
  (muse-latex-fixup-citations)
 
526
  (muse-latex-fixup-headings)
494
527
  (when (and muse-latex-permit-contents-tag
495
528
             muse-publish-generate-contents)
496
529
    (goto-char (car muse-publish-generate-contents))
497
530
    (muse-insert-markup "\\tableofcontents")))
498
531
 
 
532
(defun muse-latex-bibliography ()
 
533
  (save-excursion
 
534
    (goto-char (point-min))
 
535
    (if (re-search-forward "\\\\cite.?{" nil t)
 
536
        (concat
 
537
         "\\bibliography{"
 
538
         (muse-publishing-directive "bibsource")
 
539
         "}\n")
 
540
      "")))
 
541
 
499
542
(defun muse-latex-pdf-browse-file (file)
500
543
  (shell-command (concat "open " file)))
501
544
 
561
604
 
562
605
(muse-derive-style "slides" "latex"
563
606
                   :header 'muse-latex-slides-header
564
 
                   :tags 'muse-latex-slides-markup-tags)
 
607
                   :tags   'muse-latex-slides-markup-tags)
565
608
 
566
609
(muse-derive-style "slides-pdf" "pdf"
567
610
                   :header 'muse-latex-slides-header
568
 
                   :tags 'muse-latex-slides-markup-tags)
 
611
                   :tags   'muse-latex-slides-markup-tags)
569
612
 
570
613
(muse-derive-style "lecture-notes" "slides"
571
614
                   :header 'muse-latex-lecture-notes-header)