Questions tagged [match-data]
12 questions
5
votes
1 answer
(RegEx-)Replace: Sporadic Match data clobbered by buffer modification hooks
I know this was asked in other contexts already, but I couldn't find anything related to C++ development with my hooks that could help me.
I am working a lot with replace and query-replace and query-replace-regexp and I love it.
Now I have the very…

AltruisticDelay
- 168
- 6
3
votes
2 answers
How to count regexp in a string and use that number in replacement?
In my LaTeX code I want to replace these strings:
\left.\left.\left.
\left.\left.
\left.
with:
\left.\left.\left. \mycommand{3}
\left.\left. \mycommand{2}
\left. \mycommand{1}
where the argument of the command \mycommand is the number of the…

Gabriele Nicolardi
- 1,199
- 8
- 17
3
votes
1 answer
How can I identify all changes to match-data?
I have a sporadic error when running query-replace:
Args out of range: #, 0, 1
There are similar questions:
Match data clobbered by buffer modification hooks
(RegEx-)Replace: Sporadic Match data clobbered by buffer modification…

Shepmaster
- 267
- 1
- 6
3
votes
1 answer
Make region(s) invisible (not evaluated) to "string-match", "occur" and similar commands
In a previous question, Make region(s) invisible (not evaluated) to query-replacy and similar commands, I learned about isearch-filter-predicate. Now, I wonder if is there a similar method to make regions invisible to functions like string-match,…

Gabriele Nicolardi
- 1,199
- 8
- 17
3
votes
1 answer
Strange behaviour of match-string/string-match
I have this code
(defun string-match-test ()
(interactive)
(string-match "12345" (buffer-string))
(setq STRING (match-string 0))
(read-string STRING)
(goto-char (point-max))
(insert STRING)
)
(string-match-test)
I expected it to…

Gabriele Nicolardi
- 1,199
- 8
- 17
1
vote
0 answers
Match data clobbered by buffer modification hooks in tex files
I run into the error Match data clobbered by buffer modification hooks when editing tex files. The way to reproduce is as follows.
In terminal,
cd
mkdir tèst/
cd tèst/
touch test.tex
echo "\input ./universalMacros.tex\n\proof\n% some comment\n\nbye"…

awllower
- 111
- 5
1
vote
2 answers
match-data fails to consider only last search with string-match and persists across sessions
Using emacs 25.3.1, I am trying to access the match data after I search a string with string-match. But the match data is wrong. To find out why I tried out the manual's simple example.
(string-match "\\(qu\\)\\(ick\\)"
…

Aquaactress
- 1,393
- 8
- 11
1
vote
1 answer
Poor's man way to debug font-lock matcher functions?
I was told on Reddit that font-lock-studio will help me debug a matcher I was working on, however, I find myself with one more problem than before as I need to learn edebug and also grasp how to debug my font-lock keywords with…

shackra
- 2,702
- 18
- 47
0
votes
2 answers
(string-trim (match-data 1)) wrong type argument error
If I put the code below into a new buffer and eval the code I get an wrong type argument error. It seems string-trim is called with argument nil. how come? I feel there are some fundamentals about elisp that I do not know.
(progn (goto-char…

SparedWhisle
- 569
- 3
- 13
0
votes
0 answers
Highlighting all matched groups in font-lock-add-keywords rule
I'm trying to highlight variable-type in custom let-like form that looks like:
(mylet (( )
(...))
)
To do so I wrote my/highlight-function:
(defun my/highlight-function (bound)
…

Coestaris
- 1
- 1
0
votes
1 answer
How to bypass lines matching some regexp, when searching forward
I've written the following function to go from an error line to the next one:
(defconst mylog-mode-error-regexp
"\\(\\[ERROR\\]\\|rule did fail\\)"
"Regexp to recognize errors in my log file.")
(defun mylog-mode-next-error ()
"Go to next…

user3341592
- 67
- 6
0
votes
1 answer
How do I debug when match-data is not getting set?
Lately, I have seen some cases where I use re-search-forward to find a pattern, and then try to do something with the match, only to find that the match-data is apparently not correct.
For example, in a file I might have this…

John Kitchin
- 11,555
- 1
- 19
- 41