all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* count regexp hits
@ 2018-01-04  4:12 Emanuel Berg
  2018-01-04  5:02 ` Drew Adams
       [not found] ` <mailman.6799.1515042142.27995.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 41+ messages in thread
From: Emanuel Berg @ 2018-01-04  4:12 UTC (permalink / raw)
  To: help-gnu-emacs

Just wrote this [1] - is this somewhere already
or is it so simple so you are expected to do it
yourself? If so - well, don't count on it.
I actually know many people incapable of
writing any of this!

(defun count-regexp-hits (regexp)
  (interactive "sregexp: ")
  (let ((hits 0))
    (save-excursion
      (while (re-search-forward regexp (point-max) t)
        (cl-incf hits) ))
    (message "%d" hits) ))

Example usage - eval me:

%% how many books? (count-regexp-hits "@book")

@book{fiberglass-boat-repair-manual,
  author     = {Allan Vaitses},
  ISBN       = {0-07-156914-6},
  publisher  = {International Marine},
  title      = {The Fiberglass Boat Repair Manual},
  year       = 1988
}

@book{savage-sword-of-conan-22,
  author     = {Roy Thomas},
  ISBN       = 1616558717,
  publisher  = {Dark Horse},
  title      = {Savage Sword of Conan 22},
  year       = 2016
}

[1] http://user.it.uu.se/~embe8573/emacs-init/count.el

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2018-01-10  3:31 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-04  4:12 count regexp hits Emanuel Berg
2018-01-04  5:02 ` Drew Adams
     [not found] ` <mailman.6799.1515042142.27995.help-gnu-emacs@gnu.org>
2018-01-04 18:47   ` Emanuel Berg
2018-01-04 21:32     ` DWIM region (was: Re: count regexp hits) Emanuel Berg
2018-01-04 22:18       ` DWIM region Stefan Monnier
2018-01-05 23:18         ` Philipp Stephani
2018-01-04 22:48       ` DWIM region (was: Re: count regexp hits) Kaushal Modi
     [not found]       ` <mailman.6836.1515106138.27995.help-gnu-emacs@gnu.org>
2018-01-04 23:03         ` Emanuel Berg
2018-01-04 23:14           ` Kaushal Modi
     [not found]           ` <mailman.6837.1515107666.27995.help-gnu-emacs@gnu.org>
2018-01-05  2:10             ` Emanuel Berg
2018-01-08 16:09           ` advice vs hooks in org (was DWIM region) Rusi
     [not found]       ` <mailman.6835.1515104325.27995.help-gnu-emacs@gnu.org>
2018-01-04 23:09         ` DWIM region Emanuel Berg
2018-01-04 23:14           ` Stefan Monnier
     [not found]           ` <mailman.6838.1515107716.27995.help-gnu-emacs@gnu.org>
2018-01-04 23:36             ` Emanuel Berg
2018-01-05  0:19               ` Emanuel Berg
2018-01-05 20:45             ` Emanuel Berg
2018-01-05 22:31               ` Stefan Monnier
     [not found]               ` <mailman.6892.1515191546.27995.help-gnu-emacs@gnu.org>
2018-01-06  2:20                 ` Emanuel Berg
2018-01-06 15:53                   ` Stefan Monnier
     [not found]                   ` <mailman.6929.1515254243.27995.help-gnu-emacs@gnu.org>
2018-01-06 18:52                     ` Emanuel Berg
2018-01-06 20:29                     ` Emanuel Berg
2018-01-06 22:14                     ` Emanuel Berg
2018-01-07  3:14                       ` Emanuel Berg
2018-01-07  3:25                         ` Emanuel Berg
2018-01-08 14:17                           ` Stefan Monnier
     [not found]                           ` <mailman.7019.1515421057.27995.help-gnu-emacs@gnu.org>
2018-01-09  1:41                             ` Emanuel Berg
2018-01-09  2:30                               ` Stefan Monnier
     [not found]                               ` <mailman.7052.1515465048.27995.help-gnu-emacs@gnu.org>
2018-01-09  4:11                                 ` Emanuel Berg
2018-01-09 13:40                                   ` Stefan Monnier
2018-01-08 14:11                         ` Stefan Monnier
     [not found]                         ` <mailman.7018.1515420745.27995.help-gnu-emacs@gnu.org>
2018-01-08 20:26                           ` Emanuel Berg
2018-01-08 14:08                       ` Stefan Monnier
2018-01-04 23:20         ` Emanuel Berg
2018-01-07  5:32       ` DWIM region (was: Re: count regexp hits) Marcin Borkowski
     [not found]       ` <mailman.6953.1515303153.27995.help-gnu-emacs@gnu.org>
2018-01-07  6:45         ` Emanuel Berg
2018-01-07  7:21           ` Marcin Borkowski
     [not found]           ` <mailman.6967.1515337253.27995.help-gnu-emacs@gnu.org>
2018-01-07 20:57             ` Emanuel Berg
2018-01-09  5:28               ` Marcin Borkowski
2018-01-09 13:42                 ` DWIM region Stefan Monnier
     [not found]                 ` <mailman.7069.1515505638.27995.help-gnu-emacs@gnu.org>
2018-01-10  3:31                   ` Emanuel Berg
     [not found]               ` <mailman.7055.1515475732.27995.help-gnu-emacs@gnu.org>
2018-01-09  6:20                 ` DWIM region (was: Re: count regexp hits) Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.