Bug 72489 - auto search and replace function
Summary: auto search and replace function
Status: RESOLVED INTENTIONAL
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-12 17:31 UTC by rgpublic
Modified: 2011-07-11 19:58 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rgpublic 2004-01-12 17:31:46 UTC
Version:            (using KDE KDE 3.1.94)
Installed from:    SuSE RPMs

There has been lots of excellent innovation in Quanta with
VPL and stuff like that but I hope you have't yet forgotten
that there are still people out there who must / or want
to edit normal HTML files ;-)
So, this is now quite an innovative idea and has
AFAIK never been implemented before in any editor but 
is very useful IMO. And the best thing - It might be
surprisingly easy to implement though it sounds
complicated at first:

At some point in time - if you don't have 
a text selection -  you can say that the text cursor is
currently in line y. Quanta can of course watch this and
notices whenever you go into a _different_ line either
by clicking or my using the arrow keys. Now, Quanta
knows when you just entered (*not* in the sense of
typing, but in the sense of visited) a line and when
you leave it. All changes in a line occur between
those two points in time. Quanta can compare what has
been in the line when you entered it and what is there
when you leave it. Now Quanta can find out what has changed
by comparing both lines and should be able quite easily 
to detect the following conditions:
1) only sth. at the beginning has been inserted
2) only sth. at the end has been appended
3) some string has been replace by some other string
Now you call 
Edit - Global Auto Replace (i.e. Shift+Ctrl+F8)
Edit - Auto Replace in Function (i.e. Ctrl+F8)
Edit - Auto Replace in Current Line (i.e F8)
and it will automatically perfom the last detected 
operation on the current line / (PHP/C-function) / in
the whole file.
Why is this useful you might ask?
Often you start replacing variable names or sth.
and after changing one or two lines you think: 
Argh, why didn't I use the replace function? 
In the replace dialog you would have to enter the
search and replace word again.
I think this is much more intuitive and user-friendly
because this means basically:
I replace it once. Now do it like that.
How often did you change 5-10 similar lines by hand
though there is a replace function? I often think:
Well, 5-10 lines are not THAT much. I've already changed
one line. And I don't want to open the dialog, check all
the options, do the selection right. So I end up changing
them manually. Not anymore if this idea ever becomes 
a reality ;-)
BTW: There should be just a beep if the last operation
was to complex for Quanta to analyze what's been going
on.
Comment 1 András Manţia 2004-01-13 20:54:54 UTC
I like the idea and look to be innovative, but I think this belongs to the text editor itself, thus to Kate. You know, we don't maintain our own editor, but reusing what KDE provides. ;-)
Comment 2 András Manţia 2004-01-13 21:06:08 UTC
Subject: quanta_be: quanta/quanta

CVS commit by amantia: 

Close file when it's removed from project. Avoids a warning dialog on next startup in some cases.

CCMAIL: 72489-done@bugs.kde.org


  M +8 -0      quanta.cpp   1.387.2.43
  M +2 -0      quanta.h   1.179.2.10
  M +2 -0      quanta_init.cpp   1.380.2.23
  M +1 -0      project/project.cpp   1.125.2.13
  M +1 -0      project/project.h   1.48.2.2


--- quanta/quanta/quanta.cpp  #1.387.2.42:1.387.2.43
@@ -501,4 +501,12 @@ void QuantaApp::slotFileClose()
 }
 
+void QuantaApp::slotFileClose(const KURL &url)
+{
+  Document *w = m_doc->isOpened(url);
+  if (w)
+    slotClosePage(w);
+}
+
+
 void QuantaApp::slotFileCloseAll()
 {

--- quanta/quanta/quanta.h  #1.179.2.9:1.179.2.10
@@ -220,4 +220,6 @@ public slots:
   void slotFileReloadAll();
   void slotFileClose();
+  /** Close the document specified in the parameter if it's opened */
+  void slotFileClose(const KURL &url);
   void slotFileCloseAll();
   void slotFilePrint();

--- quanta/quanta/quanta_init.cpp  #1.380.2.22:1.380.2.23
@@ -315,4 +315,6 @@ void QuantaApp::initProject()
   connect(m_project,  SIGNAL(openFile    (const KURL &, const QString&)),
           this,     SLOT  (slotFileOpen(const KURL &, const QString&)));
+  connect(m_project,  SIGNAL(closeFile   (const KURL &)),
+          this,     SLOT  (slotFileClose(const KURL &)));
   connect(m_project,  SIGNAL(reloadTree(const KURL::List & ,bool)),
           pTab,     SLOT  (slotReloadTree(const KURL::List &,bool)));

--- quanta/quanta/project/project.cpp  #1.125.2.12:1.125.2.13
@@ -1034,4 +1034,5 @@ void Project::slotRemove(const KURL& url
     }
   }
+  emit closeFile(urlToRemove);
   emit reloadTree( m_projectFiles, false );
   emit newStatus();

--- quanta/quanta/project/project.h  #1.48.2.1:1.48.2.2
@@ -125,4 +125,5 @@ signals:
 
   void openFile( const KURL&, const QString& );
+  void closeFile( const KURL&);
   void closeFiles();
 


Comment 3 András Manţia 2004-01-13 23:10:58 UTC
Oops, closed by mistaked
Comment 4 Maciej Pilichowski 2008-04-03 19:23:00 UTC
Did I understand the wish correctly -- replace based on user manual replace, replace by pattern?

Really nice! I often fall in this trap. Diff on undo buffer could serve as the source of (initial) values for the replace.
Comment 5 Dominik Haumann 2011-07-11 19:58:34 UTC
It may sound nice, but - to face the facts - it's a bit too fuzzy to always have a well-defined behaviour. KDevelop can do very clever search & replace, because it understands/parses the code. Hence, this very specific feature is very unlikely to be implemented. Given this, I close the report as wont-fix... Sorry.

PS: You can do a lot with KatePart's scripting API. You cannot access the clipboard or the undo/redo history, though, right now.
http://docs.kde.org/stable/en/kdesdk/kate/advanced-editing-tools-scripting.html