branch: elpa/evil-matchit
commit cf584eb62e4c759229f7c11370846246308bbb8b
Author: Chen Bin <[email protected]>
Commit: Chen Bin <[email protected]>
support c like languages
support languages like c/c++/perl/java/perl/javascript
---
README.org | 8 +++---
evil-matchit-c.el | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
evil-matchit-pkg.el | 2 +-
evil-matchit.el | 13 +++++++---
pkg.sh | 2 +-
5 files changed, 90 insertions(+), 9 deletions(-)
diff --git a/README.org b/README.org
index 199e184f4d..257fb33f89 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-matchit (current version 1.0.0)
+* evil-matchit (current version 1.0.1)
Vim [[http://www.vim.org/scripts/script.php?script_id=39][matchit.vim]] by
Benji Fisher ported into Emacs.
@@ -76,7 +76,7 @@ Here is a complete sample:
;; detect tag in current line and return the result in variable rlt
;; the rlt will be used by evilmi-mylanguage-jump as the first
;; parameter.
-;; if not tag found, the rlt SHOULD be nil
+;; if NO tag found, the rlt SHOULD be nil
;;
;; @return the data to be used by evilmi-mylanguage-jump
(defun evilmi-mylanguage-find-tag ()
@@ -106,9 +106,9 @@ Place above code into your ~/.emacs, after the line
"(global-evil-matchit-mode 1
** Share your code to the world
Tweak your code a little bit to make it a plugin and ask me to merge it into
main stream.
-Please check "evil-matchit-latext.el" for general guidance on naming
convention and other tech details of plugin.
+Please check "evil-matchit-latext.el" for technical details about plugin.
-Here are some suggestions about quality of plugin:
+Key points about code quality of plugin:
- minimum dependency. For example, if your plugin for html template files are
just some web-mode API wrapper, it will break when user don't have web-mode
- support emacs 23
- performance is the first priority
diff --git a/evil-matchit-c.el b/evil-matchit-c.el
new file mode 100644
index 0000000000..cc4ad231d4
--- /dev/null
+++ b/evil-matchit-c.el
@@ -0,0 +1,74 @@
+;;; evil-matchit-c.el ---c like language (c/c++/perl/java/javascript) plugin
of evil-matchit
+
+;; Copyright (C) 2013 Chen Bin <[email protected]>
+
+;; Author: Chen Bin <[email protected]>
+
+;; This file is not part of GNU Emacs.
+
+;;; License:
+
+;; This file is part of evil-matchit
+;;
+;; evil-matchit 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.
+;;
+;; evil-matchit 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 'evil-matchit)
+
+(defun evilmi--c-find-open-brace (cur-line)
+ (let (rlt)
+ (if (string-match "^[ \t]* [a-zA-Z0-9]+.*[{] *$" cur-line)
+ (setq rlt 1)
+ (save-excursion
+ (forward-line)
+ (setq cur-line (buffer-substring-no-properties
+ (line-beginning-position) (line-end-position)))
+ (if (string-match "^[ \t]*{ *$" cur-line)
+ (setq rlt 2)
+ )
+ )
+ )
+ rlt
+ )
+ )
+
+;;;###autoload
+(defun evilmi-c-get-tag ()
+ (let (rlt
+ (cur-line (buffer-substring-no-properties
+ (line-beginning-position) (line-end-position)))
+ )
+
+ ;; only handle open tag
+ (when (and (not (memq (following-char) (string-to-list "{[(}}])")))
+ (setq rlt (evilmi--c-find-open-brace cur-line))
+ )
+ (when rlt
+ (forward-line (1- rlt))
+ (search-forward "{" nil nil)
+ (backward-char)
+ )
+ )
+ rlt
+ )
+ )
+
+;;;###autoload
+(defun evilmi-c-jump (rlt NUM)
+ (if rlt (evil-jump-item))
+ )
+
+(provide 'evil-matchit-c)
\ No newline at end of file
diff --git a/evil-matchit-pkg.el b/evil-matchit-pkg.el
index ff8578f832..96bf44091d 100644
--- a/evil-matchit-pkg.el
+++ b/evil-matchit-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-matchit" "1.0.0"
+(define-package "evil-matchit" "1.0.1"
"Vim matchit ported into Emacs (requires EVIL)")
diff --git a/evil-matchit.el b/evil-matchit.el
index 4761df6b9e..79456d276b 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -4,7 +4,7 @@
;; Author: Chen Bin <[email protected]>
;; URL: http://github.com/redguardtoo/evil-matchit
-;; Version: 1.0.0
+;; Version: 1.0.1
;; Keywords: matchit vim evil
;; Package-Requires: ((evil "1.0.7"))
;;
@@ -80,6 +80,7 @@
)
(defun evilmi--init-plugins ()
+ (interactive)
;; html
(autoload 'evilmi-html-get-tag "evil-matchit-html" nil t)
(autoload 'evilmi-html-jump "evil-matchit-html" nil t)
@@ -99,6 +100,14 @@
(autoload 'evilmi-python-jump "evil-matchit-python" nil t)
(plist-put evilmi-plugins 'python-mode '((evilmi-simple-get-tag
evilmi-simple-jump)
(evilmi-python-get-tag
evilmi-python-jump)))
+
+ ;; c like language (c/c++/perl/java/javascript)
+ (autoload 'evilmi-c-get-tag "evil-matchit-c" nil t)
+ (autoload 'evilmi-c-jump "evil-matchit-c" nil t)
+ (mapc (lambda (mode)
+ (plist-put evilmi-plugins mode '((evilmi-c-get-tag evilmi-c-jump)))
+ )
+ '(c-mode c++-mode java-mode js-mode js2-mode javascript-mode perl-mode
cperl-mode))
)
;;;###autoload
@@ -185,8 +194,6 @@
(defun evilmi-simple-jump (rlt NUM)
(interactive)
- (message "evilmi-simple-jump called")
-
(evil-jump-item)
)
;; }}
diff --git a/pkg.sh b/pkg.sh
index 182d733914..4c7e891ff3 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-pkg=evil-matchit-1.0.0
+pkg=evil-matchit-1.0.1
mkdir $pkg
cp README.org $pkg
cp *.el $pkg