From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Bj=C3=B6rn_Lindqvist?= Newsgroups: gmane.emacs.help Subject: Re: SMIE examples or guides Date: Thu, 30 Jun 2016 13:27:38 +0200 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1467286097 12477 80.91.229.3 (30 Jun 2016 11:28:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 30 Jun 2016 11:28:17 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 30 13:28:17 2016 Return-path: Envelope-to: geh-help-gnu-emacs@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 1bIa8l-00006k-OB for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Jun 2016 13:28:15 +0200 Original-Received: from localhost ([::1]:48558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIa8c-0003Td-Gg for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Jun 2016 07:28:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIa8F-0003TS-BA for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 07:27:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIa8D-0000Fd-58 for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 07:27:42 -0400 Original-Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:38670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIa8C-0000FQ-RM for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 07:27:41 -0400 Original-Received: by mail-wm0-x234.google.com with SMTP id r201so114051364wme.1 for ; Thu, 30 Jun 2016 04:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Vn3JalDZ5Rjap3jo5VI8kdaV9cUVHW66YdSQF7snyXc=; b=UgxmuRuPdy1EG9Nw50tu0pGBv+iULN7mX21FPEQerxsyNlaO7jOr0n8cuqzlbnhVb2 ulIll1XLoBpdJ8rl+YaSav31/ImLdRjc9FMfGZKpq8ytPkjgHoDPI5HotzzHq0O9E2nI VaPp48W4NtiFQ9heN+7BG/ueMI+nCtvsF1pAY7jdW1L8pa9IFct+ZyBXdCtg7RJAMU9+ 4oc+QI80LYry0OhWD39L9G0H4Camsu2EjVyzGHaXJvwhlYpZ+2qweEsE6/Wt2v2seMQ7 4kVARf3+mBMUZm+BmNFgEs8Esl+K4FkRLofLOzl2JMmsZLOB+WURIxE3jKjlLZYkf+wy K48w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Vn3JalDZ5Rjap3jo5VI8kdaV9cUVHW66YdSQF7snyXc=; b=ODRUktm72PIHb6JcrSTD7HpuFNs0csqDzGAkk+VsLAWJrH3y0sX9rp9RzTEQa/iP8e hzx6azf+UJ6XANNKKp0+bTSmktfNPUWm98uxZLdUc9xBOFtv25O3848qDddnJYlZwv3K h1xlVGtSGYHPNfo67HEhS1lg5ky5kqgWeO9ygkOCS6gNWLoJq1vEfONNBGYyH/nk9ZdV Sgb54ZCQ/pI6cLMrMQABI/GeM0xUQbxDekCMP9PpJZ8D7ctK4qjhcnvsyLNFDMIZWNS4 ZR5E3UDMTLc1OmjuIHacRX5NnpHZ5tJkjn95J43PLBvgQ6ejOrrVunfYXHNcx9LcRTwJ 4vSg== X-Gm-Message-State: ALyK8tLT/LFCc3WXZ3fEkDeTrgImV9sKp/1fn4s1FjWzAezeqfpNB3ZBSnK7AjS7LsLTYEnQHjuRTNzi/5f8kA== X-Received: by 10.194.89.5 with SMTP id bk5mr14701733wjb.55.1467286059825; Thu, 30 Jun 2016 04:27:39 -0700 (PDT) Original-Received: by 10.194.45.202 with HTTP; Thu, 30 Jun 2016 04:27:38 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::234 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110668 Archived-At: I'm not sure I understand. There are just two indentation-dependent tokens in my language; HELLO which increases indentation by four for subsequent lines and BYE which decreases indentation by four for subsequent lines. So yes, one, two, three is an arbitrary sequence and it could have been: HELLO three one four ten BYE eleven HELLO twelve BYE instead. This is what is required even if it doesn't look like proper indentation. :) In the real mode I'm working on (HELLO/BYE is a toy example) it makes more sense. 2016-06-30 9:23 GMT+02:00 Stefan Monnier : >> I got it to work almost by experimenting with your suggestions. But it >> appears to do some kind of automatic aligning I don't want: >> >> HELLO one >> two >> three >> BYE > > If one, two, and three are an arbitrary sequence of <...> bracketed by > HELLO and BYE, then the above looks like the proper indentation to me. > >> That should instead have been: >> >> HELLO one >> two >> three >> BYE > > The indentation here looks wrong to me unless "one" is special in the > sense that it's some kind of argument to HELLO and "two" and "three" are > an arbitrary sequence of <...> bracketed by "HELLO " and "BYE"= . > > Which is it? And if it's the latter, how do you distinguish the > separation between "one" and "two" (e.g. can the first line be something > like "HELLO one two" where the "one two" is the argument to HELLO, and > if so, how can you distinguish this case from the case where we have > "HELLO one" and the subsequent "two" is part of the inner sequence)? > > > Stefan > > >> 2016-06-29 9:37 GMT+02:00 Stefan Monnier : >>>> HELLO >>>> HELLO foo BYE >>>> HELLO >>>> bla >>>> net >>>> neat >>>> BYE >>>> text more >>>> more >>>> BYE >>> >>> That's expected: the third HELLO...BYE is indented as an argument of >>> the first. Similarly to: >>> >>> (table->method) >>> (arg1, >>> arg2 >>> ) >>> >>> [ Read the above, thinking that "(" is like HELLO and ")" is like >>> "BYE". ] >>> >>> Similarly, "net" and "neat" are treated as arguments to "bla". >>> >>> A quick fix to that part would be to add an indentation rule along the >>> lines of >>> >>> (`(:elem . arg) 0) >>> >>> or alternatively >>> >>> (`(:list-intro . ,_) t) >>> >>> Tho, if your language makes newlines significant (i.e. "bla\nnet" is no= t >>> equivalent to "bla net"), then you might be better off changing the >>> tokenizer (by providing appropriate :forward-token and :backward-token >>> arguments to `smie-setup') so as to return an actual token for every >>> newline encountered, after which you can add corresponding rules to >>> the grammar. >>> >>>> HELLO >>>> bla >>>> net >>>> neat >>>> BYE >>> >>> To get the BYE indented this way, a quick-fix could be to add a rule >>> like >>> >>> (`(:before . "BYE") 4) >>> >>> >>> -- Stefan >>> >>> > > >> -- >> mvh/best regards Bj=C3=B6rn Lindqvist --=20 mvh/best regards Bj=C3=B6rn Lindqvist