all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* In place (live) editing of matches - is there a package for it?
@ 2011-10-14 10:57 Tom
  2011-10-14 11:09 ` mehran khajavi
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Tom @ 2011-10-14 10:57 UTC (permalink / raw)
  To: help-gnu-emacs

Recently I had to work multiple times with text files and it 
involved search/replacing strings in the file multiple times.

For example, if the file has the word "phone" in multiple places
and I want to replace it with "phoning" then I go to the beginning
of the file and replace all the matches with a search/replace
command.

It occurred to me it would be more convenient if I could just select
the word (or a phrase) and use a command which allows me to live edit
this region, so that all the changes I make within the selected part are
reflected instantly at all the other places in the file which have
the same text as the initial selection.

Is there an existing package which does this?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: In place (live) editing of matches - is there a package for it?
  2011-10-14 10:57 In place (live) editing of matches - is there a package for it? Tom
@ 2011-10-14 11:09 ` mehran khajavi
  2011-10-14 11:15   ` Tom
  2011-10-14 11:17 ` Jambunathan K
  2011-10-14 12:43 ` Tom
  2 siblings, 1 reply; 8+ messages in thread
From: mehran khajavi @ 2011-10-14 11:09 UTC (permalink / raw)
  To: Tom; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]

I don't know is there any package relating to you question
but for editing multiple files I found this
http://blog.gabrielsaldana.org/emacs-tip-how-to-edit-multiple-files/
 <http://blog.gabrielsaldana.org/emacs-tip-how-to-edit-multiple-files/>it
might useful for you
find-dired is easy to use

On Fri, Oct 14, 2011 at 2:27 PM, Tom <adatgyujto@gmail.com> wrote:

> Recently I had to work multiple times with text files and it
> involved search/replacing strings in the file multiple times.
>
> For example, if the file has the word "phone" in multiple places
> and I want to replace it with "phoning" then I go to the beginning
> of the file and replace all the matches with a search/replace
> command.
>
> It occurred to me it would be more convenient if I could just select
> the word (or a phrase) and use a command which allows me to live edit
> this region, so that all the changes I make within the selected part are
> reflected instantly at all the other places in the file which have
> the same text as the initial selection.
>
> Is there an existing package which does this?
>
>
>
>


-- 
-----
Mehran Khajavi
http://mehran.khajavi.ir

[-- Attachment #2: Type: text/html, Size: 1798 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: In place (live) editing of matches - is there a package for it?
  2011-10-14 11:09 ` mehran khajavi
@ 2011-10-14 11:15   ` Tom
  0 siblings, 0 replies; 8+ messages in thread
From: Tom @ 2011-10-14 11:15 UTC (permalink / raw)
  To: help-gnu-emacs

mehran khajavi <sinoohe.mkh <at> gmail.com> writes:

> 
> I don't know is there any package relating to you questionbut for 
> editing multiple files I found this 
> http://blog.gabrielsaldana.org/emacs-tip-how-to-edit-multiple-files/
> 

Yes, I know Dired can do this, but point is not editing multiple files.
I worked with several files, but the edits I made to them concerned 
only individual files, so plain old search/replace did the job.

The question is about making single file replace even easier by
simply selecting what you want to replace wherever you are in the
buffer and edit it in-place and have the changes reflected to other 
parts of the buffer.






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: In place (live) editing of matches - is there a package for it?
  2011-10-14 10:57 In place (live) editing of matches - is there a package for it? Tom
  2011-10-14 11:09 ` mehran khajavi
@ 2011-10-14 11:17 ` Jambunathan K
  2011-10-14 11:24   ` Tom
  2011-10-14 12:43 ` Tom
  2 siblings, 1 reply; 8+ messages in thread
From: Jambunathan K @ 2011-10-14 11:17 UTC (permalink / raw)
  To: Tom; +Cc: help-gnu-emacs


all.el in GNU's ELPA - http://elpa.gnu.org/packages/

If you are running recent Emacs-24 pretest builds, checkout
occur-edit-mode.

Btw, You may want to say Hi! to Carsten after reading this mail.
http://lists.gnu.org/archive/html/emacs-orgmode/2011-10/msg00125.html

Tom <adatgyujto@gmail.com> writes:

> Recently I had to work multiple times with text files and it 
> involved search/replacing strings in the file multiple times.
>
> For example, if the file has the word "phone" in multiple places
> and I want to replace it with "phoning" then I go to the beginning
> of the file and replace all the matches with a search/replace
> command.
>
> It occurred to me it would be more convenient if I could just select
> the word (or a phrase) and use a command which allows me to live edit
> this region, so that all the changes I make within the selected part are
> reflected instantly at all the other places in the file which have
> the same text as the initial selection.
>
> Is there an existing package which does this?
>
>
>
>

-- 



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: In place (live) editing of matches - is there a package for it?
  2011-10-14 11:17 ` Jambunathan K
