The following code is an excerpt from the elisp tutorial, section 14.6.
(while (re-search-forward "^(defun" nil t) (setq lengths-list (cons (count-words-in-defun) lengths-list)))
Placing the cursor just before the code and executing (forward-sexp) will fail, because of the ( symbol imbedded in the regexp
"^(defun". My ugly remedy is below:
(setq my-regexp (concat "^" (char-to-string 40) "defun")) (while (re-search-forward my-regexp nil t) (setq lengths-list (cons (count-words-in-defun) lengths-list)))
Is there a less ugly approach? Alternatively, is there a wrapper for (forward-sexp) that provides optional arguments to ignore imbedded quotes and ignore imbedded comments (e.g.
If not, I will reference this posting as a feature request for both forward-sexp and backward-sexp.