diff options
| author | Eli Zaretskii | 2019-08-03 12:41:35 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2019-08-03 12:43:10 +0300 |
| commit | 5a5ad99d2f5abc431e269e4f591fdabad9d59e70 (patch) | |
| tree | 1b5008fbe3f0219d10f1eb5004adb57568ca776d | |
| parent | 0148fc73538e2dccb586abe80ba48fdaf2041ca7 (diff) | |
| download | emacs-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.texi | 45 |
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 | |||
| 796 | missing parenthesis belongs. How, then, to find what to change? | 796 | missing 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 |
| 799 | technique is to try @kbd{C-M-e} at the beginning of each defun, and see | 799 | technique is to try @kbd{C-M-e} (@code{end-of-defun}, @pxref{Moving by |
| 800 | if it goes to the place where that defun appears to end. If it does | 800 | Defuns,,,emacs, The GNU Emacs Manual}) at the beginning of each defun, |
| 801 | not, there is a problem in that defun. | 801 | and see if it goes to the place where that defun appears to end. If |
| 802 | it 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 |
| 820 | an excess open parenthesis, the way to do this is to go to the end of | 821 | an excess open parenthesis, the way to do this is to go to the end of |
| 821 | the file and type @kbd{C-u C-M-u}. This will move you to the | 822 | the file and type @kbd{C-u C-M-u} (@code{backward-up-list}, |
| 822 | beginning of the first defun that is unbalanced. | 823 | @pxref{Moving by Parens,,,emacs, The GNU Emacs Manual}). This will |
| 824 | move 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 |
| 825 | way to be sure of this except by studying the program, but often the | 827 | way to be sure of this except by studying the program, but often the |
| 826 | existing indentation is a clue to where the parentheses should have | 828 | existing indentation is a clue to where the parentheses should have |
| 827 | been. The easiest way to use this clue is to reindent with @kbd{C-M-q} | 829 | been. The easiest way to use this clue is to reindent with @kbd{C-M-q} |
| 828 | and see what moves. @strong{But don't do this yet!} Keep reading, | 830 | (@code{indent-pp-sexp}, @pxref{Multi-line Indent,,,emacs, The GNU |
| 829 | first. | 831 | Emacs Manual}) and see what moves. @strong{But don't do this yet!} |
| 832 | Keep 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. |
| 832 | Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest | 835 | Otherwise, @kbd{C-M-q} will get an error, or will reindent all the rest |
| 833 | of the file until the end. So move to the end of the defun and insert a | 836 | of the file until the end. So move to the end of the defun and insert a |
| 834 | close parenthesis there. Don't use @kbd{C-M-e} to move there, since | 837 | close parenthesis there. Don't use @kbd{C-M-e} (@code{end-of-defun}) to |
| 835 | that too will fail to work until the defun is balanced. | 838 | move 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}. |
| 838 | Usually all the lines from a certain point to the end of the function | 841 | Usually all the lines from a certain point to the end of the function |
| 839 | will shift to the right. There is probably a missing close parenthesis, | 842 | will shift to the right. There is probably a missing close parenthesis, |
| 840 | or a superfluous open parenthesis, near that point. (However, don't | 843 | or a superfluous open parenthesis, near that point. (However, don't |
| 841 | assume this is true; study the code to make sure.) Once you have found | 844 | assume this is true; study the code to make sure.) Once you have found |
| 842 | the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the old | 845 | the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_} (@code{undo}), |
| 843 | indentation is probably appropriate to the intended parentheses. | 846 | since the old indentation is probably appropriate to the intended |
| 847 | parentheses. | ||
| 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 |
| 846 | the old indentation actually fit the intended nesting of parentheses, | 850 | the 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 |
| 855 | of the file, then type @kbd{C-u -1 C-M-u} to find the end of the first | 859 | of the file, then type @kbd{C-u -1 C-M-u} (@code{backward-up-list} |
| 856 | unbalanced defun. | 860 | with an argument of @minus{}1) to find the end of the first unbalanced |
| 861 | defun. | ||
| 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}) | ||
| 859 | at the beginning of that defun. This will leave you somewhere short of | 865 | at the beginning of that defun. This will leave you somewhere short of |
| 860 | the place where the defun ought to end. It is possible that you will | 866 | the place where the defun ought to end. It is possible that you will |
| 861 | find a spurious close parenthesis in that vicinity. | 867 | find 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 |
| 864 | type @kbd{C-M-q} at the beginning of the defun. A range of lines will | 870 | type @kbd{C-M-q} (@code{indent-pp-sexp}) at the beginning of the defun. |
| 865 | probably shift left; if so, the missing open parenthesis or spurious | 871 | A range of lines will probably shift left; if so, the missing open |
| 866 | close parenthesis is probably near the first of those lines. (However, | 872 | parenthesis or spurious close parenthesis is probably near the first of |
| 867 | don't assume this is true; study the code to make sure.) Once you have | 873 | those lines. (However, don't assume this is true; study the code to |
| 868 | found the discrepancy, undo the @kbd{C-M-q} with @kbd{C-_}, since the | 874 | make sure.) Once you have found the discrepancy, undo the @kbd{C-M-q} |
| 869 | old indentation is probably appropriate to the intended parentheses. | 875 | with @kbd{C-_} (@code{undo}), since the old indentation is probably |
| 876 | appropriate 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 |
| 872 | the old indentation actually fits the intended nesting of parentheses, | 879 | the old indentation actually fits the intended nesting of parentheses, |