Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rinari (and deps) are now in ELPA, fix a bug in package.el.

We should see a new release of package.el later today...
  • Loading branch information...
commit da1a21bcbef1b3862754da6c9bbfdaf9ba0612e5 1 parent e3dd93a
@technomancy authored
View
258 elpa-to-submit/findr.el
@@ -1,258 +0,0 @@
-;;; findr.el -- Breadth-first file-finding facility for (X)Emacs
-;; Dec 1, 2006
-
-;; Copyright (C) 1999 Free Software Foundation, Inc.
-
-;; Author: David Bakhash <cadet@bu.edu>
-;; Maintainer: David Bakhash <cadet@bu.edu>
-;; Version: 0.7
-;; Created: Tue Jul 27 12:49:22 EST 1999
-;; Keywords: files
-
-;; This file is not part of emacs or XEmacs.
-
-;; This file 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 2 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 XEmacs; see the file COPYING. If not, write to the Free
-;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-;; 02111-1307, USA.
-
-
-;;; Commentary:
-
-;; This code contains a command, called `findr', which allows you to
-;; search for a file breadth-first. This works on UNIX, Windows, and
-;; over the network, using efs and ange-ftp. It's pretty quick, and (at
-;; times) is a better and easier alternative to other mechanisms of
-;; finding nested files, when you've forgotten where they are.
-
-;; You pass `findr' a regexp, which must match the file you're looking
-;; for, and a directory, and then it just does its thing:
-
-;; M-x findr <ENTER> ^my-lib.p[lm]$ <ENTER> c:/ <ENTER>
-
-;; If called interactively, findr will prompt the user for opening the
-;; found file(s). Regardless, it will continue to search, until
-;; either the search is complete or the user quits the search.
-;; Regardless of the exit (natural or user-invoked), a findr will
-;; return a list of found matches.
-
-;; Two other entrypoints let you to act on regexps within the files:
-;; `findr-search' to search
-;; `findr-query-replace' to replace
-
-
-;;; Installation:
-
-;; (autoload 'findr "findr" "Find file name." t)
-;; (define-key global-map [(meta control S)] 'findr)
-
-;; (autoload 'findr-search "findr" "Find text in files." t)
-;; (define-key global-map [(meta control s)] 'findr-search)
-
-;; (autoload 'findr-query-replace "findr" "Replace text in files." t)
-;; (define-key global-map [(meta control r)] 'findr-query-replace)
-
-
-;; Change Log:
-
-;; 0.1: Added prompt to open file, if uses so chooses, following
-;; request and code example from Thomas Plass.
-;; 0.2: Made `findr' not stop after the first match, based on the
-;; request by Thomas Plass.
-;; Also, fixed a minor bug where findr was finding additional
-;; files that were not correct matches, based on
-;; `file-relative-name' misuse (I had to add the 2nd arg to it).
-;; 0.3: Added a `sit-for' for redisplay reasons.
-;; Modifications as suggested by RMS: e.g. docstring.
-;; 0.4 Added `findr-query-replace', courtesy of Dan Nelsen.
-;; 0.5 Fixed spelling and minor bug in `findr-query-replace' when
-;; non-byte-compiled.
-;; 0.6 http://groups.google.com/groups?selm=cxjhfml4b2c.fsf_-_%40acs5.bu.edu :
-;; From: David Bakhash (cadet@bu.edu)
-;; Subject: Re: latest version of findr.el (5)
-;; Date: 1999/07/31
-;; Courtesy of Dan Nelsen, this version has search-and-replace capabilities.
-;; it's still a bit experimental, so I wouldn't expect too much of it. But it
-;; hasn't been tested yet for friendly behavior.
-;;
-;; The function `findr-query-replace' wasn't working unless you byte-compile the
-;; file. But, since findr is really designed for speed, that's not a bad thing
-;; (i.e. it forces you to byte-compile it). It's as simple as:
-;;
-;; M-x byte-compile-file <ENTER> /path/to/findr.el <ENTER>
-;;
-;; anyhow, I think it should work now.
-;;
-;; dave
-;;
-;; 0.7: Added `findr-search', broke `findr' by Patrick Anderson
-;; 0.8: fixed 0.7 breakage by Patrick Anderson
-;; 0.9: Added customize variables, added file/directory filter regexp
-;; minibuffer history by attila.lendvai@gmail.com
-;; 0.9.1: Updated date at the top of the file, added .svn filter
-;; 0.9.2: Added support for skipping symlinks
-
-(eval-when-compile
- (require 'cl))
-
-(provide 'findr)
-
-(defgroup findr nil
- "findr configuration."
- :prefix "findr-"
- :group 'findr)
-
-;; To build the expression below:
-;;(let ((result nil))
-;; (dolist (el (list ".backups" "_darcs" ".git" "CVS" ".svn"))
-;; (setf result (if result
-;; (concatenate 'string result "\\|")
-;; ""))
-;; (setf result (concatenate 'string result "^" (regexp-quote el) "$")))
-;; result)
-
-(defcustom findr-skip-directory-regexp "^\\.backups$\\|^_darcs$\\|^\\.git$\\|^CVS$\\|^\\.svn$"
- "A regexp that will be matched against the directory names and when it matches then the entire directory is skipped."
- :type 'string
- :group 'findr)
-
-(defcustom findr-skip-file-regexp "^[#\\.]"
- "A regexp that will be matched against all file names (including directories) and when it matches then the file is skipped."
- :type 'string
- :group 'findr)
-
-(defvar findr-search-regexp-history nil)
-(defvar findr-search-replacement-history nil)
-(defvar findr-file-name-regexp-history nil)
-(defvar findr-directory-history nil)
-
-(defun findr-read-search-regexp (&optional prompt)
- (read-from-minibuffer
- (or prompt "Search through files for (regexp): ")
- nil nil nil 'findr-search-regexp-history))
-
-(defun findr-read-file-regexp (&optional prompt)
- (read-from-minibuffer
- (or prompt "Look in these files (regexp): ")
- (first findr-file-name-regexp-history)
- nil nil 'findr-file-name-regexp-history))
-
-(defun findr-read-starting-directory (&optional prompt)
- (apply 'read-directory-name
- (append
- (list (or prompt "Start in directory: ") default-directory
- default-directory t nil)
- (when (featurep 'xemacs)
- (list 'findr-directory-history)))))
-
-;;;; breadth-first file finder...
-
-(defun* findr (name dir &key (prompt-p (interactive-p)) (skip-symlinks t))
- "Search directory DIR breadth-first for files matching regexp NAME.
-If PROMPT-P is non-nil, or if called interactively, Prompts for visiting
-search result\(s\)."
- (let ((*dirs* (findr-make-queue))
- *found-files*)
- (labels ((findr-1 (dir)
- (message "Searching %s ..." dir)
- (let ((files (directory-files dir t "\\w")))
- (loop
- for file in files
- for fname = (file-relative-name file dir)
- when (and (file-directory-p file)
- (not (string-match findr-skip-directory-regexp fname))
- (and skip-symlinks
- (not (file-symlink-p file))))
- do (findr-enqueue file *dirs*)
- when (and (string-match name fname)
- (not (string-match findr-skip-file-regexp fname))
- (and skip-symlinks
- (not (file-symlink-p file))))
- do
- ;; Don't return directory names when
- ;; building list for `tags-query-replace' or `tags-search'
- ;;(when (and (file-regular-p file)
- ;; (not prompt-p))
- ;; (push file *found-files*))
-
- ;; _never_ return directory names
- (when (file-regular-p file)
- (push file *found-files*))
- (message file)
- (when (and prompt-p
- (y-or-n-p (format "Find file %s? " file)))
- (find-file file)
- (sit-for 0) ; redisplay hack
- )))))
- (unwind-protect
- (progn
- (findr-enqueue dir *dirs*)
- (while (findr-queue-contents *dirs*)
- (findr-1 (findr-dequeue *dirs*)))
- (message "Searching... done."))
- (return-from findr (nreverse *found-files*))))))
-
-(defun findr-query-replace (from to name dir)
- "Do `query-replace-regexp' of FROM with TO, on each file found by findr.
-If you exit (\\[keyboard-quit] or ESC), you can resume the query replace
-with the command \\[tags-loop-continue]."
- (interactive (let ((search-for (findr-read-search-regexp "Search through files for (regexp): ")))
- (list search-for
- (read-from-minibuffer (format "Query replace '%s' with: " search-for)
- nil nil nil 'findr-search-replacement-history)
- (findr-read-file-regexp)
- (findr-read-starting-directory))))
- (tags-query-replace from to nil '(findr name dir)))
-
-(defun findr-search (regexp files dir)
- "Search through all files listed in tags table for match for REGEXP.
-Stops when a match is found.
-To continue searching for next match, use command \\[tags-loop-continue]."
- (interactive (list (findr-read-search-regexp)
- (findr-read-file-regexp)
- (findr-read-starting-directory)))
- (tags-search regexp '(findr files dir)))
-
-
-(defun findr-find-files (files dir)
- "Same as `findr' except file names are put in a compilation buffer."
- (interactive (list (findr-read-file-regexp)
- (findr-read-starting-directory)))
- ;; TODO: open a scratch buffer or store in the clipboard
- (mapcar 'message (findr files dir)))
-
-;;;; Queues
-
-(defun findr-make-queue ()
- "Build a new queue, with no elements."
- (let ((q (cons nil nil)))
- (setf (car q) q)
- q))
-
-(defun findr-enqueue (item q)
- "Insert item at the end of the queue."
- (setf (car q)
- (setf (rest (car q))
- (cons item nil)))
- q)
-
-(defun findr-dequeue (q)
- "Remove an item from the front of the queue."
- (prog1 (pop (cdr q))
- (when (null (cdr q))
- (setf (car q) q))))
-
-(defsubst findr-queue-contents (q)
- (cdr q))
-
-;;; findr.el ends here
View
350 elpa-to-submit/inf-ruby.el
@@ -1,350 +0,0 @@
-;;; inf-ruby.el --- Run a ruby process in a buffer
-
-;; Copyright (C) 1999-2008 Yukihiro Matsumoto, Nobuyoshi Nakada
-
-;; Authors: Yukihiro Matsumoto, Nobuyoshi Nakada
-;; URL: http://www.emacswiki.org/cgi-bin/wiki/RubyMode
-;; Created: 8 April 1998
-;; Keywords: languages ruby
-;; Version: 2.0
-;; Package-Requires: (("ruby-mode"))
-
-;;; Commentary:
-;;
-;; inf-ruby.el provides a REPL buffer connected to an IRB subprocess.
-;;
-;; If you're installing manually, you'll need to:
-;; * drop the file somewhere on your load path (perhaps ~/.emacs.d)
-;; * Add the following lines to your .emacs file:
-;; (autoload 'inf-ruby "inf-ruby" "Run an inferior Ruby process" t)
-;; (autoload 'inf-ruby-keys "inf-ruby" "" t)
-;; (eval-after-load 'ruby-mode
-;; '(add-hook 'ruby-mode-hook 'inf-ruby-keys))
-
-;;; TODO:
-;;
-;; inferior-ruby-error-regexp-alist doesn't match this example
-;; SyntaxError: /home/eschulte/united/org/work/arf/arf/lib/cluster.rb:35: syntax error, unexpected '~', expecting kEND
-;; similarity = comparison_cache[m][n] ||= clusters[m] ~ clusters[n]
-;;
-;; M-p skips the first entry in the input ring.
-;;
-
-(require 'comint)
-(require 'compile)
-(require 'ruby-mode)
-
-(defvar inf-ruby-default-implementation "ruby"
- "Which ruby implementation to use if none is specified.")
-
-(defvar inf-ruby-first-prompt-pattern "^irb(.*)[0-9:]+0> *"
- "First prompt regex pattern of ruby interpreter.")
-
-(defvar inf-ruby-prompt-pattern "^\\(irb(.*)[0-9:]+[>*\"'] *\\)+"
- "Prompt regex pattern of ruby interpreter.")
-
-(defvar inf-ruby-mode-hook nil
- "*Hook for customising inf-ruby mode.")
-
-(defvar inf-ruby-mode-map
- (let ((map (copy-keymap comint-mode-map)))
- (define-key map (kbd "C-c C-l") 'inf-ruby-load-file)
- (define-key map (kbd "C-x C-e") 'ruby-send-last-sexp)
- (define-key map (kbd "TAB") 'inf-ruby-complete-or-tab)
- map)
- "*Mode map for inf-ruby-mode")
-
-(defvar inf-ruby-implementations
- '(("ruby" . "irb --inf-ruby-mode -r irb/completion")
- ("jruby" . "jruby -S irb -r irb/completion")
- ("rubinius" . "rbx -r irb/completion")
- ("yarv" . "irb1.9 --inf-ruby-mode -r irb/completion")) ;; TODO: ironruby?
- "An alist of ruby implementations to irb executable names.")
-
-;; TODO: do we need these two defvars?
-(defvar ruby-source-modes '(ruby-mode)
- "*Used to determine if a buffer contains Ruby source code.
-If it's loaded into a buffer that is in one of these major modes, it's
-considered a ruby source file by ruby-load-file.
-Used by these commands to determine defaults.")
-
-(defvar ruby-prev-l/c-dir/file nil
- "Caches the last (directory . file) pair.
-Caches the last pair used in the last ruby-load-file command.
-Used for determining the default in the
-next one.")
-
-(defconst inf-ruby-error-regexp-alist
- '(("SyntaxError: compile error\n^\\([^\(].*\\):\\([1-9][0-9]*\\):" 1 2)
- ("^\tfrom \\([^\(].*\\):\\([1-9][0-9]*\\)\\(:in `.*'\\)?$" 1 2)))
-
-;;;###autoload
-(defun inf-ruby-keys ()
- "Set local key defs to invoke inf-ruby from ruby-mode."
- (define-key ruby-mode-map "\M-\C-x" 'ruby-send-definition)
- (define-key ruby-mode-map "\C-x\C-e" 'ruby-send-last-sexp)
- (define-key ruby-mode-map "\C-c\C-b" 'ruby-send-block)
- (define-key ruby-mode-map "\C-c\M-b" 'ruby-send-block-and-go)
- (define-key ruby-mode-map "\C-c\C-x" 'ruby-send-definition)
- (define-key ruby-mode-map "\C-c\M-x" 'ruby-send-definition-and-go)
- (define-key ruby-mode-map "\C-c\C-r" 'ruby-send-region)
- (define-key ruby-mode-map "\C-c\M-r" 'ruby-send-region-and-go)
- (define-key ruby-mode-map "\C-c\C-z" 'ruby-switch-to-inf)
- (define-key ruby-mode-map "\C-c\C-l" 'ruby-load-file)
- (define-key ruby-mode-map "\C-c\C-s" 'inf-ruby))
-
-(defvar inf-ruby-buffer nil "Current irb process buffer.")
-
-(defun inf-ruby-mode ()
- "Major mode for interacting with an inferior ruby (irb) process.
-
-The following commands are available:
-\\{inf-ruby-mode-map}
-
-A ruby process can be fired up with M-x inf-ruby.
-
-Customisation: Entry to this mode runs the hooks on comint-mode-hook and
-inf-ruby-mode-hook (in that order).
-
-You can send text to the inferior ruby process from other buffers containing
-Ruby source.
- ruby-switch-to-inf switches the current buffer to the ruby process buffer.
- ruby-send-definition sends the current definition to the ruby process.
- ruby-send-region sends the current region to the ruby process.
-
- ruby-send-definition-and-go, ruby-send-region-and-go,
- switch to the ruby process buffer after sending their text.
-
-Commands:
-Return after the end of the process' output sends the text from the
- end of process to point.
-Return before the end of the process' output copies the sexp ending at point
- to the end of the process' output, and sends it.
-Delete converts tabs to spaces as it moves back.
-Tab indents for ruby; with arugment, shifts rest
- of expression rigidly with the current line.
-C-M-q does Tab on each line starting within following expression.
-Paragraphs are separated only by blank lines. # start comments.
-If you accidentally suspend your process, use \\[comint-continue-subjob]
-to continue it."
- (interactive)
- (comint-mode)
- (setq comint-prompt-regexp inf-ruby-prompt-pattern)
- (ruby-mode-variables)
- (setq major-mode 'inf-ruby-mode)
- (setq mode-name "Inf-Ruby")
- (setq mode-line-process '(":%s"))
- (use-local-map inf-ruby-mode-map)
- (setq comint-input-filter (function inf-ruby-input-filter))
- (setq comint-get-old-input (function inf-ruby-get-old-input))
- (make-local-variable 'compilation-error-regexp-alist)
- (setq compilation-error-regexp-alist inf-ruby-error-regexp-alist)
- (compilation-shell-minor-mode t)
- (run-hooks 'inf-ruby-mode-hook))
-
-(defvar inf-ruby-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'"
- "*Input matching this regexp are not saved on the history list.
-Defaults to a regexp ignoring all inputs of 0, 1, or 2 letters.")
-
-(defun inf-ruby-input-filter (str)
- "Don't save anything matching inf-ruby-filter-regexp"
- (not (string-match inf-ruby-filter-regexp str)))
-
-;; adapted from replace-in-string in XEmacs (subr.el)
-(defun inf-ruby-remove-in-string (str regexp)
- "Remove all matches in STR for REGEXP and returns the new string."
- (let ((rtn-str "") (start 0) match prev-start)
- (while (setq match (string-match regexp str start))
- (setq prev-start start
- start (match-end 0)
- rtn-str (concat rtn-str (substring str prev-start match))))
- (concat rtn-str (substring str start))))
-
-(defun inf-ruby-get-old-input ()
- "Snarf the sexp ending at point"
- (save-excursion
- (let ((end (point)))
- (re-search-backward inf-ruby-first-prompt-pattern)
- (inf-ruby-remove-in-string (buffer-substring (point) end)
- inf-ruby-prompt-pattern))))
-
-;;;###autoload
-(defun inf-ruby (&optional impl)
- "Run an inferior Ruby process in a buffer.
-With prefix argument, prompts for which Ruby implementation
-\(from the list `inf-ruby-implementations') to use. Runs the
-hooks `inf-ruby-mode-hook' \(after the `comint-mode-hook' is
-run)."
-
- (interactive (list (if current-prefix-arg
- (completing-read "Ruby Implementation: "
- (mapc #'car inf-ruby-implementations))
- inf-ruby-default-implementation)))
- (setq impl (or impl "ruby"))
-
- (let ((command (cdr (assoc impl inf-ruby-implementations))))
- (run-ruby command impl)))
-
-;;;###autoload
-(defun run-ruby (command &optional name)
- "Run an inferior Ruby process, input and output via buffer *ruby*.
-If there is a process already running in `*ruby*', switch to that buffer.
-With argument, allows you to edit the command line (default is value
-of `ruby-program-name'). Runs the hooks `inferior-ruby-mode-hook'
-\(after the `comint-mode-hook' is run).
-\(Type \\[describe-mode] in the process buffer for a list of commands.)"
-
- (interactive)
- (setq command (or command (cdr (assoc inf-ruby-default-implementation
- inf-ruby-implementations))))
- (setq name (or name "ruby"))
-
- (if (not (comint-check-proc inf-ruby-buffer))
- (let ((commandlist (split-string command)))
- (set-buffer (apply 'make-comint name (car commandlist)
- nil (cdr commandlist)))
- (inf-ruby-mode)))
- (pop-to-buffer (setq inf-ruby-buffer (format "*%s*" name))))
-
-(defun inf-ruby-proc ()
- "Returns the current IRB process. See variable inf-ruby-buffer."
- (or (get-buffer-process (if (eq major-mode 'inf-ruby-mode)
- (current-buffer)
- inf-ruby-buffer))
- (error "No current process. See variable inf-ruby-buffer")))
-
-;; These commands are added to the ruby-mode keymap:
-
-(defconst ruby-send-terminator "--inf-ruby-%x-%d-%d-%d--"
- "Template for irb here document terminator.
-Must not contain ruby meta characters.")
-
-(defconst ruby-eval-separator "")
-
-(defun ruby-send-region (start end)
- "Send the current region to the inferior Ruby process."
- (interactive "r")
- (let (term (file (buffer-file-name)) line)
- (save-excursion
- (save-restriction
- (widen)
- (goto-char start)
- (setq line (+ start (forward-line (- start)) 1))
- (goto-char start)
- (while (progn
- (setq term (apply 'format ruby-send-terminator (random) (current-time)))
- (re-search-forward (concat "^" (regexp-quote term) "$") end t)))))
- ;; compilation-parse-errors parses from second line.
- (save-excursion
- (let ((m (process-mark (inf-ruby-proc))))
- (set-buffer (marker-buffer m))
- (goto-char m)
- (insert ruby-eval-separator "\n")
- (set-marker m (point))))
- (comint-send-string (inf-ruby-proc) (format "eval <<'%s', nil, %S, %d\n" term file line))
- (comint-send-region (inf-ruby-proc) start end)
- (comint-send-string (inf-ruby-proc) (concat "\n" term "\n"))))
-
-(defun ruby-send-definition ()
- "Send the current definition to the inferior Ruby process."
- (interactive)
- (save-excursion
- (ruby-end-of-defun)
- (let ((end (point)))
- (ruby-beginning-of-defun)
- (ruby-send-region (point) end))))
-
-(defun ruby-send-last-sexp ()
- "Send the previous sexp to the inferior Ruby process."
- (interactive)
- (ruby-send-region (save-excursion (backward-sexp) (point)) (point)))
-
-(defun ruby-send-block ()
- "Send the current block to the inferior Ruby process."
- (interactive)
- (save-excursion
- (ruby-end-of-block)
- (end-of-line)
- (let ((end (point)))
- (ruby-beginning-of-block)
- (ruby-send-region (point) end))))
-
-(defun ruby-switch-to-inf (eob-p)
- "Switch to the ruby process buffer.
-With argument, positions cursor at end of buffer."
- (interactive "P")
- (if (get-buffer inf-ruby-buffer)
- (pop-to-buffer inf-ruby-buffer)
- (error "No current process buffer. See variable inf-ruby-buffer."))
- (cond (eob-p
- (push-mark)
- (goto-char (point-max)))))
-
-(defun ruby-send-region-and-go (start end)
- "Send the current region to the inferior Ruby process.
-Then switch to the process buffer."
- (interactive "r")
- (ruby-send-region start end)
- (ruby-switch-to-inf t))
-
-(defun ruby-send-definition-and-go ()
- "Send the current definition to the inferior Ruby.
-Then switch to the process buffer."
- (interactive)
- (ruby-send-definition)
- (ruby-switch-to-inf t))
-
-(defun ruby-send-block-and-go ()
- "Send the current block to the inferior Ruby.
-Then switch to the process buffer."
- (interactive)
- (ruby-send-block)
- (ruby-switch-to-inf t))
-
-(defun ruby-load-file (file-name)
- "Load a Ruby file into the inferior Ruby process."
- (interactive (comint-get-source "Load Ruby file: " ruby-prev-l/c-dir/file
- ruby-source-modes t)) ;; T because LOAD needs an exact name
- (comint-check-source file-name) ; Check to see if buffer needs saved.
- (setq ruby-prev-l/c-dir/file (cons (file-name-directory file-name)
- (file-name-nondirectory file-name)))
- (comint-send-string (inf-ruby-proc) (concat "(load \""
- file-name
- "\"\)\n")))
-
-(defun inf-ruby-completions (seed)
- "Return a list of completions for the line of ruby code starting with SEED."
- (let* ((proc (get-buffer-process inf-ruby-buffer))
- (comint-filt (process-filter proc))
- (kept "") completions)
- (set-process-filter proc (lambda (proc string) (setf kept (concat kept string))))
- (process-send-string proc (format "puts IRB::InputCompletor::CompletionProc.call('%s').compact\n" seed))
- (while (not (string-match inf-ruby-prompt-pattern kept)) (accept-process-output proc))
- (if (string-match "^[[:alpha:]]+?Error: " kept) (error kept))
- (setf completions (butlast (split-string kept "[\r\n]") 2))
- (set-process-filter proc comint-filt)
- completions))
-
-(defun inf-ruby-complete-or-tab (&optional command)
- "Either complete the ruby code at point or call
-`indent-for-tab-command' if no completion is available. Relies
-on the irb/completion Module used by readline when running irb
-through a terminal."
- (interactive (list (let* ((curr (thing-at-point 'line))
- (completions (inf-ruby-completions curr)))
- (case (length completions)
- (0 nil)
- (1 (car completions))
- (t (completing-read "possible completions: " completions nil 'confirm-only curr))))))
- (if (not command)
- (call-interactively 'indent-for-tab-command)
- (move-beginning-of-line 1)
- (kill-line 1)
- (insert command)))
-
-;;;###autoload
-(eval-after-load 'ruby-mode
- '(add-hook 'ruby-mode-hook 'inf-ruby-keys))
-
-(provide 'inf-ruby)
-;;; inf-ruby.el ends here
View
149 elpa-to-submit/inflections.el
@@ -1,149 +0,0 @@
-;;; inflections.el --- convert english words between singular and plural
-
-;; Copyright (C) 2006 Dmitry Galinsky <dima dot exe at gmail dot com>
-
-;; Authors: Dmitry Galinsky, Howard Yeh
-;; URL: http://emacs-rails.rubyforge.org/svn/trunk/inflections.el
-;; Version: 1.0
-;; Created: 2007-11-02
-;; Keywords: ruby rails languages oop
-
-;; This file is NOT part of GNU Emacs.
-
-;;; License
-
-;; 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 2
-;; 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, write to the Free Software
-;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-;;; Code:
-(require 'cl)
-(defvar inflection-singulars nil)
-(defvar inflection-plurals nil)
-(defvar inflection-irregulars nil)
-(defvar inflection-uncountables nil)
-
-(defmacro define-inflectors (&rest specs)
- (loop for (type . rest) in specs do
- (case type
- (:singular (push rest inflection-singulars))
- (:plural (push rest inflection-plurals))
- (:irregular (push rest inflection-irregulars))
- (:uncountable (setf inflection-uncountables
- (append rest inflection-uncountables))))))
-
-(defmacro string=~ (regex string &rest body)
- "regex matching similar to the =~ operator found in other languages."
- (let ((str (gensym)))
- `(lexical-let ((,str ,string))
- ;; Use lexical-let to make closures (in flet).
- (when (string-match ,regex ,str)
- (symbol-macrolet ,(loop for i to 9 collect
- (let ((sym (intern (concat "$" (number-to-string i)))))
- `(,sym (match-string ,i ,str))))
- (flet (($ (i) (match-string i ,str))
- (sub (replacement &optional (i 0) &key fixedcase literal-string)
- (replace-match replacement fixedcase literal-string ,str i)))
- (symbol-macrolet ( ;;before
- ($b (substring ,str 0 (match-beginning 0)))
- ;;match
- ($m (match-string 0 ,str))
- ;;after
- ($a (substring ,str (match-end 0) (length ,str))))
- ,@body)))))))
-
-(define-inflectors
- (:plural "$" "s")
- (:plural "s$" "s")
- (:plural "\\(ax\\|test\\)is$" "\\1es")
- (:plural "\\(octop\\|vir\\)us$" "\\1i")
- (:plural "\\(alias\\|status\\)$" "\\1es")
- (:plural "\\(bu\\)s$" "\\1ses")
- (:plural "\\(buffal\\|tomat\\)o$" "\\1oes")
- (:plural "\\([ti]\\)um$" "\\1a")
- (:plural "sis$" "ses")
- (:plural "\\(?:\\([^f]\\)fe\\|\\([lr]\\)f\\)$" "\\1\\2ves")
- (:plural "\\(hive\\)$" "\\1s")
- (:plural "\\([^aeiouy]\\|qu\\)y$" "\\1ies")
- (:plural "\\(x\\|ch\\|ss\\|sh\\)$" "\\1es")
- (:plural "\\(matr\\|vert\\|ind\\)ix\\|ex$" "\\1ices")
- (:plural "\\([m\\|l]\\)ouse$" "\\1ice")
- (:plural "^\\(ox\\)$" "\\1en")
- (:plural "\\(quiz\\)$" "\\1zes")
-
- (:singular "s$" "")
- (:singular "\\(n\\)ews$" "\\1ews")
- (:singular "\\([ti]\\)a$" "\\1um")
- (:singular "\\(\\(a\\)naly\\|\\(b\\)a\\|\\(d\\)iagno\\|\\(p\\)arenthe\\|\\(p\\)rogno\\|\\(s\\)ynop\\|\\(t\\)he\\)ses$" "\\1\\2sis")
- (:singular "\\(^analy\\)ses$" "\\1sis")
- (:singular "\\([^f]\\)ves$" "\\1fe")
- (:singular "\\(hive\\)s$" "\\1")
- (:singular "\\(tive\\)s$" "\\1")
- (:singular "\\([lr]\\)ves$" "\\1f")
- (:singular "\\([^aeiouy]\\|qu\\)ies$" "\\1y")
- (:singular "\\(s\\)eries$" "\\1eries")
- (:singular "\\(m\\)ovies$" "\\1ovie")
- (:singular "\\(x\\|ch\\|ss\\|sh\\)es$" "\\1")
- (:singular "\\([m\\|l]\\)ice$" "\\1ouse")
- (:singular "\\(bus\\)es$" "\\1")
- (:singular "\\(o\\)es$" "\\1")
- (:singular "\\(shoe\\)s$" "\\1")
- (:singular "\\(cris\\|ax\\|test\\)es$" "\\1is")
- (:singular "\\(octop\\|vir\\)i$" "\\1us")
- (:singular "\\(alias\\|status\\)es$" "\\1")
- (:singular "^\\(ox\\)en" "\\1")
- (:singular "\\(vert\\|ind\\)ices$" "\\1ex")
- (:singular "\\(matr\\)ices$" "\\1ix")
- (:singular "\\(quiz\\)zes$" "\\1")
-
- (:irregular "stratum" "strate")
- (:irregular "syllabus" "syllabi")
- (:irregular "radius" "radii")
- (:irregular "addendum" "addenda")
- (:irregular "cactus" "cacti")
- (:irregular "child" "children")
- (:irregular "corpus" "corpora")
- (:irregular "criterion" "criteria")
- (:irregular "datum" "data")
- (:irregular "genus" "genera")
- (:irregular "man" "men")
- (:irregular "medium" "media")
- (:irregular "move" "moves")
- (:irregular "person" "people")
- (:irregular "man" "men")
- (:irregular "child" "children")
- (:irregular "sex" "sexes")
- (:irregular "move" "moves")
-
- (:uncountable "equipment" "information" "rice" "money" "species" "series" "fish" "sheep" "news"))
-
-(defun singularize-string (str)
- (when (stringp str)
- (or (car (member str inflection-uncountables))
- (caar (member* (downcase str) inflection-irregulars :key 'cadr :test 'equal))
- (loop for (from to) in inflection-singulars
- for singular = (string=~ from str (sub to))
- when singular do (return singular))
- str)))
-
-(defun pluralize-string (str)
- (when (stringp str)
- (or (car (member str inflection-uncountables))
- (cadar (member* (downcase str) inflection-irregulars :key 'car :test 'equal))
- (loop for (from to) in inflection-plurals
- for plurals = (string=~ from str (sub to))
- when plurals do (return plurals))
- str)))
-
-(provide 'inflections)
-;;; inflections.el ends here
View
299 elpa-to-submit/jump.el
@@ -1,299 +0,0 @@
-;;; jump.el --- build functions which contextually jump between files
-
-;; Copyright (C) 2008 Eric Schulte
-
-;; Author: Eric Schulte
-;; URL: http://github.com/eschulte/jump.el/tree/master
-;; Version: 2.0
-;; Created: 2008-08-21
-;; Keywords: project, convenience, navigation
-;; Package-Requires: ((findr "0.7")
-;; (inflections "1.0"))
-
-;; This file is NOT part of GNU Emacs.
-
-;;; License:
-
-;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-;;; Commentary:
-
-;; This library is intended to aid in the construction of functions
-;; for navigating projects. The `defjump' function using a hopefully
-;; convenient specification schema which jumps to new file/methods
-;; based upon the file/method context of the current buffer/point.
-
-;; This effort was inspired heavily by find-file-in-project.el by Phil
-;; Hagelberg and Doug Alcorn, and toggle.el by Ryan Davis. The
-;; initial goal of jump.el was to subsume both of these tools.
-
-;;; Example: (jumping to the related model in a rails application)
-
-;; (defjump
-;; 'rinari-find-model
-;; '(("app/controllers/\\1_controller.rb#\\2" . "app/models/\\1.rb#\\2")
-;; ("app/views/\\1/.*" . "app/models/\\1.rb")
-;; ("app/helpers/\\1_helper.rb" . "app/models/\\1.rb")
-;; ("db/migrate/.*create_\\1.rb" . "app/models/\\1.rb")
-;; ("test/functional/\\1_controller_test.rb" . "app/models/\\1.rb")
-;; ("test/unit/\\1_test.rb#test_\\2" . "app/models/\\1.rb#\\2")
-;; ("test/unit/\\1_test.rb" . "app/models/\\1.rb")
-;; ("test/fixtures/\\1.yml" . "app/models/\\1.rb")
-;; (t . "app/models/"))
-;; 'rinari-root
-;; "Go to the most logical model given the current location."
-;; '(lambda (path)
-;; (message (shell-command-to-string
-;; (format "ruby %sscript/generate model %s"
-;; (rinari-root)
-;; (and (string-match ".*/\\(.+?\\)\.rb" path)
-;; (match-string 1 path))))))
-;; 'ruby-add-log-current-method)
-
-;;; Code:
-(require 'which-func)
-(require 'findr)
-(require 'inflections)
-
-(defvar jump-ignore-file-regexp ;; TODO actually start using this
- "\\(.*\\.\\(git\\|svn\\|cvs\\).*\\|.*~\\|.*\\#.*\\#\\)"
- "regexp for the find shell command to ignore undesirable files")
-
-(defun jump-completing-read (prompt choices &optional predicate require-match initial-input hist def)
- "if `ido-mode' is turned on use ido speedups completing the read"
- (if ido-mode
- (ido-completing-read prompt choices predicate require-match initial-input hist def)
- (completing-read prompt choices predicate require-match initial-input hist def)))
-
-(defun jump-find-file-in-dir (dir)
- "if `ido-mode' is turned on use ido speedups finding the file"
- (if (or (equal ido-mode 'file) (equal ido-mode 'both))
- (ido-find-file-in-dir dir)
- (let ((default-directory dir)) (call-interactively 'find-file))))
-
-(defun jump-method ()
- "Return the method defined at the current position in current
-buffer."
- (let ((func (funcall method-command)))
- (or (and func (string-match "#\\(.+\\)" func) (match-string 1 func))
- func)))
-
-(defun jump-uniqueify (file-cons)
- "Set the car of the argument to include the directory name plus the file name."
- (setcar file-cons
- (concat (car file-cons) " "
- (cadr (reverse (split-string (cdr file-cons) "/"))))))
-
-(defun jump-select-and-find-file (files)
- "Select a single file from an alist of file names and paths.
-Return the path selected or nil if files was empty."
- (let ((file (case (length files)
- (0 nil)
- (1 (caar files))
- (t (jump-completing-read "Jump to: "
- (mapcar 'car files))))))
- (if file (find-file (cdr (assoc file files))))))
-
-(defun jump-remove-unwanted-files (files)
- (delete-if nil (mapcar (lambda (file-cons)
- (unless (string-match
- jump-ignore-file-regexp (cdr file-cons)) file-cons))
- files)))
-
-(defun jump-to-file (&optional file)
- "Open the file located at file if file ends in a / then look in
-the related directory, and if file contains regexps then select
-from all matches."
- (interactive "Mfile: ")
- (let ((file-cons (cons (file-name-nondirectory file) file))
- file-alist)
- (if (and (equal (file-name-directory file) file) (file-exists-p file))
- (jump-find-file-in-dir (expand-file-name file root)) ;; open directory
- (if (file-exists-p file)
- (find-file file) ;; open file
- (jump-select-and-find-file ;; open with regexp
- (jump-remove-unwanted-files
- (mapcar (lambda (file)
- (let ((file-cons (cons (file-name-nondirectory file)
- (expand-file-name file))))
- (when (assoc (car file-cons) file-alist)
- (jump-uniqueify (assoc (car file-cons) file-alist))
- (jump-uniqueify file-cons))
- (add-to-list 'file-alist file-cons)
- file-cons))
- (findr (car file-cons)
- (expand-file-name (or (file-name-directory
- (cdr file-cons)) "") root)))))))))
-
-(defun jump-to-method (&optional method)
- "If `jump-method' returns method in buffer, go to the first
-line inside of method."
- (interactive "Mmethod: ")
- (goto-char (point-min))
- (let (results)
- (while (not (setf results
- (or (string-equal (jump-method) method)
- (and (> (forward-line 1) 0)
- (goto-char (point-min)))))))
- (when (and (commandp 'recenter-top-bottom) (not (equal results 1))) (recenter-top-bottom))))
-
-(defun jump-to-path (path)
- "Jump to the location specified by PATH (regexp allowed in
-path). If path ends in / then just look in that directory"
- (let ((file path)
- method)
- (when (string-match "^\\(.*\\)#\\(.*\\)$" path)
- (setf method (match-string 2 path))
- (setf file (match-string 1 path)))
- (when (jump-to-file file) ;; returns t as long as a file was found
- (when method (jump-to-method method))
- t)))
-
-(defun jump-insert-matches (spec matches)
- (if matches
- (let ((count 1) (new-spec spec) (spec nil))
- (while (not (equal spec new-spec))
- (setf spec new-spec)
- (setf new-spec
- (replace-regexp-in-string (format "\\\\%d" count)
- (or (nth (- count 1) matches) ".*?")
- spec))
- (setf count (+ 1 count)))
- new-spec) spec))
-
-(defun jump-inflections (terms)
- "Return all combinations of the singular and pluralizations of TERMS."
- (let ((terms (mapcar
- (lambda (term)
- (delete-dups (list term
- (singularize-string term)
- (pluralize-string term))))
- terms))
- results interum-results)
- (dolist (group terms)
- (dolist (term group)
- (if results
- (dolist (combination results)
- (setf interum-results (cons
- (cons term combination)
- interum-results)))
- (setf interum-results (cons (list term) interum-results))))
- (setf results interum-results)
- (setf interum-results nil))
- (mapcar 'reverse results)))
-
-(defun jump-to-all-inflections (spec matches)
- (let (status) ;; TODO maybe try file first and method second
- (loop for path in (mapcar (lambda (option)
- (jump-insert-matches spec option))
- (jump-inflections matches))
- until (setf status (jump-to-path path)))
- status))
-
-(defun jump-to (spec &optional matches make)
- "Jump to a spot defined by SPEC. If optional argument MATCHES
-replace all '\\n' portions of SPEC with the nth (1 indexed)
-element of MATCHES. If optional argument MAKE, then create the
-target file if it doesn't exist, if MAKE is a function then use
-MAKE to create the target file."
- (if (functionp spec) (eval (list spec matches)) ;; custom function in spec
- (let ((path (jump-insert-matches spec matches)))
- (if (not (or (jump-to-path path)
- (and matches (jump-to-all-inflections spec matches))))
- (when make (message (format "making %s" path))
- (let ((path (if (or (string-match "^\\(.*?\\)\\.\\*" path)
- (string-match "^\\(.*/\\)$" path))
- (read-from-minibuffer "create " (match-string 1 path))
- path)))
- (when (functionp make) (eval (list make path)))
- (find-file (concat root (if (string-match "^\\(.*\\)#" path)
- (match-string 1 path) path)))))
- t))))
-
-(defun jump-from (spec)
- "Match SPEC to the current location returning a list of any matches"
- (cond ((stringp spec)
- (let* ((file (or (and (buffer-file-name)
- (expand-file-name (buffer-file-name)))
- (buffer-name)))
- (method (jump-method))
- (path (if (string-match "#.+" spec)
- (concat file "#" method)
- file)))
- (and (string-match spec path)
- (or (let ((counter 1) mymatch matches)
- (while (setf mymatch (match-string counter path))
- (setf matches (cons mymatch matches))
- (setf counter (+ 1 counter)))
- (reverse matches)) t))))
- ((functionp spec) (eval (list spec)))
- ((equal t spec) t)
- (t (message (format "unrecognized jump-from specification format %s")))))
-
-(defun defjump (name specs root &optional doc make method-command)
- "Define NAME as a function with behavior determined by SPECS.
-SPECS should be a list of cons cells of the form
-
- (jump-from-spec . jump-to-spec)
-
-NAME will then try subsequent jump-from-specs until one succeeds,
-at which point any resulting match information, along with the
-related jump-to-spec will be used to jump to the intended buffer.
-See `jump-to' and `jump-from' for information on spec
-construction.
-
-ROOT should specify the root of the project in which all jumps
-take place, it can be either a string directory path, or a
-function returning
-
-Optional argument DOC specifies the documentation of the
-resulting function.
-
-Optional argument MAKE can be used to specify that missing files
-should be created. If MAKE is a function then it will be called
-with the file path as it's only argument. After possibly calling
-MAKE `find-file' will be used to open the path.
-
-Optional argument METHOD-COMMAND overrides the function used to
-find the current method which defaults to `which-function'."
- (eval
- `(defun ,name (&optional create) ,(concat doc "\n\nautomatically created by `defjump'")
- (interactive "P")
- (let ((root ,(if (functionp root) `(,root) root))
- (method-command (quote ,(or method-command 'which-function)))
- matches)
- (loop ;; try every rule in mappings
- for spec in (quote ,(mapcar
- (lambda (spec)
- (if (stringp (car spec))
- (cons (replace-regexp-in-string
- "\\\\[[:digit:]]+" "\\\\(.*?\\\\)"
- (car spec)) (cdr spec))
- spec))
- specs))
- ;; don't stop until both the front and the back match
- ;;
- ;; the back should match if the user is presented with a list
- ;; of files, or a single file is jumped to
- until (and (setf matches (jump-from (car spec)))
- (cond
- ((equal t matches)
- (jump-to (cdr spec) nil (if create (quote ,make))))
- ((consp matches)
- (jump-to (cdr spec) matches (if create (quote ,make)))))))))))
-
-(provide 'jump)
-;;; jump.el ends here
View
605 elpa-to-submit/rinari.el
@@ -1,605 +0,0 @@
-;;; rinari.el --- Rinari Is Not A Rails IDE
-
-;; Copyright (C) 2008 Phil Hagelberg, Eric Schulte
-
-;; Authors: Phil Hagelberg, Eric Schulte
-;; URL: http://rinari.rubyforge.org
-;; Version: 2.0
-;; Created: 2006-11-10
-;; Keywords: ruby, rails, project, convenience, web
-;; EmacsWiki: Rinari
-;; Package-Requires: ((ruby-mode "1.0")
-;; (inf-ruby "2.0")
-;; (ruby-compilation "0.5")
-;; (jump "2.0"))
-
-;; This file is NOT part of GNU Emacs.
-
-;;; License:
-
-;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-;;; Commentary:
-
-;; Rinari Is Not A Ruby IDE.
-
-;; Well, ok it kind of is. Rinari is a set of Emacs Lisp modes that is
-;; aimed towards making Emacs into a top-notch Ruby and Rails
-;; development environment.
-
-;; Copy the directory containing this file into your Emacs lisp
-;; directory, assumed here to be ~/.emacs.d. Add these lines of code
-;; to your .emacs file:
-
-;; ;; ido
-;; (require 'ido)
-;; (ido-mode t)
-;; ;; rinari
-;; (add-to-list 'load-path "~/.emacs.d/rinari")
-;; (require 'rinari)
-
-;; Note: if you cloned this from a git repo, you probably have to grab
-;; the submodules which can be done simply with the following commands
-;; from the root of the rinari directory
-
-;; git submodule init
-;; git submodule update
-
-;; See TODO file in this directory.
-
-;;; Code:
-(let* ((this-dir (file-name-directory (or load-file-name buffer-file-name)))
- (util-dir (file-name-as-directory
- (expand-file-name "util" this-dir)))
- (jump-dir (file-name-as-directory
- (expand-file-name "jump" util-dir))))
- (add-to-list 'load-path this-dir)
- (add-to-list 'load-path util-dir)
- (add-to-list 'load-path jump-dir))
-(require 'ruby-mode)
-(require 'inf-ruby)
-(require 'ruby-compilation)
-(require 'jump)
-(require 'cl)
-
-(defcustom rinari-tags-file-name
- "TAGS"
- "Path to your TAGS file inside of your rails project. See `tags-file-name'."
- :group 'rinari)
-
-(defvar rinari-minor-mode-hook nil
- "*Hook for customising Rinari.")
-
-(defcustom rinari-rails-env nil
- "Use this to force a value for RAILS_ENV when running rinari.
-Leave this set to nil to not force any value for RAILS_ENV, and
-leave this to the environment variables outside of Emacs.")
-
-(defadvice ruby-compilation-do (around rinari-compilation-do activate)
- "Set default directory to the root of the rails application
- before running ruby processes."
- (let ((default-directory (or (rinari-root) default-directory)))
- ad-do-it
- (rinari-launch)))
-
-(defadvice ruby-compilation-rake (around rinari-compilation-rake activate)
- "Set default directory to the root of the rails application
- before running rake processes."
- (let ((default-directory (or (rinari-root) default-directory)))
- ad-do-it
- (rinari-launch)))
-
-(defun rinari-parse-yaml ()
- (let ((start (point))
- (end (save-excursion (re-search-forward "^[^:]*$" nil t) (point)))
- alist)
- (while (and (< (point) end)
- (re-search-forward "^ *\\(.*\\): \\(.*\\)$" nil t))
- (setf alist (cons (cons (match-string 1) (match-string 2)) alist)))
- alist))
-
-(defun rinari-root (&optional dir home)
- (or dir (setq dir default-directory))
- (if (file-exists-p (expand-file-name
- "environment.rb" (expand-file-name "config" dir)))
- dir
- (let ((new-dir (expand-file-name (file-name-as-directory "..") dir)))
- ;; regexp to match windows roots, tramp roots, or regular posix roots
- (unless (string-match "\\(^[[:alpha:]]:/$\\|^/[^\/]+:\\|^/$\\)" dir)
- (rinari-root new-dir)))))
-
-;;--------------------------------------------------------------------------------
-;; user functions
-
-(defun rinari-rake (&optional task edit-cmd-args)
- "Tab completion selection of a rake task to execute with the
-output dumped to a compilation buffer allowing jumping between
-errors and source code. With optional prefix argument allows
-editing of the rake command arguments."
- (interactive "P")
- (ruby-compilation-rake task edit-cmd-args
- (if rinari-rails-env (list (cons "RAILS_ENV" rinari-rails-env)))))
-
-(defun rinari-script (&optional script)
- "Tab completing selection of a script from the script/
-directory of the rails application."
- (interactive)
- (let* ((root (rinari-root))
- (script (or script
- (completing-read "Script: " (directory-files (concat root "script") nil "^[^.]"))))
- (ruby-compilation-error-regexp-alist ;; for jumping to newly created files
- (if (equal script "generate")
- '(("^ +\\(exists\\|create\\) +\\([^[:space:]]+\\.rb\\)" 2 3))
- ruby-compilation-error-regexp-alist))
- (script (concat "script/" script " ")))
- (ruby-compilation-run (concat root script (read-from-minibuffer script)))))
-
-(defun rinari-test (&optional edit-cmd-args)
- "Test the current ruby function. If current function is not a
-test, then try to jump to the related test using
-`rinari-find-test'. Dump output to a compilation buffer allowing
-jumping between errors and source code. With optional prefix
-argument allows editing of the test command arguments."
- (interactive "P")
- (or (string-match "test" (or (ruby-add-log-current-method)
- (file-name-nondirectory (buffer-file-name))))
- (rinari-find-test))
- (let* ((funname (ruby-add-log-current-method))
- (fn (and funname
- (string-match "#\\(.*\\)" funname)
- (match-string 1 funname)))
- (path (buffer-file-name))
- (default-command (if fn
- (concat path " --name /" fn "/")
- path))
- (command (if edit-cmd-args
- (read-string "Run w/Compilation: " default-command)
- default-command)))
- (if path (ruby-compilation-run command)
- (message "no test available"))))
-
-(defun rinari-console (&optional edit-cmd-args)
- "Run script/console in a compilation buffer, with command
-history and links between errors and source code. With optional
-prefix argument allows editing of the console command arguments."
- (interactive "P")
- (let* ((script ;; (concat (rinari-root) "script/console")
- (concat (expand-file-name "console" (file-name-as-directory
- (expand-file-name "script" (rinari-root))))
- (if rinari-rails-env (concat " " rinari-rails-env))))
- (command (if edit-cmd-args
- (read-string "Run Ruby: " (concat script " "))
- script)))
- (run-ruby command)
- (save-excursion
- (set-buffer "*ruby*")
- (set (make-local-variable 'inf-ruby-first-prompt-pattern) "^>> ")
- (set (make-local-variable 'inf-ruby-prompt-pattern) "^>> ")
- (rinari-launch))))
-
-(defun rinari-sql ()
- "Browse the application's database. Looks up login information
-from your conf/database.sql file."
- (interactive)
- (flet ((sql-name (env) (format "*%s-sql*" env)))
- (let* ((environment (or rinari-rails-env (getenv "RAILS_ENV") "development"))
- (sql-buffer (get-buffer (sql-name environment))))
- (if sql-buffer
- (pop-to-buffer sql-buffer)
- (let* ((database-alist (save-excursion
- (with-temp-buffer
- (insert-file-contents
- (expand-file-name
- "database.yml"
- (file-name-as-directory
- (expand-file-name "config" (rinari-root)))))
- (goto-char (point-min))
- (re-search-forward (concat "^" environment ":"))
- (rinari-parse-yaml))))
- (adapter (or (cdr (assoc "adapter" database-alist)) "sqlite"))
- (sql-user (or (cdr (assoc "username" database-alist)) "root"))
- (sql-password (or (cdr (assoc "password" database-alist)) ""))
- (sql-password (if (> (length sql-password) 0) sql-password nil))
- (sql-database (or (cdr (assoc "database" database-alist))
- (concat (file-name-nondirectory (rinari-root))
- "_" environment)))
- (server (or (cdr (assoc "host" database-alist)) "localhost"))
- (port (cdr (assoc "port" database-alist)))
- (sql-server (if port (concat server ":" port) server)))
- (if (string-match "sqlite" adapter) (setf adapter "sqlite"))
- (eval (list (intern (concat "sql-" adapter))))
- (rename-buffer (sql-name environment)) (rinari-launch))))))
-
-(defun rinari-web-server (&optional edit-cmd-args)
- "Run script/server. Dump output to a compilation buffer
-allowing jumping between errors and source code. With optional
-prefix argument allows editing of the server command arguments."
- (interactive "P")
- (let* ((default-directory (rinari-root))
- (script (concat (expand-file-name "server"
- (file-name-as-directory
- (expand-file-name "script" (rinari-root))))
- (if rinari-rails-env (concat " -e " rinari-rails-env))))
- (command (if edit-cmd-args
- (read-string "Run Ruby: " (concat script " "))
- script)))
- (ruby-compilation-run command)) (rinari-launch))
-
-(defun rinari-insert-erb-skeleton (no-equals)
- "Insert an erb skeleton at point, with optional prefix argument
-don't include an '='."
- (interactive "P")
- (insert "<%") (if no-equals (insert " -") (insert "= ")) (insert "%>")
- (if no-equals (backward-char 4) (backward-char 3)))
-
-(defun rinari-extract-partial (begin end partial-name)
- (interactive "r\nsName your partial: ")
- (let* ((path (buffer-file-name)) ending)
- (if (string-match "view" path)
- (let ((ending (and (string-match ".+?\\(\\..*\\)" path)
- (match-string 1 path)))
- (partial-name
- (replace-regexp-in-string "[[:space:]]+" "_" partial-name)))
- (kill-region begin end)
- (if (string-match "\\(.+\\)/\\(.+\\)" partial-name)
- (let ((default-directory (expand-file-name (match-string 1 partial-name)
- (expand-file-name ".."))))
- (find-file (concat "_" (match-string 2 partial-name) ending)))
- (find-file (concat "_" partial-name ending)))
- (yank) (pop-to-buffer nil)
- (insert (concat "<%= render :partial => '" partial-name "' %>\n")))
- (message "not in a view"))))
-
-(defvar rinari-rgrep-file-endings
- "*.[^l]*"
- "Ending of files to search for matches using `rinari-rgrep'")
-
-(defun rinari-rgrep (&optional arg)
- "Search through the rails project for a string or `regexp'.
-With optional prefix argument just run `rgrep'."
- (interactive "P")
- (grep-compute-defaults)
- (if arg (call-interactively 'rgrep)
- (let ((word (thing-at-point 'word)))
- (funcall 'rgrep (read-from-minibuffer "search for: " word)
- rinari-rgrep-file-endings (rinari-root)))))
-
-;;--------------------------------------------------------------------
-;; rinari movement using jump.el
-
-(defun rinari-generate (type name)
- (message (shell-command-to-string
- (format "ruby %sscript/generate %s %s" (rinari-root) type
- (read-from-minibuffer (format "create %s: " type) name)))))
-
-(defvar rinari-ruby-hash-regexp
- "\\(:[^[:space:]]*?\\)[[:space:]]*\\(=>[[:space:]]*[\"\':]?\\([^[:space:]]*?\\)[\"\']?[[:space:]]*\\)?[,){}\n]"
- "Regexp to match subsequent key => value pairs of a ruby hash.")
-
-(defun rinari-ruby-values-from-render (controller action)
- "Adjusts CONTROLLER and ACTION acording to keyword arguments in
-the hash at `point', then return (CONTROLLER . ACTION)"
- (let ((end (save-excursion
- (re-search-forward "[^,{(]$" nil t)
- (+ 1 (point)))))
- (save-excursion
- (while (and (< (point) end)
- (re-search-forward rinari-ruby-hash-regexp end t))
- (if (> (length (match-string 3)) 1)
- (case (intern (match-string 1))
- (:partial
- (let ((partial (match-string 3)))
- (if (string-match "\\(.+\\)/\\(.+\\)" partial)
- (progn
- (setf controller (match-string 1 partial))
- (setf action (concat "_" (match-string 2 partial))))
- (setf action (concat "_" partial)))))
- (:action (setf action (match-string 3)))
- (:controller (setf controller (match-string 3)))))))
- (cons controller action)))
-
-(defun rinari-which-render (renders)
- (let ((path (jump-completing-read
- "Follow: "
- (mapcar (lambda (lis)
- (concat (car lis) "/" (cdr lis)))
- renders))))
- (string-match "\\(.*\\)/\\(.*\\)" path)
- (cons (match-string 1 path) (match-string 2 path))))
-
-(defun rinari-follow-controller-and-action (controller action)
- "Follow the current controller-and-action through all of the
-renders and redirects to find the final controller or view."
- (save-excursion ;; if we can find the controller#action pair
- (if (and (jump-to-path (format "app/controllers/%s_controller.rb#%s" controller action))
- (equalp (jump-method) action))
- (let ((start (point)) ;; demarcate the borders
- (renders (list (cons controller action))) render view)
- (ruby-forward-sexp)
- ;; collect redirection options and pursue
- (while (re-search-backward "re\\(?:direct_to\\|nder\\)" start t)
- (add-to-list 'renders (rinari-ruby-values-from-render controller action)))
- (let ((render (if (equalp 1 (length renders))
- (car renders)
- (rinari-which-render renders))))
- (if (and (equalp (cdr render) action)
- (equalp (car render) controller))
- (list controller action) ;; directed to here so return
- (rinari-follow-controller-and-action (or (car render)
- controller)
- (or (cdr render)
- action)))))
- ;; no controller entry so return
- (list controller action))))
-
-(setf
- rinari-jump-schema
- '((model
- "m"
- (("app/controllers/\\1_controller.rb#\\2" . "app/models/\\1.rb#\\2")
- ("app/views/\\1/.*" . "app/models/\\1.rb")
- ("app/helpers/\\1_helper.rb" . "app/models/\\1.rb")
- ("db/migrate/.*create_\\1.rb" . "app/models/\\1.rb")
- ("spec/models/\\1_spec.rb" . "app/models/\\1.rb")
- ("spec/controllers/\\1_controller_spec.rb". "app/models/\\1.rb")
- ("spec/views/\\1/.*" . "app/models/\\1.rb")
- ("spec/fixtures/\\1.yml" . "app/models/\\1.rb")
- ("test/functional/\\1_controller_test.rb" . "app/models/\\1.rb")
- ("test/unit/\\1_test.rb#test_\\2" . "app/models/\\1.rb#\\2")
- ("test/unit/\\1_test.rb" . "app/models/\\1.rb")
- ("test/fixtures/\\1.yml" . "app/models/\\1.rb")
- (t . "app/models/"))
- (lambda (path)
- (rinari-generate "model"
- (and (string-match ".*/\\(.+?\\)\.rb" path)
- (match-string 1 path)))))
- (controller
- "c"
- (("app/models/\\1.rb" . "app/controllers/\\1_controller.rb")
- ("app/views/\\1/\\2\\..*" . "app/controllers/\\1_controller.rb#\\2")
- ("app/helpers/\\1_helper.rb" . "app/controllers/\\1_controller.rb")
- ("db/migrate/.*create_\\1.rb" . "app/controllers/\\1_controller.rb")
- ("spec/models/\\1_spec.rb" . "app/controllers/\\1_controller.rb")
- ("spec/controllers/\\1_spec.rb" . "app/controllers/\\1.rb")
- ("spec/views/\\1/\\2\\.*_spec.rb" . "app/controllers/\\1_controller.rb#\\2")
- ("spec/fixtures/\\1.yml" . "app/controllers/\\1_controller.rb")
- ("test/functional/\\1_test.rb#test_\\2" . "app/controllers/\\1.rb#\\2")
- ("test/functional/\\1_test.rb" . "app/controllers/\\1.rb")
- ("test/unit/\\1_test.rb#test_\\2" . "app/controllers/\\1_controller.rb#\\2")
- ("test/unit/\\1_test.rb" . "app/controllers/\\1_controller.rb")
- ("test/fixtures/\\1.yml" . "app/controllers/\\1_controller.rb")
- (t . "app/controllers/"))
- (lambda (path)
- (rinari-generate "controller"
- (and (string-match ".*/\\(.+?\\)_controller\.rb" path)
- (match-string 1 path)))))
- (view
- "v"
- (("app/models/\\1.rb" . "app/views/\\1/.*")
- ((lambda () ;; find the controller/view
- (let* ((raw-file (and (buffer-file-name)
- (file-name-nondirectory (buffer-file-name))))
- (file (and raw-file
- (string-match "^\\(.*\\)_controller.rb" raw-file)
- (match-string 1 raw-file))) ;; controller
- (raw-method (ruby-add-log-current-method))
- (method (and file raw-method ;; action
- (string-match "#\\(.*\\)" raw-method)
- (match-string 1 raw-method))))
- (if (and file method) (rinari-follow-controller-and-action file method))))
- . "app/views/\\1/\\2.*")
- ("app/controllers/\\1_controller.rb" . "app/views/\\1/.*")
- ("app/helpers/\\1_helper.rb" . "app/views/\\1/.*")
- ("db/migrate/.*create_\\1.rb" . "app/views/\\1/.*")
- ("spec/models/\\1_spec.rb" . "app/views/\\1/.*")
- ("spec/controllers/\\1_spec.rb" . "app/views/\\1/.*")
- ("spec/views/\\1/\\2_spec.rb" . "app/views/\\1/\\2.*")
- ("spec/fixtures/\\1.yml" . "app/views/\\1/.*")
- ("test/functional/\\1_controller_test.rb" . "app/views/\\1/.*")
- ("test/unit/\\1_test.rb#test_\\2" . "app/views/\\1/_?\\2.*")
- ("test/fixtures/\\1.yml" . "app/views/\\1/.*")
- (t . "app/views/.*"))
- t)
- (test
- "t"
- (("app/models/\\1.rb#\\2" . "test/unit/\\1_test.rb#test_\\2")
- ("app/controllers/\\1.rb#\\2" . "test/functional/\\1_test.rb#test_\\2")
- ("app/views/\\1/_?\\2\\..*" . "test/functional/\\1_controller_test.rb#test_\\2")
- ("app/helpers/\\1_helper.rb" . "test/functional/\\1_controller_test.rb")
- ("db/migrate/.*create_\\1.rb" . "test/unit/\\1_test.rb")
- ("test/functional/\\1_controller_test.rb" . "test/unit/\\1_test.rb")
- ("test/unit/\\1_test.rb" . "test/functional/\\1_controller_test.rb")
- (t . "test/.*"))
- t)
- (rspec
- "r"
- (("app/\\1\\.rb" . "spec/\\1_spec.rb")
- ("app/\\1" . "spec/\\1_spec.rb")
- ("spec/views/\\1_spec.rb" . "app/views/\\1")
- ("spec/\\1_spec.rb" . "app/\\1.rb")
- (t . "spec/.*"))
- t)
- (fixture
- "x"
- (("app/models/\\1.rb" . "test/fixtures/\\1.yml")
- ("app/controllers/\\1_controller.rb" . "test/fixtures/\\1.yml")
- ("app/views/\\1/.*" . "test/fixtures/\\1.yml")
- ("app/helpers/\\1_helper.rb" . "test/fixtures/\\1.yml")
- ("db/migrate/.*create_\\1.rb" . "test/fixtures/\\1.yml")
- ("spec/models/\\1_spec.rb" . "test/fixtures/\\1.yml")
- ("spec/controllers/\\1_controller_spec.rb". "test/fixtures/\\1.yml")
- ("spec/views/\\1/.*" . "test/fixtures/\\1.yml")
- ("test/functional/\\1_controller_test.rb" . "test/fixtures/\\1.yml")
- ("test/unit/\\1_test.rb" . "test/fixtures/\\1.yml")
- (t . "test/fixtures/"))
- t)
- (rspec-fixture
- "z"
- (("app/models/\\1.rb" . "spec/fixtures/\\1.yml")
- ("app/controllers/\\1_controller.rb" . "spec/fixtures/\\1.yml")
- ("app/views/\\1/.*" . "spec/fixtures/\\1.yml")
- ("app/helpers/\\1_helper.rb" . "spec/fixtures/\\1.yml")
- ("db/migrate/.*create_\\1.rb" . "spec/fixtures/\\1.yml")
- ("spec/models/\\1_spec.rb" . "spec/fixtures/\\1.yml")
- ("spec/controllers/\\1_controller_spec.rb". "spec/fixtures/\\1.yml")
- ("spec/views/\\1/.*" . "spec/fixtures/\\1.yml")
- ("test/functional/\\1_controller_test.rb" . "spec/fixtures/\\1.yml")
- ("test/unit/\\1_test.rb" . "spec/fixtures/\\1.yml")
- (t . "spec/fixtures/"))
- t)
- (helper
- "h"
- (("app/models/\\1.rb" . "app/helpers/\\1_helper.rb")
- ("app/controllers/\\1_controller.rb" . "app/helpers/\\1_helper.rb")
- ("app/views/\\1/.*" . "app/helpers/\\1_helper.rb")
- ("app/helpers/\\1_helper.rb" . "app/helpers/\\1_helper.rb")
- ("db/migrate/.*create_\\1.rb" . "app/helpers/\\1_helper.rb")
- ("spec/models/\\1_spec.rb" . "app/helpers/\\1_helper.rb")
- ("spec/controllers/\\1_spec.rb" . "app/helpers/\\1_helper.rb")
- ("spec/views/\\1/.*" . "app/helpers/\\1_helper.rb")
- ("test/functional/\\1_controller_test.rb" . "app/helpers/\\1_helper.rb")
- ("test/unit/\\1_test.rb#test_\\2" . "app/helpers/\\1_helper.rb#\\2")
- ("test/unit/\\1_test.rb" . "app/helpers/\\1_helper.rb")
- (t . "app/helpers/"))
- t)
- (migration
- "i"
- (("app/controllers/\\1_controller.rb" . "db/migrate/.*create_\\1.rb")
- ("app/views/\\1/.*" . "db/migrate/.*create_\\1.rb")
- ("app/helpers/\\1_helper.rb" . "db/migrate/.*create_\\1.rb")
- ("app/models/\\1.rb" . "db/migrate/.*create_\\1.rb")
- ("spec/models/\\1_spec.rb" . "db/migrate/.*create_\\1.rb")
- ("spec/controllers/\\1_spec.rb" . "db/migrate/.*create_\\1.rb")
- ("spec/views/\\1/.*" . "db/migrate/.*create_\\1.rb")
- ("test/functional/\\1_controller_test.rb" . "db/migrate/.*create_\\1.rb")
- ("test/unit/\\1_test.rb#test_\\2" . "db/migrate/.*create_\\1.rb#\\2")
- ("test/unit/\\1_test.rb" . "db/migrate/.*create_\\1.rb")
- (t . "db/migrate/"))
- (lambda (path)
- (rinari-generate "migration"
- (and (string-match ".*create_\\(.+?\\)\.rb" path)
- (match-string 1 path)))))
- (environment "e" ((t . "config/environments/")) nil)
- (configuration "n" ((t . "config/")) nil)
- (script "s" ((t . "script/")) nil)
- (lib "l" ((t . "lib/")) nil)
- (log "o" ((t . "log/")) nil)
- (worker "w" ((t . "lib/workers/")) nil)
- (public "p" ((t . "public/")) nil)
- (stylesheet "y" ((t . "public/stylesheets/.*")) nil)
- (javascript "j" ((t . "public/javascripts/.*")) nil)
- (plugin "u" ((t . "vendor/plugins/")) nil)
- (file-in-project "f" ((t . ".*")) nil)
- (by-context
- ";"
- (((lambda () ;; Find-by-Context
- (let ((path (buffer-file-name))
- cv)
- (when (string-match ".*/\\(.+?\\)/\\(.+?\\)\\..*" path)
- (setf cv (cons (match-string 1 path) (match-string 2 path)))
- (when (re-search-forward "<%=[ \n\r]*render(? *" nil t)
- (setf cv (rinari-ruby-values-from-render (car cv) (cdr cv)))
- (list (car cv) (cdr cv))))))
- . "app/views/\\1/\\2.*")))))
-
-(defun rinari-apply-jump-schema (schema)
- "This function takes a of SCHEMA s.t. each element in the list
-can be fed to `defjump'. This is used to define all of the
-rinari-find-* functions, and can be used to customize their
-behavior."
- (mapcar
- (lambda (type)
- (let ((name (first type))
- (specs (third type))
- (make (fourth type)))
- (eval `(defjump
- (quote ,(read (format "rinari-find-%S" name)))
- (quote ,specs)
- 'rinari-root
- ,(format "Go to the most logical %S given the current location" name)
- ,(if make `(quote ,make))
- 'ruby-add-log-current-method))))
- schema))
-(rinari-apply-jump-schema rinari-jump-schema)
-
-;;--------------------------------------------------------------------
-;; minor mode and keymaps
-
-(defvar rinari-minor-mode-map
- (let ((map (make-sparse-keymap)))
- map)
- "Key map for Rinari minor mode.")
-
-(defun rinari-bind-key-to-func (key func)
- (eval `(define-key rinari-minor-mode-map
- ,(format "\C-c;%s" key) ,func))
- (eval `(define-key rinari-minor-mode-map
- ,(format "\C-c'%s" key) ,func)))
-
-(defvar rinari-minor-mode-keybindings
- '(("s" . 'rinari-script) ("q" . 'rinari-sql)
- ("e" . 'rinari-insert-erb-skeleton) ("t" . 'rinari-test)
- ("r" . 'rinari-rake) ("c" . 'rinari-console)
- ("w" . 'rinari-web-server) ("g" . 'rinari-rgrep)
- ("x" . 'rinari-extract-partial)
- (";" . 'rinari-find-by-context) ("'" . 'rinari-find-by-context))
- "alist mapping of keys to functions in `rinari-minor-mode'")
-
-(mapcar (lambda (el) (rinari-bind-key-to-func (car el) (cdr el)))
- (append (mapcar (lambda (el)
- (cons (concat "f" (second el))
- (read (format "'rinari-find-%S" (first el)))))
- rinari-jump-schema)
- rinari-minor-mode-keybindings))
-
-;;;###autoload
-(defun rinari-launch ()
- "Run `rinari-minor-mode' if inside of a rails projecct,
-otherwise turn `rinari-minor-mode' off if it is on."
- (interactive)
- (let* ((root (rinari-root)) (r-tags-path (concat root rinari-tags-file-name)))
- (if root (progn
- (set (make-local-variable 'tags-file-name)
- (and (file-exists-p r-tags-path) r-tags-path))
- (run-hooks 'rinari-minor-mode-hook)
- (rinari-minor-mode t))
- (if (and (fboundp rinari-minor-mode) rinari-nimor-mode) (rinari-minor-mode)))))
-
-;;;###autoload
-(defvar rinari-major-modes
- (if (boundp 'rinari-major-modes)
- rinari-major-modes
- (list 'find-file-hook 'mumamo-after-change-major-mode-hook 'dired-mode-hook))
- "Major Modes from which to launch Rinari.")
-
-;;;###autoload
-(dolist (hook rinari-major-modes) (add-hook hook 'rinari-launch))
-
-(defadvice cd (after rinari-on-cd activate)
- "Active/Deactive rinari-minor-node when changing into and out
- of raills project directories."
- (rinari-launch))
-
-;;;###autoload
-(define-minor-mode rinari-minor-mode
- "Enable Rinari minor mode providing Emacs support for working
-with the Ruby on Rails framework."
- nil
- " Rinari"
- rinari-minor-mode-map)
-
-(provide 'rinari)
-;;; rinari.el ends here
View
206 elpa-to-submit/ruby-compilation.el
@@ -1,206 +0,0 @@
-;;; ruby-compilation.el --- run a ruby process in a compilation buffer
-
-;; Copyright (C) 2008 Eric Schulte
-
-;; Author: Eric Schulte
-;; URL: http://www.emacswiki.org/cgi-bin/emacs/ruby-compilation.el
-;; Version: 0.5
-;; Created: 2008-08-23
-;; Keywords: test convenience
-;; Package-Requires: (("ruby-mode") ("inf-ruby"))
-
-;;; License:
-
-;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-;;; Commentary:
-
-;; Allow for execution of ruby processes dumping the results into a
-;; compilation buffer. Useful for executing tests, or rake tasks
-;; where the ability to jump to errors in source code is desirable.
-;;
-;; The functions you will probably want to use are
-;;
-;; ruby-compilation-run
-;; ruby-compilation-rake
-;; ruby-compilation-this-buffer (C-x t)
-;; ruby-compilation-this-buffer (C-x C-t)
-;;
-
-;;; TODO:
-
-;; Clean up function names so they use a common prefix.
-;; "p" doesn't work at the end of the compilation buffer.
-;; Package it up with dependencies for ELPA.
-
-;;; Code:
-
-(require 'ansi-color)
-(require 'pcmpl-rake)
-(require 'compile)
-(require 'inf-ruby)
-(require 'which-func)
-
-(defvar ruby-compilation-error-regexp
- "^\\([[:space:]]*\\|.*\\[\\|[^\*].*at \\)\\[?\\([^[:space:]]*\\):\\([[:digit:]]+\\)[]:)\n]?"
- "regular expression to match errors in ruby process output")
-
-(defvar ruby-compilation-error-regexp-alist
- `((,ruby-compilation-error-regexp 2 3))
- "a version of `compilation-error-regexp-alist' to be used in
- rails logs (should be used with `make-local-variable')")
-
-(defvar ruby-compilation-executable "ruby"
- "What bin to use to launch the tests. Override if you use JRuby etc.")
-
-(defvar ruby-compilation-test-name-flag "-n"
- "What flag to use to specify that you want to run a single test.")
-
-(defvar ruby-compilation-clear-between t
- "Whether to clear the compilation output between runs.")
-
-(defun ruby-compilation-run (cmd)
- "Run a ruby process dumping output to a ruby compilation buffer."
- (interactive "FRuby Comand: ")
- (let ((name (file-name-nondirectory (car (split-string cmd))))
- (cmdlist (cons ruby-compilation-executable
- (split-string (expand-file-name cmd)))))
- (pop-to-buffer (ruby-compilation-do name cmdlist))))
-
-(defun ruby-compilation-rake (&optional edit task)
- "Run a rake process dumping output to a ruby compilation buffer."
- (interactive "P")
- (let* ((task (or task (if (stringp edit) edit)
- (completing-read "Rake: " (pcmpl-rake-tasks))))
- (rake-args (if (and edit (not (stringp edit)))
- (read-from-minibuffer "Edit Rake Command: " (concat task " "))
- task)))
- (pop-to-buffer (ruby-compilation-do
- "rake" (cons "rake"
- (split-string rake-args))))))
-
-(defun ruby-compilation-this-buffer ()
- "Run the current buffer through Ruby compilation."
- (interactive)
- (ruby-compilation-run (buffer-file-name)))
-
-(defun ruby-compilation-this-test ()
- "Run the test at point through Ruby compilation."
- (interactive)
- (let ((test-name (ruby-compilation-this-test-name)))
- (pop-to-buffer (ruby-compilation-do
- (format "ruby: %s - %s"
- (file-name-nondirectory (buffer-file-name))
- test-name)
- (list ruby-compilation-executable
- (buffer-file-name)
- ruby-compilation-test-name-flag test-name)))))
-
-(defun ruby-compilation-this-test-name ()
- "Which test are we currently in?"
- (let ((this-test (which-function)))
- (if (listp this-test) (setq this-test (car this-test)))
- (if (or (not this-test)
- (not (string-match "#test_" this-test)))
- (message "Point is not in a test.")
- (cadr (split-string this-test "#")))))
-
-(defun ruby-compilation-do (name cmdlist)
- (let ((comp-buffer-name (format "*%s*" name)))
- (unless (comint-check-proc comp-buffer-name)
- ;; (if (get-buffer comp-buffer-name) (kill-buffer comp-buffer-name)) ;; actually rather keep
- (let* ((buffer (apply 'make-comint name (car cmdlist) nil (cdr cmdlist)))
- (proc (get-buffer-process buffer)))
- (save-excursion
- (set-buffer buffer) ;; set buffer local variables and process ornaments
- (set-process-sentinel proc 'ruby-compilation-sentinel)
- (set-process-filter proc 'ruby-compilation-insertion-filter)
- (set (make-local-variable 'compilation-error-regexp-alist)
- ruby-compilation-error-regexp-alist)
- (set (make-local-variable 'kill-buffer-hook)
- (lambda ()
- (let ((orphan-proc (get-buffer-process (buffer-name))))
- (if orphan-proc
- (kill-process orphan-proc)))))
- (compilation-minor-mode t)
- (ruby-compilation-minor-mode t))))
- comp-buffer-name))
-
-(defun ruby-compilation-insertion-filter (proc string)
- "Insert text to buffer stripping ansi color codes"
- ;; Can we use ansi-color-apply-on-region instead?
- (with-current-buffer (process-buffer proc)
- (let ((moving (= (point) (process-mark proc))))
- (save-excursion
- (goto-char (process-mark proc))
- (insert (ansi-color-filter-apply string))
- (set-marker (process-mark proc) (point)))
- (if moving (goto-char (process-mark proc))))))
-
-(defun ruby-compilation-sentinel (proc msg)
- "Notify to changes in process state"
- (message "%s - %s" proc (replace-regexp-in-string "\n" "" msg)))
-
-(defun ruby-compilation-previous-error-group ()
- "Jump to the start of the previous error group in the current
-compilation buffer."
- (interactive)
- (compilation-previous-error 1)
- (while (string-match ruby-compilation-error-regexp (thing-at-point 'line))
- (forward-line -1))
- (forward-line 1) (recenter))
-
-(defun ruby-compilation-next-error-group ()
- "Jump to the start of the previous error group in the current
-compilation buffer."
- (interactive)
- (while (string-match ruby-compilation-error-regexp (thing-at-point 'line))
- (forward-line 1))
- (compilation-next-error 1) (recenter))
-
-(defvar ruby-compilation-minor-mode-map
- (let ((map (make-sparse-keymap)))
- (define-key map "q" 'quit-window)
- (define-key map "p" 'previous-error-no-select)
- (define-key map "n" 'next-error-no-select)
- (define-key map "\M-p" 'ruby-compilation-previous-error-group)
- (define-key map "\M-n" 'ruby-compilation-next-error-group)
- (define-key map (kbd "C-c C-c") 'comint-interrupt-subjob)
- map)
- "Key map for Ruby Compilation minor mode.")
-
-(define-minor-mode ruby-compilation-minor-mode
- "Enable Ruby Compilation minor mode providing some key-bindings
- for navigating ruby compilation buffers."
- nil
- " ruby:comp"
- ruby-compilation-minor-mode-map
- (when ruby-compilation-clear-between
- (delete-region (point-min) (point-max))))
-
-;; So we can invoke it easily.
-(eval-after-load 'ruby-mode
- '(progn
- (define-key ruby-mode-map (kbd "C-x t") 'ruby-compilation-this-buffer)
- (define-key ruby-mode-map (kbd "C-x C-t") 'ruby-compilation-this-test)))
-
-;; So we don't get warnings with .dir-settings.el files
-(dolist (executable (list "jruby" "rbx" "ruby1.9" "ruby1.8" "ruby"))
- (add-to-list 'safe-local-variable-values
- (cons 'ruby-compilation-executable executable)))
-
-(provide 'ruby-compilation)
-;;; ruby-compilation.el ends here
View
5 package.el
@@ -414,9 +414,8 @@ Recursively activates all dependencies of the named package."
(keep-going (or (not (memq package package-activated-list))
(package-version-compare this-version version '>))))
(while (and req-list keep-going)
- (or (package-activate (car (car req-list))
- (car (cdr (car req-list))))
- (setq keep-going nil))
+ (package-activate (car (car req-list))
+ (car (cdr (car req-list))))
(setq req-list (cdr req-list)))
(if keep-going
(package-do-activate package (cdr pkg-desc))))))
View
7 starter-kit-elpa.el
@@ -9,6 +9,7 @@
'css-mode
'nxml
'gist
+ 'rinari
;; To submit
;;; "magit"
;;; "paredit"
@@ -23,18 +24,12 @@
;;; "color-theme-vivid-chalk"
;; Complicated ones
;;; "nxhtml"
-;;; "rinari"
;;; "jabber"
;;; "slime"
;;; "swank-clojure"
)
"Libraries that should be installed by default.")
-;; Work around a bug in ELPA
-(ignore-errors (load "elpa/inf-ruby-2.0/inf-ruby-autoloads"))
-(ignore-errors (load "elpa/lisppaste-1.5/lisppaste-autoloads"))
-(add-to-list 'load-path (concat dotfiles-dir "elpa/lisppaste-1.5/"))
-
(defun starter-kit-elpa-install ()
"Install all starter-kit packages that aren't installed."
(interactive)
View
1  starter-kit-ruby.el
@@ -88,7 +88,6 @@ exec-to-string command, but it works and seems fast"
(setq rinari-major-modes
(list 'mumamo-after-change-major-mode-hook 'dired-mode-hook 'ruby-mode-hook
'css-mode-hook 'yaml-mode-hook 'javascript-mode-hook))
-(require 'rinari)
;; TODO: set up ri
;; TODO: electric

3 comments on commit da1a21b

@deepakjois
(require 'ruby-compilation)
in starter-kit-ruby.el is causing an error due to the removal of the file in this commit. For now, I have removes that piece of code. Any idea how i can fix it permanently.
@eschulte

ruby-compilation is now loaded through ELPA. Run `package-list-packages’ and install ruby-compilation through the ELPA interface.

@technomancy

This should be happening automatically, but something is screwed up. Sorry for the breakage; I will try to get this fixed tomorrow.

Please sign in to comment.
Something went wrong with that request. Please try again.