<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,13 @@
 2007-04-03  Dmitry Galinsky  &lt;dima.exe@gmail.com&gt;
 
+	* rails-model-layout.el (rails-model-layout:keymap): created
+
+	* rails-core.el (rails-core:buffer-file-match): allow passing nil
+
+	* rails-controller-layout.el (rails-controller-layout:keymap): created
+
+	* rails-cmd-proxy.el (rails-cmd-proxy:convert-buffer-from-remote): fixed compilation warning 
+
 	* rails-ruby.el: added flymake support to on the fly syntax check in ruby-mode
 
 	* rails-test.el (rails-test:error-regexp-alist): updated</diff>
      <filename>ChangeLog</filename>
    </modified>
    <modified>
      <diff>@@ -109,7 +109,8 @@ otherwise if set REVERSE convert from remote to local.&quot;
             (remote (rails-cmd-proxy:struct-remote struct))
             (root default-directory)
             (remote-with-root (concat remote (substring root (length local))))
-            (buffer-read-only nil))
+            (buffer-read-only nil)
+            point)
        (while (setq point (re-search-forward (format &quot;^\\s-*\\(%s\\)&quot;
                                                      remote-with-root) end t))
          (replace-match (format &quot;%s &quot;</diff>
      <filename>rails-cmd-proxy.el</filename>
    </modified>
    <modified>
      <diff>@@ -109,6 +109,38 @@ If the action is nil, return all views for the controller.&quot;
       (setq menu (list)))
     menu))
 
