From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [patch] better(?) indention for cdlatex-environment Date: Sat, 14 Feb 2015 22:20:59 +0100 Message-ID: <87pp9cnq9w.fsf@nicolasgoaziou.fr> References: <87386e0zuy.fsf@gmx.us> <87wq3pwg29.fsf@nicolasgoaziou.fr> <87lhk48z9x.fsf@gmx.us> <87fvacw2jv.fsf@nicolasgoaziou.fr> <87mw4kyq2e.fsf@gmx.us> <87fva9tqdj.fsf@nicolasgoaziou.fr> <873869h0cd.fsf@gmx.us> <87twypgwt5.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMk85-0003mg-Bh for emacs-orgmode@gnu.org; Sat, 14 Feb 2015 16:19:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMk80-0005uO-Am for emacs-orgmode@gnu.org; Sat, 14 Feb 2015 16:19:57 -0500 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:54303) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMk80-0005uE-4d for emacs-orgmode@gnu.org; Sat, 14 Feb 2015 16:19:52 -0500 In-Reply-To: <87twypgwt5.fsf@gmx.us> (rasmus@gmx.us's message of "Sat, 14 Feb 2015 01:29:26 +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: > This patch applies indentation unless at BOL in which case it stays at > BOL. The rest is basically just to work with cdlatex and not insert too > many blank lines. It's still quicky, but these quirks seem to be cdlatex > quirks. > > I wonder, are there any commands to merge two elements buffer-undo-list > into one? 'Cause ATM it takes two undo-presses to undo an environment > insert via this command. Another idea: insert the environment in a temp buffer. Check for buffer emptiness. If there is something, insert it with appropriate indentation. > + (let ((non-blank-eolp > + (save-excursion > + (and (not (save-excursion > + (skip-chars-backward " \t") > + (bolp))) > + (progn (skip-chars-forward " \t") (eolp))))) > + (ind (if (bolp) 0 > + (save-excursion > + (unless (and (bolp) > + (save-excursion > + (skip-chars-forward " \t") > + (eolp))) (bolp) is always nil, and so it (and (bolp) ...) so you can skip the unless test and write (org-return-indent) > + (org-return-indent)) > + (org-get-indentation))))) > + ;; Skip forward to next bol to avoid extra newline from > + ;; cdlatex-environment. > + (when non-blank-eolp (forward-line 1) (beginning-of-line)) (forward-line 1), which is (forward-line) always put point at the beginning of line, excepted at eob. As a consequence, (beginning-of-line) should be removed here. Regards,