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: Fri, 1 Jul 2016 02:49:32 +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 1467334207 26402 80.91.229.3 (1 Jul 2016 00:50:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 Jul 2016 00:50:07 +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 Fri Jul 01 02:50:05 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 1bImeh-00027d-Ez for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Jul 2016 02:50:03 +0200 Original-Received: from localhost ([::1]:53197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bImeg-0001C0-Hu for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Jun 2016 20:50:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bImeG-0001Br-GM for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 20:49:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bImeE-00058U-CW for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 20:49:35 -0400 Original-Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:36719) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bImeE-00058O-51 for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 20:49:34 -0400 Original-Received: by mail-wm0-x235.google.com with SMTP id f126so7243779wma.1 for ; Thu, 30 Jun 2016 17:49:33 -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=tOUmYSWQIfy+zyQ4Y7yxoYWH9/n6JkE2zkAOSI0fcCI=; b=kmtfqgiQ4/OebgB7zoCAK9o7MsASqOrzAYY1TKP/1noNINElPGR0o8T06T9ezwqOlt 81ePj585EJRJJbo8F1xmSmVFlMuIeF/doBEifR0+lpLkjUgU3zamhAA2umnKdqdWm8Od FfV9HIJ15Kh+iELxrD6W+/D0ItgermCOr6PqGDCXOlmjw7LTe5bvvj5jzpcs3+YaLcES JvOe+DRLT7UFO8OYE+7EecIn8slTBNSK1Pyl+t2wV+npJSH7cAKSUp3a02GQBTeXCbqs P9d8ymt2IEPwSgRmuLQkkGOtEt4ue1U8+paQO6a1bm1Pd/bcsdtnWLbZniqcpeSYVSPs YsTQ== 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=tOUmYSWQIfy+zyQ4Y7yxoYWH9/n6JkE2zkAOSI0fcCI=; b=g/g03m7jtHvTTuLCZ2VHgxubG9tEOHj8BMFChRBgZnW4WH89meuUDTR4y3tteQs+s7 HbJXujOtOISoQOOfwMU47SLghUiWPUrB+rxgfEgdcY8wORH1dzIQ/nujseOqeyK9HsMO 0yQ6Y7XU22Jjz5u4b5m/ns/GpMA38/qcLsHj9dSA7TWwN3TrQ4S5e1CrsKKw2ebF7B1w J3UlzSPSn4Qf4gZZb2LHhd5WYX7+tyYmg9RhVAggNGdBLPY+VfsNrNGqgRcqpEFX8CLm 40mzx/bdpdr47t0yBKd8nrQIy/7UxiOtZXV5xkncc4ti1iaOJ/sXnTT4NBrMsG97N3GA IFaw== X-Gm-Message-State: ALyK8tKxOJXGP0r8Llt1JAOew/9zvVebhKe3jQBC4Fodq7jyJXmiN30zQ+1AGroSPogHb+1A6F1cIc63i+thrA== X-Received: by 10.194.89.5 with SMTP id bk5mr840127wjb.55.1467334173210; Thu, 30 Jun 2016 17:49:33 -0700 (PDT) Original-Received: by 10.194.45.202 with HTTP; Thu, 30 Jun 2016 17:49:32 -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::235 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:110677 Archived-At: Many thanks! That appears to work. But there is one problem. In a buffer with just this content: [ \ ] I get the error: (error "Bumped into unknown token") And another problem I'm having is trying to support multiple indentation start tokens: (deconst factor-smie-grammar (smie-prec2->grammar (smie-bnf->prec2 '((exp (("HELLO" "HALLO" "CIAO" "SALUT") exp "BYE")))))) My intent is to allow either of those four words to be used to start the indented block. I only need one ending token so there will be no alternative to BYE. Seems like it should be trivial to extend the BNF grammar in this way, but I can't figure out what syntax smie-bnf->prec2 expects for it. 2016-06-30 20:49 GMT+02:00 Stefan Monnier : >> HELLO three one >> four ten BYE >> eleven HELLO >> twelve >> BYE > > This goes a bit against SMIE's default indentation principles, so it's > going to take more efforts (IOW adding support for this kind of > indentation is still on the todo list). > > Maybe something along the following lines would work: > > (defun my-indent-foo () > (unless (looking-at "BYE\\_>") > (save-excursion > (let ((x nil)) > (while (progn (setq x (smie-backward-sexp)) > (null (car-safe x)))) > (when (equal "HELLO" (nth 2 x)) > (goto-char (nth 1 x)) > (+ 4 (smie-indent-virtual))))))) > and add > > (add-hook 'smie-indent-functions #'my-indent-foo nil t) > > in your major mode function. > > > Stefan --=20 mvh/best regards Bj=C3=B6rn Lindqvist