diff options
| author | Stefan Monnier | 2010-08-30 17:21:14 +0200 |
|---|---|---|
| committer | Stefan Monnier | 2010-08-30 17:21:14 +0200 |
| commit | ee992a8cede0a4f2fca21b882772a2cc940dc2ff (patch) | |
| tree | 4f4d35eed0b2649bb14aa2a70aae231a2a3d43ac | |
| parent | d36b74ca27f877023620d33ca05f2b5b2ccb05cd (diff) | |
| download | emacs-ee992a8cede0a4f2fca21b882772a2cc940dc2ff.tar.gz emacs-ee992a8cede0a4f2fca21b882772a2cc940dc2ff.zip | |
* lisp/emacs-lisp/smie.el (smie-indent-offset-rule): Let :parent take
a list of parents.
(smie-indent-column): Allow indirection through variables.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/smie.el | 15 |
2 files changed, 14 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ab0b9744048..69b11bd7a9a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2010-08-30 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2010-08-30 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emacs-lisp/smie.el (smie-indent-offset-rule): Let :parent take | ||
| 4 | a list of parents. | ||
| 5 | (smie-indent-column): Allow indirection through variables. | ||
| 6 | |||
| 3 | * composite.el (save-buffer-state): Delete, unused. | 7 | * composite.el (save-buffer-state): Delete, unused. |
| 4 | * font-lock.el (save-buffer-state): Use with-silent-modifications. | 8 | * font-lock.el (save-buffer-state): Use with-silent-modifications. |
| 5 | (font-lock-default-fontify-region): Use with-syntax-table. | 9 | (font-lock-default-fontify-region): Use with-syntax-table. |
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el index 2fbf0628dbe..c9876c55014 100644 --- a/lisp/emacs-lisp/smie.el +++ b/lisp/emacs-lisp/smie.el | |||
| @@ -593,20 +593,21 @@ OFFSET-RULES is a list of elements which can each either be: | |||
| 593 | \(:bolp . OFFSET-RULES) If TOK is first on a line, use OFFSET-RULES. | 593 | \(:bolp . OFFSET-RULES) If TOK is first on a line, use OFFSET-RULES. |
| 594 | OFFSET the offset to use. | 594 | OFFSET the offset to use. |
| 595 | 595 | ||
| 596 | PARENT can be either the name of the parent or `open' to mean any parent | 596 | PARENT can be either the name of the parent or a list of such names. |
| 597 | which acts as an open-paren (i.e. has a nil left-precedence). | ||
| 598 | 597 | ||
| 599 | OFFSET can be of the form: | 598 | OFFSET can be of the form: |
| 600 | `point' align with the token. | 599 | `point' align with the token. |
| 601 | `parent' align with the parent. | 600 | `parent' align with the parent. |
| 602 | NUMBER offset by NUMBER. | 601 | NUMBER offset by NUMBER. |
| 603 | \(+ OFFSETS...) use the sum of OFFSETS. | 602 | \(+ OFFSETS...) use the sum of OFFSETS. |
| 603 | VARIABLE use the value of VARIABLE as offset. | ||
| 604 | 604 | ||
| 605 | The precise meaning of `point' depends on various details: it can | 605 | The precise meaning of `point' depends on various details: it can |
| 606 | either mean the position of the token we're indenting, or the | 606 | either mean the position of the token we're indenting, or the |
| 607 | position of its parent, or the position right after its parent. | 607 | position of its parent, or the position right after its parent. |
| 608 | 608 | ||
| 609 | A nil offset for indentation after a token defaults to `smie-indent-basic'.") | 609 | A nil offset for indentation after an opening token defaults |
| 610 | to `smie-indent-basic'.") | ||
| 610 | 611 | ||
| 611 | (defun smie-indent-hanging-p () | 612 | (defun smie-indent-hanging-p () |
| 612 | ;; A hanging keyword is one that's at the end of a line except it's not at | 613 | ;; A hanging keyword is one that's at the end of a line except it's not at |
| @@ -674,8 +675,9 @@ PARENT if non-nil should be the parent info returned by `smie-backward-sexp'." | |||
| 674 | (save-excursion | 675 | (save-excursion |
| 675 | (if after (goto-char after)) | 676 | (if after (goto-char after)) |
| 676 | (setq parent (smie-backward-sexp 'halfsexp)))) | 677 | (setq parent (smie-backward-sexp 'halfsexp)))) |
| 677 | (when (or (equal (nth 2 parent) (cadr rule)) | 678 | (when (if (listp (cadr rule)) |
| 678 | (and (eq (cadr rule) 'open) (null (car parent)))) | 679 | (member (nth 2 parent) (cadr rule)) |
| 680 | (equal (nth 2 parent) (cadr rule))) | ||
| 679 | (setq rules (cddr rule)))) | 681 | (setq rules (cddr rule)))) |
| 680 | (t (error "Unknown rule %s for indentation of %s" | 682 | (t (error "Unknown rule %s for indentation of %s" |
| 681 | rule (car tokinfo)))))) | 683 | rule (car tokinfo)))))) |
| @@ -726,6 +728,8 @@ If VIRTUAL-POINT is non-nil, then `point' is virtual." | |||
| 726 | (if (consp parent) (goto-char (cadr parent))) | 728 | (if (consp parent) (goto-char (cadr parent))) |
| 727 | (smie-indent-virtual)) | 729 | (smie-indent-virtual)) |
| 728 | ((eq offset nil) nil) | 730 | ((eq offset nil) nil) |
| 731 | ((and (symbolp offset) (boundp 'offset)) | ||
| 732 | (smie-indent-column (symbol-value offset) base parent virtual-point)) | ||
| 729 | (t (error "Unknown indentation offset %s" offset)))) | 733 | (t (error "Unknown indentation offset %s" offset)))) |
| 730 | 734 | ||
| 731 | (defun smie-indent-forward-token () | 735 | (defun smie-indent-forward-token () |
| @@ -1016,6 +1020,7 @@ in order to figure out the indentation of some other (further down) point." | |||
| 1016 | (positions | 1020 | (positions |
| 1017 | ;; We're the first arg. | 1021 | ;; We're the first arg. |
| 1018 | (goto-char (car positions)) | 1022 | (goto-char (car positions)) |
| 1023 | ;; FIXME: Use smie-indent-column. | ||
| 1019 | (+ (smie-indent-offset 'args) | 1024 | (+ (smie-indent-offset 'args) |
| 1020 | ;; We used to use (smie-indent-virtual), but that | 1025 | ;; We used to use (smie-indent-virtual), but that |
| 1021 | ;; doesn't seem right since it might then indent args less than | 1026 | ;; doesn't seem right since it might then indent args less than |