1
(defun my-find-orgfiles ()
  (interactive)
  (find-name-dired "." "*py"))

(global-set-key (kbd "M-n") 'my-find-orgfiles)

Than, t to toggle marked/unmarked files (thus marking them all, since none were marked). Then I use Q to use query-replace on the marked files. And enter .value to replace with value.


=> What am I trying to do? Replace a string that is starting or ending with . (dot) such as: .value or value..

=> What happens instead? During replacement Emacs also finds text such as (value, [space]value, [value and so on. In other words, .value is matching any character followed by value.

=> How can I force dired-do-find-regexp-and-replace (bound to Q in Dired buffers) to look for a literal . during string replacement?

5
  • After use of M-n, I press t and Q. Afterwards Query replace regexp in marked files pops up and I type .value goal is to replace it with value. So basically on the selected files I want to replace .value withvalue
    – alper
    Apr 23, 2020 at 17:20
  • 1
    Ah, so you use t to toggle marked/unmarked files (thus marking them all, since none were marked). Then you use Q to use query-replace on the marked files. You might want to add that info to the question, for clarity.
    – Drew
    Apr 23, 2020 at 19:01
  • Yes, please. Comments can be deleted at any time. Questions and answers should stand on their own. They are what get searched on the site and what get indexed by search engines (e.g. Google). No important info should be kept only in comments, in general. Thx.
    – Drew
    Apr 23, 2020 at 19:08
  • I updated, I hope it is more clear
    – alper
    Apr 23, 2020 at 19:15
  • Yes. Thanks. ...
    – Drew
    Apr 23, 2020 at 20:21

1 Answer 1

1

This really has nothing to do with find-name-dired.

This is about Q in Dired buffers (including from find-name-dired).

Q is dired-do-find-regexp-and-replace. That command treats your first input pattern as a regexp. And . in a regexp matches any character except newline.

What you want to use, instead of .value, is [.]value. That is, you want a pattern that matches only a . character.

2
  • This also occurs for words ending with . right?
    – alper
    Apr 23, 2020 at 19:11
  • 1
    It has nothing to do with words, per se. In a regexp, the character . matches any character other than a newline char. So yes, if you're asking about, say, value., then that would match value?, value), value[, valueX, values, etc.
    – Drew
    Apr 23, 2020 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.