emacs.rst
changeset 175 95c55e2920e5
parent 171 8e806cddee36
child 177 02b79b857ee1
equal deleted inserted replaced
168:8a80c98c044c 175:95c55e2920e5
     1 -*- mode: outline -*-
     1 -*- mode: outline -*-
     2 
     2 
     3 * How debug ini file?
     3 * Debugging.
       
     4 
       
     5 ** Using edebug.
       
     6 
       
     7 Execute ‘M-x edebug-defun’ (also on ‘C-u C-M-x’) on defun in source code to
       
     8 enable debugging for desired function. When next time this function invoked
       
     9 you entered to its debugging (jamped to its source code).
       
    10 
       
    11 To start debug execute code which used debugged function.
       
    12 
       
    13 You can disable edebug on a function by evaluating the function again using
       
    14 ‘C-M-x’.
       
    15 
       
    16 ** How debug func?
       
    17 
       
    18 Use M-x debug-on-entry and M-x cancel-debug-on-entry to control
       
    19 which functions will enter the debugger when called.
       
    20 
       
    21 When next time that function called automatically loaded debug-mode.
       
    22 
       
    23 ** How debug ini file?
     4 
    24 
     5 When your InitFile has a bug, or when you load external files that cause
    25 When your InitFile has a bug, or when you load external files that cause
     6 errors, the bug is often hard to find, because the Emacs Lisp reader does not
    26 errors, the bug is often hard to find, because the Emacs Lisp reader does not
     7 know about line numbers and files – it just knows an error happened, and
    27 know about line numbers and files – it just knows an error happened, and
     8 that’s it.
    28 that’s it.
     9 
    29 
    10 ** Binary Search.
    30 *** Binary Search.
    11 
    31 
    12 Select half of the file in a region, and M-x eval-region. Depending on whether
    32 Select half of the file in a region, and M-x eval-region. Depending on whether
    13 that causes the error or not, split this half or the other half again, and
    33 that causes the error or not, split this half or the other half again, and
    14 repeat.
    34 repeat.
    15 
    35 
    16 ** Elisp.
    36 *** Elisp.
    17 
    37 
    18  - Use a keyboard macro that moves forward one expression (sexp) and evaluates
    38  - Use a keyboard macro that moves forward one expression (sexp) and evaluates
    19    it.
    39    it.
    20  - Try C-x check-parens.
    40  - Try C-x check-parens.
    21  - Set (setq debug-on-error t).
    41  - Set (setq debug-on-error t).
    22 
    42 
    23 ** CLI.
    43 *** CLI.
    24 
    44 
    25   $ emacs --no-init-file --no-site-file --debug-init
    45   $ emacs --no-init-file --no-site-file --debug-init
    26 
    46 
    27 ** Simplified Binary Search.
    47 *** Simplified Binary Search.
    28 
    48 
    29 Add (error “No error until here”) in the middle of your file. If you get the
    49 Add (error “No error until here”) in the middle of your file. If you get the
    30 error “No error until here” when reloading the file, move the expression
    50 error “No error until here” when reloading the file, move the expression
    31 towards the back of the file, otherwise towards the front of the file.
    51 towards the back of the file, otherwise towards the front of the file.
    32 
       
    33 * Using edebug.
       
    34 
       
    35 The main entry point is ‘M-x edebug-defun’ (also on ‘C-u C-M-x’). Use it
       
    36 instead of `C-x C-e’ or ‘C-M-x’ to evaluate a ‘defun’ and instrument it for
       
    37 debugging.
       
    38 
       
    39 You can disable edebug on a function by evaluating the function again using
       
    40 ‘C-M-x’.
       
    41 
       
    42 * How debug func?
       
    43 
       
    44 Use M-x debug-on-entry and M-x cancel-debug-on-entry to control
       
    45 which functions will enter the debugger when called.
       
    46 
       
    47 When next time that function called automatically loaded debug-mode.