diff --git a/elpa-to-submit/espresso.el b/elpa-to-submit/espresso.el index fb8addf651..34f84498db 100644 --- a/elpa-to-submit/espresso.el +++ b/elpa-to-submit/espresso.el @@ -4,8 +4,8 @@ ;; Author: Karl Landstrom ;; Author: Daniel Colascione ;; Maintainer: Daniel Colascione -;; Version: 8 -;; Date: 2009-05-22 +;; Version: 9 +;; Date: 2009-07-25 ;; Keywords: languages, oop, javascript ;; This file is free software; you can redistribute it and/or modify @@ -507,7 +507,7 @@ messages." (let ((keymap (make-sparse-keymap))) (mapc (lambda (key) (define-key keymap key #'espresso-insert-and-indent)) - '("+" "-" "/" "*" "{" "}" "(" ")" ":" ";" ",")) + '("+" "-" "*" "{" "}" "(" ")" ":" ";" ",")) (define-key keymap [(control ?c) (meta ?:)] #'espresso-js-eval) (define-key keymap [(control ?c) (control ?j)] #'espresso-set-js-context) (define-key keymap [(control meta ?x)] #'espresso-eval-defun) @@ -910,22 +910,37 @@ pitem of the function we went to the beginning of." (when pstate (goto-char (espresso--pitem-h-begin (car pstate)))))) -(defun espresso--beginning-of-defun () +(defun espresso--beginning-of-defun (&optional arg) "Used as beginning-of-defun-function" - ;; If we're just past the end of a function, the user probably wants - ;; to go to the beginning of *that* function - (when (eq (char-before) ?}) - (backward-char)) + (setq arg (or arg 1)) + (while (and (not (eobp)) (< arg 0)) + (incf arg) + (when (and (not espresso-flat-functions) + (or (eq (espresso-syntactic-context) 'function) + (espresso--function-prologue-beginning))) + (espresso--end-of-defun)) + + (if (espresso--re-search-forward + "\\_" nil t) + (goto-char (espresso--function-prologue-beginning)) + (goto-char (point-max)))) + + (while (> arg 0) + (decf arg) + ;; If we're just past the end of a function, the user probably wants + ;; to go to the beginning of *that* function + (when (eq (char-before) ?}) + (backward-char)) - (let ((prologue-begin (espresso--function-prologue-beginning))) - (cond ((and prologue-begin (< prologue-begin (point))) - (goto-char prologue-begin)) + (let ((prologue-begin (espresso--function-prologue-beginning))) + (cond ((and prologue-begin (< prologue-begin (point))) + (goto-char prologue-begin)) - (espresso-flat-functions - (espresso--beginning-of-defun-flat)) - (t - (espresso--beginning-of-defun-nested))))) + (espresso-flat-functions + (espresso--beginning-of-defun-flat)) + (t + (espresso--beginning-of-defun-nested)))))) (defun espresso--flush-caches (&optional beg ignored) "Flush syntax cache info after position BEG. BEG defaults to @@ -1213,6 +1228,7 @@ given item ends instead of parsing all the way to LIMIT." (defun espresso--end-of-defun-nested () "Internal helper for espresso--end-of-defun" + (message "test") (let* (pitem (this-end (save-excursion (and (setq pitem (espresso--beginning-of-defun-nested)) @@ -1236,26 +1252,37 @@ given item ends instead of parsing all the way to LIMIT." ;; ... or eob. (goto-char (point-max)))))) -(defun espresso--end-of-defun () +(defun espresso--end-of-defun (&optional arg) "Used as end-of-defun-function" - ;; look for function backward. if we're inside it, go to that - ;; function's end. otherwise, search for the next function's end and - ;; go there - (if espresso-flat-functions - (espresso--end-of-defun-flat) - - ;; if we're doing nested functions, see whether we're in the - ;; prologue. If we are, go to the end of the function; otherwise, - ;; call espresso--end-of-defun-nested to do the real work - (let ((prologue-begin (espresso--function-prologue-beginning))) - (cond ((and prologue-begin (<= prologue-begin (point))) - (goto-char prologue-begin) - (re-search-forward "\\_ arg 0) + (decf arg) + ;; look for function backward. if we're inside it, go to that + ;; function's end. otherwise, search for the next function's end and + ;; go there + (if espresso-flat-functions + (espresso--end-of-defun-flat) + + ;; if we're doing nested functions, see whether we're in the + ;; prologue. If we are, go to the end of the function; otherwise, + ;; call espresso--end-of-defun-nested to do the real work + (let ((prologue-begin (espresso--function-prologue-beginning))) + (cond ((and prologue-begin (<= prologue-begin (point))) + (goto-char prologue-begin) + (re-search-forward "\\_