aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2019-08-03 12:41:35 +0300
committerEli Zaretskii2019-08-03 12:43:10 +0300
commit5a5ad99d2f5abc431e269e4f591fdabad9d59e70 (patch)
tree1b5008fbe3f0219d10f1eb5004adb57568ca776d
parent0148fc73538e2dccb586abe80ba48fdaf2041ca7 (diff)
downloademacs-5a5ad99d2f5abc431e269e4f591fdabad9d59e70.tar.gz
emacs-5a5ad99d2f5abc431e269e4f591fdabad9d59e70.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) (cherry picked from commit faafd467a374c9398ee4668cdc173611d35693ed)
-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 2576fbe39d7..575ec75d407 100644
--- a/doc/lispref/debugging.texi
+++ b/doc/lispref/debugging.texi
@@ -796,9 +796,10 @@ parenthesis or missing open parenthesis, but does not say where the
796missing parenthesis belongs. How, then, to find what to change? 796missing parenthesis belongs. How, then, to find what to change?
797 797
798 If the problem is not simply an imbalance of parentheses, a useful 798 If the problem is not simply an imbalance of parentheses, a useful
799technique is to try @kbd{C-M-e} at the beginning of each defun, and see 799technique is to try @kbd{C-M-e} (@code{end-of-defun}, @pxref{Moving by
800if it goes to the place where that defun appears to end. If it does 800Defuns,,,emacs, The GNU Emacs Manual}) at the beginning of each defun,
801not, there is a problem in that defun. 801and see if it goes to the place where that defun appears to end. If
802it does not, there is a problem in that defun.
802 803
803@cindex unbalanced parentheses 804@cindex unbalanced parentheses
804@cindex parenthesis mismatch, debugging 805@cindex parenthesis mismatch, debugging
@@ -818,29 +819,32 @@ find the mismatch.)
818 819
819 The first step is to find the defun that is unbalanced. If there is 820 The first step is to find the defun that is unbalanced. If there is
820an excess open parenthesis, the way to do this is to go to the end of 821an excess open parenthesis, the way to do this is to go to the end of
821the file and type @kbd{C-u C-M-u}. This will move you to the 822the file and type @kbd{C-u C-M-u} (@code{backward-up-list},
822beginning of the first defun that is unbalanced. 823@pxref{Moving by Parens,,,emacs, The GNU Emacs Manual}). This will
824move you to the beginning of the first defun that is unbalanced.
823 825
824 The next step is to determine precisely what is wrong. There is no 826 The next step is to determine precisely what is wrong. There is no
825way to be sure of this except by studying the program, but often the 827way to be sure of this except by studying the program, but often the
826existing indentation is a clue to where the parentheses should have 828existing indentation is a clue to where the parentheses should have
827been. The easiest way to use this clue is to reindent with @kbd{C-M-q} 829been. The easiest way to use this clue is to reindent with @kbd{C-M-q}
828and see what moves. @strong{But don't do this yet!} Keep reading, 830(@code{indent-pp-sexp}, @pxref{Multi-line Indent,,,emacs, The GNU
829first. 831Emacs Manual}) and see what moves. @strong{But don't do this yet!}
832Keep reading, first.
830 833
831 Before you do this, make sure the defun has enough close parentheses. 834 Before you do this, make sure the defun has enough close parentheses.
832Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest 835Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest
833of the file until the end. So move to the end of the defun and insert a 836of the file until the end. So move to the end of the defun and insert a
834close parenthesis there. Don't use @kbd{C-M-e} to move there, since 837close parenthesis there. Don't use @kbd{C-M-e} (@code{end-of-defun}) to
835that too will fail to work until the defun is balanced. 838move there, since that too will fail to work until the defun is balanced.
836 839
837 Now you can go to the beginning of the defun and type @kbd{C-M-q}. 840 Now you can go to the beginning of the defun and type @kbd{C-M-q}.
838Usually all the lines from a certain point to the end of the function 841Usually all the lines from a certain point to the end of the function
839will shift to the right. There is probably a missing close parenthesis, 842will shift to the right. There is probably a missing close parenthesis,
840or a superfluous open parenthesis, near that point. (However, don't 843or a superfluous open parenthesis, near that point. (However, don't
841assume this is true; study the code to make sure.) Once you have found 844assume this is true; study the code to make sure.) Once you have found
842the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the old 845the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_} (@code{undo}),
843indentation is probably appropriate to the intended parentheses. 846since the old indentation is probably appropriate to the intended
847parentheses.
844 848
845 After you think you have fixed the problem, use @kbd{C-M-q} again. If 849 After you think you have fixed the problem, use @kbd{C-M-q} again. If
846the old indentation actually fit the intended nesting of parentheses, 850the old indentation actually fit the intended nesting of parentheses,
@@ -852,21 +856,24 @@ anything.
852@cindex excess close parentheses 856@cindex excess close parentheses
853 857
854 To deal with an excess close parenthesis, first go to the beginning 858 To deal with an excess close parenthesis, first go to the beginning
855of the file, then type @kbd{C-u -1 C-M-u} to find the end of the first 859of the file, then type @kbd{C-u -1 C-M-u} (@code{backward-up-list}
856unbalanced defun. 860with an argument of @minus{}1) to find the end of the first unbalanced
861defun.
857 862
858 Then find the actual matching close parenthesis by typing @kbd{C-M-f} 863 Then find the actual matching close parenthesis by typing @kbd{C-M-f}
864(@code{forward-sexp}, @pxref{Expressions,,,emacs, The GNU Emacs Manual})
859at the beginning of that defun. This will leave you somewhere short of 865at the beginning of that defun. This will leave you somewhere short of
860the place where the defun ought to end. It is possible that you will 866the place where the defun ought to end. It is possible that you will
861find a spurious close parenthesis in that vicinity. 867find a spurious close parenthesis in that vicinity.
862 868
863 If you don't see a problem at that point, the next thing to do is to 869 If you don't see a problem at that point, the next thing to do is to
864type @kbd{C-M-q} at the beginning of the defun. A range of lines will 870type @kbd{C-M-q} (@code{indent-pp-sexp}) at the beginning of the defun.
865probably shift left; if so, the missing open parenthesis or spurious 871A range of lines will probably shift left; if so, the missing open
866close parenthesis is probably near the first of those lines. (However, 872parenthesis or spurious close parenthesis is probably near the first of
867don't assume this is true; study the code to make sure.) Once you have 873those lines. (However, don't assume this is true; study the code to
868found the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the 874make sure.) Once you have found the discrepancy, undo the @kbd{C-M-q}
869old indentation is probably appropriate to the intended parentheses. 875with @kbd{C-_} (@code{undo}), since the old indentation is probably
876appropriate to the intended parentheses.
870 877
871 After you think you have fixed the problem, use @kbd{C-M-q} again. If 878 After you think you have fixed the problem, use @kbd{C-M-q} again. If
872the old indentation actually fits the intended nesting of parentheses, 879the old indentation actually fits the intended nesting of parentheses,