[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#30393: 24.4; cperl-mode: indentation failure
From: |
Alan Mackenzie |
Subject: |
bug#30393: 24.4; cperl-mode: indentation failure |
Date: |
Sat, 10 Feb 2018 11:26:54 +0000 |
User-agent: |
Mutt/1.7.2 (2016-11-26) |
Hello, Dmitry.
On Sat, Feb 10, 2018 at 11:53:55 +0300, Dmitry Gutov wrote:
> On 2/9/18 8:50 PM, Alan Mackenzie wrote:
> >> Specifically, it's the open paren in the column 0 that triggers it. You
> >> can set `open-paren-in-column-0-is-defun-start' to nil to fix it. Same
> >> idea as Bug#25480 (that one is cc-mode).
[ .... ]
> > If my fix isn't going to be accepted, I think it's high time that
> > somebody else stepped up to the plate and fixed this monstrosity once
> > and for all.
> Have you seen 14b95587520959c5b54356547a0a69932a9bb480?
No, I hadn't. Thanks, Stefan!
I'm not sure, but I think there's a danger of a recursive loop, should a
major mode use a hook in syntax-ppss to calculate syntax-table
properties, and that hook call forward-comment.
> AFAICT, open-paren-in-column-0-is-defun-start doesn't have much effect now.
That patch is incomplete, though. I propose the following, to make it
more complete:
diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi
index 4289124545..0fa37530ef 100644
--- a/doc/emacs/programs.texi
+++ b/doc/emacs/programs.texi
@@ -153,54 +153,35 @@ Left Margin Paren
@cindex ( in leftmost column
Many programming-language modes assume by default that any opening
delimiter found at the left margin is the start of a top-level
-definition, or defun. Therefore, @strong{don't put an opening
-delimiter at the left margin unless it should have that significance}.
-For instance, never put an open-parenthesis at the left margin in a
-Lisp file unless it is the start of a top-level list.
-
- The convention speeds up many Emacs operations, which would
-otherwise have to scan back to the beginning of the buffer to analyze
-the syntax of the code.
-
- If you don't follow this convention, not only will you have trouble
-when you explicitly use the commands for motion by defuns; other
-features that use them will also give you trouble. This includes the
-indentation commands (@pxref{Program Indent}) and Font Lock mode
-(@pxref{Font Lock}).
-
- The most likely problem case is when you want an opening delimiter
-at the start of a line inside a string. To avoid trouble, put an
-escape character (@samp{\}, in C and Emacs Lisp, @samp{/} in some
-other Lisp dialects) before the opening delimiter. This will not
-affect the contents of the string, but will prevent that opening
-delimiter from starting a defun. Here's an example:
-
-@example
- (insert "Foo:
-\(bar)
-")
-@end example
-
- To help you catch violations of this convention, Font Lock mode
-highlights confusing opening delimiters (those that ought to be
-quoted) in bold red.
+definition, or defun. Therefore, in these modes, don't put an opening
+delimiter at the left margin, except in a comment or string, unless it
+should have that significance. For instance, never put an
+open-parenthesis at the left margin in a Lisp file unless it is the
+start of a top-level list.
+
+ In earlier versions of Emacs (through version 26.n), Emacs exploited
+this convention to speed up many low-level operations, which would
+otherwise have to scan back to the beginning of the buffer.
+Unfortunately, this caused confusion when an opening delimiter
+occurred at column zero inside a comment. The resulting faulty
+analysis often caused wrong indentation or fontification. The
+convention could be overridden by setting the user option
+@code{open-paren-in-column-0-is-defun-start} to @code{nil}, but this
+slowed Emacs down, particularaly when editing large buffers.
+
+ To eliminate these problems, the low level functionality which used
+to test for opening delimiters at column 0 no longer does so. Open
+delimiters may now be freely written at the left margin inside
+comments and strings without triggering these problems.
@vindex open-paren-in-column-0-is-defun-start
- If you need to override this convention, you can do so by setting
-the variable @code{open-paren-in-column-0-is-defun-start}.
-If this user option is set to @code{t} (the default), opening
-parentheses or braces at column zero always start defuns. When it is
-@code{nil}, defuns are found by searching for parens or braces at the
-outermost level.
-
- Usually, you should leave this option at its default value of
-@code{t}. If your buffer contains parentheses or braces in column
-zero which don't start defuns, and it is somehow impractical to remove
-these parentheses or braces, it might be helpful to set the option to
-@code{nil}. Be aware that this might make scrolling and display in
-large buffers quite sluggish. Furthermore, the parentheses and braces
-must be correctly matched throughout the buffer for it to work
-properly.
+ If you want to override the convention, which is still used by some
+higher level commands, you can do so by setting the variable
+@code{open-paren-in-column-0-is-defun-start} to @code{nil}. If this
+user option is set to @code{t} (the default), these commands will stop
+at opening parentheses or braces at column zero when seeking the start
+of defuns. When it is @code{nil}, defuns are found by searching for
+parens or braces at the outermost level.
@node Moving by Defuns
@subsection Moving by Defuns
--
Alan Mackenzie (Nuremberg, Germany).
- bug#30393: 24.4; cperl-mode: indentation failure, paulusm, 2018/02/08
- bug#30393: 24.4; cperl-mode: indentation failure, Noam Postavsky, 2018/02/08
- Message not available
- bug#30393: 24.4; cperl-mode: indentation failure, Alan Mackenzie, 2018/02/09
- bug#30393: 24.4; cperl-mode: indentation failure, Noam Postavsky, 2018/02/09
- bug#30393: 24.4; cperl-mode: indentation failure, Dmitry Gutov, 2018/02/10
- bug#30393: 24.4; cperl-mode: indentation failure,
Alan Mackenzie <=
- bug#30393: 24.4; cperl-mode: indentation failure, Eli Zaretskii, 2018/02/10
- bug#30393: 24.4; cperl-mode: indentation failure, Alan Mackenzie, 2018/02/11
- bug#30393: 24.4; cperl-mode: indentation failure, Eli Zaretskii, 2018/02/11
- bug#30393: 24.4; cperl-mode: indentation failure, Alan Mackenzie, 2018/02/14
- bug#30393: 24.4; cperl-mode: indentation failure, Eli Zaretskii, 2018/02/15
- bug#30393: 24.4; cperl-mode: indentation failure, Dmitry Gutov, 2018/02/16
- bug#30393: 24.4; cperl-mode: indentation failure, Alan Mackenzie, 2018/02/16
- bug#30393: 24.4; cperl-mode: indentation failure, Dmitry Gutov, 2018/02/16
- bug#30393: 24.4; cperl-mode: indentation failure, Alan Mackenzie, 2018/02/17
- bug#30393: 24.4; cperl-mode: indentation failure, Stefan Monnier, 2018/02/10