From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: char equivalence classes in search - why not symmetric? Date: Wed, 9 Sep 2015 15:52:55 -0700 (PDT) Message-ID: <4bf04d46-418d-4950-9de3-d9f9130ce8bf@default> References: <2a7b9134-af2a-462d-af6c-d02bad60bbe8@default> <834mjecdy7.fsf@gnu.org> <38061f42-eaf1-47c6-b74d-f676ac952b18@default> <83r3miatvl.fsf@gnu.org> <21998.29683.916211.867479@a1i15.kph.uni-mainz.de> <9A972800-D8F0-4DA8-877E-07D5BDC2E1F9@gmail.com> <87oahd11i9.fsf@uwakimon.sk.tsukuba.ac.jp> <8cf269bc-69d8-4752-8506-de8d992512e1@default> <87mvwx0wdq.fsf@uwakimon.sk.tsukuba.ac.jp> <42be0ab7-f1e0-4fac-8b80-0e1686e88445@default> <87fv2o24mf.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="__1441839177480173097abhmp0005.oracle.com" X-Trace: ger.gmane.org 1441839215 21403 80.91.229.3 (9 Sep 2015 22:53:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Sep 2015 22:53:35 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Stephen J. Turnbull" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 10 00:53:23 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZZoEm-0002tK-St for ged-emacs-devel@m.gmane.org; Thu, 10 Sep 2015 00:53:09 +0200 Original-Received: from localhost ([::1]:46024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZoEm-000846-9L for ged-emacs-devel@m.gmane.org; Wed, 09 Sep 2015 18:53:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZoEh-000837-NL for emacs-devel@gnu.org; Wed, 09 Sep 2015 18:53:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZoEe-0008GD-EE for emacs-devel@gnu.org; Wed, 09 Sep 2015 18:53:03 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:37858) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZoEe-0008G7-5r for emacs-devel@gnu.org; Wed, 09 Sep 2015 18:53:00 -0400 Original-Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t89MqwqV005708 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 9 Sep 2015 22:52:58 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t89MqwYa022794 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 9 Sep 2015 22:52:58 GMT Original-Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t89MqvRB024340; Wed, 9 Sep 2015 22:52:57 GMT In-Reply-To: <87fv2o24mf.fsf@uwakimon.sk.tsukuba.ac.jp> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6691.5000 (x86)] X-Source-IP: userv0022.oracle.com [156.151.31.74] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:189781 Archived-At: --__1441839177480173097abhmp0005.oracle.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > > I've approached this question only from a user point of > > view (it is useful to be able to do it). >=20 > Well, since I'm not going to do it any time soon, and you > haven't even considered doing it yet, this thread is moot. AFAICT, this (or similar) is the only code needed. It fixes the char-table entries for the equivalent chars, so each points to the equivalence class and not just to itself. (Currently, only the "base" char points to the equivalence class.) ;; Add an entry for each equivalent char. (let ((others ())) (map-char-table (lambda (base v) (let ((chrs (aref equiv base))) (when (consp chrs) (dolist (chr (cdr chrs)) (push (cons (string-to-char chr) (remove chr chrs)) others))))) equiv) (dolist (it others) (let ((base (car it)) (chars (cdr it))) (aset equiv base (append chars (aref equiv base))))))) This code fragment is included in the attached code that updates `character-fold-table'. Evaluate the attached code, to try the behavior proposed in this thread. The attached code provides: * A Boolean option, `char-fold-symmetric', so you can choose which behavior you want. (Let users decide, instead of "flipping a coin" at design time.) If you use Customize (or the equivalent) to change the option value then `character-fold-table' is automatically updated to reflect the new option value. * A function that updates `character-fold-table' to reflect the option value. It evaluates the above code conditionally. Just as now, you can use M-s ' to toggle char folding. With the option value non-nil you get the behavior proposed in this thread. With the option value nil you get the current, more limited behavior. [I'm no expert on char tables. Perhaps the code could be improved. But this seems to work OK. I think it exhibits the proposed behavior.] --__1441839177480173097abhmp0005.oracle.com Content-Type: application/octet-stream; name="symmetric-char-fold.el" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="symmetric-char-fold.el" OzsgTG9hZCB0aGlzIGZpbGUsIHRvIGV2YWx1YXRlIHRoZXNlIHR3byBkZWZpbml0aW9ucyBpbiBv cmRlci4KOzsKOzsgVGhlIHNlY29uZCBpcyBhbiBvcHRpb24gdGhhdCB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gIChsZXQqICgoZXF1aXYgKG1ha2UtY2hhci10YWJs ZSAnY2hhcmFjdGVyLWZvbGQtdGFibGUpKQogICAgICAgICAgICAgICAodGFibGUgKHVuaWNvZGUt cHJvcGVydHktdGFibGUtaW50ZXJuYWwgJ2RlY29tcG9zaXRpb24pKQogICAgICAgICAgICAgICAo ZnVuYyAoY2hhci10YWJsZS1leHRyYS1zbG90IHRhYmxlIDEpKSkKICAgICAgICAgIDs7IEVuc3Vy ZSB0aGUgdGFibGUgaXMgcG9wdWxhdGVkLgogICAgICAgICAgKG1hcC1jaGFyLXRhYmxlCiAgICAg ICAgICAgKGxhbWJkYSAoaSB2KSAod2hlbiAoY29uc3AgaSkgKGZ1bmNhbGwgZnVuYyAoY2FyIGkp IHYgdGFibGUpKSkKICAgICAgICAgICB0YWJsZSkKICAgICAgICAgIDs7IENvbXBpbGUgYSBsaXN0 IG9mIGFsbCBjb21wbGV4IGNoYXJzIHRoYXQgZWFjaCBzaW1wbGUgY2hhciBzaG91bGQgbWF0Y2gu CiAgICAgICAgICAobWFwLWNoYXItdGFibGUKICAgICAgICAgICAobGFtYmRhIChpIGRlYykKICAg ICAgICAgICAgICh3aGVuIChjb25zcCBkZWMpCiAgICAgICAgICAgICAgIDs7IERpc2NhcmQgYSBw b3NzaWJsZSBmb3JtYXR0aW5nIHRhZy4KICAgICAgICAgICAgICAgKHdoZW4gKHN5bWJvbHAgKGNh ciBkZWMpKQogICAgICAgICAgICAgICAgIChzZXRxIGRlYyAoY2RyIGRlYykpKQogICAgICAgICAg ICAgICA7OyBTa2lwIHRyaXZpYWwgY2FzZXMgbGlrZSA/YSBkZWNvbXBvc2luZyB0byAoP2EpLgog ICAgICAgICAgICAgICAodW5sZXNzIChvciAoYW5kIChlcSBpIChjYXIgZGVjKSkgIChub3QgIChj ZHIgZGVjKSkpKQogICAgICAgICAgICAgICAgIChsZXQgKChkIGRlYykKICAgICAgICAgICAgICAg ICAgICAgICAoZm9sZC1kZWNvbXAgdCkKICAgICAgICAgICAgICAgICAgICAgICBrIGZvdW5kKQog ICAgICAgICAgICAgICAgICAgKHdoaWxlIChhbmQgZCAobm90IGZvdW5kKSkKICAgICAgICAgICAg ICAgICAgICAgKHNldHEgayAocG9wIGQpKQogICAgICAgICAgICAgICAgICAgICA7OyBJcyBrIGEg bnVtYmVyIG9yIGxldHRlciwgcGVyIHVuaWNvZGUgc3RhbmRhcmQ/CiAgICAgICAgICAgICAgICAg ICAgIChzZXRxIGZvdW5kIChtZW1xIChnZXQtY2hhci1jb2RlLXByb3BlcnR5IGsgJ2dlbmVyYWwt Y2F0ZWdvcnkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICcoTHUgTGwg THQgTG0gTG8gTmQgTmwgTm8pKSkpCiAgICAgICAgICAgICAgICAgICAoaWYgZm91bmQKICAgICAg ICAgICAgICAgICAgICAgICA7OyBDaGVjayBpZiB0aGUgZGVjb21wb3NpdGlvbiBoYXMgbW9yZSB0 aGFuIG9uZSBsZXR0ZXIsCiAgICAgICAgICAgICAgICAgICAgICAgOzsgYmVjYXVzZSB0aGVuIHdl IGRvbid0IHdhbnQgdGhlIGZpcnN0IGxldHRlciB0byBtYXRjaAogICAgICAgICAgICAgICAgICAg ICAgIDs7IHRoZSBkZWNvbXBvc2l0aW9uLgogICAgICAgICAgICAgICAgICAgICAgIChkb2xpc3Qg KGsgZCkKICAgICAgICAgICAgICAgICAgICAgICAgICh3aGVuIChhbmQgZm9sZC1kZWNvbXAKICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKG1lbXEgKGdldC1jaGFyLWNvZGUtcHJv cGVydHkgayAnZ2VuZXJhbC1jYXRlZ29yeSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgJyhMdSBMbCBMdCBMbSBMbyBOZCBObCBObykpKQogICAgICAgICAgICAgICAg ICAgICAgICAgICAoc2V0cSBmb2xkLWRlY29tcCBuaWwpKSkKICAgICAgICAgICAgICAgICAgICAg OzsgSWYgdGhlcmUncyBubyBudW1iZXIgb3IgbGV0dGVyIG9uIHRoZQogICAgICAgICAgICAgICAg ICAgICA7OyBkZWNvbXBvc2l0aW9uLCB0YWtlIHRoZSBmaXJzdCBjaGFyYWN0ZXIgaW4gaXQuCiAg ICAgICAgICAgICAgICAgICAgIChzZXRxIGZvdW5kIChjYXItc2FmZSBkZWMpKSkKICAgICAgICAg ICAgICAgICAgIDs7IEZpbmFsbHksIHdlIG9ubHkgZm9sZCBtdWx0aS1jaGFyIGRlY29tcG9zaXRp b24gaWYgYXQKICAgICAgICAgICAgICAgICAgIDs7IGxlYXN0IG9uZSBvZiB0aGUgY2hhcnMgaXMg bm9uLXNwYWNpbmcgKGNvbWJpbmluZykuCiAgICAgICAgICAgICAgICAgICAod2hlbiBmb2xkLWRl Y29tcAogICAgICAgICAgICAgICAgICAgICAoc2V0cSBmb2xkLWRlY29tcCBuaWwpCiAgICAgICAg ICAgICAgICAgICAgIChkb2xpc3QgKGsgZGVjKQogICAgICAgICAgICAgICAgICAgICAgICh3aGVu IChhbmQgKG5vdCBmb2xkLWRlY29tcCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICg+IChnZXQtY2hhci1jb2RlLXByb3BlcnR5IGsgJ2Nhbm9uaWNhbC1jb21iaW5pbmctY2xhc3Mp IDApKQogICAgICAgICAgICAgICAgICAgICAgICAgKHNldHEgZm9sZC1kZWNvbXAgdCkpKSkKICAg ICAgICAgICAgICAgICAgIDs7IEFkZCBpIHRvIHRoZSBsaXN0IG9mIGNoYXJhY3RlcnMgdGhhdCBr IGNhbgogICAgICAgICAgICAgICAgICAgOzsgcmVwcmVzZW50LiBBbHNvIHBvc3NpYmx5IGFkZCBp dHMgZGVjb21wb3NpdGlvbiwgc28gd2UgY2FuCiAgICAgICAgICAgICAgICAgICA7OyBtYXRjaCBt dWx0aS1jaGFyIHJlcHJlc2VudGF0aW9ucyBsaWtlIChmb3JtYXQgImElYyIgNzY5KQogICAgICAg ICAgICAgICAgICAgKHdoZW4gKGFuZCBmb3VuZCAobm90IChlcSBpIGspKSkKICAgICAgICAgICAg ICAgICAgICAgKGxldCAoKGNoYXJzIChjb25zIChjaGFyLXRvLXN0cmluZyBpKSAoYXJlZiBlcXVp diBrKSkpKQogICAgICAgICAgICAgICAgICAgICAgIChhc2V0IGVxdWl2IGsgKGlmIGZvbGQtZGVj b21wCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGNvbnMgKGFwcGx5 ICMnc3RyaW5nIGRlYykgY2hhcnMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIGNoYXJzKSkpKSkpKSkKICAgICAgICAgICB0YWJsZSkKICAgICAgICAgIDs7IEFkZCBzb21l IG1hbnVhbCBlbnRyaWVzLgogICAgICAgICAgKGRvbGlzdCAoaXQgJygoP1wiICLvvIIiICLigJwi ICLigJ0iICLigJ0iICLigJ4iICLiuYIiICLjgJ4iICLigJ8iICLigJ8iICLinZ4iICLinZ0iCiAg ICAgICAgICAgICAgICAgICAgICAgICAi4p2gIiAi4oCcIiAi4oCeIiAi44CdIiAi44CfIiAi8J+Z tyIgIvCfmbYiICLwn5m4IiAiwqsiICLCuyIpCiAgICAgICAgICAgICAgICAgICAgICAgICg/JyAi 4p2fIiAi4p2bIiAi4p2cIiAi4oCYIiAi4oCZIiAi4oCaIiAi4oCbIiAi4oCaIiAi86CAoiIgIuKd riIgIuKdryIgIuKAuSIgIuKAuiIpCiAgICAgICAgICAgICAgICAgICAgICAgICg/YCAi4p2bIiAi 4oCYIiAi4oCbIiAi86CAoiIgIuKdriIgIuKAuSIpKSkKICAgICAgICAgICAgKGxldCAoKGlkeCAo Y2FyIGl0KSkKICAgICAgICAgICAgICAgICAgKGNoYXJzIChjZHIgaXQpKSkKICAgICAgICAgICAg ICAoYXNldCBlcXVpdiBpZHggKGFwcGVuZCBjaGFycyAoYXJlZiBlcXVpdiBpZHgpKSkpKQoKICAg ICAgICAgIDs7IC0tLS0tLS0tODwtLS0tLS10aGUgb25seSBhZGRpdGlvbi0tLS0tLS0tLS0tLS0t LS0KICAgICAgICAgICh3aGVuIGNoYXItZm9sZC1zeW1tZXRyaWMKICAgICAgICAgICAgOzsgQWRk IGFuIGVudHJ5IGZvciBlYWNoIGVxdWl2YWxlbnQgY2hhci4KICAgICAgICAgICAgKGxldCAoKG90 aGVycyAgKCkpKQogICAgICAgICAgICAgIChtYXAtY2hhci10YWJsZQogICAgICAgICAgICAgICAo bGFtYmRhIChiYXNlIHYpCiAgICAgICAgICAgICAgICAgKGxldCAoKGNocnMgIChhcmVmIGVxdWl2 IGJhc2UpKSkKICAgICAgICAgICAgICAgICAgICh3aGVuIChjb25zcCBjaHJzKQogICAgICAgICAg ICAgICAgICAgICAoZG9saXN0IChjaHIgIChjZHIgY2hycykpCiAgICAgICAgICAgICAgICAgICAg ICAgKHB1c2ggKGNvbnMgKHN0cmluZy10by1jaGFyIGNocikgKHJlbW92ZSBjaHIgY2hycykpIG90 aGVycykpKSkpCiAgICAgICAgICAgICAgIGVxdWl2KQogICAgICAgICAgICAgIChkb2xpc3QgKGl0 ICBvdGhlcnMpCiAgICAgICAgICAgICAgICAobGV0ICgoYmFzZSAgIChjYXIgaXQpKQogICAgICAg ICAgICAgICAgICAgICAgKGNoYXJzICAoY2RyIGl0KSkpCiAgICAgICAgICAgICAgICAgIChhc2V0 IGVxdWl2IGJhc2UgKGFwcGVuZCBjaGFycyAoYXJlZiBlcXVpdiBiYXNlKSkpKSkpKQogICAgICAg ICAgOzsgLS0tLS0tLS04PC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQoK ICAgICAgICAgIDs7IENvbnZlcnQgdGhlIGxpc3RzIG9mIGNoYXJhY3RlcnMgd2UgY29tcGlsZWQg aW50byByZWdleHBzLgogICAgICAgICAgKG1hcC1jaGFyLXRhYmxlCiAgICAgICAgICAgKGxhbWJk YSAoaSB2KSAobGV0ICg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