From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: syntax-after Date: Sat, 13 Nov 2004 12:57:54 +0200 Organization: JURTA Message-ID: <878y969ew1.fsf@jurta.org> References: <87mzxoc8bi.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1100345125 24003 80.91.229.6 (13 Nov 2004 11:25:25 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 13 Nov 2004 11:25:25 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 13 12:25:14 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CSw1q-0006it-00 for ; Sat, 13 Nov 2004 12:25:14 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CSwAQ-0004Jb-QX for ged-emacs-devel@m.gmane.org; Sat, 13 Nov 2004 06:34:06 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CSwA5-0004FQ-In for emacs-devel@gnu.org; Sat, 13 Nov 2004 06:33:45 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CSwA4-0004Em-QA for emacs-devel@gnu.org; Sat, 13 Nov 2004 06:33:44 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CSwA4-0004EC-7I for emacs-devel@gnu.org; Sat, 13 Nov 2004 06:33:44 -0500 Original-Received: from [66.33.205.9] (helo=spatula.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CSw0z-0001UW-72; Sat, 13 Nov 2004 06:24:21 -0500 Original-Received: from mail.jurta.org (80-235-37-219-dsl.mus.estpak.ee [80.235.37.219]) by spatula.dreamhost.com (Postfix) with ESMTP id 4B43117D020; Sat, 13 Nov 2004 03:24:14 -0800 (PST) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Fri, 12 Nov 2004 16:25:21 -0500") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:29795 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:29795 Richard Stallman writes: > It seems really gratuitous. There are already 2 ways to represent the > syntax info of a char: as a cons cell and as a string. Both are documented > in the elisp manual. > > The above change introduces yet a third representation, and an undocumented > one at that. Was that really necessary? > > It is not new. My change makes it compatible with char-syntax, which > is why I did it. It is also more comparible with the way > modify-syntax-entry works, since the same character is used now by both. > > This change reduces the number of representations of the syntax by > one, as far as I know. Or is there some other function that uses the > old representation of syntax-after? If so, perhaps it should be > changed too. Actually, with the change in `syntax-after' there are 4 representations now: modify-syntax-entry aref(syntax-table) char-syntax syntax-after "w" (2) ?w (?w) "w p" (1048578) ?w args-out-of-range ". 124b" (2818049) ?. args-out-of-range "(]" (4 . ?\]) ?\( (?\( . ?\]) (Note that `syntax-after' fails with args-out-of-range on some syntaxes.) It seems you wanted to add syntax flags to the returned value which are not available from `char-syntax'. I think a better solution that would reduce the number of representations is to implement a new function `syntax-to-string' returning a syntax string (e.g. ". 124b"). All flags can be accessed from this string easily either with a regexp or with `substring' or `aref' when needed. As I see in the Emacs source tree `char-syntax' is mostly used in combination with `char-after': (eq (char-syntax (char-after point)) ?w) where only syntax class character is needed, and not flags. For such cases `syntax-after' would serve as a replacement to make code simpler: (defun syntax-after (point) (char-syntax (char-after point))) > I just saw that the above change caused Juri to install a fix to > descr-text.el that replaces a call to syntax-after with a copy of its > (previous) body. > > That is strange, I searched for all the calls and only found them in > paren.el. Since `describe-char' calls `internal-describe-syntax-value' which accepts the internal syntax representation, I think no special function for that code is needed, because there are too few cases where the internal syntax representation is used (another one I know is `describe-syntax' command). -- Juri Linkov http://www.jurta.org/emacs/