all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Herbert Euler" <herberteuler@hotmail.com>
To: rms@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: A prototype of intelligent replace for Emacs
Date: Sat, 05 May 2007 10:30:27 +0800	[thread overview]
Message-ID: <BAY143-F171966D91B21EB412623BDDA470@phx.gbl> (raw)
In-Reply-To: <E1Hie3t-00022K-GI@fencepost.gnu.org>

Sorry for the delay.  I went travel these days and I could not connect
to net.

>The concept of "classes" and "blocks" sounds rather complex.  In order
>to install such a feature, we would have to document it.  At present,
>I don't understand it myself.
>
>Could you give an example to explain what that means?

Sure.  The reason I did not write comment/document in the attached
source code is that, the user interface included in the prototype is
in unstable status, and it may be changed hugely to satisfy most
people.  In such a progress, the written comment/document must be
updated, which in my opinion is not so easy for the sake of
consistency.  So I do not want to maintain both the code and the
comment/document when they are unstable, and I was deciding to
postpone them until the prototype is stable.  I am sorry for this.

Now I am going to try to explain the concept of "blocks" and
"classes".  These concepts are defined in the search phase of a
search/replace process.  When a word is searched in a document, many
matches may be found in it.  "Blocks" and "classes" are defined based
on the matches.

To define "block" and "class", the concept of "feature" has to be
introduced first.  A _feature_ of a match is a value, computed from
the context of the match and a predefined rule.  A restriction to
features computed from a same rule is that they must be able to be
compared.  Features can be strings, or integers.  For example, rule A
could be "a feature of a match is the shortest word sequence that
contains the match".  Now suppose the word "at" is searched in a
document.  Three matches are found, the first is "status", the second
is "match", and the third is "status" again.  Under rule A, the
feature of the first and the third match is "status", since the
shortest word sequence that contains the match "at" is the sequence
"status".  Similarly, the feature for the second match is the word
"match".  In this example, both word sequences consist of only one
word.  If another word "a b" is searched under rule A, the word
sequences may consist of more than one word.

If there are many different rules, many features can be computed for a
match.  Because features computed from a same rule can be compared,
matches can be classified, or grouped together, with their features.
This is based on similarity among the matches.  Now the concept of
"block" and "class" can be defined.  A _block_ is a match plus its
features.  A _class_ is a set of blocks, all of which have the same
features.  Continuing from the previous example, since the first and
the third block have the same feature "status", they are in one class.
The second block is a class itself.

Now let us go back to the search/replace topic.  When the user wants
to replace A with B in a document, it can invoke `replace-string' to
replace all matches of A with B, or invoke `query-replace' to replace
matches of A with B one by one, by answering `y' or `n' on each of the
matches.  As described in the paper Cluster-Based Find and Replace by
Robert C. Miller and Alisa M. Marshall (1), another approach,
replacing several matches at one time by similarity, is faster and
more reliable, provided the predefined rules are carefully defined.
The prototype "ireplace" tries to implement such a search/replace
mechanism for Emacs, with the concept of "blocks" and "classes".

Currently, there is only one feature for every match in the prototype:
the shortest word sequence that contains the match.  In the ireplace
buffer, the feature of the blocks in a class is displayed after the
class number (i.e. [Class m of n]).  Defining proper rules is
important future work.  For example, another rule of computing
features for matches in program source code could be the section
(separated by ^L) a match appears in, or the type (variable, function,
and so on) of a match.

I hope I explained clearly.  In fact, because English is not my native
language, I chose the words "feature", "block", and "class" at will.
I am not sure how to call them in English.  But since you found them
complex, perhaps I should change them to clearer names.  What do you
think are better names?  Thanks.

And both the user interface and the concepts are needing to be checked
now.

Regards,
Guanpeng Xu

(1) Web link: http://graphics.csail.mit.edu/~rcm/chi04.pdf

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

  reply	other threads:[~2007-05-05  2:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-29  8:32 A prototype of intelligent replace for Emacs Herbert Euler
2007-04-29 18:39 ` Drew Adams
2007-05-05  2:29   ` Herbert Euler
2007-04-30 22:09 ` Richard Stallman
2007-05-05  2:30   ` Herbert Euler [this message]
2007-05-05 23:18     ` Richard Stallman
2007-05-06 15:01       ` Herbert Euler
2007-05-06 22:26         ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BAY143-F171966D91B21EB412623BDDA470@phx.gbl \
    --to=herberteuler@hotmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.