[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r101246: * lisp/emacs-lisp/smie.el (s
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r101246: * lisp/emacs-lisp/smie.el (smie-down-list): New command. |
Date: |
Tue, 31 Aug 2010 14:22:40 +0200 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 101246
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Tue 2010-08-31 14:22:40 +0200
message:
* lisp/emacs-lisp/smie.el (smie-down-list): New command.
modified:
lisp/ChangeLog
lisp/emacs-lisp/smie.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2010-08-31 12:13:51 +0000
+++ b/lisp/ChangeLog 2010-08-31 12:22:40 +0000
@@ -1,5 +1,7 @@
2010-08-31 Stefan Monnier <address@hidden>
+ * emacs-lisp/smie.el (smie-down-list): New command.
+
Remove old indentation and navigation code on octave-mode.
* progmodes/octave-mod.el (octave-mode-map): Remap down-list to
smie-down-list rather than add a binding for octave-down-block.
=== modified file 'lisp/emacs-lisp/smie.el'
--- a/lisp/emacs-lisp/smie.el 2010-08-30 15:21:14 +0000
+++ b/lisp/emacs-lisp/smie.el 2010-08-31 12:22:40 +0000
@@ -560,6 +560,42 @@
(indent-according-to-mode)
(reindent-then-newline-and-indent))))
+(defun smie-down-list (&optional arg)
+ "Move forward down one level paren-like blocks. Like `down-list'.
+With argument ARG, do this that many times.
+A negative argument means move backward but still go down a level.
+This command assumes point is not in a string or comment."
+ (interactive "p")
+ (let ((start (point))
+ (inc (if (< arg 0) -1 1))
+ (offset (if (< arg 0) 1 0))
+ (next-token (if (< arg 0)
+ smie-backward-token-function
+ smie-forward-token-function)))
+ (while (/= arg 0)
+ (setq arg (- arg inc))
+ (while
+ (let* ((pos (point))
+ (token (funcall next-token))
+ (levels (assoc token smie-op-levels)))
+ (cond
+ ((zerop (length token))
+ (if (if (< inc 0) (looking-back "\\s(\\|\\s)" (1- (point)))
+ (looking-at "\\s(\\|\\s)"))
+ ;; Go back to `start' in case of an error. This presumes
+ ;; none of the token we've found until now include a ( or ).
+ (progn (goto-char start) (down-list inc) nil)
+ (forward-sexp inc)
+ (/= (point) pos)))
+ ((and levels (null (nth (+ 1 offset) levels))) nil)
+ ((and levels (null (nth (- 2 offset) levels)))
+ (let ((end (point)))
+ (goto-char start)
+ (signal 'scan-error
+ (list "Containing expression ends prematurely"
+ pos end))))
+ (t)))))))
+
;;; The indentation engine.
(defcustom smie-indent-basic 4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r101246: * lisp/emacs-lisp/smie.el (smie-down-list): New command.,
Stefan Monnier <=