[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-matchit fcf6b25407 063/244: fortran
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-matchit fcf6b25407 063/244: fortran |
Date: |
Thu, 6 Jan 2022 02:58:49 -0500 (EST) |
branch: elpa/evil-matchit
commit fcf6b2540713b2ecf1db4b3ab440913a57c14431
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
fortran
---
evil-matchit-fortran.el | 67 +++++++++++++++++++++++++++++++++++++++++++++++++
evil-matchit-sdk.el | 10 +++++++-
evil-matchit.el | 7 ++++++
3 files changed, 83 insertions(+), 1 deletion(-)
diff --git a/evil-matchit-fortran.el b/evil-matchit-fortran.el
new file mode 100644
index 0000000000..5bbeed072a
--- /dev/null
+++ b/evil-matchit-fortran.el
@@ -0,0 +1,67 @@
+;;; evil-matchit-fortran.el ---fortran (ruby/lua) plugin of evil-matchit
+
+;; Copyright (C) 2014 Chen Bin <chenbin.sh@gmail.com>
+
+;; Author: Chen Bin <chenbin.sh@gmail.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/>.
+
+
+;;; Code:
+
+;; OPTIONAL, you don't need SDK to write a plugin for evil-matchit
+;; but SDK don make you write less code, isn't it?
+;; All you need to do is just define the match-tags for SDK algorithm to
lookup.
+(require 'evil-matchit-sdk)
+
+(defvar evilmi-fortran-extract-keyword-howtos
+ '(("^[ \t]*\\([a-zA-Z _]+\\)[(:].*$" 1) ;; "if (...)"
+ ("^[ \t]*\\([a-zA-Z]+\\) *$" 1) ;; "end"
+ ("^[ \t]*\\(do\\) .*$" 1) ;; "do i=1,10"
+ ("^[ \t]*\\([a-zA-Z]+ [a-zA-Z0-9_]+\\).*$" 1) ;; "end program"
+ ))
+
+;; Fortran (http://www.fortran.org) syntax
+(defvar evilmi-fortran-match-tags
+ '((("if") ("else if" "else") ("end" "end *if"))
+ (("do" "while") () ("end *do" "until" "continue"))
+ (("where") ("elsewhere") ("end *where") "MONOGAMY")
+ (("select *case") ("case" "case default") ("end *select") "MONOGAMY")
+ (("forall") () ("end *forall.*") "MONOGAMY")
+ (("associate .*") () ("end *associate.*") "MONOGAMY")
+ (("enum") () ("end *enum.*") "MONOGAMY")
+ (("interface") () ("end *interface.*") "MONOGAMY")
+ (("subroutine .*") () ("end *subroutine" "end"))
+ (("function .*") () ("end *function" "end"))
+ (("module .*") () ("end *module.*") "MONOGAMY")
+ (("program .*") () ("end *program.*") "MONOGAMY")
+ ))
+
+;;;###autoload
+(defun evilmi-fortran-get-tag ()
+ (evilmi-sdk-get-tag evilmi-fortran-match-tags
evilmi-fortran-extract-keyword-howtos)
+ )
+
+;;;###autoload
+(defun evilmi-fortran-jump (rlt NUM)
+ (evilmi-sdk-jump rlt NUM evilmi-fortran-match-tags
evilmi-fortran-extract-keyword-howtos)
+ )
+
+(provide 'evil-matchit-fortran)
diff --git a/evil-matchit-sdk.el b/evil-matchit-sdk.el
index 4f4ab39c83..e3c8229e88 100644
--- a/evil-matchit-sdk.el
+++ b/evil-matchit-sdk.el
@@ -9,6 +9,11 @@ to extract the keyword which starts from one. The sub-match is
the match defined
between '\\(' and '\\)' in regular expression.
")
+;; slower but I don't care
+;; @see http://ergoemacs.org/emacs/modernization_elisp_lib_problem.html
+(defun evilmi-sdk-trim-string (string)
+ (replace-regexp-in-string "\\`[ \t\n]*" "" (replace-regexp-in-string "[
\t\n]*\\'" "" string)))
+
(defun evilmi-sdk-tags-is-matched (level orig-tag-info cur-tag-info match-tags)
(let (rlt
(tag-pair-status (nth 2 cur-tag-info)))
@@ -105,7 +110,10 @@ is-function-exit-point could be 'FN_EXIT' or other status"
(setq howto (nth i howtos))
(when (string-match (nth 0 howto) cur-line)
- (setq keyword (match-string (nth 1 howto) cur-line))
+ ;; keyword should be trimmed because FORTRAN use "else if"
+ (setq keyword (evilmi-sdk-trim-string (match-string (nth 1 howto)
cur-line) ))
+ ;; (message "keyword=%s" keyword)
+
;; keep search keyword by using next howto (regex and match-string
index)
(if (not (evilmi-sdk-member keyword match-tags)) (setq keyword nil))
)
diff --git a/evil-matchit.el b/evil-matchit.el
index 4efb90aa59..88ed0b1d74 100644
--- a/evil-matchit.el
+++ b/evil-matchit.el
@@ -137,6 +137,13 @@ If this flag is nil, then 50 means jump 50 times.")
)
'(c-mode c++-mode))
+ ;; Fortran
+ (autoload 'evilmi-fortran-get-tag "evil-matchit-fortran" nil)
+ (autoload 'evilmi-fortran-jump "evil-matchit-fortran" nil)
+ (mapc (lambda (mode)
+ (plist-put evilmi-plugins mode '((evilmi-fortran-get-tag
evilmi-fortran-jump))))
+ '(f90-mode fortran-mode))
+
;; CMake (http://www.cmake.org)
(autoload 'evilmi-cmake-get-tag "evil-matchit-cmake" nil)
(autoload 'evilmi-cmake-jump "evil-matchit-cmake" nil)
- [nongnu] elpa/evil-matchit 2d038e4d59 019/244: minor tweek of matching algorithm priority, (continued)
- [nongnu] elpa/evil-matchit 2d038e4d59 019/244: minor tweek of matching algorithm priority, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 1a663b20fd 029/244: #18 minor bug for python, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 210155ee8f 030/244: update developer guide v1.2.1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 369eb7ca8c 032/244: minor typo in README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 694e6fba3d 045/244: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 13c528765e 050/244: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 642fcdaf52 051/244: README updated, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit b4163c71c3 038/244: support org-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 11ba040ab0 055/244: support json-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 5bc34a6bd5 060/244: minor ruby bug, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit fcf6b25407 063/244: fortran,
ELPA Syncer <=
- [nongnu] elpa/evil-matchit 338a10ccd6 066/244: fixed: by default shortcut % is disabled, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8540a4c12a 068/244: supports inner text object, v1.5.0, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 8b4db43dc2 075/244: Merge pull request #44 from thegreatape/master, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit af40d309c6 078/244: documentation, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 89fd968ac2 080/244: spacemacs use enh-ruby-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit ff29cd2264 084/244: workaround issue in python-mode v2.0.2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 63846fc4c0 089/244: Add melpa badge, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 62d948743e 092/244: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 98c045d352 094/244: Merge pull request #61 from robbyoconnor/patch-2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-matchit 94e359e30c 095/244: Fix embedded major-mode detection in org-mode, ELPA Syncer, 2022/01/06