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