From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: orgstruct minor mode (WAS: latex <-> org ?) Date: Fri, 19 Dec 2008 09:40:00 +0100 Message-ID: <32BD40B8-4DD1-4B11-A664-F1B1199FABE2@uva.nl> References: <20081204165144.GA8550@stats.ox.ac.uk> <20081204231231.GE8550@stats.ox.ac.uk> <20081208.143918.07440426.harri.kiiskinen@utu.fi> <20081218165041.GA9810@stats.ox.ac.uk> Mime-Version: 1.0 (Apple Message framework v929.2) Content-Type: multipart/mixed; boundary="===============2056568990==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LDau3-0004rN-UF for emacs-orgmode@gnu.org; Fri, 19 Dec 2008 03:40:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LDau1-0004q1-MA for emacs-orgmode@gnu.org; Fri, 19 Dec 2008 03:40:09 -0500 Received: from [199.232.76.173] (port=60177 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LDatz-0004pi-II for emacs-orgmode@gnu.org; Fri, 19 Dec 2008 03:40:07 -0500 Received: from ug-out-1314.google.com ([66.249.92.169]:29035) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LDatx-0002hj-QG for emacs-orgmode@gnu.org; Fri, 19 Dec 2008 03:40:06 -0500 Received: by ug-out-1314.google.com with SMTP id 36so614657uga.17 for ; Fri, 19 Dec 2008 00:40:05 -0800 (PST) In-Reply-To: <20081218165041.GA9810@stats.ox.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: emacs-orgmode@gnu.org --===============2056568990== Content-Type: multipart/alternative; boundary=Apple-Mail-6-113213361 --Apple-Mail-6-113213361 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hi Dan, you best bet for this is using outline-minor-mode, in connection with org-cycle, see http://orgmode.org/worg/org-faq.php#use-visibility-cycling-in-outline-mode Trying to get orgstruct-mode working correctly for this means entering a world of pain. A world of pain, Larry. Of you want structure editing in LaTeX files, look at reftex-mode, use ">" and "<" in the reftex-toc buffer to demote and promote sections. - Carsten On Dec 18, 2008, at 5:50 PM, Dan Davison wrote: > Hi all, > > I'm still working on a good strategy for using org-mode style > visibility cycling when working on latex documents, and also for > function bodies in code files. My current idea is that I should be > using orgstruct minor mode to do this. I'm hoping that will allow me > to have all the org-mode navigation/visibility cycling I want, while > retaining all the native mode functionality, including font lock. So > basically what I have in mind is the following psuedo-code > > org-convert-some-src-mode () > insert-asterisks-at-appropriate-places > enable-orgstruct-minor-mode > org-overview > > and the reverse. > > The above works very nicely for hiding function bodies in files > containing R function definitions, but I'm running into some problems > with latex. Say I open this file (with a .tex extension) > > \begin{document} > * h1 > ** h11 > * h2 > ** h21 > \end{document} > > It opens in latex-mode, and I enable orgstruct minor mode. I notice > that the value of outline-regexp is currently a complicated regexp > containing various latex section headings / macros. Now org-overview > results in > > \begin{document} > \end{document} > > In contrast, without the \begin \end macros, the file opens in TeX > mode, outline-regexp is "[*\f]+" (what's the \f?), and org-overview > results in > > * h1 > * h2 > > as desired. > > However simply setting outline-regexp to "[*\f]+" doesn't seem to do > the job -- then org-overview does nothing, with an "Unrecognized > header" error. (I haven't found the source of that error message yet > in org/emacs lisp code). > > I'd appreciate any comments on the approach I've outlined, and advice > on how to get the asterisked latex buffer to respond to org-overview > as desired. > > I know that there are existing applications of outline-mode to various > major modes, but seeing as I am accustomed to org-mode, and seeing as > Carsten worked on improving outline-mode at the outset of the org > project, I am thinking that it's worth doing this in an org-specific > way. Is that wrong? Should I just be using outline-mode for what I > want to do? > > Thanks! > > Dan > > p.s. I note that org-overview is not listed as one of the functions > that is available in orgstruct minor mode. Nevertheless it seems to > often work, and I was hoping that (something like) it could indeed be > _expected_ to work. > > > > > > On Mon, Dec 08, 2008 at 02:39:18PM +0200, Harri Kiiskinen wrote: >> Very nice! I've been hoping for this kind of functionality for a >> while, since I'm really struggling to organize some text-mass >> produced >> by myself over the years, and it seems, that with this I can >> re-organize largish LaTeX-documents with relative ease. (For some >> reason, the order in which a text is naturally written may not be the >> one that is most interesting to read...) A quick test drive gives >> ok, >> the document is exactly the same (tested with diff) after having gone >> through the conversion back and forth. >> >> I think it is a good thing to keep this separate from any of the >> org-mode export functions. As far as I can see, the main use for this >> is the editing of already existing LaTeX file (as in the case of the >> original request), where you have to keep the file as closely >> resembling the original as possible. >> >> Also, this does not seem like something you use all the time when >> editing LaTeX-files, but more like a tool very handy for reorganizing >> and restructuring your work, i.e. not a replacement for >> org-export-latex, but a tool to integrate existing material to the >> new, exciting org-mode work flow. >> >> Harri K. >> >> From: Dan Davison >> Subject: Re: [Orgmode] latex <-> org ? >> Date: Thu, 4 Dec 2008 18:12:31 -0500 >> >>> For what it's worth, here's my attempt at a simple version of >>> this. These flip a latex document into org mode so that you can see >>> the document structure, and then flip it back, hopefully to the same >>> latex document. #+begin_src ... #+end_src are inserted in the org >>> version so that text in unfolded sections can be edited in latex- >>> mode >>> via C-c '. The only latex tags operated on are \section, \subsection >>> and \subsubsection. But maybe a proper version of this already >>> exists >>> somewhere? >>> >>> Dan >>> >>> (defun org-latex-to-org () >>> "Convert latex buffer to org." >>> (interactive) >>> (beginning-of-buffer) >>> (if (save-excursion (re-search-forward "^\\\\title{\\([^}]*\\)}" >>> nil t)) >>> (insert (concat "#+title: " (match-string 1) "\n")) >>> (insert "#+title: [No title found]\n")) >>> (insert "* Preamble\n") >>> (let (level dummy) >>> (dotimes (level 3) >>> (let (string) >>> (dotimes (dummy level) (setq string (concat "sub" string))) ;; >>> how do you make e.g. 'subsub'? >>> (save-excursion >>> (while (re-search-forward (concat "^\\\\" string "section\\(\\*? >>> {.*\\)$") nil t) >>> (replace-match >>> (concat (make-string (1+ level) (string-to-char "*")) " " >>> (replace-regexp-in-string "\\\\" "\\\\\\\\" (match-string >>> 1))) ;; further '\'s might occur e.g. \label{} >>> nil nil) >>> (beginning-of-line) >>> (insert "#+end_src\n") >>> (end-of-line) >>> (insert "\n#+begin_src latex")))))) >>> (org-mode)) >>> >>> (defun org-latex-to-org-inverse () >>> "Convert org buffer to latex. Intended to be the inverse of org- >>> latex-to-org." >>> (interactive) >>> (latex-mode) >>> (beginning-of-buffer) >>> (kill-line 2) >>> (save-excursion (while (re-search-forward "^#\\+begin_src latex" >>> nil t) (kill-line 0) (kill-line))) >>> (save-excursion (while (re-search-forward "^#\\+end_src" nil t) >>> (kill-line 0) (kill-line))) >>> (save-excursion >>> (while (re-search-forward "^\\* \\(.*\\)$" nil t) >>> (replace-match >>> (concat "\\\\section" (replace-regexp-in-string "\\\\" "\\\\\\ >>> \\" (match-string 1))) nil nil))) >>> (save-excursion >>> (while (re-search-forward "^\\*\\* \\(.*\\)$" nil t) >>> (replace-match >>> (concat "\\\\subsection" (replace-regexp-in-string "\\\\" "\\\ >>> \\\\\" (match-string 1))) nil nil))) >>> (save-excursion >>> (while (re-search-forward "^\\*\\*\\* \\(.*\\)$" nil t) >>> (replace-match >>> (concat "\\\\subsubsection" (replace-regexp-in-string "\\\\" >>> "\\\\\\\\" (match-string 1))) nil nil)))) >>> >>> >>> On Thu, Dec 04, 2008 at 11:51:44AM -0500, Dan Davison wrote: >>>> Has anyone worked on reversible transformation between org and >>>> latex? >>>> I'm collaborating on a latex document with some non-org >>>> users. Basically what I'd like to do is transform a latex document >>>> into an org document, fold/unfold sections and edit the document >>>> under >>>> org-mode, and then reconvert to latex. The end result would be as >>>> if >>>> the transformation to org had never happened. >>>> >>>> At its simplest those functions would convert between '\section' >>>> <-> >>>> '* section', '\subsection' <-> '** subsection' etc, but obviously >>>> there's a lot more that could be done such as all the conversions >>>> that >>>> org-export-to-latex does; I imagine that function couldn't be used >>>> directly, but ideally the inverse of the latex->org function would >>>> share conversion code with org-export-to-latex. Does this idea make >>>> sense, and has anyone already worked on this? >>>> >>>> Dan >>>> >>>> -- >>>> http://www.stats.ox.ac.uk/~davison >>>> >>>> >>>> _______________________________________________ >>>> Emacs-orgmode mailing list >>>> Remember: use `Reply All' to send replies to the list. >>>> Emacs-orgmode@gnu.org >>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >>> >>> -- >>> http://www.stats.ox.ac.uk/~davison > > -- > http://www.stats.ox.ac.uk/~davison > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode --Apple-Mail-6-113213361 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Dan,

