aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/ruby-mode.el
diff options
context:
space:
mode:
authorDmitry Gutov2012-09-07 09:06:05 +0400
committerDmitry Gutov2012-09-07 09:06:05 +0400
commit8f06accefa669c323731525946eeaef4a3decf6d (patch)
tree5816045f934587b2dd1923d06f89813da2d44aef /lisp/progmodes/ruby-mode.el
parent74c582e64c6b14545fd4188a604e313cbe56a89f (diff)
downloademacs-8f06accefa669c323731525946eeaef4a3decf6d.tar.gz
emacs-8f06accefa669c323731525946eeaef4a3decf6d.zip
* lisp/progmodes/ruby-mode.el
(ruby-beginning-of-defun): Only consider 3 keywords defun beginners. (ruby-end-of-defun): Expect that the point is at the beginning of the defun.
Diffstat (limited to 'lisp/progmodes/ruby-mode.el')
-rw-r--r--lisp/progmodes/ruby-mode.el15
1 files changed, 9 insertions, 6 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index e8e6b3dbaef..ef1daa5e936 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -98,6 +98,10 @@
98 98
99(defconst ruby-block-end-re "\\_<end\\_>") 99(defconst ruby-block-end-re "\\_<end\\_>")
100 100
101(defconst ruby-defun-beg-re
102 '"\\(def\\|class\\|module\\)"
103 "Regexp to match the beginning of a defun, in the general sense.")
104
101(eval-and-compile 105(eval-and-compile
102 (defconst ruby-here-doc-beg-re 106 (defconst ruby-here-doc-beg-re
103 "\\(<\\)<\\(-\\)?\\(\\([a-zA-Z0-9_]+\\)\\|[\"]\\([^\"]+\\)[\"]\\|[']\\([^']+\\)[']\\)" 107 "\\(<\\)<\\(-\\)?\\(\\([a-zA-Z0-9_]+\\)\\|[\"]\\([^\"]+\\)[\"]\\|[']\\([^']+\\)[']\\)"
@@ -833,13 +837,12 @@ and `\\' when preceded by `?'."
833 (+ indent ruby-indent-level) 837 (+ indent ruby-indent-level)
834 indent)))) 838 indent))))
835 839
836;; TODO: Why isn't one ruby-*-of-defun written in terms of the other?
837(defun ruby-beginning-of-defun (&optional arg) 840(defun ruby-beginning-of-defun (&optional arg)
838 "Move backward to the beginning of the current top-level defun. 841 "Move backward to the beginning of the current top-level defun.
839With ARG, move backward multiple defuns. Negative ARG means 842With ARG, move backward multiple defuns. Negative ARG means
840move forward." 843move forward."
841 (interactive "p") 844 (interactive "p")
842 (and (re-search-backward (concat "^\\s *\\(" ruby-block-beg-re "\\)\\_>") 845 (and (re-search-backward (concat "^\\s *" ruby-defun-beg-re "\\_>")
843 nil t (or arg 1)) 846 nil t (or arg 1))
844 (beginning-of-line))) 847 (beginning-of-line)))
845 848
@@ -848,9 +851,9 @@ move forward."
848With ARG, move forward multiple defuns. Negative ARG means 851With ARG, move forward multiple defuns. Negative ARG means
849move backward." 852move backward."
850 (interactive "p") 853 (interactive "p")
851 (and (re-search-forward (concat "^\\s *" ruby-block-end-re) nil t (or arg 1)) 854 (ruby-forward-sexp)
852 (beginning-of-line)) 855 (when (looking-back (concat "^\\s *" ruby-block-end-re))
853 (forward-line 1)) 856 (forward-line 1)))
854 857
855(defun ruby-beginning-of-indent () 858(defun ruby-beginning-of-indent ()
856 "Backtrack to a line which can be used as a reference for 859 "Backtrack to a line which can be used as a reference for
@@ -1050,7 +1053,7 @@ See `add-log-current-defun-function'."
1050 (let (mname mlist (indent 0)) 1053 (let (mname mlist (indent 0))
1051 ;; get current method (or class/module) 1054 ;; get current method (or class/module)
1052 (if (re-search-backward 1055 (if (re-search-backward
1053 (concat "^[ \t]*\\(def\\|class\\|module\\)[ \t]+" 1056 (concat "^[ \t]*" ruby-defun-beg-re "[ \t]+"
1054 "\\(" 1057 "\\("
1055 ;; \\. and :: for class method 1058 ;; \\. and :: for class method
1056 "\\([A-Za-z_]" ruby-symbol-re "*\\|\\.\\|::" "\\)" 1059 "\\([A-Za-z_]" ruby-symbol-re "*\\|\\.\\|::" "\\)"