@ 2011-10-14 11:24   ` Tom
  0 siblings, 0 replies; 8+ messages in thread
From: Tom @ 2011-10-14 11:24 UTC (permalink / raw)
  To: help-gnu-emacs

Jambunathan K <kjambunathan <at> gmail.com> writes:

> 
> all.el in GNU's ELPA - http://elpa.gnu.org/packages/
> 
> If you are running recent Emacs-24 pretest builds, checkout
> occur-edit-mode.
> 

These are not the same, because I have to do an occur first and
then edit the matches in the occur buffer. Or if it supports 
search/replace then I can do it in the occur buffer, but in
that case I can do search/replace in the original buffer in
the first place and the point is making this simpler.


> Btw, You may want to say Hi! to Carsten after reading this mail.
> http://lists.gnu.org/archive/html/emacs-orgmode/2011-10/msg00125.html
> 

I did answer to that:

http://lists.gnu.org/archive/html/emacs-orgmode/2011-10/msg00166.html






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: In place (live) editing of matches - is there a package for it?
  2011-10-14 10:57 In place (live) editing of matches - is there a package for it? Tom
  2011-10-14 11:09 ` mehran khajavi
  2011-10-14 11:17 ` Jambunathan K
@ 2011-10-14 12:43 ` Tom
  2011-10-14 13:08   ` Drew Adams
  2 siblings, 1 reply; 8+ messages in thread
From: Tom @ 2011-10-14 12:43 UTC (permalink / raw)
  To: help-gnu-emacs

Tom <adatgyujto <at> gmail.com> writes:

> 
> It occurred to me it would be more convenient if I could just select
> the word (or a phrase) and use a command which allows me to live edit
> this region, so that all the changes I make within the selected part are
> reflected instantly at all the other places in the file which have
> the same text as the initial selection.
> 

I created this trivial function which does this without the instant visual 
feedback, but at least it spares me copying the text, going back
to the beginning of buffer, pasting it to the replace prompt and when all
instances are replaced then going back to the place where the whole
thing is started:

(defun my-replace-region ()
  (interactive)
  (unless (use-region-p)
    (error "no region"))
  (let ((what (buffer-substring-no-properties
               (region-beginning) (region-end)))
        (replacement (read-string "replace with: ")))
    (save-excursion
      (goto-char (point-min))
      (while (search-forward what nil t)
        (replace-match replacement)))))

The live feedback would be better, because it's more fancy and the
user can see an instant confirmation of the replacements during typing
if more than one of them is visible on the screen. 






^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: In place (live) editing of matches - is there a package for it?
  2011-10-14 12:43 ` Tom
@ 2011-10-14 13:08   ` Drew Adams
  2011-10-14 13:35     ` Tom
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2011-10-14 13:08 UTC (permalink / raw)
  To: 'Tom', help-gnu-emacs

Tom, this sounds very similar to what you are requesting:
http://www.emacswiki.org/emacs/Iedit.  However, it apparently acts on the whole
buffer, so you might need to narrow first.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: In place (live) editing of matches - is there a package for it?
  2011-10-14 13:08   ` Drew Adams
@ 2011-10-14 13:35     ` Tom
  0 siblings, 0 replies; 8+ messages in thread
From: Tom @ 2011-10-14 13:35 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams <drew.adams <at> oracle.com> writes:

> 
> Tom, this sounds very similar to what you are requesting:
> http://www.emacswiki.org/emacs/Iedit.  
> 

Thanks. It is indeed exactly what I want.

I knew someone must have thought of this before me. :)




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-10-14 13:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-14 10:57 In place (live) editing of matches - is there a package for it? Tom
2011-10-14 11:09 ` mehran khajavi
2011-10-14 11:15   ` Tom
2011-10-14 11:17 ` Jambunathan K
2011-10-14 11:24   ` Tom
2011-10-14 12:43 ` Tom
2011-10-14 13:08   ` Drew Adams
2011-10-14 13:35     ` Tom

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.