you best bet for = this is using outline-minor-mode, in connection with
org-cycle, = see

http://orgmode.org/worg/org-faq.php#use-visibility-cycling-in-ou= tline-mode

Trying to get orgstruct-mode working correctly for = this means
entering a world of pain.  A world of pain, = Larry.

Of you want structure editing in LaTeX files, look at = reftex-mode, use
">" and "<" in the reftex-toc buffer to demote = and promote sections.

- Carsten

On Dec 18, 2008, at 5:50 = PM, Dan Davison wrote:

Hi = all,

I'm still = working on a good strategy for using org-mode = style
visibility cycling when = working on latex documents, and also for
function bodies in code files. My current idea is that I = should be
using orgstruct = minor mode to do this. I'm hoping that will allow = me
to have all the org-mode = navigation/visibility cycling I want, while
retaining all the native mode functionality, including = font lock. So
basically what I = have in mind is the following psuedo-code

org-convert-some-src-mode ()
=   insert-asterisks-at-appropriate-places
=   enable-orgstruct-minor-mode
  org-overview

and the = reverse.

The above works = very nicely for hiding function bodies in = files
containing R function = definitions, but I'm running into some = problems
with latex. Say I = open this file (with a .tex extension)

\begin{document}
*= h1
** = h11
* = h2
** = h21
\end{document}

