help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: outline -> latex


From: Oliver Scholz
Subject: Re: outline -> latex
Date: Sun, 19 Oct 2003 16:04:03 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (windows-nt)

ray@nabuli.de writes:
[...]
> just a question here: Isn't there an easy way to convert outline into
> latex?  I am not realy sure, but I thought there was something.  Does
> somebody have a clue?

I am not aware of any package doing this, but unless I am
misunderstanding you, I dare say that this task is rather trivial,
since it is just about regexp matching and replacing.

Hmm, maybe:

(defconst ray-outline-to-latex-alist
  '((1 "\\section{%s}")
    (2 "\\subsection{%s}")
    (3 "\\subsubsection{%s}")))

(defun ray-outline-to-latex ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (ray-convert-heading-maybe)
    (while (= 0 (forward-line 1))
      (ray-convert-heading-maybe))))

(defun ray-convert-heading-maybe ()
  (when (looking-at outline-regexp)
    (let ((format (cadr (assq (funcall outline-level)
                              ray-outline-to-latex-alist)))
          str)
      (when format
        (goto-char (match-end 0))
        (skip-syntax-forward "-")
        (setq str (buffer-substring (point) (line-end-position)))
        (delete-region (line-beginning-position)
                       (line-end-position))
        (insert (format format str))))))


    Oliver
-- 
28 Vendémiaire an 212 de la Révolution
Liberté, Egalité, Fraternité!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]