From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= Newsgroups: gmane.emacs.help Subject: Debugging SMIE for sh-script.el Date: Thu, 02 Sep 2021 12:49:21 +0200 Message-ID: <87k0jz9rri.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38880"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 02 12:52:25 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mLkKX-0009vi-KY for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 02 Sep 2021 12:52:25 +0200 Original-Received: from localhost ([::1]:42808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLkKW-0000Gc-4K for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 02 Sep 2021 06:52:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLkJZ-0008Qe-Hf for help-gnu-emacs@gnu.org; Thu, 02 Sep 2021 06:51:25 -0400 Original-Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:35750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLkHd-0001Er-53 for help-gnu-emacs@gnu.org; Thu, 02 Sep 2021 06:51:25 -0400 Original-Received: by mail-wr1-x431.google.com with SMTP id i6so2187107wrv.2 for ; Thu, 02 Sep 2021 03:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:user-agent:mime-version :content-transfer-encoding; bh=1GLRxbLyZPEr2trdjpDdIshtqNdm2nHvohcfDrCQNEA=; b=bFbfknOFzU1pULQBfDmla1ozMtiZvx3vobDAEmiL2qOuxt8DDI+0hq/BhUBDK1tE3M GmKHN8nKd5pKsa3g5HKdOJxzRiF8xY2VigGIzVzuTqPx+PvoesCoJvBxrTPN306lZ55l noLiHoYZVbdVcrFgYbT+knqsZQ1CoGDnEAZt7S1q/Ah2KFwA0TsR2b+bsy0IKVpLWdGi GB8/54nWOQdZK2R4NavlU8G9xe7Fl2d1LtDvG+HXsoGNr0PKBPv7jXf4bA3aCWqwRv3x zGuYgD01PMsdGDGvDzn6YRJdO9jk/L8YtjOFV+Uz3IsBWykL9A0UOflm02yCzlQ8OVyD HHVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version:content-transfer-encoding; bh=1GLRxbLyZPEr2trdjpDdIshtqNdm2nHvohcfDrCQNEA=; b=JvYDWucUcCG8ML3gjzCssrjGkOgMDX9xANFfy2o0TGazeW/1IoMuXZCpA2hFXuv3eQ rG76Pnms4K+VHtvEBFBWofggPicH0HSNr8/lO993M0su7sj+ZOG4PPoHsvhvgBrEY9Gs 85hZ4KGmX1849gMo5Ru7l3VlZdavkopRgbBQvK8B+C2trNFY05XH9VWYa06XwJGsHdvD /iumSV+udTikSerp0MpKN2n6u+A3B4l8srIZb8ZuN7ssAuqb0HGnTnb6GnwAatAvW6in x/Iozfwg8yVEbQ0+1IsHgaFGeQzzRIW9WHFcjb0YraY5FHdf//wk1eGECuOl7ME1yjty HUbA== X-Gm-Message-State: AOAM531RRqo2z+ck2mefdgHDmNZoPrjjcifk2HXBjMTHI514JHy5al3Z yq79k57N8Qd1dGXNRmFlIjG7N2HQCVU= X-Google-Smtp-Source: ABdhPJyK2hBXTFX12gFD635HoocVxNY0l7pMqY3OswMeU1xFBaWfkqqizBE9IgBBdBXGfHBxbr4sTg== X-Received: by 2002:a5d:6e91:: with SMTP id k17mr2922690wrz.77.1630579762636; Thu, 02 Sep 2021 03:49:22 -0700 (PDT) Original-Received: from hirondell ([2a01:e0a:20e:d340:dc7f:dc92:6317:69ca]) by smtp.gmail.com with ESMTPSA id y1sm1331274wmq.43.2021.09.02.03.49.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 03:49:22 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=kevin.legouguec@gmail.com; helo=mail-wr1-x431.google.com X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:132854 Archived-At: Hello, I am having a hard time understanding the mechanics of SMIE in the context of sh-script.el; for starters, I am stumped trying to debug a call to smie-indent-calculate. Take this two-line shell snippet: #+begin_src sh ${foo}/bar --baz \ --quux #+end_src With point on "--quux", evaluate (smie-indent-calculate): this yields 6. Looking at this function, I see that it simply funcalls everything in smie-indent-functions, which in a shell buffer is (sh-smie--indent-continuation t). Instrumenting sh-smie--indent-continuation with C-M-x, I see that we first go into the catch-all branch of the cond (";; Just make sure a line-continuation is indented deeper."), which let-binds "indent" to: #+begin_src elisp (let ((sh-indent-after-continuation nil)) (smie-indent-calculate)) #+end_src Stepping through this recursive call with Edebug, I see that we go into the first branch of sh-smie--indent-continuation's opening cond, which returns nil. Continuing into the parent call of sh-smie--indent-continuation=E2=80=A6 "indent" is set to 6 for some reason?? I struggle to understand whether I am missing something, or whether this binding is bogus. On the one hand, run-hook-wrapped makes no promises as to its return value when all functions return nil; on the other hand, "indent" gets consistently assigned to whatever column "/bar" begins at (e.g. 6 here, or 9 with "${foobar}/bar"), so there is a method to the madness=E2=80=A6 What am I missing?