It opens in = latex-mode, and I enable orgstruct minor mode. I = notice
that the value of = outline-regexp is currently a complicated = regexp
containing various = latex section headings / macros. Now = org-overview
results = in

\begin{document}
\end{document}

In contrast, = without the \begin \end macros, the file opens in = TeX
mode, outline-regexp is = "[*\f]+" (what's the \f?), and org-overview
results in

* = h1
* = h2

as desired.

However simply = setting outline-regexp to "[*\f]+" doesn't seem to = do
the job -- then = org-overview does nothing, with an = "Unrecognized
header" error. = (I haven't found the source of that error message = yet
in org/emacs lisp = code).

I'd appreciate = any comments on the approach I've outlined, and = advice
on how to get the = asterisked latex buffer to respond to = org-overview
as = desired.

I know that = there are existing applications of outline-mode to = various
major modes, but = seeing as I am accustomed to org-mode, and seeing = as
Carsten worked on improving = outline-mode at the outset of the org
project, I am thinking that it's worth doing this in an = org-specific
way. Is that = wrong? Should I just be using outline-mode for what = I
want to = do?

Thanks!

Dan

p.s. I note = that org-overview is not listed as one of the = functions
that is available in = orgstruct minor mode. Nevertheless it seems = to
often work, and I was = hoping that (something like) it could indeed = be
_expected_ to = work.





On Mon, Dec 08, = 2008 at 02:39:18PM +0200, Harri Kiiskinen = wrote:
Very nice! I've been hoping for this kind of functionality = for a
while, since I'm really struggling to organize some = text-mass produced
by myself over the years, and it = seems, that with this I can
re-organize largish = LaTeX-documents with relative ease. (For = some
reason, the order in which a text is naturally written may = not be the
one that is most interesting to = read...)  A quick test drive gives = ok,
the document is exactly the same (tested with diff) after = having gone
through the conversion back and = forth.

I think it is a good thing to = keep this separate from any of = the
org-mode export functions. As far as I can see, the main = use for this
is the editing of already = existing LaTeX file (as in the case of = the
original request), where you have to keep the file as = closely
resembling the original as = possible.

Also, this does not seem like = something you use all the time = when
editing LaTeX-files, but more like a tool very handy for = reorganizing
and restructuring your work, = i.e. not a replacement for
org-export-latex, but a tool to = integrate existing material to = the
new, exciting org-mode work = flow.

