aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2010-08-31 14:22:40 +0200
committerStefan Monnier2010-08-31 14:22:40 +0200
commitc8977b2e622e2c1ff46a160b252feff30bc1025e (patch)
treeea06e1aa16a296cd4ce3a545873582733f2e67c9
parentec5d3ff71f442d8d867082669ab6bcbdbb24a24b (diff)
downloademacs-c8977b2e622e2c1ff46a160b252feff30bc1025e.tar.gz
emacs-c8977b2e622e2c1ff46a160b252feff30bc1025e.zip
* lisp/emacs-lisp/smie.el (smie-down-list): New command.
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/emacs-lisp/smie.el36
2 files changed, 38 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index eba622b6bee..f01ddd2b2fd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,7 @@
12010-08-31 Stefan Monnier <monnier@iro.umontreal.ca> 12010-08-31 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * emacs-lisp/smie.el (smie-down-list): New command.
4
3 Remove old indentation and navigation code on octave-mode. 5 Remove old indentation and navigation code on octave-mode.
4 * progmodes/octave-mod.el (octave-mode-map): Remap down-list to 6 * progmodes/octave-mod.el (octave-mode-map): Remap down-list to
5 smie-down-list rather than add a binding for octave-down-block. 7 smie-down-list rather than add a binding for octave-down-block.
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index c9876c55014..e8b5c2448e8 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -560,6 +560,42 @@ Possible return values:
560 (indent-according-to-mode) 560 (indent-according-to-mode)
561 (reindent-then-newline-and-indent)))) 561 (reindent-then-newline-and-indent))))
562 562
563(defun smie-down-list (&optional arg)
564 "Move forward down one level paren-like blocks. Like `down-list'.
565With argument ARG, do this that many times.
566A negative argument means move backward but still go down a level.
567This command assumes point is not in a string or comment."
568 (interactive "p")
569 (let ((start (point))
570 (inc (if (< arg 0) -1 1))
571 (offset (if (< arg 0) 1 0))
572 (next-token (if (< arg 0)
573 smie-backward-token-function
574 smie-forward-token-function)))
575 (while (/= arg 0)
576 (setq arg (- arg inc))
577 (while
578 (let* ((pos (point))
579 (token (funcall next-token))
580 (levels (assoc token smie-op-levels)))
581 (cond
582 ((zerop (length token))
583 (if (if (< inc 0) (looking-back "\\s(\\|\\s)" (1- (point)))
584 (looking-at "\\s(\\|\\s)"))
585 ;; Go back to `start' in case of an error. This presumes
586 ;; none of the token we've found until now include a ( or ).
587 (progn (goto-char start) (down-list inc) nil)
588 (forward-sexp inc)
589 (/= (point) pos)))
590 ((and levels (null (nth (+ 1 offset) levels))) nil)
591 ((and levels (null (nth (- 2 offset) levels)))
592 (let ((end (point)))
593 (goto-char start)
594 (signal 'scan-error
595 (list "Containing expression ends prematurely"
596 pos end))))
597 (t)))))))
598
563;;; The indentation engine. 599;;; The indentation engine.
564 600
565(defcustom smie-indent-basic 4 601(defcustom smie-indent-basic 4