4

In LaTeX code I can have:

Lorem ipsum dolor sit amet, consectetur
\begin{comment}
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 

Ut enim ad minim veniam, quis nostrud exercitation 
\end{comment}
ullamco laboris nisi ut aliquip ex ea commodo consequat.

If I use comment-region (in a script) to comment the comment environment in la LaTeX code i obtain:

Lorem ipsum dolor sit amet, consectetur
%% \begin{comment}
%% adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 

%% Ut enim ad minim veniam, quis nostrud exercitation 
%% \end{comment}
ullamco laboris nisi ut aliquip ex ea commodo consequat.

This is not good because LaTeX interpret the empty line(s) (outside of comment environment) as a paragraph break.

My question is: Can I make comment-region comment empty lines?

I tried customizing (let-bind) the comment-syle variable but all the options I've seen do not comment empty lines.

An alternative could be a "built-in" (otherwise I already know how to make this funcion by myself) function that let me append a string on every line of a region (not a triangle). Remember, I need to do it programmatically.

1 Answer 1

9

Customize option comment-empty-lines.

comment-empty-lines is a variable defined in newcomment.el.

Documentation: If nil, comment-region does not comment out empty lines. If t, it always comments out empty lines. If eol it only comments out empty lines if comments are terminated by the end of line (i.e. comment-end is empty).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.