Harri = K.

From: Dan Davison = <davison@stats.ox.ac.uk>
Subject: Re: [Orgmode] latex = <-> org ?
Date: Thu, 4 Dec 2008 18:12:31 = -0500

For = what it's worth, here's my attempt at a simple version = of
this. = These flip a latex document into org mode so that you can = see
the = document structure, and then flip it back, hopefully to the = same
latex = document. #+begin_src ... #+end_src are inserted in the = org
version = so that text in unfolded sections can be edited in = latex-mode
via = C-c '. The only latex tags operated on are \section, = \subsection
and = \subsubsection. But maybe a proper version of this already = exists
somewhere?

Dan

(defun = org-latex-to-org = ()
= "Convert latex buffer to = org."
= (interactive)
= (beginning-of-buffer)
(if = (save-excursion (re-search-forward "^\\\\title{\\([^}]*\\)}" nil = t))
=     (insert (concat "#+title: " (match-string 1) = "\n"))
=   (insert "#+title: [No title = found]\n"))
= (insert "* = Preamble\n")
(let = (level dummy)
=   (dotimes (level = 3)
=     (let = (string)
(dotimes = (dummy level) (setq string (concat "sub" string))) ;; how do you make = e.g. 'subsub'?
= (save-excursion
=  (while (re-search-forward (concat "^\\\\" string = "section\\(\\*?{.*\\)$") nil = t)
=    (replace-match
=     (concat (make-string (1+ level) = (string-to-char "*")) " = "
=     (replace-regexp-in-string "\\\\" "\\\\\\\\" = (match-string 1))) ;; further '\'s might occur e.g. = \label{}
=     nil = nil)
=    (beginning-of-line)
=    (insert = "#+end_src\n")
=    (end-of-line)
=
=    (insert "\n#+begin_src = latex"))))))
= (org-mode))

(defun = org-latex-to-org-inverse = ()
= "Convert org buffer to latex. Intended to be the inverse of = org-latex-to-org."
= (interactive)
= (latex-mode)
= (beginning-of-buffer)
= (kill-line 2)
= (save-excursion (while (re-search-forward "^#\\+begin_src latex" nil t) = (kill-line 0) = (kill-line)))
= (save-excursion (while (re-search-forward "^#\\+end_src" nil t) = (kill-line 0) = (kill-line)))
= (save-excursion
=   (while (re-search-forward "^\\* \\(.*\\)$" nil = t)
=     (replace-match
     (concat "\\\\section" = (replace-regexp-in-string "\\\\" "\\\\\\\\" (match-string 1))) nil = nil)))
= (save-excursion
=   (while (re-search-forward "^\\*\\* \\(.*\\)$" nil = t)
=     (replace-match
     (concat "\\\\subsection" = (replace-regexp-in-string "\\\\" "\\\\\\\\" (match-string 1))) nil = nil)))
= (save-excursion
=   (while (re-search-forward "^\\*\\*\\* \\(.*\\)$" nil = t)
=     (replace-match
     (concat "\\\\subsubsection" = (replace-regexp-in-string "\\\\" "\\\\\\\\" (match-string 1))) nil = nil))))


On = Thu, Dec 04, 2008 at 11:51:44AM -0500, Dan Davison = wrote:
Has anyone worked on reversible = transformation between org and = latex?
I'm collaborating on a latex = document with some = non-org
users. Basically what I'd like = to do is transform a latex = document
into an org document, = fold/unfold sections and edit the document = under
org-mode, and then reconvert to = latex. The end result would be as = if
the transformation to org had = never = happened.

At its simplest those functions = would convert between '\section' = <->
'* section', '\subsection' = <-> '** subsection' etc, but = obviously
there's a lot more that could be = done such as all the conversions = that
org-export-to-latex does; I = imagine that function couldn't be = used
directly, but ideally the = inverse of the latex->org function = would
share conversion code with = org-export-to-latex. Does this idea = make
sense, and has anyone already = worked on = this?

Dan
<= blockquote type=3D"cite">

-- =
http://www.stats.ox.ac.uk/~davison


_______________________________________________
Emacs-orgmode mailing = list
Remember: use `Reply All' to = send replies to the = list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

-- =
http://www.stats.ox.ac.uk/~davison

--
http://www.stats.ox.ac.uk/~davison


_______________________________________________
Emacs-orgmode mailing = list
Remember: use `Reply All' = to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

= --Apple-Mail-6-113213361-- --===============2056568990== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============2056568990==--