Commit 674728d4 authored by Stefan Monnier's avatar Stefan Monnier

* lisp/emacs-lisp/smie.el: Simplify the smie-rules-function return values.

(smie-precs->prec2): Rename from smie-precs-precedence-table.
(smie-bnf->prec2): Rename from smie-bnf-precedence-table.
(smie-prec2->grammar): Rename from smie-prec2-levels.
(smie-grammar): Rename from smie-op-levels.
(smie-indent--hanging-p): Rename from smie-hanging-p.
(smie-rule-hanging-p): New alias.
(smie-indent--bolp): Rename from smie-bolp.
(smie-indent--hanging-p): New alias.
(smie--token): New dynamically bound variable.
(smie-indent--parent): New function.
(smie-rule-parent-p): Use it; rename from smie-parent-p.
(smie-rule-next-p): Rename from smie-next-p.
(smie-rule-prev-p): Rename from smie-prev-p.
(smie-rule-sibling-p, smie-rule-parent)
(smie-indent--separator-outdent, smie-rule-separator): New functions.
(smie-rule-separator-outdent): New var.
(smie-indent--rule): Merge with smie-indent--column.
(smie-indent-forward-token, smie-indent-backward-token):
Also recognize close parens.
(smie-indent-keyword): Don't use smie-indent--column any more.
(smie-indent-after-keyword): Ignore closers by default.
(smie-indent-line): Use with-demoted-errors.
* lisp/progmodes/octave-mod.el (octave-smie-grammar):
Rename from octave-smie-op-levels.
(octave-smie-rules): Adjust to new behavior.
* lisp/progmodes/prolog.el (prolog-smie-grammar):
Rename from prolog-smie-op-levels.
parent 66b16767
2010-11-07 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/smie.el: Simplify the smie-rules-function return values.
(smie-precs->prec2): Rename from smie-precs-precedence-table.
(smie-bnf->prec2): Rename from smie-bnf-precedence-table.
(smie-prec2->grammar): Rename from smie-prec2-levels.
(smie-grammar): Rename from smie-op-levels.
(smie-indent--hanging-p): Rename from smie-hanging-p.
(smie-rule-hanging-p): New alias.
(smie-indent--bolp): Rename from smie-bolp.
(smie-indent--hanging-p): New alias.
(smie--token): New dynamically bound variable.
(smie-indent--parent): New function.
(smie-rule-parent-p): Use it; rename from smie-parent-p.
(smie-rule-next-p): Rename from smie-next-p.
(smie-rule-prev-p): Rename from smie-prev-p.
(smie-rule-sibling-p, smie-rule-parent)
(smie-indent--separator-outdent, smie-rule-separator): New functions.
(smie-rule-separator-outdent): New var.
(smie-indent--rule): Merge with smie-indent--column.
(smie-indent-forward-token, smie-indent-backward-token):
Also recognize close parens.
(smie-indent-keyword): Don't use smie-indent--column any more.
(smie-indent-after-keyword): Ignore closers by default.
(smie-indent-line): Use with-demoted-errors.
* progmodes/octave-mod.el (octave-smie-grammar):
Rename from octave-smie-op-levels.
(octave-smie-rules): Adjust to new behavior.
* progmodes/prolog.el (prolog-smie-grammar):
Rename from prolog-smie-op-levels.
2010-11-07 Glenn Morris <rgm@gnu.org>
* eshell/esh-util.el (subst-char-in-string)
......
This diff is collapsed.
......@@ -446,14 +446,13 @@ Non-nil means always go to the next Octave code line after sending."
;; (fundesc (atom "=" atom))
))
(defconst octave-smie-op-levels
(smie-prec2-levels
(defconst octave-smie-grammar
(smie-prec2->grammar
(smie-merge-prec2s
(smie-bnf-precedence-table
octave-smie-bnf-table
'((assoc "\n" ";")))
(smie-bnf->prec2 octave-smie-bnf-table
'((assoc "\n" ";")))
(smie-precs-precedence-table octave-operator-table))))
(smie-precs->prec2 octave-operator-table))))
;; Tokenizing needs to be refined so that ";;" is treated as two
;; tokens and also so as to recognize the \n separator (and
......@@ -520,13 +519,19 @@ Non-nil means always go to the next Octave code line after sending."
(defun octave-smie-rules (kind token)
(pcase (cons kind token)
;; We could set smie-indent-basic instead, but that would have two
;; disadvantages:
;; - changes to octave-block-offset wouldn't take effect immediately.
;; - edebug wouldn't show the use of this variable.
(`(:elem . basic) octave-block-offset)
(`(:before . "case") octave-block-offset)
;; Since "case" is in the same BNF rules as switch..end, SMIE by default
;; aligns it with "switch".
(`(:before . "case") (if (not (smie-rule-sibling-p)) octave-block-offset))
(`(:after . ";")
(if (smie-parent-p "function" "if" "while" "else" "elseif" "for"
"otherwise" "case" "try" "catch" "unwind_protect"
"unwind_protect_cleanup")
'(+ parent octave-block-offset)
(if (smie-rule-parent-p "function" "if" "while" "else" "elseif" "for"
"otherwise" "case" "try" "catch" "unwind_protect"
"unwind_protect_cleanup")
(smie-rule-parent octave-block-offset)
;; For (invalid) code between switch and case.
;; (if (smie-parent-p "switch") 4)
0))))
......@@ -619,7 +624,7 @@ already added. You just need to add a description of the problem,
including a reproducible test case and send the message."
(setq local-abbrev-table octave-abbrev-table)
(smie-setup octave-smie-op-levels #'octave-smie-rules
(smie-setup octave-smie-grammar #'octave-smie-rules
:forward-token #'octave-smie-forward-token
:backward-token #'octave-smie-backward-token)
(set (make-local-variable 'smie-indent-basic) 'octave-block-offset)
......
......@@ -123,7 +123,7 @@ When nil, send actual operating system end of file."
((not (zerop (skip-syntax-backward ".")))))
(point))))
(defconst prolog-smie-op-levels
(defconst prolog-smie-grammar
;; Rather than construct the operator levels table from the BNF,
;; we directly provide the operator precedences from GNU Prolog's
;; manual (7.14.10 op/3). The only problem is that GNU Prolog's
......@@ -188,7 +188,7 @@ When nil, send actual operating system end of file."
(setq imenu-generic-expression '((nil "^\\sw+" 0)))
;; Setup SMIE.
(smie-setup prolog-smie-op-levels #'prolog-smie-rules
(smie-setup prolog-smie-grammar #'prolog-smie-rules
:forward-token #'prolog-smie-forward-token
:backward-token #'prolog-smie-backward-token)
(set (make-local-variable 'smie-blink-matching-triggers) '(?.))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment