From: npostavs@users.sourceforge.net
To: <richard.wiseman@bt.com>
Cc: 24848@debbugs.gnu.org
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 [thread overview]
Message-ID: <871sns8vm0.fsf@users.sourceforge.net> (raw)
In-Reply-To: <1503668647564.74012@bt.com> (richard wiseman's message of "Fri, 25 Aug 2017 13:44:07 +0000")
[-- Attachment #1: Type: text/plain, Size: 657 bytes --]
tags 24848 + patch
quit
<richard.wiseman@bt.com> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 3024 bytes --]
From 69365325783e5f980cd0e1460465b8562a5180ef Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
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
next prev parent reply other threads:[~2017-08-30 23:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-01 15:07 bug#24848: 24.5; "Local rules set" richard.wiseman
2017-08-24 11:39 ` bug#24848: Any progress? richard.wiseman
2017-08-24 12:41 ` bug#24848: [sh-script] How to save "Local rules set" result from sh-learn-buffer-indent? npostavs
2017-08-24 13:44 ` richard.wiseman
2017-08-25 1:12 ` npostavs
2017-08-25 8:11 ` richard.wiseman
2017-08-25 8:37 ` richard.wiseman
2017-08-25 12:07 ` npostavs
2017-08-25 13:44 ` richard.wiseman
2017-08-25 14:31 ` richard.wiseman
2017-08-26 20:08 ` Noam Postavsky
2017-08-29 7:43 ` richard.wiseman
2017-08-30 23:49 ` npostavs [this message]
2017-09-04 8:30 ` richard.wiseman
2017-09-08 23:15 ` npostavs
2017-09-11 7:44 ` richard.wiseman
2017-09-11 9:53 ` richard.wiseman
2017-09-11 18:48 ` npostavs
2017-09-12 7:09 ` richard.wiseman
2017-09-22 22:46 ` Noam Postavsky
2017-09-25 11:10 ` richard.wiseman
2017-09-25 12:19 ` Noam Postavsky
2017-09-25 13:06 ` richard.wiseman
2017-09-25 23:41 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871sns8vm0.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=24848@debbugs.gnu.org \
--cc=richard.wiseman@bt.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).