I have the following code to count the number of opening and closing
brackets in a selected region. How can I allow a user to select
the bracketing sign (
,[
,{
to count, and return two counts, one for the opening mark and another for the closing mark?
(defun veak-count (region-start region-end)
"Count open-parens between REGION-START and REGION-END."
(interactive "r") ; gets region start and end
(message "Counting bracketing marks ...")
(save-excursion
(let ( (a 0) (b 0) (c 0) (d 0))
(goto-char region-start)
(while (and (< (point) region-end)
(search-forward "(" region-end t))
(cl-incf a))
(goto-char region-start)
(while (and (< (point) region-end)
(search-forward ")" region-end t))
(cl-incf b))
(message "%s %d %d" "count: ()" a b)
(goto-char region-start)
(while (and (< (point) region-end)
(search-forward "[" region-end t))
(cl-incf c))
(goto-char region-start)
(while (and (< (point) region-end)
(search-forward "]" region-end t))
(cl-incf d))
(message "%s %d %d" "count: {}" c d) )) )