[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 4fe67764e2 059/244: extra commands to delete/
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 4fe67764e2 059/244: extra commands to delete/select items v1.4.3 |
Date: |
Thu, 6 Jan 2022 02:58:49 -0500 (EST) |
branch: elpa/evil-matchit
commit 4fe67764e263d691c607305b07ac749f4511f29d
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
extra commands to delete/select items v1.4.3
---
README.org | 14 ++++++-----
evil-matchit-pkg.el | 2 +-
evil-matchit.el | 71 ++++++++++++++++++++++++++++++++++++++++++++---------
3 files changed, 69 insertions(+), 18 deletions(-)
diff --git a/README.org b/README.org
index 8be1466935..a03d12b2b9 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* evil-matchit (v1.4.2)
+* evil-matchit (v1.4.3)
Vim [[http://www.vim.org/scripts/script.php?script_id=39][matchit.vim]] by
Benji Fisher ported into Emacs.
@@ -56,12 +56,14 @@ Text object "%" is also created. It roughly equal the
region when you press "%"
Inner text object or outer object is the same thing in evil-matchit.
-Press "va%" or "vi%" to select line(s) wrapped by tags.
+Press "va%" or "vi%" to select line(s) wrapped by tags. `M-x
evilmi-select-items` does the same thing.
-Press "da%" or "di%" to delete line(s) wrapped by tags.
+Press "da%" or "di%" to delete line(s) wrapped by tags. `M-x
evilmi-delete-items` does the same thing.
All commands support numeric argument like "3%", "5va%" or "9da%"
+Please note "3%" will jump to a line *3 percentage down the file*. It's the
default behavior in original evil-mode . You can `(setq
evilmi-may-jump-by-percentage nil)` to turn off this feature. Then "3%" will
*jump 3 times*.
+
* Advanced tips
** Support more major modes
Let's use html tag matching as an example.
@@ -76,15 +78,15 @@ Let's say you want a new major-mode "my-mode" to do the
html tag matching. Easy.
Further explanation: "evilmi-html-get-tag" and "evilmi-html-jump" are existing
APIs which are defined in evil-matchit-html.el. The above line means that in
my-mode, use "evilmi-html-get-tag" to find open/closed tag in current line and
use "evilmi-html-jump" to jump to matched closed/open tag.
-** mixed languages in one html template file can be supported
-Say you embed python language in a html file. You can match both html tags and
python statement by inserting below code into your ~/.emacs:
+** Mixed languages in one html template file is supported
+If you embed python language in a html file. You can match both html tags and
python statement by inserting below code into your ~/.emacs:
#+BEGIN_SRC elisp
(plist-put evilmi-plugins web-mode
'((evilmi-python-get-tag evilmi-python-jump)
(evilmi-html-get-tag evilmi-html-jump)
))
#+END_SRC
-** re-define keybinding
+** Re-define keybinding
You can define your own key bindings instead using evil-matchit default key
binding.
All you need to do is to define function evilmi-customize-keybinding before
turning on evil-mathcit-mode:
diff --git a/evil-matchit-pkg.el b/evil-matchit-pkg.el
index dd43af024e..73ad3fc7e2 100644
--- a/evil-matchit-pkg.el
+++ b/evil-matchit-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-matchit" "1.4.2"
+(define-package "evil-matchit" "1.4.3"
"Vim matchit ported into Emacs (requires EVIL)")
diff --git a/evil-matchit.el b/evil-matchit.el
index b4b230428b..373190aca6 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -4,7 +4,7 @@
;; Author: Chen Bin <chenbin.sh@gmail.com>
;; URL: http://github.com/redguardtoo/evil-matchit
-;; Version: 1.4.2
+;; Version: 1.4.3
;; Keywords: matchit vim evil
;; Package-Requires: ((evil "1.0.7"))
;;
@@ -40,8 +40,12 @@
(require 'evil)
(defvar evilmi-plugins '(emacs-lisp-mode
- ((evilmi-simple-get-tag evilmi-simple-jump))
- ))
+ ((evilmi-simple-get-tag evilmi-simple-jump)))
+ "The table to define which algorithm to use and when to to jump items")
+
+(defvar evilmi-may-jump-by-percentage t
+ "Simulate evil-jump-item behaviour. For example, press 50% to jump to 50
percentage in buffer.
+If this flag is nil, then 50 means jump 50 times.")
(defun evilmi--operate-on-item (NUM &optional FUNC)
(let ((plugin (plist-get evilmi-plugins major-mode))
@@ -72,8 +76,7 @@
(setq where-to-jump-in-theory (point))
)
where-to-jump-in-theory
- )
- )
+ ))
(defun evilmi--push-mark (rlt)
(push-mark (nth 0 rlt) t t)
@@ -159,9 +162,7 @@
'(ruby-mode))
)
-(evil-define-text-object evilmi-text-object (&optional NUM begin end type)
- "text object describing the region selected when you press % from
evil-matchit"
- :type line
+(defun evilmi--region-to-select-or-delete (NUM)
(let (where-to-jump-in-theory b e)
(save-excursion
(setq where-to-jump-in-theory (evilmi--operate-on-item NUM
'evilmi--push-mark))
@@ -173,22 +174,70 @@
(setq b (line-beginning-position))
;; 1+ because the line feed
))
- (evil-range b e 'line)))
+ (list b e)))
+
+(evil-define-text-object evilmi-text-object (&optional NUM begin end type)
+ "text object describing the region selected when you press % from
evil-matchit"
+ :type line
+ (let (selected-region)
+ (setq selected-region (evilmi--region-to-select-or-delete NUM))
+ (evil-range (car selected-region) (cadr selected-region) 'line)))
(define-key evil-inner-text-objects-map "%" 'evilmi-text-object)
(define-key evil-outer-text-objects-map "%" 'evilmi-text-object)
+;;;###autoload
+(defun evilmi-select-items (&optional NUM)
+ "Select items/tags and the region between them"
+ (interactive "p")
+ (let (selected-region)
+ (setq selected-region (evilmi--region-to-select-or-delete NUM))
+ (when selected-region
+ (evilmi--push-mark selected-region)
+ (goto-char (cadr selected-region)))
+ ))
+
+;;;###autoload
+(defun evilmi-delete-items (&optional NUM)
+ "Delete items/tags and the region between them"
+ (interactive "p")
+ (let (selected-region)
+ (setq selected-region (evilmi--region-to-select-or-delete NUM))
+ ;; 1+ because the line feed
+ (kill-region (car selected-region) (1+ (cadr selected-region)))
+ ))
+
+;;;###autoload
+(defun evilmi-jump-to-percentage (NUM)
+ "Re-implementation of evil's similar functionality"
+ (interactive "P")
+ (let (dst)
+ (when (and NUM (> NUM 0))
+ (setq dst (let ((size (- (point-max) (point-min))))
+ (+ (point-min)
+ (if (> size 80000)
+ (* NUM (/ size 100))
+ (/ (* NUM size) 100)))))
+ (cond
+ ((< dst (point-min))
+ (setq dst (point-min)))
+ ((> dst (point-max))
+ (setq dst (point-max))))
+ (goto-char dst)
+ (back-to-indentation))))
+
;;;###autoload
(defun evilmi-jump-items (&optional NUM)
"jump between item/tag(s)"
(interactive "P")
(cond
- (NUM (evil-jump-item NUM))
+ ((and evilmi-may-jump-by-percentage NUM)
+ (evilmi-jump-to-percentage NUM))
(t (evilmi--operate-on-item NUM))
))
;;;###autoload
-(defun evilmi-version() (interactive) (message "1.4.2"))
+(defun evilmi-version() (interactive) (message "1.4.3"))
;;;###autoload
(define-minor-mode evil-matchit-mode
- [nongnu] elpa/evil-matchit 1017e2e6ec 069/244: README.org: update MELPA URL, (continued)
- [nongnu] elpa/evil-matchit 1017e2e6ec 069/244: README.org: update MELPA URL, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 3f08492ec4 072/244: FIXED: #43 no jump at the first line in html v1.5.2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit bfe8afe2a1 070/244: Merge pull request #40 from xuchunyang/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 257d4ab10c 071/244: #41 workaround web-mode v11 issue, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit c4be28092f 087/244: perfect support for visual-line state v2.1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4780ef4e4a 104/244: scan-sexps buggy in latex-mode, fallback to Evil API, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 38df050735 103/244: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0941f38bfe 118/244: Add ocaml plugin to evil-matchit.el, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4fdcda9fec 056/244: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 2f8449cfec 057/244: support Laravel Blade Templating, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4fe67764e2 059/244: extra commands to delete/select items v1.4.3,
ELPA Syncer <=
- [nongnu] elpa/evil-matchit d2e7b21038 061/244: remove duplicated code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4efd9e0fac 064/244: use % in evil-visual-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 965efc080a 065/244: updated pkg.sh, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit acb89199d0 074/244: Fix matching chaining off end blocks, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 296c31f93d 073/244: Fix matching multiple arguments and varibles with underscores in do/end blocks., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 9a1b6ac1f9 076/244: can jump between brackets in visual-state #42, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 11352e24ff 083/244: support more pattern in lua-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit e831d42aa5 085/244: relax regex for python matching, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 3c9d97f3d3 090/244: Merge pull request #60 from robbyoconnor/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 14e23187df 093/244: Put the melpa badges on the same line, ELPA Syncer, 2022/01/06