From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [patch] better(?) indention for cdlatex-environment Date: Wed, 11 Feb 2015 22:39:32 +0100 Message-ID: <87fvacw2jv.fsf@nicolasgoaziou.fr> References: <87386e0zuy.fsf@gmx.us> <87wq3pwg29.fsf@nicolasgoaziou.fr> <87lhk48z9x.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLezM-0000Zn-Ts for emacs-orgmode@gnu.org; Wed, 11 Feb 2015 16:38:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLezJ-0004xn-OP for emacs-orgmode@gnu.org; Wed, 11 Feb 2015 16:38:28 -0500 Received: from relay6-d.mail.gandi.net ([2001:4b98:c:538::198]:36274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLezJ-0004xh-Hb for emacs-orgmode@gnu.org; Wed, 11 Feb 2015 16:38:25 -0500 In-Reply-To: <87lhk48z9x.fsf@gmx.us> (rasmus@gmx.us's message of "Wed, 11 Feb 2015 12:26:34 +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 Rasmus writes: > Indeed that this the trick. The attached patch seems to work nicely and > takes care of the corner cases I could think of. > > I now get the following (desirable) behavior > > - key :: foo | bar > baz > # insert latex-environment with cdlatex > > - key :: foo | bar > \begin{ENV} > whatever > \end{ENV} > baz I don't see how it is desirable. The logical behaviour is to split the line, unless, of course, docstring clearly specifies this. AFAICT `cdlatex-environment' splits the line. Is there a particular reason for `org-cdlatex-environment-indent' to proceed differently? > Here's another case > p1 > - item | item > p2 > # insert latex-environment with cdlatex > p1 > - item item > \begin{equation} > \label{eq:9} > > \end{equation} Ditto. > + ;; TODO: Cleanup if quit. Unfortunately `cdlatex-environment' > + ;; always return nil. What do you want to clean up? In what situations? Can't `unwind-protect' help you? > + (let* (;; Insert environment on next line unless at beginning of line. Comments starting with ";;" need to be on a line on their own. > + (eol > + (unless (<= (point) > + (save-excursion (beginning-of-line) > + (org-skip-whitespace) > + (point))) Nitpick: (unless (save-excursion (skip-chars-backward " \t") (bolp)) ...) > + (end-of-line) t)) > + ;; Get correct indention for next line. > + (ind (if eol (save-excursion > + (org-return-indent) > + (prog1 (org-get-indentation) > + (unless (or (eobp) (looking-at "[^ \t]")) Nitpick: (org-looking-at-p "\\S-") > + (kill-whole-line)))) There's no need to pollute the kill ring. (delete-region (line-beginning-position) (line-end-position)) Anyway, why bother? Regards,