/ Published in: Emacs Lisp
An answer to the 'count-string-matches exercise listed here: http://stackoverflow.com/questions/41522/tips-for-learning-elisp/59589#59589
- (defun count-string-matches (strn)
- "Return number of matches STRING following the point.
- Continues until end of buffer. Also display the count as a message."
- (interactive (list (read-string "Enter string: ")))
- (let ((count -1))
- (setq count (1+ count))
- (search-forward strn nil t)))
- (message "%d matches" count)
You need to login to post a comment.