Skip to content

Instantly share code, notes, and snippets.

@whym
Created May 15, 2009 12:43
Show Gist options
  • Save whym/112196 to your computer and use it in GitHub Desktop.
Save whym/112196 to your computer and use it in GitHub Desktop.
(defun my-change-log-extract (regexp)
"Extract the entries that matches to the regexp in change-log-mode"
(interactive "sregexp: ")
(goto-char (point-max))
(do ((expression "^[0-9]\\{4\\}-[0-1][0-9]-[0-3][0-9]")
(pos (point) (point))
(list nil (cons
(cons
(match-string 0)
(buffer-substring (match-beginning 0) pos)) list)))
((not (re-search-backward expression nil t))
(with-output-to-temp-buffer "*Extracted*"
(switch-to-buffer "*Extracted*")
(mapc (lambda (item)
(if (string-match regexp (prin1-to-string (cdr item)))
(insert (cdr item))))
list)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment