Skip to content

Commit

Permalink
Merge pull request #156 from LefterisJP/er_subword_mode
Browse files Browse the repository at this point in the history
Adding a mark-subword function and including it in expand-region.el
  • Loading branch information
magnars committed Dec 23, 2014
2 parents 5d10abb + 6e25a97 commit b97bd19
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions expand-region.el
Expand Up @@ -189,6 +189,7 @@ before calling `er/expand-region' for the first time."
(eval-after-load "cperl-mode" '(require 'cperl-mode-expansions))
(eval-after-load "sml-mode" '(require 'sml-mode-expansions))
(eval-after-load "enh-ruby-mode" '(require 'enh-ruby-mode-expansions))
(eval-after-load "subword-mode" '(require 'subword-mode-expansions))

(provide 'expand-region)

Expand Down
49 changes: 49 additions & 0 deletions subword-mode-expansions.el
@@ -0,0 +1,49 @@
;;; subword-mode-expansions.el --- Expansions for subword-mode to be used for CamelCase

;; Copyright (C) 2014 Lefteris Karapetsas

;; Author: Lefteris Karapetsas
;; Keywords: marking region

;; 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:

;; Provides extra expansions for subword mode so that when
;; subword-mode is non-nil different words can be selected in CamelCase.
;; Feel free to contribute any other expansions:
;;
;; https://github.com/magnars/expand-region.el

;;; Code:

(require 'expand-region-core)

(defun er/mark-subword ()
"Mark a subword, a part of a CamelCase identifier."
(interactive)
(subword-right 1)
(set-mark (point))
(subword-left 1))

(defun er/add-subword-mode-expansions ()
"Add expansions for buffers in `subword-mode'."
(set (make-local-variable 'er/try-expand-list)
(append er/try-expand-list
'(er/mark-subword))))

(er/enable-mode-expansions 'subword-mode 'er/add-subword-mode-expansions)

(provide 'subword-mode-expansions)
;;; subword-mode-expansions.el ends here

0 comments on commit b97bd19

Please sign in to comment.