When writing Emacs Lisp code, I use forward-sexp
(C-M-right) and backward-sexp
(C-M-left) to navigate the buffer. However, in some cases these functions stops with error like:
forward-sexp: Scan error: "Containing expression ends prematurely"
Here is an example:
(defun my-test1()
(message "ok1"))
(defun my-test2()
(message "ok2"))
If cursor is on the first (
, pressing C-M-right twice works fine. However, if cursor is on the first d
(in defun
), pressing C-M-right five times results in the error. Instead of the error, I would like to move further down the buffer to the next defun
that is to the start of the line (defun my-test2()
..