From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [patch] better(?) indention for cdlatex-environment Date: Tue, 10 Feb 2015 23:35:26 +0100 Message-ID: <87wq3pwg29.fsf@nicolasgoaziou.fr> References: <87386e0zuy.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLJNx-0002Ip-HO for emacs-orgmode@gnu.org; Tue, 10 Feb 2015 17:34:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLJNr-0005bn-IV for emacs-orgmode@gnu.org; Tue, 10 Feb 2015 17:34:25 -0500 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:50487) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLJNr-0005bd-CS for emacs-orgmode@gnu.org; Tue, 10 Feb 2015 17:34:19 -0500 In-Reply-To: <87386e0zuy.fsf@gmx.us> (rasmus@gmx.us's message of "Tue, 10 Feb 2015 12:28:53 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Rasmus Cc: emacs-orgmode@gnu.org Hello, Rasmus 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