+(defun rails-controller-layout:keymap (type)
+  (let* ((name (capitalize (substring (symbol-name type) 1)))
+         (map (make-sparse-keymap))
+         (menubar (make-sparse-keymap))
+         (controller (rails-core:current-controller))
+         (model (singularize-string controller)))
+    (when type
+      (unless (eq type :mailer)
+        (when (rails-core:model-exist-p model)
+          (when (rails-core:migration-file (concat &quot;Create&quot; controller))
+            (define-key menubar [go-to-migration]     '(&quot;Go to Migration&quot; . rails-controller-layout:switch-to-migration))
+            (define-key map (kbd &quot;\C-c g&quot;)            'rails-controller-layout:switch-to-migration))
+          (define-key menubar [go-to-model]           '(&quot;Go to Model&quot; . rails-controller-layout:switch-to-model))
+          (define-key map (kbd &quot;\C-c m&quot;)              'rails-controller-layout:switch-to-model))
+        (unless (eq type :helper)
+          (define-key menubar [go-to-helper]          '(&quot;Go to Helper&quot; . rails-controller-layout:switch-to-helper))
+          (define-key map (kbd &quot;\C-c h&quot;)              'rails-controller-layout:switch-to-helper))
+        (unless (eq type :functional-test)
+          (define-key menubar [go-to-functional-test] '(&quot;Go to Functional Test&quot; . rails-controller-layout:switch-to-functional-test))
+          (define-key map (kbd &quot;\C-c f&quot;)              'rails-controller-layout:switch-to-functional-test))
+        (unless (eq type :controller)
+          (define-key menubar [go-to-controller]      '(&quot;Go to Controller&quot; . rails-controller-layout:switch-to-controller))
+          (define-key map (kbd &quot;\C-c c&quot;)              'rails-controller-layout:switch-to-controller)))
+      (when (eq type :mailer)
+        (define-key menubar [go-to-unit-test] '(&quot;Go to Unit Test&quot; . rails-model-layout:switch-to-unit-test))
+        (define-key map (kbd &quot;\C-c u&quot;)        'rails-model-layout:switch-to-unit-test))
+      (define-key menubar [sep] (rails-core:menu-separator))
+      (define-key menubar [primary-switch] '(&quot;Switch to related&quot; . rails-lib:run-primary-switch))
+      (define-key menubar [secondary-switch] '(&quot;Switch to related with menu&quot; . rails-lib:run-secondary-switch))
+      (define-key map [menu-bar rails-controller-layout] (cons name menubar)))
+    map))
+
 (defun rails-controller-layout:switch-to (type)
   (let* ((controller (rails-core:current-controller))
          (model (singularize-string controller))
@@ -126,6 +158,12 @@ If the action is nil, return all views for the controller.&quot;
               (message (format &quot;%s: %s&quot; (substring (symbol-name type) 1) controller)))
           (message &quot;File %s not exists&quot; file))))))
 
+(defun rails-controller-layout:switch-to-helper () (interactive) (rails-controller-layout:switch-to :helper))
+(defun rails-controller-layout:switch-to-functional-test () (interactive) (rails-controller-layout:switch-to :functional-test))
+(defun rails-controller-layout:switch-to-controller () (interactive) (rails-controller-layout:switch-to :controller))
+(defun rails-controller-layout:switch-to-model () (interactive) (rails-controller-layout:switch-to :model))
+(defun rails-controller-layout:switch-to-migration () (interactive) (rails-controller-layout:switch-to :migration))
+
 (defun rails-controller-layout:menu ()
   (interactive)
   (let* ((type (rails-core:buffer-type))</diff>
      <filename>rails-controller-layout.el</filename>
    </modified>
    <modified>
      <diff>@@ -29,9 +29,8 @@
 
 (define-minor-mode rails-controller-minor-mode
   &quot;Minor mode for RubyOnRails controllers.&quot;
-  nil
-  &quot; controller&quot;
-  nil
+  :lighter &quot; Controller&quot;
+  :keymap (rails-controller-layout:keymap :controller)
   (setq rails-secondary-switch-func 'rails-controller-layout:menu)
   (setq rails-primary-switch-func 'rails-controller-layout:toggle-action-view))
 </diff>
      <filename>rails-controller-minor-mode.el</filename>
    </modified>
    <modified>
      <diff>@@ -447,8 +447,9 @@ If the action is nil, return all views for the controller.&quot;
 
 (defun rails-core:buffer-file-match (regexp)
   &quot;Match the current buffer file name to RAILS_ROOT + REGEXP.&quot;
-  (string-match (rails-core:file regexp)
-                (buffer-file-name (current-buffer))))
+  (when-bind (file (rails-core:file regexp))
+             (string-match file
+                           (buffer-file-name (current-buffer)))))
 
 (defun rails-core:buffer-type ()
   &quot;Return the type of the current Rails file or nil if the type</diff>
      <filename>rails-core.el</filename>
    </modified>
    <modified>
      <diff>@@ -28,10 +28,9 @@
 
 (define-minor-mode rails-fixture-minor-mode
   &quot;Minor mode for RubyOnRails fixtures.&quot;
-  nil
-  &quot; fixture&quot;
-  nil
-  (setq rails-primary-switch-func (lambda() (interactive) (rails-model-layout:switch-to :unit-test)))
+  :lighter &quot; Fixture&quot;
+  :keymap (rails-model-layout:keymap :fixture)
+  (setq rails-primary-switch-func 'rails-model-layout:switch-to-unit-test)
   (setq rails-secondary-switch-func 'rails-model-layout:menu))
 
 (provide 'rails-fixture-minor-mode)
\ No newline at end of file</diff>
      <filename>rails-fixture-minor-mode.el</filename>
    </modified>
    <modified>
      <diff>@@ -28,11 +28,12 @@
 
 (define-minor-mode rails-functional-test-minor-mode
   &quot;Minor mode for RubyOnRails functional tests.&quot;
-  nil
-  &quot; func-test&quot;
-  nil
-  (setq rails-primary-switch-func (lambda() (interactive) (rails-controller-layout:switch-to :controller)))
-  (setq rails-secondary-switch-func 'rails-controller-layout:menu)
-  (local-set-key (kbd &quot;\C-c .&quot;) 'rails-test:run-current-method))
+  :lighter &quot; FTest&quot;
+  :keymap (let ((map (rails-controller-layout:keymap :functional-test)))
+            (define-key map (kbd &quot;\C-c .&quot;) 'rails-test:run-current-method)
+            (define-key map [menu-bar rails-controller-layout run] '(&quot;Test current method&quot; . rails-test:run-current-method))
+            map)
+  (setq rails-primary-switch-func 'rails-controller-layout:switch-to-controller)
+  (setq rails-secondary-switch-func 'rails-controller-layout:menu))
 
 (provide 'rails-functional-test-minor-mode)
\ No newline at end of file</diff>
      <filename>rails-functional-test-minor-mode.el</filename>
    </modified>
    <modified>
      <diff>@@ -28,10 +28,9 @@
 
 (define-minor-mode rails-helper-minor-mode
   &quot;Minor mode for RubyOnRails helpers.&quot;
-  nil
-  &quot; helper&quot;
-  nil
-  (setq rails-primary-switch-func (lambda() (interactive) (rails-controller-layout:switch-to :controller)))
+  :lighter &quot; Helper&quot;
+  :keymap (rails-controller-layout:keymap :helper)
+  (setq rails-primary-switch-func 'rails-controller-layout:switch-to-controller)
   (setq rails-secondary-switch-func 'rails-controller-layout:menu))
 
 (provide 'rails-helper-minor-mode)
\ No newline at end of file</diff>
      <filename>rails-helper-minor-mode.el</filename>
    </modified>
    <modified>
      <diff>@@ -29,9 +29,8 @@
 
 (define-minor-mode rails-mailer-minor-mode
   &quot;Minor mode for RubyOnRails mailers.&quot;
-  nil
-  &quot; mailer&quot;
-  nil
+  :lighter &quot; Mailer&quot;
+  :keymap (rails-controller-layout:keymap :mailer)
   (setq rails-secondary-switch-func 'rails-controller-layout:menu)
   (setq rails-primary-switch-func 'rails-controller-layout:toggle-action-view))
 </diff>
      <filename>rails-mailer-minor-mode.el</filename>
    </modified>
    <modified>
      <diff>@@ -28,9 +28,8 @@
 
 (define-minor-mode rails-migration-minor-mode
   &quot;Minor mode for RubyOnRails migrations.&quot;
-  nil
-  &quot; migration&quot;
-  nil
+  :lighter &quot; Migration&quot;
+  :keymap (rails-model-layout:keymap :migration)
   (setq rails-primary-switch-func nil)
   (setq rails-secondary-switch-func 'rails-model-layout:menu))
 </diff>
      <filename>rails-migration-minor-mode.el</filename>
    </modified>
    <modified>
      <diff>@@ -26,13 +26,49 @@
 
 ;;; Code:
 
+(defun rails-model-layout:keymap (type)
+  (let* ((name (capitalize (substring (symbol-name type) 1)))
+         (map (make-sparse-keymap))
+         (menubar (make-sparse-keymap))
+         (model (rails-core:current-model))
+         (controller (pluralize-string model)))
+    (when type
+      (unless (rails-core:mailer-p model)
+        (unless (eq type :model)
+          (define-key menubar [go-to-model]      '(&quot;Go to Model&quot; . rails-model-layout:switch-to-model))
+          (define-key map (kbd &quot;\C-c m&quot;)         'rails-model-layout:switch-to-model))
+        (unless (eq type :unit-test)
+          (define-key menubar [go-to-unit-test]  '(&quot;Go to Unit Test&quot; . rails-model-layout:switch-to-unit-test))
+          (define-key map (kbd &quot;\C-c u&quot;)         'rails-model-layout:switch-to-unit-test))
+        (when (and (not (eq type :migration))
+                   (rails-core:migration-file (format &quot;Create%s&quot; controller)))
+          (define-key menubar [go-to-migration]  '(&quot;Go to Migration&quot; . rails-model-layout:switch-to-migration))
+          (define-key map (kbd &quot;\C-c g&quot;)         'rails-model-layout:switch-to-migration))
+        (when (and (not (eq type :controller))
+                   (rails-core:controller-exist-p controller))
+          (define-key menubar [go-to-controller] '(&quot;Go to Controller&quot; . rails-model-layout:switch-to-controller))
+          (define-key map (kbd &quot;\C-c c&quot;)         'rails-model-layout:switch-to-controller))
+        (unless (eq type :fixture)
+          (define-key menubar [go-to-fixture]    '(&quot;Go to Fixture&quot; . rails-model-layout:switch-to-fixture))
+          (define-key map (kbd &quot;\C-c x&quot;)         'rails-model-layout:switch-to-fixture)))
+      (when (rails-core:mailer-p model)
+        (define-key menubar [go-to-mailer] '(&quot;Go to Mailer&quot; . rails-model-layout:switch-to-mailer))
+        (define-key map (kbd &quot;\C-c n&quot;)         'rails-model-layout:switch-to-mailer))
+      (define-key menubar [sep] (rails-core:menu-separator))
+      (define-key menubar [primary-switch] '(&quot;Switch to related&quot; . rails-lib:run-primary-switch))
+      (define-key menubar [secondary-switch] '(&quot;Switch to related with menu&quot; . rails-lib:run-secondary-switch))
+      (define-key map [menu-bar rails-model-layout] (cons name menubar)))
+    map))
+
 (defun rails-model-layout:switch-to (type)
   (let* ((model (rails-core:current-model))
+         (controller (rails-core:current-controller))
+         (item (if controller controller model))
          (item (case type
                  (:mailer (rails-core:mailer-file model))
                  (:controller (rails-core:controller-file (pluralize-string model)))
                  (:fixture (rails-core:fixture-file model))
-                 (:unit-test (rails-core:unit-test-file model))
+                 (:unit-test (rails-core:unit-test-file item))
                  (:model (rails-core:model-file model))
                  (:migration (rails-core:migration-file (concat &quot;Create&quot; (pluralize-string model)))))))
     (when item
@@ -40,9 +76,16 @@
         (if (file-exists-p file)
             (progn
               (find-file file)
-              (message (format &quot;%s: %s&quot; (substring (symbol-name type) 1) model)))
+              (message (format &quot;%s: %s&quot; (substring (symbol-name type) 1) item)))
           (message &quot;File %s not exists&quot; file))))))
 
+(defun rails-model-layout:switch-to-mailer () (interactive) (rails-model-layout:switch-to :mailer))
+(defun rails-model-layout:switch-to-controller () (interactive) (rails-model-layout:switch-to :controller))
+(defun rails-model-layout:switch-to-fixture () (interactive) (rails-model-layout:switch-to :fixture))
+(defun rails-model-layout:switch-to-unit-test () (interactive) (rails-model-layout:switch-to :unit-test))
+(defun rails-model-layout:switch-to-model () (interactive) (rails-model-layout:switch-to :model))
+(defun rails-model-layout:switch-to-migration () (interactive) (rails-model-layout:switch-to :migration))
+
 (defun rails-model-layout:menu ()
   (interactive)
   (let* ((item (list))</diff>
      <filename>rails-model-layout.el</filename>
    </modified>
    <modified>
      <diff>@@ -28,10 +28,9 @@
 
 (define-minor-mode rails-model-minor-mode
   &quot;Minor mode for RubyOnRails models.&quot;
-  nil
-  &quot; model&quot;
-  nil
-  (setq rails-primary-switch-func (lambda() (interactive) (rails-model-layout:switch-to :unit-test)))
+  :lighter &quot; Model&quot;
+  :keymap (rails-model-layout:keymap :model)
+  (setq rails-primary-switch-func 'rails-model-layout:switch-to-unit-test)
   (setq rails-secondary-switch-func 'rails-model-layout:menu))
 
 (provide 'rails-model-minor-mode)
\ No newline at end of file</diff>
      <filename>rails-model-minor-mode.el</filename>
    </modified>
    <modified>
      <diff>@@ -87,8 +87,6 @@
       ([recent]      '(&quot;Recent tests&quot;      . (lambda() (interactive) (rails-test:run &quot;recent&quot;))))
       ([tests]       '(&quot;All&quot;               . (lambda() (interactive) (rails-test:run &quot;all&quot;))))
       ([separator]   '(&quot;--&quot;))
-      ([method]      '(menu-item &quot;Test current method&quot; rails-test:run-current-method
-                                 :enable (find (rails-core:buffer-type) '(:unit-test :functional-test))))
       ([toggle]      '(menu-item &quot;Toggle output window&quot; rails-script:toggle-output-window
                                  :enable (get-buffer rails-script:buffer-name)))
       ([run-current] '(&quot;Test current model/controller/mailer&quot; . rails-test:run-current))
@@ -208,10 +206,10 @@
   ((kbd &quot;\C-c \C-c g u&quot;) 'rails-nav:goto-unit-tests)
 
   ;; Switch
-  ((kbd &quot;\C-c &lt;up&gt;&quot;)     'rails-lib:run-primary-switch)
-  ((kbd &quot;\C-c &lt;down&gt;&quot;)   'rails-lib:run-secondary-switch)
   ((kbd &quot;&lt;M-S-up&gt;&quot;)      'rails-lib:run-primary-switch)
   ((kbd &quot;&lt;M-S-down&gt;&quot;)    'rails-lib:run-secondary-switch)
+  ((kbd &quot;\C-c &lt;up&gt;&quot;)     'rails-lib:run-primary-switch)
+  ((kbd &quot;\C-c &lt;down&gt;&quot;)   'rails-lib:run-secondary-switch)
   ((kbd &quot;&lt;C-return&gt;&quot;)    'rails-goto-file-on-current-line)
 
   ;; Scripts &amp; SQL</diff>
      <filename>rails-ui.el</filename>
    </modified>
    <modified>
      <diff>@@ -28,15 +28,16 @@
 
 (define-minor-mode rails-unit-test-minor-mode
   &quot;Minor mode for RubyOnRails unit tests.&quot;
-  nil
-  &quot; unit-test&quot;
-  nil
+  :lighter &quot; UTest&quot;
+  :keymap (let ((map (rails-model-layout:keymap :unit-test)))
+            (define-key map (kbd &quot;\C-c .&quot;) 'rails-test:run-current-method)
+            (define-key map [menu-bar rails-model-layout run] '(&quot;Test current method&quot; . rails-test:run-current-method))
+            map)
   (setq rails-primary-switch-func (lambda()
                                     (interactive)
                                     (if (rails-core:mailer-p (rails-core:current-model))
-                                        (rails-model-layout:switch-to :mailer)
-                                      (rails-model-layout:switch-to :model))))
-  (setq rails-secondary-switch-func 'rails-model-layout:menu)
-  (local-set-key (kbd &quot;\C-c .&quot;) 'rails-test:run-current-method))
+                                        (rails-model-layout:switch-to-mailer)
+                                      (rails-model-layout:switch-to-model))))
+  (setq rails-secondary-switch-func 'rails-model-layout:menu))
 
 (provide 'rails-unit-test-minor-mode)
\ No newline at end of file</diff>
      <filename>rails-unit-test-minor-mode.el</filename>
    </modified>
    <modified>
      <diff>@@ -100,9 +100,8 @@
 
 (define-minor-mode rails-view-minor-mode
   &quot;Minor mode for RubyOnRails views.&quot;
-  nil
-  &quot; view&quot;
-  nil
+  :lighter &quot; View&quot;
+  :keymap (rails-controller-layout:keymap :view)
   (setq rails-primary-switch-func 'rails-controller-layout:toggle-action-view)
   (setq rails-secondary-switch-func 'rails-controller-layout:menu)
   (if (boundp 'mmm-mode-map)</diff>
      <filename>rails-view-minor-mode.el</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2bf7edde742c6e776f78774f76f1ab116de4a370</id>
    </parent>
  </parents>
  <author>
    <name>dimaexe</name>
    <email>dimaexe@cc5033d0-740f-0410-afc7-949910e492f2</email>
  </author>
  <url>http://github.com/tomtt/emacs-rails/commit/52c7ab7943162c608a307f369bf66776ff383992</url>
  <id>52c7ab7943162c608a307f369bf66776ff383992</id>
  <committed-date>2007-04-03T01:45:46-07:00</committed-date>
  <authored-date>2007-04-03T01:45:46-07:00</authored-date>
  <message>rails-model-layout.el (rails-model-layout:keymap): created
rails-core.el (rails-core:buffer-file-match): allow passing nil
rails-controller-layout.el (rails-controller-layout:keymap): created
rails-cmd-proxy.el (rails-cmd-proxy:convert-buffer-from-remote): fixed compilation warning


git-svn-id: svn+ssh://rubyforge.org/var/svn/emacs-rails/trunk@158 cc5033d0-740f-0410-afc7-949910e492f2</message>
  <tree>374ccc785f22f424635589c19ed4db78ef9c38db</tree>
  <committer>
    <name>dimaexe</name>
    <email>dimaexe@cc5033d0-740f-0410-afc7-949910e492f2</email>
  </committer>
</commit>
