Rasmus <ras...@gmx.us> 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,

Reply via email to