forked from magnars/expand-region.el
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cperl-mode-expansions.el
67 lines (53 loc) · 2.16 KB
/
cperl-mode-expansions.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
;;; cperl-mode-expansions.el --- perl-specific expansions for expand-region
;; Copyright (C) 2012 Kang-min Liu
;; Author: Kang-min Liu <[email protected]>
;; Keywords: marking region cperl
;; 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/>.
;;; Code:
(require 'expand-region-core)
(defun er/mark-cperl-variable-name ()
"Marks one perl variable"
(interactive)
(forward-word)
(backward-word)
(search-backward-regexp "[@$%]" (line-beginning-position))
(set-mark (point))
(forward-char)
(search-forward-regexp "[^a-z_]" (line-end-position))
(backward-char)
(exchange-point-and-mark))
(defun er/mark-cperl-package-name ()
"Marks one perl package name"
(interactive)
(forward-sexp)
(backward-sexp)
(set-mark (point))
(forward-sexp)
(search-backward "::" (line-beginning-position))
(exchange-point-and-mark))
(defun er/mark-cperl-subroutine ()
"Marks current subroutine body."
(interactive)
(end-of-defun)
(set-mark (point))
(beginning-of-defun))
(defun er/add-cperl-mode-expansions ()
"Add cprel mode expansinos"
(set (make-local-variable 'er/try-expand-list) (append
er/try-expand-list
'(er/mark-cperl-variable-name
er/mark-cperl-package-name
er/mark-cperl-subroutine
))))
(er/enable-mode-expansions 'cperl-mode 'er/add-cperl-mode-expansions)
(provide 'cperl-mode-expansions)
;; cperl-mode-expansions.el ends here