From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#24848: [sh-script] How to save "Local rules set" result from sh-learn-buffer-indent? Date: Wed, 30 Aug 2017 19:49:11 -0400 Message-ID: <871sns8vm0.fsf@users.sourceforge.net> References: <1478012827020.47948@bt.com> <1503574770199.95054@bt.com> <87o9r59lyp.fsf_-_@users.sourceforge.net> <1503582257373.58386@bt.com> <87inhca1s9.fsf@users.sourceforge.net> <1503648698123.80907@bt.com> <87d17jam0g.fsf@users.sourceforge.net> <1503668647564.74012@bt.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1504136908 20432 195.159.176.226 (30 Aug 2017 23:48:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 30 Aug 2017 23:48:28 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: 24848@debbugs.gnu.org To: Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 31 01:48:21 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnCiO-0004Li-Bl for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Aug 2017 01:48:08 +0200 Original-Received: from localhost ([::1]:53243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnCiV-0006dg-0M for geb-bug-gnu-emacs@m.gmane.org; Wed, 30 Aug 2017 19:48:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnCiN-0006cx-8d for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2017 19:48:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnCiJ-00026R-60 for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2017 19:48:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54969) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dnCiJ-000265-0Y for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2017 19:48:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dnCiI-0005me-Gt for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2017 19:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Aug 2017 23:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24848 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24848-submit@debbugs.gnu.org id=B24848.150413686422203 (code B ref 24848); Wed, 30 Aug 2017 23:48:02 +0000 Original-Received: (at 24848) by debbugs.gnu.org; 30 Aug 2017 23:47:44 +0000 Original-Received: from localhost ([127.0.0.1]:35416 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnChx-0005m1-SC for submit@debbugs.gnu.org; Wed, 30 Aug 2017 19:47:43 -0400 Original-Received: from mail-io0-f193.google.com ([209.85.223.193]:38888) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnCht-0005lY-UD; Wed, 30 Aug 2017 19:47:38 -0400 Original-Received: by mail-io0-f193.google.com with SMTP id m40so2467252ioi.5; Wed, 30 Aug 2017 16:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=KW/2OSUTKeWblnZw7jeJbivtlDCloDNWbsm8jFX4zOQ=; b=WyArNV10s5XdBI4r7MklVFxbH5Qvs3U6oGfgNpuznFapBmnQjN3o3wvypARxjZT+1p OklzYuX7JrHjseXBBJYNOIRmWr7S4NnOmM2xVCRiXr/1E2Khq3lEwT6s5+wB/HEdv9z9 O893+XCCsRELzjY6gy+jq1XSMLlCt0IEKLTGlpcVmvvQt2WfOGabdq/K3lP23te5swGz lYnGtnYa4ILjWyh/IexeKRnNzpmr88/eIKrSX/JHWk/YZtCKcvTDfpTm/TeJvvqvVTy1 6Hirhv1eehPtk895NxcgFBHF3bJ8vcthmNFjIWe4VcDeYot+3hW6EJABXHKwYHEdJZCY MO3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=KW/2OSUTKeWblnZw7jeJbivtlDCloDNWbsm8jFX4zOQ=; b=XBH0fnHiLF747uMZYBRew1IA/Nqiie8qGpgUswDGj2YRwRtwhLX/rx9mJ+WMOkjp6a z7H+vavHNsFPRG4qSvB9sf1KEIikNMA4AlPuSu5IyQAuTGu9u8fYrKLqlEXAWj7eNHaB 6u4EsxgRuZbPCu6LuqMziioEaIbnJIpI+BPkQ6q1mO1iRyCksb73m27wFdkWhgtN1qCi QdsqLaJ5dIDJPff01FYXz4n+x/V3a5Ra4CFt03/4YpFi9Pb5uq4bjBhVX32y4QAlvE7N BgtGYiBtvxrT9c9Uk28D9I+UkjY/kJeUW90pLt8yD7T83nKAhpBiyi7Eork3dlcqqvP1 YkuA== X-Gm-Message-State: AHYfb5jKfEJEtbbztRkkcsZxnrLehSqa62H7lcOVPoq+DJImd2gdY4M4 CvTrMoClwnNXcyOE X-Received: by 10.36.206.69 with SMTP id v66mr3988455itg.161.1504136852163; Wed, 30 Aug 2017 16:47:32 -0700 (PDT) Original-Received: from zony ([45.2.119.49]) by smtp.googlemail.com with ESMTPSA id j127sm8398itj.0.2017.08.30.16.47.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Aug 2017 16:47:30 -0700 (PDT) In-Reply-To: <1503668647564.74012@bt.com> (richard wiseman's message of "Fri, 25 Aug 2017 13:44:07 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136394 Archived-At: --=-=-= Content-Type: text/plain tags 24848 + patch quit writes: > Anyway, to help get to the bottom of this, I disabled sh-indentation > and tried your steps around editing smie-config and M-x normal-mode > and I got the same result as you: it worked. > > So as you indicated, it appears to be that smie-config isn't being loaded (properly) when Emacs starts. > > I await your next inspiration! :-) Okay, the patch below fixes the loading for me. I also added a mention of `smie-config-guess' in `sh-learn-buffer-indent's docstring so that it should be possible to figure how to save config rules by reading docstrings rather than hunting in the source code. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Fix-loading-of-smie-config-rules-Bug-24848.patch Content-Description: patch >From 69365325783e5f980cd0e1460465b8562a5180ef Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 30 Aug 2017 19:31:48 -0400 Subject: [PATCH v1] Fix loading of smie-config rules (Bug#24848) * lisp/emacs-lisp/smie.el (smie-config--setter): Use `set-default' instead of `setq-default'. (smie-config): Use `custom-initialize-set' instead of `custom-initialize-default' as the :initialize argument. * lisp/progmodes/sh-script.el (sh-learn-buffer-indent): Mention that we call `smie-config-guess' so that the user will have a chance to find the correct docstring to consult. Remove hedging comments regarding use of abnormal hooks. --- lisp/emacs-lisp/smie.el | 4 ++-- lisp/progmodes/sh-script.el | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el index 7baccbc752..9afbfe4446 100644 --- a/lisp/emacs-lisp/smie.el +++ b/lisp/emacs-lisp/smie.el @@ -1956,7 +1956,7 @@ smie-config--mode-hook (defvar smie-config--modefuns nil) (defun smie-config--setter (var value) - (setq-default var value) + (set-default var value) (let ((old-modefuns smie-config--modefuns)) (setq smie-config--modefuns nil) (pcase-dolist (`(,mode . ,rules) value) @@ -1982,7 +1982,7 @@ smie-config ;; FIXME improve value-type. :type '(choice (const nil) (alist :key-type symbol)) - :initialize 'custom-initialize-default + :initialize 'custom-initialize-set :set #'smie-config--setter) (defun smie-config-local (rules) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 07604ad665..ca31635dbc 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -3600,6 +3600,10 @@ sh-learned-buffer-hook (defun sh-learn-buffer-indent (&optional arg) "Learn how to indent the buffer the way it currently is. +If `sh-use-smie' is non-nil, call `smie-config-guess'. +Otherwise, run the sh-script specific indent learning command, as +decribed below. + Output in buffer \"*indent*\" shows any lines which have conflicting values of a variable, and the final value of all variables learned. When called interactively, pop to this buffer automatically if @@ -3616,8 +3620,7 @@ sh-learn-buffer-indent Abnormal hook `sh-learned-buffer-hook' if non-nil is called when the function completes. The function is abnormal because it is called -with an alist of variables learned. This feature may be changed or -removed in the future. +with an alist of variables learned. This command can often take a long time to run." (interactive "P") @@ -3815,7 +3818,6 @@ sh-learn-buffer-indent " has" "s have") (if (zerop num-diffs) "." ":")))))) - ;; Are abnormal hooks considered bad form? (run-hook-with-args 'sh-learned-buffer-hook learned-var-list) (and (called-interactively-p 'any) (or sh-popup-occur-buffer (> num-diffs 0)) -- 2.14.1 --=-=-=--