From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: SMIE examples or guides Date: Thu, 30 Jun 2016 14:49:55 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1467312652 30960 80.91.229.3 (30 Jun 2016 18:50:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 30 Jun 2016 18:50:52 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: =?windows-1252?Q?Bj=F6rn?= Lindqvist Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 30 20:50:41 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 1bIh2p-0007pd-Uh for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Jun 2016 20:50:36 +0200 Original-Received: from localhost ([::1]:52109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIh2p-0004dF-0F for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Jun 2016 14:50:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIh2J-0004ct-W3 for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 14:50:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIh2F-0004c2-S2 for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 14:50:02 -0400 Original-Received: from smtp-as-02-03.vtxnet.net ([194.38.175.142]:59363 helo=smtp-as-02.vtxnet.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIh2F-0004by-Kt for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 14:49:59 -0400 Original-Received: from smtp-as-02.vtxnet.net (localhost [127.0.0.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-as-02.vtxnet.net (Postfix) with ESMTPS id 4FD124BDC0; Thu, 30 Jun 2016 20:49:58 +0200 (CEST) Original-Received: from smtp-pri-01.vtxnet.net (smtp-pri-01.vtxnet.net [212.147.62.135]) by smtp-as-02.vtxnet.net (Postfix) with ESMTP id 94F6B4BDBC; Thu, 30 Jun 2016 20:49:56 +0200 (CEST) Original-Received: from fmsmemgm.homelinux.net (dyn.144-85-234-142.dsl.vtx.ch [144.85.234.142]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-pri-01.vtxnet.net (VTX Services SA) with ESMTP id 86D24CFCEC; Thu, 30 Jun 2016 20:49:56 +0200 (CEST) Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 95E5BAE2B8; Thu, 30 Jun 2016 14:49:55 -0400 (EDT) In-Reply-To: (=?windows-1252?Q?=22Bj=F6rn?= Lindqvist"'s message of "Thu, 30 Jun 2016 13:27:38 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 194.38.175.142 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:110675 Archived-At: > 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