[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 699645a 112/433: Allowed here-documents in any mode with :
From: |
Dmitry Gutov |
Subject: |
[elpa] master 699645a 112/433: Allowed here-documents in any mode with :match-submode. |
Date: |
Thu, 15 Mar 2018 19:43:46 -0400 (EDT) |
branch: master
commit 699645a86782ac0d52cd14eb36f02824450a7bbe
Author: mas <mas>
Commit: mas <mas>
Allowed here-documents in any mode with :match-submode.
Added insertion syntax to here-docs, javascript, and embperl.
---
mmm-sample.el | 71 +++++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 52 insertions(+), 19 deletions(-)
diff --git a/mmm-sample.el b/mmm-sample.el
index 03bc91a..3b3e4b6 100644
--- a/mmm-sample.el
+++ b/mmm-sample.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2000 by Michael Abraham Shulman
;; Author: Michael Abraham Shulman <address@hidden>
-;; Version: $Id: mmm-sample.el,v 1.4 2000/06/30 02:34:12 mas Exp $
+;; Version: $Id: mmm-sample.el,v 1.5 2000/07/21 00:17:21 mas Exp $
;;{{{ GPL
@@ -44,21 +44,6 @@
:back "</style>")))
;;}}}
-;;{{{ HTML Here-documents
-
-;; A little more complicated regexp to match all Perl here-documents
-;; whose identifiers include the string "HTML". We use :save-matches
-;; to match the end of the named here-document. This class has not
-;; been extensively tested.
-
-(mmm-add-classes
- '((perl-html
- :submode html-mode
- :front "<<\\([a-zA-Z0-9_-]*HTML[a-zA-Z0-9_-]*\\).*\n"
- :back "^~1$"
- :save-matches 1)))
-
-;;}}}
;;{{{ Javascript in HTML
(defvar mmm-javascript-mode
@@ -75,13 +60,50 @@ otherwise `c++-mode'. Some people prefer `c++-mode'
regardless.")
`((js-tag
:submode ,mmm-javascript-mode
:front "<script\[^>\]*>"
- :back"</script>")
+ :back"</script>"
+ :insert ((?j js-tag nil @ "<script language=\"JavaScript\">"
+ @ "\n" _ "\n" @ "</script>" @))
+ )
(js-inline
:submode ,mmm-javascript-mode
:front "on\w+=\""
:back "\"")))
;;}}}
+;;{{{ Here-documents
+
+;; Here we match the here-document syntax used by Perl and shell
+;; scripts. We assume that the delimiter of the here-document is the
+;; mode name with or without `-mode', such as <<HTML or <<HTML-MODE.
+;; Hyphens may be replaced with underscores to make <<HTML_MODE and
+;; the mode name is converted to lower case. Additional characters
+;; may be added after `MODE', such as <<HTML_MODE_EOF.
+
+(defun mmm-here-doc-get-mode (string)
+ (string-match "[a-zA-Z_-]+" string)
+ (setq string (match-string 0 string))
+ (let* ((case-fold-search t)
+ (modestr (if (string-match "mode" string)
+ (downcase (substring string 0 (match-end 0)))
+ (concat (downcase string) "-mode"))))
+ (while (string-match "_" modestr)
+ (setq modestr (replace-match "-" nil nil modestr)))
+ (and modestr (intern modestr))))
+
+(mmm-add-classes
+ `((here-doc
+ :front "<<\\([a-zA-Z0-9_-]+\\).*\n"
+ :back "^~1$"
+ :save-matches 1
+ :front-verify ,#'(lambda ()
+ (fboundp
+ (mmm-here-doc-get-mode (match-string 0))))
+ :match-submode mmm-here-doc-get-mode
+ :insert ((?d here-doc "Here-document Name: " @ "<<" str _ "\n"
+ @ "\n" @ str "\n" @))
+ )))
+
+;;}}}
;;{{{ Embperl
(defvar mmm-embperl-perl-mode
@@ -96,11 +118,22 @@ Usually either `perl-mode' or `cperl-mode'. The default is
:submode cperl-mode
:front "\\[\\([-\\+!\\*\\$]\\)"
:back "~1\\]"
- :save-matches 1)
+ :save-matches 1
+ :insert ((?p embperl "Region Type (Character): " @ "[" str
+ @ " " _ " " @ str "]" @)
+ (?+ embperl+ ?p . "+")
+ (?- embperl- ?p . "-")
+ (?! embperl! ?p . "!")
+ (?* embperl* ?p . "*")
+ (?$ embperl$ ?p . "$")
+ )
+ )
(embperl-comment
:submode text-mode
:front "\\[#"
- :back "#\\]")))
+ :back "#\\]"
+ :insert ((?# embperl-comment nil @ "[#" @ " " _ " " @ "#]" @))
+ )))
;;}}}
- [elpa] master d504cd7 134/433: (mmm-ify-by-class): Added completion on autoloaded classes. Excluded, (continued)
- [elpa] master d504cd7 134/433: (mmm-ify-by-class): Added completion on autoloaded classes. Excluded, Dmitry Gutov, 2018/03/15
- [elpa] master bb60f11 001/433: Initial revision, Dmitry Gutov, 2018/03/15
- [elpa] master da57a75 151/433: # Updated., Dmitry Gutov, 2018/03/15
- [elpa] master b59c78e 086/433: (mmm-update-mode-info): Used `mmm-make-temp-buffer'. Put font-lock, Dmitry Gutov, 2018/03/15
- [elpa] master 3c3042d 093/433: # Updated., Dmitry Gutov, 2018/03/15
- [elpa] master d367aa7 098/433: Added `version.texi' to step 3., Dmitry Gutov, 2018/03/15
- [elpa] master 9a94c1f 097/433: # Updated., Dmitry Gutov, 2018/03/15
- [elpa] master a64bc70 104/433: Added comment about `mmm-global-mode'., Dmitry Gutov, 2018/03/15
- [elpa] master e947f88 107/433: # Updated., Dmitry Gutov, 2018/03/15
- [elpa] master 67fbc7f 114/433: (mmm-match-region, mmm-ify): Caught errors from :match-submode., Dmitry Gutov, 2018/03/15
- [elpa] master 699645a 112/433: Allowed here-documents in any mode with :match-submode.,
Dmitry Gutov <=
- [elpa] master a2d04ab 128/433: # Removed another duplicate entry, Dmitry Gutov, 2018/03/15
- [elpa] master d1ed795 135/433: Added autoloading of submode classes., Dmitry Gutov, 2018/03/15
- [elpa] master 606c79e 132/433: # Updated, Dmitry Gutov, 2018/03/15
- [elpa] master 1834f4b 133/433: (mmm-classes-alist): Updated docstring for new offset values and, Dmitry Gutov, 2018/03/15
- [elpa] master 5b4b568 137/433: (mmm-get-class-spec): Implemented autoloaded submode classes., Dmitry Gutov, 2018/03/15
- [elpa] master 20deb97 138/433: # Updated, Dmitry Gutov, 2018/03/15
- [elpa] master ff7d773 136/433: (mmm-add-group): Made subclasses of a group private., Dmitry Gutov, 2018/03/15
- [elpa] master a9c086a 130/433: (mmm-ify, mmm-match-region, mmm-match->point): Added new values for, Dmitry Gutov, 2018/03/15
- [elpa] master 369d7e3 144/433: (mmm-ensure-fboundp): Created function., Dmitry Gutov, 2018/03/15
- [elpa] master 74d61d7 146/433: Added comments about `sgml-parent-document'., Dmitry Gutov, 2018/03/15