emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] [patch] better(?) indention for cdlatex-environment


From: Nicolas Goaziou
Subject: Re: [O] [patch] better(?) indention for cdlatex-environment
Date: Tue, 10 Feb 2015 23:35:26 +0100

Hello,

Rasmus <address@hidden> writes:

> Cdlatex environment inserted via org-cdlatex-environment-indent are pretty
> bad at getting the right indention.  Consider:
>
>     - concept :: a long description of concept |
>
> Where | is cursor.  When I call org-cdlatex-environment-indent, I expect 
>
>     - concept :: a long description of concept
>           \begin{equation}
>           |
>           \end{equation}
>
> But I get 
>
>     - concept :: a long description of concept
>     \begin{equation}
>     |
>     \end{equation}
>
> This is because it determines the indention after the element is inserted
> at column zero.  So the correct indention /is/ column zero but I wanted it
> to be part of the description.  IOW I want Org to use the correct
> indention of when the time when I call the command.
>
> Note that I can still get an environment at column zero by issuing the
> command here:
>
>     - concept :: a long description of concept
>     |
>
> This patch just fixes this for org-cdlatex-indent-environment only, but
> maybe it's more correct to fix it in org-indent-region?

`org-indent-region' is right here, so I don't see what should be fixed
there.

You can get real indentation by indenting a new line first. What about
the following?

  (defun org-cdlatex-environment-indent (&optional environment item)
    (org-return-indent)
    (beginning-of-line)
    (let ((ind (org-get-indentation)))
      (cdlatex-environment environment item)
      (save-excursion (forward-line -1) (org-indent-to-column ind))
      (save-excursion (forward-line 1) (org-indent-to-column ind))
      (org-indent-to-column ind)))


Regards,

-- 
Nicolas Goaziou



reply via email to

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