Skip to main content
19 events
when toggle format what by license comment
Jul 7, 2022 at 8:14 comment added alper I am not experienced in writing lisp language and its difficult for me to understand and debug. The question I asked should be straight to point where I just want to replace patterns as word same as isearch finds. Because first I always search patterns in isearch and than replace them but hence all diffierent matched patterns also changed in replace-all
Jul 7, 2022 at 6:17 comment added dalanicolai You should have a look at this and this, especially the \b, \< and \_<. Then practice a little/do some tests using replace-regexp or regexp-builder.
Jul 5, 2022 at 9:56 comment added alper I have also added another example related to this
Jul 5, 2022 at 9:51 comment added alper When you try following solution it iterates from top of the buffer to down to apply replace emacs.stackexchange.com/questions/249/… (which is also in my question)// and in isearch-forward-symbol-at-point when you search for _cost it does not found _cost in the gas_cost since it search for the words
Jul 5, 2022 at 4:26 comment added dalanicolai Sorry, I don't understand your questions: 'select the region as complete buffer by default' and 'apply replace operation to replace matches same as the find words/patterns in isearch-forward-symbol-at-point'. I do not understand those...
Jul 4, 2022 at 22:16 comment added alper _cost => cost was just an example, it can be _cost => emacs123 or anything. I just wanted apply replace operation to replace matches same as the find words/patterns in isearch-forward-symbol-at-point
Jul 4, 2022 at 22:16 comment added alper 2nd solution does not generated wanted changes, and changes gas_costs to gascosts. The first solution does not ask what to changed with as interactive input and also it does not apply changes to complete buffer by default, when I try to apply query-replace-region-or-from-top generates: The mark is not set now, so there is no region . Is it possible to select the region as complete buffer by default and ask what to replace with?
May 10, 2022 at 15:45 vote accept alper
Jul 5, 2022 at 9:51
May 10, 2022 at 15:10 history edited dalanicolai CC BY-SA 4.0
added 937 characters in body
May 10, 2022 at 15:04 comment added dalanicolai Of course it can. I have updated the answer accordingly.
May 10, 2022 at 15:03 history edited dalanicolai CC BY-SA 4.0
added 937 characters in body
May 10, 2022 at 14:04 comment added alper Could this pattern \([[:space:]{]\|^\)+_cost embedded into the function and act as its default behavior? Like if I give _cost , the function convert it into the pattern
May 2, 2022 at 13:18 comment added dalanicolai You should use the pattern \([[:space:]{]\|^\)+_cost (copy-paste it) after doing M-x query-replace-region-or-from-top (the version I've posted here). Otherwise, I am not sure what kind of Emacs you are using ;)
May 2, 2022 at 12:36 comment added alper It does not work with emacs -Q changin gas_cost into gascost :-(
May 2, 2022 at 10:13 comment added alper Let me try with a empty file ; I put to end of my init file maybe something was preventing it to work as it should be
May 2, 2022 at 8:18 comment added dalanicolai Well, I am not sure what you have tried, but with the regexp pattern I provided, the _cost in gas_cost should not get replaced, and it works like expected here. I am sure that the pattern is correct. Please try again, maybe using emacs -Q
May 2, 2022 at 8:14 history edited dalanicolai CC BY-SA 4.0
Add syntax highlighting
May 2, 2022 at 1:49 comment added alper Ah replace-all is not correct way to put it. I just wanted to search and replace in the entire buffer starting from first appearance in the buffer till end. When I tried your solution it replaces the _cost int gas_cost which I don't want
May 1, 2022 at 22:43 history answered dalanicolai CC BY-SA 4.0