Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 15606

query-replace is a built-in Emacs command for interactively replacing one string with another in a buffer. query-replace-regexp does the same thing, but with support for matching regular expressions. Use this tag for both commands.

1 vote
1 answer
137 views

Make query-replace skip certain matches

Lets say I have these strings: "foo", "fooo" and "fo". And this line of code: (query-replace-regexp "\\<fo+\\>" "foo" nil (point-min) (point-max)) I'd like to skip the query-replacement for the mat …
Gabriele's user avatar
  • 1,680
0 votes
2 answers
65 views

Build a "with-query-replace-description" macro

In the company where I work we use Emacs as the default editor for the LaTeX copy-editing tasks and we share some Emacs scripts to automate/guide some operations. Actually I need to perform some query …
Gabriele's user avatar
  • 1,680
0 votes
Accepted

Build a "with-query-replace-description" macro

I've been successfully using this solution for quite some time now: (defmacro with-interactive-tasks-explanation (MESSAGE &rest body) "It allows displaying, in a dedicated buffer resized to the nece …
Gabriele's user avatar
  • 1,680
1 vote
1 answer
45 views

query-replace* (perform-replace): highlighting issue with "act-and-show"

When I use the query-replace* (perform-replace) functions, I can type "," "to replace but not move point immediately." During the replacement, the function highlights the match, but if I type ",", the …
Gabriele's user avatar
  • 1,680
0 votes
Accepted

query-replace* (perform-replace): highlighting issue with "act-and-show"

It seems to be a bug in Emacs 29. It was fixed in Emacs 30: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71430
Gabriele's user avatar
  • 1,680
0 votes
1 answer
27 views

query-replace, add a "skip to next" in lambda function

I have this function: (defun fix-mult-punct-before-footnote () "Scope: FOOTNOTE Description: Fixes repeated/multiple punctuation before the \\footnote macro." (interactive) ;; "..\footnote{" --> …
Gabriele's user avatar
  • 1,680
0 votes
Accepted

query-replace, add a "skip to next" in lambda function

The solution is built-in in query-replace-regexp: (defun fix-mult-punct-before-footnote () "Scope: FOOTNOTE Description: Fixes repeated/multiple punctuation before the \\footnote macro." (interact …
Gabriele's user avatar
  • 1,680
0 votes
1 answer
66 views

query-replace bug?

When I run query-replace* commands if I type ? I get this explanation of the function's options: Type Space or ‘y’ to replace one match, Delete or ‘n’ to skip to next, RET or ‘q’ to exit, Period to re …
Gabriele's user avatar
  • 1,680
0 votes
Accepted

query-replace bug?

It was indeed a bug. I believe it will be fixed in Emacs version 29.2.
Gabriele's user avatar
  • 1,680
0 votes
0 answers
29 views

set-keymap-parent function and let binding of involved keymaps

I have this content in the buffer: \begin{environment} foo Some other text here \end{environment} \begin{environment} foo Some other text here \end{environment} \begin{environment} foo Some other …
Gabriele's user avatar
  • 1,680
0 votes
1 answer
40 views

Using query-replace to add text properties to replacement strings in Emacs

I'm trying to use query-replace in Emacs to replace a string with another string that has specific text properties. Specifically, in this example, I want to replace occurrences of "foo" with "bar" and …
Gabriele's user avatar
  • 1,680
1 vote
1 answer
47 views

Face-based replacements

I need to perform this kind of (query-)substitutions in LaTeX code: "fig" --> "figure" But I don't want to match text inside commands e.g. \label{fig:1} or \includegraphics[width=2cm]{fig/D.pdf}. I f …
Gabriele's user avatar
  • 1,680
1 vote
Accepted

Face-based replacements

I want to answer my own question because I've just found that the redisplay command seems to solve my problem. I want to share my solution: (goto-char (point-min) (while (search-forward-regexp "\\<\\ …
Gabriele's user avatar
  • 1,680
1 vote
1 answer
192 views

Passing a string with substitutions to the "perform-replace" command

I want to generalize this query-replace regexp: (perform-replace "Geophysical[\s\t\n]*Research[\s\t\n]*Letters" "Geophys.\\\\ Res.\\\\ Lett." t t nil 1 nil (point- …
Gabriele's user avatar
  • 1,680
3 votes
3 answers
414 views

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 …
Gabriele's user avatar
  • 1,680

15 30 50 per page