emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109915: * lisp/progmodes/ruby-mode.e


From: Dmitry Gutov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109915: * lisp/progmodes/ruby-mode.el
Date: Fri, 07 Sep 2012 09:06:05 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109915
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Fri 2012-09-07 09:06:05 +0400
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/progmodes/ruby-mode.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-07 05:00:32 +0000
+++ b/lisp/ChangeLog    2012-09-07 05:06:05 +0000
@@ -8,6 +8,9 @@
        * progmodes/ruby-mode.el (ruby-end-of-defun)
        (ruby-beginning-of-defun): Simplify, allow indentation before
        block beginning and end keywords.
+       (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.
 
 2012-09-06  Stefan Monnier  <address@hidden>
 

=== modified file 'lisp/progmodes/ruby-mode.el'
--- a/lisp/progmodes/ruby-mode.el       2012-09-07 04:36:20 +0000
+++ b/lisp/progmodes/ruby-mode.el       2012-09-07 05:06:05 +0000
@@ -98,6 +98,10 @@
 
 (defconst ruby-block-end-re "\\_<end\\_>")
 
+(defconst ruby-defun-beg-re
+  '"\\(def\\|class\\|module\\)"
+  "Regexp to match the beginning of a defun, in the general sense.")
+
 (eval-and-compile
   (defconst ruby-here-doc-beg-re
   
"\\(<\\)<\\(-\\)?\\(\\([a-zA-Z0-9_]+\\)\\|[\"]\\([^\"]+\\)[\"]\\|[']\\([^']+\\)[']\\)"
@@ -833,13 +837,12 @@
           (+ indent ruby-indent-level)
         indent))))
 
-;; TODO: Why isn't one ruby-*-of-defun written in terms of the other?
 (defun ruby-beginning-of-defun (&optional arg)
   "Move backward to the beginning of the current top-level defun.
 With ARG, move backward multiple defuns.  Negative ARG means
 move forward."
   (interactive "p")
-  (and (re-search-backward (concat "^\\s *\\(" ruby-block-beg-re "\\)\\_>")
+  (and (re-search-backward (concat "^\\s *" ruby-defun-beg-re "\\_>")
                            nil t (or arg 1))
        (beginning-of-line)))
 
@@ -848,9 +851,9 @@
 With ARG, move forward multiple defuns.  Negative ARG means
 move backward."
   (interactive "p")
-  (and (re-search-forward (concat "^\\s *" ruby-block-end-re) nil t (or arg 1))
-       (beginning-of-line))
-  (forward-line 1))
+  (ruby-forward-sexp)
+  (when (looking-back (concat "^\\s *" ruby-block-end-re))
+    (forward-line 1)))
 
 (defun ruby-beginning-of-indent ()
   "Backtrack to a line which can be used as a reference for
@@ -1050,7 +1053,7 @@
         (let (mname mlist (indent 0))
           ;; get current method (or class/module)
           (if (re-search-backward
-               (concat "^[ \t]*\\(def\\|class\\|module\\)[ \t]+"
+               (concat "^[ \t]*" ruby-defun-beg-re "[ \t]+"
                        "\\("
                        ;; \\. and :: for class method
                         "\\([A-Za-z_]" ruby-symbol-re "*\\|\\.\\|::" "\\)"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]