Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun unittest-d-file (args)
- (interactive "sEnter args:")
- (setq fname (buffer-file-name))
- (setq cmdStr (concat "time rdmd -unittest --main \"" fname "\" " args))
- (setq buffname (format "*%s*" cmdStr))
- (save-excursion
- (message (concat "Running:" cmdStr))
- (if (not (eq nil (get-buffer buffname))) (kill-buffer buffname))
- (setq compilation-scroll-output t)
- (compile cmdStr)
- (set-buffer "*compilation*")
- (rename-buffer buffname t)
- ))
- (defun run-current-file-args (args)
- (let (extention-alist fname suffix progName cmdStr)
- (setq extention-alist ; a keyed list of file suffix to comand-line program to run
- '(
- ("php" . "php")
- ("pl" . "perl")
- ("py" . "python")
- ("rb" . "ruby")
- ("rspec" . "rspec")
- ("js" . "js")
- ("sh" . "bash")
- ("bash" . "bash")
- ("ml" . "ocaml")
- ("vbs" . "cscript")
- ("java" . "javac")
- ("go" . "rungo.sh")
- ("d" . "rdmd")
- ("html" . "firefox")
- )
- )
- (setq fname (buffer-file-name))
- (setq suffix (file-name-extension fname))
- (setq progName (cdr (assoc suffix extention-alist)))
- (setq cmdStr (concat "time " progName " \"" fname "\" " args))
- (setq buffname (format "*%s*" cmdStr))
- (if (string-equal suffix "el")
- (load-file fname)
- (if progName ; is not nil
- (save-excursion
- (message (concat "Running:" cmdStr))
- (if (not (eq nil (get-buffer buffname))) (kill-buffer buffname))
- (setq compilation-scroll-output t)
- (compile cmdStr)
- (set-buffer "*compilation*")
- (rename-buffer buffname t)
- (message "No recognized program file suffix for this file.")
- )))))
- (defun run-current-file ()
- "Execute or compile the current file.
- For example, if the current buffer is the file x.pl,
- then it'll call “perl x.pl” in a shell.
- The file can be php, perl, python, ruby, javascript, bash, ocaml, java.
- File suffix is used to determine what program to run."
- (interactive)
- (run-current-file-args ""))
- (defun run-current-file-prompt (args)
- (interactive "sEnter args:")
- (run-current-file-args args))
- (global-set-key "\C-c@" 'run-current-file-prompt)
- (global-set-key "\C-c#" 'unittest-d-file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement