Emacs: narrow-to-defun, eval-defun, bug

By Xah Lee. Date:

when coding elisp, there's narrow-to-defun, and eval-defun. They do not always work.

For them to work, they require that your code be already formatted in the standard elisp convention.

Here's a example.

emacs narrow-to-defun bug 2015-06-09
Emacs: narrow-to-defun, eval-defun, bug.

This is more serious if you are habituated in Alt+x eval-defun, because it may eval only part of the code.

As a consequence, i never use them.

Here's the code you can try. Paste the following in a new buffer, Alt+x emacs-lisp-mode. Put cursor before the “3”, then Alt+x narrow-to-defun.

;; some
(defun xxtest ()
(let (x)
  (setq x
;; more

This is emacs GNU Emacs 24.4.1. But is in emacs 23.x, and i think earlier too.

Like it? Buy Xah Emacs Tutorial. Thanks.