auctex-devel
[Top][All Lists]
Advanced

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

Re: [AUCTeX-devel] extended reftex-search-document


From: Lars Madsen
Subject: Re: [AUCTeX-devel] extended reftex-search-document
Date: Tue, 2 Dec 2014 11:52:52 +0000

Hmm, that almost works

I tested this:


(defun daleif-tags-search (regexp &optional file-list-form)
  "Search through all files listed in tags table for match for REGEXP.
Stops when a match is found.
To continue searching for next match, use command \\[tags-loop-continue].

If FILE-LIST-FORM is non-nil, it should be a form that, when
evaluated, will return a list of file names.  The search will be
restricted to these files.

Also see the documentation of the `tags-file-name' variable."
  (interactive "sTags search (regexp): ")
  (if (and (equal regexp "")
           (eq (car tags-loop-scan) 're-search-forward)
           (null tags-loop-operate))
      ;; Continue last tags-search as if by M-,.
      (tags-loop-continue nil)
    (setq tags-loop-scan 
          `(when (re-search-forward ',regexp nil t)
             (not (texmathp))
             )
          tags-loop-operate nil)
    (tags-loop-continue (or file-list-form t))))


(defun reftex-search-document-extended (&optional regexp)
  "Regexp search through all files of the current document.
Starts always in the master file.  Stops when a match is found.
To continue searching for next match, use command \\[tags-loop-continue].
No active TAGS table is required."
  (interactive)
  (let ((default (reftex-this-word)))
    (unless regexp
      (setq regexp (read-string (format "Search regexp in document [%s]: "
                                        default))))
    (if (string= regexp "") (setq regexp (regexp-quote default)))

    (reftex-access-scan-info current-prefix-arg)
    ;; changed here
    (daleif-tags-search regexp (list 'reftex-all-document-files))))


And tested it by looking for ' :' (space colon), it should find those outside 
math. It does, but a few files in I get an error

wrong type argument: stringp, nil

and the buffer has opened *next-file*

It seems it was hit at the very first ' :' that is actually in math mode. So 
I'm guessing (not (textmathp)) is not the proper test?




/Lars Madsen
Institut for Matematik / Department of Mathematics
Aarhus Universitet / Aarhus University
Mere info: http://au.dk/address@hidden / More information: 
http://au.dk/en/address@hidden


________________________________________
From: address@hidden address@hidden on behalf of Tassilo Horn address@hidden
Sent: 27 November 2014 16:08
To: address@hidden
Subject: Re: [AUCTeX-devel] extended reftex-search-document

Lars Madsen <address@hidden> writes:

Hi Lars,

> I was wondering, has anyone thought of making an extended version of
> reftex-search-document?
>
> By this I mean a similar feature, but where one can add, say a
> callback, that will make extra tests on a match found, and if the test
> fails, automatically continue to the next match.
>
> This could be rather useful then editing sources other people
> wrote. For example, adding that we are only interested in matches
> outside of math.
>
> In the manuscript I'm currently editing, there are a lot of standard
> commas missing in the text, so if I had a feature like this I could
> make a regexp (only lower case matches) of standard words that should
> always be preceeded by a comma in my language, as a callback it should
> be looking to see if a comma was already present.
>
> I haven't gone too far down the details of how tags-search (which
> reftex-search-document use) actually work.

That shouldn't be too hard.  Have a look at `tags-search'.  That sets
`tags-loop-scan' to `(re-search-forward ',regexp nil t) to do the actual
search.  So just make your own `lars/tags-search' function by copying
`tags-search' and setting `tags-loop-scan' to something like

  `(when (re-search-forward ',regexp nil t)
     (check-whatever-needs-to-be-checked))

Bye,
Tassilo


_______________________________________________
auctex-devel mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/auctex-devel



reply via email to

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