[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit 24dcd74a55 205/244: support terminal in Emacs
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit 24dcd74a55 205/244: support terminal in Emacs |
Date: |
Thu, 6 Jan 2022 02:59:02 -0500 (EST) |
branch: elpa/evil-matchit
commit 24dcd74a55911662e6951e76a6a69fe9669c544d
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
support terminal in Emacs
---
README.org | 4 +-
evil-matchit-sdk.el | 6 ++-
evil-matchit-terminal.el | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
evil-matchit.el | 3 ++
4 files changed, 106 insertions(+), 3 deletions(-)
diff --git a/README.org b/README.org
index d93d901f77..6d57cd2885 100644
--- a/README.org
+++ b/README.org
@@ -31,11 +31,13 @@ Many modern languages are supported:
- Laravel Blade Templating
- Vim script
- Verilog
+- Diff/Patch
+- Shell/Terminal bundled in Emacs
- Emacs email (message-mode)
This package uses Evil as its vi layer!
-Tested on Emacs 24.3, 24.4, 24.5, 25.1
+Tested on Emacs 24.4, 24.5, 25.1, 26, 27, 28
* Why use evil-matchit
- No learning curve. Press "%" to jump. That's all!
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index 6a28ead799..2f42609a95 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -193,8 +193,10 @@ If IS-FORWARD is t, jump forward; or else jump backward."
;;;###autoload
(defun evilmi-sdk-curline ()
- (buffer-substring-no-properties (line-beginning-position)
- (line-end-position)))
+ "Get current line text."
+ (let* ((inhibit-field-text-motion t))
+ (buffer-substring-no-properties (line-beginning-position)
+ (line-end-position))))
;;;###autoload
(defun evilmi-sdk-member (keyword keyword-list)
diff --git a/evil-matchit-terminal.el b/evil-matchit-terminal.el
new file mode 100644
index 0000000000..210e4c0d4d
--- /dev/null
+++ b/evil-matchit-terminal.el
@@ -0,0 +1,96 @@
+;;; evil-matchit-terminal.el --- terminal plugin of evil-matchit
+
+;; Copyright (C) 2020 Chen Bin <chenbin DOT sh AT gmail DOT com>
+
+;; Author: Chen Bin <chenbin DOT sh AT gmail DOT com>
+
+;; 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:
+
+;; OPTIONAL, you don't need SDK to write a plugin for evil-matchit
+;; but SDK do make you write less code, isn't it?
+;; All you need to do is just define the match-tags for SDK algorithm to
lookup.
+;;
+;;; Commentary:
+;;
+;;; Code:
+
+(require 'evil-matchit-sdk)
+
+(defvar evilmi-terminal-primary-prompt "^\\$ "
+ "The primary prompt of terminal")
+
+(defvar evilmi-terminal-ps1-line-number 1
+ "The line containing PS1.")
+
+;;;###autoload
+(defun evilmi-terminal-get-tag ()
+ "Get tag at point."
+ (let* ((curline (evilmi-sdk-curline))
+ (prompt evilmi-terminal-primary-prompt)
+ line1
+ line2)
+ (cond
+ ((string-match prompt curline)
+ ;; open tag
+ (list (line-beginning-position) 0))
+ (t
+ (save-excursion
+ (forward-line)
+ (setq line1 (evilmi-sdk-curline))
+ (forward-line)
+ (setq line2 (evilmi-sdk-curline)))
+ (when (and line1 line2 (or (string-match prompt line1)
+ (string-match prompt line2)))
+ (list (line-end-position) 1))))))
+
+;;;###autoload
+(defun evilmi-terminal-jump (info num)
+ "Use INFO to jump NUM times."
+ (ignore num)
+ (when info
+ (let* ((type (nth 1 info))
+ (prompt evilmi-terminal-primary-prompt)
+ pos)
+ (cond
+ ;; from open tag
+ ((eq type 0)
+ (save-excursion
+ ;; skip current line
+ (forward-line 1)
+ (when (re-search-forward prompt (point-max) t)
+ (forward-line -1)
+ (forward-line (- evilmi-terminal-ps1-line-number))
+ (setq pos (line-end-position))))
+ (when pos (goto-char pos)))
+
+ ;; from close tag
+ ((eq type 1)
+ (save-excursion
+ ;; skip current line
+ (when (re-search-backward prompt (point-min) t)
+ (setq pos (line-beginning-position))))
+ (when pos (goto-char pos))))
+ pos)))
+
+(provide 'evil-matchit-terminal)
+;;; evil-matchit-terminal.el ends here
diff --git a/evil-matchit.el b/evil-matchit.el
index 4f30491963..107a2b27ff 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -206,6 +206,9 @@ Some people prefer using \"m\" instead.")
;; Ruby
(evilmi-load-plugin-rules '(ruby-mode enh-ruby-mode) '(simple ruby))
+ ;; terminal
+ (evilmi-load-plugin-rules '(term-mode shell-mode) '(simple terminal))
+
;; Elixir
(evilmi-load-plugin-rules '(elixir-mode enh-elixir-mode) '(simple elixir)))
- [nongnu] elpa/evil-matchit 3417dbb275 117/244: Add ocaml support, (continued)
- [nongnu] elpa/evil-matchit 3417dbb275 117/244: Add ocaml support, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 80413a836a 121/244: Merge pull request #79 from msaffer/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 47894a6cc0 151/244: Merge pull request #93 from AitBits/patch-2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 4c6b8f412f 159/244: Add autoload definitions, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 1c428e192b 149/244: ocaml use font-lock-doc-face for comment, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 0845b2a0bf 178/244: Merge pull request #109 from neojski/add-double-semicolon, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 11aa990ecb 177/244: Merge pull request #110 from leungbk/elisp, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 11d98debf8 187/244: Merge pull request #115 from dajva/jump_motion, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit bc31e7d594 199/244: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 6fd4c56855 198/244: clean code, more c unit test, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 24dcd74a55 205/244: support terminal in Emacs,
ELPA Syncer <=
- [nongnu] elpa/evil-matchit ede6382955 206/244: enhance verilog mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 721d0a9c56 211/244: More ocaml tests, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit fccad4255b 217/244: Merge pull request #128 from leungbk/byte-comp, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 593c2d53a7 224/244: `evilmi-sdk-simple-jump': skip comments, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit f397504270 204/244: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 2df3a62a8b 222/244: Add a regression test, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit d7ad7f712b 235/244: emacs 28 changed API define-obsolete-function-alias. It is EVIL code. Not my code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit d1f59ad941 225/244: Merge pull request #131 from nbfalcon/bugfix/evilmi-sdk-simple-jump-whitespace, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ccc2cc8a62 221/244: `evilmi-sdk-simple-jump': skip whitespace, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8862d8ea15 079/244: support for statement in lua-mode, ELPA Syncer, 2022/01/06