Skip to content

Commit

Permalink
Add support for expanding to ruby symbols, eg. :symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
magnars committed Jul 4, 2012
1 parent 2e889e3 commit ca212f6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ruby-mode-expansions.el
Expand Up @@ -44,6 +44,18 @@
(end-of-line) (end-of-line)
(exchange-point-and-mark)) (exchange-point-and-mark))


(defun er/mark-ruby-symbol ()
"Mark the entire symbol around or in front of point."
(interactive)
(let ((symbol-regexp ":\\|\\s_\\|\\sw"))
(when (or (looking-at symbol-regexp)
(looking-back symbol-regexp))
(while (looking-at symbol-regexp)
(forward-char))
(set-mark (point))
(while (looking-back symbol-regexp)
(backward-char)))))

(defun er/mark-ruby-function () (defun er/mark-ruby-function ()
"Mark the current Ruby function." "Mark the current Ruby function."
(interactive) (interactive)
Expand All @@ -64,7 +76,8 @@
"Adds Ruby-specific expansions for buffers in ruby-mode" "Adds Ruby-specific expansions for buffers in ruby-mode"
(set (make-local-variable 'er/try-expand-list) (append (set (make-local-variable 'er/try-expand-list) (append
er/try-expand-list er/try-expand-list
'(er/mark-ruby-block '(er/mark-ruby-symbol
er/mark-ruby-block
er/mark-ruby-function)))) er/mark-ruby-function))))


(add-hook 'ruby-mode-hook 'er/add-ruby-mode-expansions) (add-hook 'ruby-mode-hook 'er/add-ruby-mode-expansions)
Expand Down

0 comments on commit ca212f6

Please sign in to comment.