[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

count matches in string, not region?

From: Emanuel Berg
Subject: count matches in string, not region?
Date: Wed, 26 Feb 2020 05:29:34 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

This [last] I wrote a couple of nights ago, it
is part of my ISBN stuff [1] that will soon be
a MELPA package, God willing. But more on that
if and when it happens...

Anyway as you see the 4th line doesn't look
good, instead of moving the point one would
like to invoke the/a count function with the
already-fetched isbn-as argument.

So is there a count-matches-in-string or
something to that extent anywhere, that you are
aware of?


(defun check-isbn-at-point ()
  (let*((isbn-string (thing-at-point 'symbol t))
        (num-digits (count-matches "[[:digit:]]" (point) (progn (forward-symbol 
1) (point))))
        (check-digit (if (> num-digits 10)
                         (checksum-isbn-13 isbn-string)
                       (checksum-isbn-10 isbn-string) )))
    (message "check digit: %s" check-digit)
(defalias 'ciap #'check-isbn-at-point)


underground experts united

reply via email to

[Prev in Thread] Current Thread [Next in Thread]