From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Emanuel Berg via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: count matches in string, not region? Date: Wed, 26 Feb 2020 05:29:34 +0100 Message-ID: <87a756gedt.fsf@ebih.ebihd> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="70105"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:QkMsMkcLTJ2W/B5SmFrk2QfAmxs= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 26 05:30:24 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j6oL0-000I8K-Pb for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 26 Feb 2020 05:30:22 +0100 Original-Received: from localhost ([::1]:38026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6oKz-0007Pg-Qi for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 25 Feb 2020 23:30:21 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46955) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6oKO-0007PN-7j for help-gnu-emacs@gnu.org; Tue, 25 Feb 2020 23:29:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6oKN-0003X1-5D for help-gnu-emacs@gnu.org; Tue, 25 Feb 2020 23:29:44 -0500 Original-Received: from ciao.gmane.io ([159.69.161.202]:59342) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6oKM-0003Ry-Uw for help-gnu-emacs@gnu.org; Tue, 25 Feb 2020 23:29:43 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1j6oKK-000HOg-KO for help-gnu-emacs@gnu.org; Wed, 26 Feb 2020 05:29:40 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Mail-Copies-To: never X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 159.69.161.202 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:122470 Archived-At: 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? 3.1415-out (defun check-isbn-at-point () (interactive) (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) [1] https://dataswamp.org/~incal/emacs-init/isbn-new.el -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal