summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/smie.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/smie.el')
-rw-r--r--lisp/emacs-lisp/smie.el25
1 files changed, 16 insertions, 9 deletions
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index 26aa9b91927..44be9afbfae 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -52,6 +52,13 @@
;; error because the parser just automatically does something. Better yet,
;; we can afford to use a sloppy grammar.
+;; The benefits of this approach were presented in the following article,
+;; which includes a kind of tutorial to get started with SMIE:
+;;
+;; SMIE: Weakness is Power! Auto-indentation with incomplete information
+;; Stefan Monnier, <Programming> Journal 2020, volumn 5, issue 1.
+;; doi: 10.22152/programming-journal.org/2020/5/1
+
;; A good background to understand the development (especially the parts
;; building the 2D precedence tables and then computing the precedence levels
;; from it) can be found in pages 187-194 of "Parsing techniques" by Dick Grune
@@ -63,6 +70,7 @@
;; Since then, some of that code has been beaten into submission, but the
;; smie-indent-keyword is still pretty obscure.
+
;; Conflict resolution:
;;
;; - One source of conflicts is when you have:
@@ -1356,9 +1364,9 @@ Only meaningful when called from within `smie-rules-function'."
(funcall smie-rules-function :elem 'basic))
smie-indent-basic))
-(defun smie-indent--rule (method token
- ;; FIXME: Too many parameters.
- &optional after parent base-pos)
+(defun smie-indent--rule ( method token
+ ;; FIXME: Too many parameters.
+ &optional after parent base-pos)
"Compute indentation column according to `smie-rules-function'.
METHOD and TOKEN are passed to `smie-rules-function'.
AFTER is the position after TOKEN, if known.
@@ -1883,9 +1891,9 @@ KEYWORDS are additional arguments, which can use the following keywords:
(v (pop keywords)))
(pcase k
(:forward-token
- (set (make-local-variable 'smie-forward-token-function) v))
+ (setq-local smie-forward-token-function v))
(:backward-token
- (set (make-local-variable 'smie-backward-token-function) v))
+ (setq-local smie-backward-token-function v))
(_ (message "smie-setup: ignoring unknown keyword %s" k)))))
(let ((ca (cdr (assq :smie-closer-alist grammar))))
(when ca
@@ -2112,10 +2120,9 @@ position corresponding to each rule."
(throw 'found (list kind token
(or (nth 3 rewrite) res)))))))))
(default-new (smie-config--guess-value sig))
- (newstr (read-string (format "Adjust rule (%S %S -> %S) to%s: "
- (nth 0 sig) (nth 1 sig) (nth 2 sig)
- (if (not default-new) ""
- (format " (default %S)" default-new)))
+ (newstr (read-string (format-prompt
+ "Adjust rule (%S %S -> %S) to" default-new
+ (nth 0 sig) (nth 1 sig) (nth 2 sig))
nil nil (format "%S" default-new)))
(new (car (read-from-string newstr))))
(let ((old (rassoc sig smie-config--buffer-local)))