[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: collect-string
From: |
Stefan Monnier |
Subject: |
Re: collect-string |
Date: |
Fri, 03 Dec 2010 14:17:50 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Thanks, that looks pretty good now. A few more nitpicks while I'm here:
> + (defvar occur-collect-submatch-history '("1")
> + "The history of list of parenthesized expression numbers as a
> + string in occur's collect operation")
Usually history vars start at nil (and you can save them via savehist
if you so prefer).
> (defun occur-read-primary-args ()
> ! (let ((regexp)
> ! (do-collect (consp current-prefix-arg)))
> ! (list (setq regexp
> ! (read-regexp (if do-collect
> ! "Collect strings matching regexp"
> ! "List lines matching regexp")
> ! (car regexp-history)))
Always try to set the var directly in the let rather than via
a separate setq:
(let* ((do-collect (consp current-prefix-arg))
(regexp (read-regexp (if do-collect
"Collect strings matching regexp"
"List lines matching regexp")
(car regexp-history))))
(list regexp ...))
> ! (if do-collect
> ! (if (zerop (regexp-opt-depth regexp))
> ! ;; no subexpression so collect entire the match
Comments should start with a capital letter and end with a ".".
> ! '(0)
> ! ;; construct a list of subexpression integers
> ! (mapcar 'string-to-number
> ! (split-string
> ! (let ((default (car occur-collect-submatch-history)))
> ! (read-from-minibuffer
> ! (format "Subexpressions to collect (default %s): "
> default)
> ! "" nil nil 'occur-collect-submatch-history default)
> ! (car occur-collect-submatch-history)))))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This should be `default', right?
> ! When NLINES is a list of integers or when the function is called
> ! interactively with prefix argument without a number (`C-u' alone
> ! as prefix) the matching strings are collected into the `*Occur*'
> ! buffer. The parenthesized match strings in REGEXP indicated by
> ! the integers in NLINES are collected. For example, providing
> ! \"defun \\(\\S +\\)\" for REGEXP and (1) for NLINES collects all
> ! the function names in a lisp program. When there is no
> ! parenthesized subexpressions in REGEXP the entire match is
> ! collected."
Hmm... I didn't think of NLINES turning into a list of submatch-numbers,
but that makes me think that maybe we should go one step further and
turn it into a string, like the ones used in replace-match.
Stefan
- Re: collect-string, Stephen J. Turnbull, 2010/12/01
- Re: collect-string, Stefan Monnier, 2010/12/02
- Re: collect-string, Tak Ota, 2010/12/02
- Re: collect-string, Stefan Monnier, 2010/12/03
- Re: collect-string, Tak Ota, 2010/12/03
- Re: collect-string, Stefan Monnier, 2010/12/03
- Re: collect-string, Tak Ota, 2010/12/03
- Re: collect-string, Glenn Morris, 2010/12/03