-;; xr-mock.el --- major mode to view mock scripts
+;;; xr-mock.el --- view mock files
+;; Copyright (C) 2015, 2018  Dan Harms (dan.harms)
 ;; Author: Dan Harms <dan.harms@xrtrading.com>
 ;; Created: Wednesday, June 10, 2015
-;; Version: 1.2
-;; Modified Time-stamp: <2016-05-13 09:51:10 dan.harms>
-;; Keywords: mock script
+;; Version: 1.0
+;; Modified Time-stamp: <2018-06-04 10:59:20 dan.harms>
+;; Modified by: Dan Harms
+;; Keywords: tools mock
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;; View xr mock files.
+;;
 
 ;;; Code:
+(defgroup xr-mock-mode nil "*mock script mode" :group 'mock)
 
-(defgroup mock-mode nil "*mock script mode" :group 'mock)
+(defvar xr-mock-mode-map
+  (let ((map (make-sparse-keymap)))
+    map)
+  "Keymap for `xr-mock-mode'.")
 
-(defvar mock-mode-map
-  (let ((map (make-sparse-keymap)))
-    map) "Keymap for mock-mode")
-
-(defun mock-mode()
+(defun xr-mock-mode()
   "Major mode for browsing mock scripts."
   (interactive)
   (kill-all-local-variables)
-  (setq major-mode 'mock-mode)
+  (setq major-mode 'xr-mock-mode)
   (setq mode-name "mock-view")
   (set-syntax-table (let ((table (make-syntax-table nil)))
                       (modify-syntax-entry ?# "<" table)
                       (modify-syntax-entry ?\n ">" table)
                       table))
   (make-local-variable 'font-lock-defaults)
-  (eval-when-compile (defvar mock-mode-font-lock-keywords nil)) ;silence compilation warning
-  (setq mock-mode-font-lock-keywords
+  (eval-when-compile (defvar xr-mock-mode-font-lock-keywords nil)) ;silence compilation warning
+  (setq xr-mock-mode-font-lock-keywords
         (list
          ;; opening timestamp
          (list "^[[:digit:]]+"

               '(0 font-lock-keyword-face))
         (list "\\(CommandConsole\\|SetValidLogin\\|SetInvalidLogin\\)"
               '(0 font-lock-keyword-face))
         ;; functions
         (list "@@\\sw+=\\([^(]+()\\)"
               '(1 font-lock-function-name-face))

        ("=\\<en\\(d\\)\\_>" (1 "> b"))
        ("\\_<end_commen\\(t\\)\\_>" (1 "> b"))
        ))
  (use-local-map xr-mock-mode-map)
  (define-key xr-mock-mode-map "\M-sg" 'xr-mock-goto-line)
  (setq comment-start "#" comment-end "")
  (subword-mode 1)
  (run-hooks 'xr-mock-mode-hook)
  )

(add-to-list
 'auto-mode-alist
 '("mockobjects/testscripts/.*\\.\\(txt\\|script\\|defines\\)$"
   . xr-mock-mode))
(add-to-list
 'ff-special-constructs
 '("^\\(?:@@\\)?\\(?:.*\\.\\)?\\(include\\|sourceFiles\\|scriptfile\\)\\s-*=\\s-*\\(.*\\)"
   lambda nil (buffer-substring (match-beginning 2) (match-end 2))) t)

(defun xr-mock-goto-line (n)
  "Go to line N in a mock script, exclusive of continuation lines."
  (interactive "nGoto mock line: ")
  (goto-char (point-min))
  (while (> n 1)
