aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2019-08-03 12:41:35 +0300
committerEli Zaretskii2019-08-03 12:41:35 +0300
commitfaafd467a374c9398ee4668cdc173611d35693ed (patch)
tree4f0050dee1e3015ccd1e3a9ae2ef86a5eea25836
parent49a5b573b25b70b3efd288efab0e27af1191d8c7 (diff)
downloademacs-faafd467a374c9398ee4668cdc173611d35693ed.tar.gz
emacs-faafd467a374c9398ee4668cdc173611d35693ed.zip
Improve documentation of debugging Lisp syntax error
* doc/lispref/debugging.texi (Syntax Errors, Excess Open) (Excess Close): Name the commands invoked by the key sequences. Add cross-references to appropriate sections of the Emacs manual. (Bug#21385)
-rw-r--r--doc/lispref/debugging.texi45
1 files changed, 26 insertions, 19 deletions
diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi
index 9e433433107..12caeaf1289 100644
--- a/doc/lispref/debugging.texi
+++ b/doc/lispref/debugging.texi
@@ -849,9 +849,10 @@ parenthesis or missing open parenthesis, but does not say where the
849missing parenthesis belongs. How, then, to find what to change? 849missing parenthesis belongs. How, then, to find what to change?
850 850
851 If the problem is not simply an imbalance of parentheses, a useful 851 If the problem is not simply an imbalance of parentheses, a useful
852technique is to try @kbd{C-M-e} at the beginning of each defun, and see 852technique is to try @kbd{C-M-e} (@code{end-of-defun}, @pxref{Moving by
853if it goes to the place where that defun appears to end. If it does 853Defuns,,,emacs, The GNU Emacs Manual}) at the beginning of each defun,
854not, there is a problem in that defun. 854and see if it goes to the place where that defun appears to end. If
855it does not, there is a problem in that defun.
855 856
856@cindex unbalanced parentheses 857@cindex unbalanced parentheses
857@cindex parenthesis mismatch, debugging 858@cindex parenthesis mismatch, debugging
@@ -871,29 +872,32 @@ find the mismatch.)
871 872
872 The first step is to find the defun that is unbalanced. If there is 873 The first step is to find the defun that is unbalanced. If there is
873an excess open parenthesis, the way to do this is to go to the end of 874an excess open parenthesis, the way to do this is to go to the end of
874the file and type @kbd{C-u C-M-u}. This will move you to the 875the file and type @kbd{C-u C-M-u} (@code{backward-up-list},
875beginning of the first defun that is unbalanced. 876@pxref{Moving by Parens,,,emacs, The GNU Emacs Manual}). This will
877move you to the beginning of the first defun that is unbalanced.
876 878
877 The next step is to determine precisely what is wrong. There is no 879 The next step is to determine precisely what is wrong. There is no
878way to be sure of this except by studying the program, but often the 880way to be sure of this except by studying the program, but often the
879existing indentation is a clue to where the parentheses should have 881existing indentation is a clue to where the parentheses should have
880been. The easiest way to use this clue is to reindent with @kbd{C-M-q} 882been. The easiest way to use this clue is to reindent with @kbd{C-M-q}
881and see what moves. @strong{But don't do this yet!} Keep reading, 883(@code{indent-pp-sexp}, @pxref{Multi-line Indent,,,emacs, The GNU
882first. 884Emacs Manual}) and see what moves. @strong{But don't do this yet!}
885Keep reading, first.
883 886
884 Before you do this, make sure the defun has enough close parentheses. 887 Before you do this, make sure the defun has enough close parentheses.
885Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest 888Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest
886of the file until the end. So move to the end of the defun and insert a 889of the file until the end. So move to the end of the defun and insert a
887close parenthesis there. Don't use @kbd{C-M-e} to move there, since 890close parenthesis there. Don't use @kbd{C-M-e} (@code{end-of-defun}) to
888that too will fail to work until the defun is balanced. 891move there, since that too will fail to work until the defun is balanced.
889 892
890 Now you can go to the beginning of the defun and type @kbd{C-M-q}. 893 Now you can go to the beginning of the defun and type @kbd{C-M-q}.
891Usually all the lines from a certain point to the end of the function 894Usually all the lines from a certain point to the end of the function
892will shift to the right. There is probably a missing close parenthesis, 895will shift to the right. There is probably a missing close parenthesis,
893or a superfluous open parenthesis, near that point. (However, don't 896or a superfluous open parenthesis, near that point. (However, don't
894assume this is true; study the code to make sure.) Once you have found 897assume this is true; study the code to make sure.) Once you have found
895the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the old 898the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_} (@code{undo}),
896indentation is probably appropriate to the intended parentheses. 899since the old indentation is probably appropriate to the intended
900parentheses.
897 901
898 After you think you have fixed the problem, use @kbd{C-M-q} again. If 902 After you think you have fixed the problem, use @kbd{C-M-q} again. If
899the old indentation actually fit the intended nesting of parentheses, 903the old indentation actually fit the intended nesting of parentheses,
@@ -905,21 +909,24 @@ anything.
905@cindex excess close parentheses 909@cindex excess close parentheses
906 910
907 To deal with an excess close parenthesis, first go to the beginning 911 To deal with an excess close parenthesis, first go to the beginning
908of the file, then type @kbd{C-u -1 C-M-u} to find the end of the first 912of the file, then type @kbd{C-u -1 C-M-u} (@code{backward-up-list}
909unbalanced defun. 913with an argument of @minus{}1) to find the end of the first unbalanced
914defun.
910 915
911 Then find the actual matching close parenthesis by typing @kbd{C-M-f} 916 Then find the actual matching close parenthesis by typing @kbd{C-M-f}
917(@code{forward-sexp}, @pxref{Expressions,,,emacs, The GNU Emacs Manual})
912at the beginning of that defun. This will leave you somewhere short of 918at the beginning of that defun. This will leave you somewhere short of
913the place where the defun ought to end. It is possible that you will 919the place where the defun ought to end. It is possible that you will
914find a spurious close parenthesis in that vicinity. 920find a spurious close parenthesis in that vicinity.
915 921
916 If you don't see a problem at that point, the next thing to do is to 922 If you don't see a problem at that point, the next thing to do is to
917type @kbd{C-M-q} at the beginning of the defun. A range of lines will 923type @kbd{C-M-q} (@code{indent-pp-sexp}) at the beginning of the defun.
918probably shift left; if so, the missing open parenthesis or spurious 924A range of lines will probably shift left; if so, the missing open
919close parenthesis is probably near the first of those lines. (However, 925parenthesis or spurious close parenthesis is probably near the first of
920don't assume this is true; study the code to make sure.) Once you have 926those lines. (However, don't assume this is true; study the code to
921found the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the 927make sure.) Once you have found the discrepancy, undo the @kbd{C-M-q}
922old indentation is probably appropriate to the intended parentheses. 928with @kbd{C-_} (@code{undo}), since the old indentation is probably
929appropriate to the intended parentheses.
923 930
924 After you think you have fixed the problem, use @kbd{C-M-q} again. If 931 After you think you have fixed the problem, use @kbd{C-M-q} again. If
925the old indentation actually fits the intended nesting of parentheses, 932the old indentation actually fits the intended nesting of parentheses,