[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 03f46e4006 001/244: first import
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 03f46e4006 001/244: first import |
Date: |
Thu, 6 Jan 2022 02:58:43 -0500 (EST) |
branch: elpa/evil-matchit
commit 03f46e40066f87c18cb51f96b9023d676d303a7e
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
first import
---
.gitignore | 26 ++++++++
README.org | 14 ++++
evil-matchit-pkg.el | 2 +
evil-matchit.el | 185 ++++++++++++++++++++++++++++++++++++++++++++++++++++
pkg.sh | 11 ++++
5 files changed, 238 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..208721001a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,26 @@
+### /Users/cb/.gitignore-boilerplates/Global/Emacs.gitignore
+
+*~
+\#*\#
+/.emacs.desktop
+/.emacs.desktop.lock
+.elc
+auto-save-list
+tramp
+.\#*
+
+# Org-mode
+.org-id-locations
+*_archive
+
+
+### /Users/cb/.gitignore-boilerplates/Global/Vim.gitignore
+
+.*.sw[a-z]
+*.un~
+Session.vim
+.netrwhist
+
+*.tar
+*.elc
+
diff --git a/README.org b/README.org
new file mode 100644
index 0000000000..3129bb9455
--- /dev/null
+++ b/README.org
@@ -0,0 +1,14 @@
+* evil-matchit (current version 0.0.1)
+
+*Please note this program requires evil-mode!*
+
+Vim matchit.vim ported into Emacs.
+
+* Install
+evil-matchit is already uploaded to [[http://marmalade-repo.org/]]. So the
best way to install it is using Emacs' package manager.
+
+* How to use
+Press % in evil-normal-mode.
+
+* Contact me
+You can report bugs at [[https://github.com/redguardtoo/evil-matchit]].
diff --git a/evil-matchit-pkg.el b/evil-matchit-pkg.el
new file mode 100644
index 0000000000..6fe7c9da16
--- /dev/null
+++ b/evil-matchit-pkg.el
@@ -0,0 +1,2 @@
+(define-package "evil-matchit" "0.0.1"
+ "Vim matchit ported into Emacs (requires EVIL)")
diff --git a/evil-matchit.el b/evil-matchit.el
new file mode 100644
index 0000000000..0c3b7a80cd
--- /dev/null
+++ b/evil-matchit.el
@@ -0,0 +1,185 @@
+;;; evil-matchit --- Vim matchit ported into Emacs (requires EVIL)
+
+;; Copyright (C) 2013 Chen Bin
+
+;; Author: Chen Bin <chenbin.sh@gmail.com>
+;; URL: http://github.com/redguardtoo/evil-matchit
+;; Version: 0.0.1
+;; Keywords: matchit vim evil
+;;
+;; 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/>.
+
+;;; Commentary:
+;;
+;; This program emulates matchit.vim by Benji Fisher.
+;; It allows you use % to match items.
+;;
+;; This program requires EVIL (http://gitorious.org/evil)
+;;
+
+;;; Code:
+
+(require 'evil)
+
+(defvar evilmi-html-major-modes
+ '(nxml-mode
+ web-mode
+ html-mode
+ nxhtml-mode
+ )
+ "major modes containing html tags")
+
+;; @return (list position_first_char found_tag is_end_tag)
+(defun evilmi--find-lt-or-gt-char-at-current-line ()
+ (interactive)
+ (let ((b (line-beginning-position))
+ (e (line-end-position))
+ (char (following-char))
+ (p (point))
+ (found_tag nil)
+ (is_end_tag nil)
+ )
+
+ (save-excursion
+ ;; search backward
+ (if (not (= char 60))
+ (while (and (<= b (point)) (not (= char 60)))
+ (setq char (following-char))
+ (setq p (point))
+ (backward-char)
+ )
+ )
+ ;; search forward
+ (if (not (= char 60))
+ (save-excursion
+ (while (and (>= e (point)) (not (= char 60)))
+ (setq char (following-char))
+ (setq p (point))
+ (forward-char)
+ )
+ )
+ )
+
+ ;; is end tag?
+ (when (and (= char 60) (< p e))
+ (goto-char p)
+ (forward-char)
+ (if (= (following-char) 47)
+ (progn
+ ;; </
+ (skip-chars-forward "^>")
+ (forward-char)
+ (setq p (point))
+ (setq found_tag t)
+ (setq is_end_tag t)
+ )
+ (progn
+ ;; < , looks fine
+ (backward-char)
+ (setq found_tag t)
+ )
+ )
+ )
+ )
+ (list p found_tag is_end_tag)
+ ))
+
+(defun evilmi--operate-on-item (NUM fn)
+ (if (memq major-mode evilmi-html-major-modes)
+ (let ((rlt (evilmi--find-lt-or-gt-char-at-current-line)))
+ ;; prepare to jump
+ (when (nth 1 rlt)
+ (if (nth 2 rlt)
+ ;; it's the end tag
+ (progn
+ (funcall fn (nth 0 rlt))
+ (sgml-skip-tag-backward NUM)
+ )
+ ;; open tag
+ (progn
+ (funcall fn (nth 0 rlt))
+ (sgml-skip-tag-forward NUM)
+ )
+ )
+ )
+ )
+ ;; just use evil-jump item
+ (progn
+ (funcall fn (point))
+ (evil-jump-item NUM)
+ )
+ )
+ )
+
+(defun evilmi--push-mark (p)
+ (push-mark p t t)
+ )
+
+;;;###autoload
+(defun evilmi-jump-items (&optional NUM)
+ "jump between item/tag(s)"
+ (interactive "p")
+ (evilmi--operate-on-item NUM 'goto-char)
+ )
+
+;;;###autoload
+(defun evilmi-select-items (&optional NUM)
+ "select item/tag(s)"
+ (interactive "p")
+ (evilmi--operate-on-item NUM 'evilmi--push-mark)
+ )
+
+;;;###autoload
+(defun evilmi-delete-items (&optional NUM)
+ "delete item/tag(s)"
+ (interactive "p")
+ (evilmi--operate-on-item NUM 'evilmi--push-mark)
+ (kill-region (region-beginning) (region-end))
+ )
+
+;;;###autoload
+(define-minor-mode evil-matchit-mode
+ "Buffer-local minor mode to emulate matchit.vim"
+ :keymap (make-sparse-keymap)
+ (evil-normalize-keymaps)
+ )
+
+;;;###autoload
+(defun turn-on-evil-matchit-mode ()
+ "Enable evil-matchit-mode in the current buffer."
+ (evil-matchit-mode 1))
+
+;;;###autoload
+(defun turn-off-evil-matchit-mode ()
+ "Disable evil-matchit-mode in the current buffer."
+ (evil-matchit-mode -1))
+
+;;;###autoload
+(define-globalized-minor-mode global-evil-matchit-mode
+ evil-matchit-mode turn-on-evil-matchit-mode
+ "Global minor mode to emulate matchit.vim")
+
+(evil-define-key 'normal evil-matchit-mode-map "%" 'evilmi-jump-items)
+(evil-define-key 'normal evil-matchit-mode-map ",si" 'evilmi-select-items)
+(evil-define-key 'normal evil-matchit-mode-map ",di" 'evilmi-delete-items)
+
+(provide 'evil-matchit)
+
+;;; evil-matchit.el ends here
\ No newline at end of file
diff --git a/pkg.sh b/pkg.sh
new file mode 100755
index 0000000000..2e2a295079
--- /dev/null
+++ b/pkg.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+pkg=evil-matchit-0.0.1
+mkdir $pkg
+cp README.org $pkg
+cp *.el $pkg
+if [[ `uname -s` == *Darwin* ]]; then
+ COPYFILE_DISABLE="" tar cvf $pkg.tar $pkg/
+else
+ tar cvf $pkg.tar $pkg/
+fi
+rm -rf $pkg/
- [nongnu] branch elpa/evil-matchit created (now f9faa0b9bf), ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 13b95b675d 003/244: evil-jump-item parameter is wierd, v0.0.3, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit a837c1897e 006/244: tweak README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 05f80aacf2 004/244: Declare package dependency on evil, improve package description, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 808f226b2e 002/244: updated doc, v0.0.2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 9ed81c8b78 014/244: fixed typo in README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 03f46e4006 001/244: first import,
ELPA Syncer <=
- [nongnu] elpa/evil-matchit fc1731e8b2 013/244: updated doc, hotkey set up, v0.0.5, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit eb5e0bedc6 021/244: select/delete matching tags in C v1.0.2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 748647d518 017/244: dependent on sgml-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit cfcf0d083c 022/244: weak README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 90c8367856 027/244: add sdk v1.2.0, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 65b474bb02 031/244: Better C/C++, v1.2.2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 3b64df7610 005/244: Merge pull request #3 from purcell/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 363b6683ab 033/244: ignore elisp flymake file, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4f993303e1 044/244: delete leading spaces AND matched tags v1.2.9, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit dd3d90bf95 010/244: Fix malformed header line, ELPA Syncer, 2022/01/06