diff options
| author | Eli Zaretskii | 2019-08-03 12:41:35 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2019-08-03 12:41:35 +0300 |
| commit | faafd467a374c9398ee4668cdc173611d35693ed (patch) | |
| tree | 4f0050dee1e3015ccd1e3a9ae2ef86a5eea25836 | |
| parent | 49a5b573b25b70b3efd288efab0e27af1191d8c7 (diff) | |
| download | emacs-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.texi | 45 |
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 | |||
| 849 | missing parenthesis belongs. How, then, to find what to change? | 849 | missing 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 |
| 852 | technique is to try @kbd{C-M-e} at the beginning of each defun, and see | 852 | technique is to try @kbd{C-M-e} (@code{end-of-defun}, @pxref{Moving by |
| 853 | if it goes to the place where that defun appears to end. If it does | 853 | Defuns,,,emacs, The GNU Emacs Manual}) at the beginning of each defun, |
| 854 | not, there is a problem in that defun. | 854 | and see if it goes to the place where that defun appears to end. If |
| 855 | it 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 |
| 873 | an excess open parenthesis, the way to do this is to go to the end of | 874 | an excess open parenthesis, the way to do this is to go to the end of |
| 874 | the file and type @kbd{C-u C-M-u}. This will move you to the | 875 | the file and type @kbd{C-u C-M-u} (@code{backward-up-list}, |
| 875 | beginning of the first defun that is unbalanced. | 876 | @pxref{Moving by Parens,,,emacs, The GNU Emacs Manual}). This will |
| 877 | move 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 |
| 878 | way to be sure of this except by studying the program, but often the | 880 | way to be sure of this except by studying the program, but often the |
| 879 | existing indentation is a clue to where the parentheses should have | 881 | existing indentation is a clue to where the parentheses should have |
| 880 | been. The easiest way to use this clue is to reindent with @kbd{C-M-q} | 882 | been. The easiest way to use this clue is to reindent with @kbd{C-M-q} |
| 881 | and see what moves. @strong{But don't do this yet!} Keep reading, | 883 | (@code{indent-pp-sexp}, @pxref{Multi-line Indent,,,emacs, The GNU |
| 882 | first. | 884 | Emacs Manual}) and see what moves. @strong{But don't do this yet!} |
| 885 | Keep 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. |
| 885 | Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest | 888 | Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest |
| 886 | of the file until the end. So move to the end of the defun and insert a | 889 | of the file until the end. So move to the end of the defun and insert a |
| 887 | close parenthesis there. Don't use @kbd{C-M-e} to move there, since | 890 | close parenthesis there. Don't use @kbd{C-M-e} (@code{end-of-defun}) to |
| 888 | that too will fail to work until the defun is balanced. | 891 | move 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}. |
| 891 | Usually all the lines from a certain point to the end of the function | 894 | Usually all the lines from a certain point to the end of the function |
| 892 | will shift to the right. There is probably a missing close parenthesis, | 895 | will shift to the right. There is probably a missing close parenthesis, |
| 893 | or a superfluous open parenthesis, near that point. (However, don't | 896 | or a superfluous open parenthesis, near that point. (However, don't |
| 894 | assume this is true; study the code to make sure.) Once you have found | 897 | assume this is true; study the code to make sure.) Once you have found |
| 895 | the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the old | 898 | the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_} (@code{undo}), |
| 896 | indentation is probably appropriate to the intended parentheses. | 899 | since the old indentation is probably appropriate to the intended |
| 900 | parentheses. | ||
| 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 |
| 899 | the old indentation actually fit the intended nesting of parentheses, | 903 | the 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 |
| 908 | of the file, then type @kbd{C-u -1 C-M-u} to find the end of the first | 912 | of the file, then type @kbd{C-u -1 C-M-u} (@code{backward-up-list} |
| 909 | unbalanced defun. | 913 | with an argument of @minus{}1) to find the end of the first unbalanced |
| 914 | defun. | ||
| 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}) | ||
| 912 | at the beginning of that defun. This will leave you somewhere short of | 918 | at the beginning of that defun. This will leave you somewhere short of |
| 913 | the place where the defun ought to end. It is possible that you will | 919 | the place where the defun ought to end. It is possible that you will |
| 914 | find a spurious close parenthesis in that vicinity. | 920 | find 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 |
| 917 | type @kbd{C-M-q} at the beginning of the defun. A range of lines will | 923 | type @kbd{C-M-q} (@code{indent-pp-sexp}) at the beginning of the defun. |
| 918 | probably shift left; if so, the missing open parenthesis or spurious | 924 | A range of lines will probably shift left; if so, the missing open |
| 919 | close parenthesis is probably near the first of those lines. (However, | 925 | parenthesis or spurious close parenthesis is probably near the first of |
| 920 | don't assume this is true; study the code to make sure.) Once you have | 926 | those lines. (However, don't assume this is true; study the code to |
| 921 | found the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the | 927 | make sure.) Once you have found the discrepancy, undo the @kbd{C-M-q} |
| 922 | old indentation is probably appropriate to the intended parentheses. | 928 | with @kbd{C-_} (@code{undo}), since the old indentation is probably |
| 929 | appropriate 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 |
| 925 | the old indentation actually fits the intended nesting of parentheses, | 932 | the old indentation actually fits the intended nesting of parentheses, |