emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master f156169 225/433: * mmm-cweb.el: New file.


From: Dmitry Gutov
Subject: [elpa] master f156169 225/433: * mmm-cweb.el: New file.
Date: Thu, 15 Mar 2018 19:44:08 -0400 (EDT)

branch: master
commit f1561695029021ae177b2ae86a9f9c9c5e295630
Author: alanshutko <alanshutko>
Commit: alanshutko <alanshutko>

    * mmm-cweb.el: New file.
    
    * mmm-region.el (mmm-valid-submode-region): New function.
    (mmm-make-region): Allow nested submodes and put the priority in
    the overlay.
---
 ChangeLog     |   8 +++++
 mmm-cweb.el   | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 mmm-region.el |  27 +++++++++++----
 3 files changed, 133 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ee2b8d3..2e10811 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-05-14  Alan Shutko  <address@hidden>
+
+       * mmm-cweb.el: New file.
+
+       * mmm-region.el (mmm-valid-submode-region): New function.
+       (mmm-make-region): Allow nested submodes and put the priority in
+       the overlay.
+
 2001-02-23  Michael Abraham Shulman  <address@hidden>
 
        * configure.in, mmm-mode.el, mmm-vars.el, version.texi: Released 0.4.7
diff --git a/mmm-cweb.el b/mmm-cweb.el
new file mode 100644
index 0000000..a3270b6
--- /dev/null
+++ b/mmm-cweb.el
@@ -0,0 +1,104 @@
+;;; mmm-cweb.el --- MMM submode class for CWeb programs
+
+;; Copyright (C) 2001 by Alan Shutko
+
+;; Author: Alan Shutko <address@hidden>
+;; Version: $Id: mmm-cweb.el,v 1.1 2001/05/14 21:16:54 alanshutko Exp $
+
+;;{{{ GPL
+
+;; This file 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 2, or (at your option)
+;; any later version.
+
+;; This file 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 GNU Emacs; see the file COPYING.  If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;}}}
+
+;;; Commentary:
+
+;; This file contains the definition of an MMM Mode submode class for
+;; editing CWeb programs.
+
+;;; Code:
+
+(require 'mmm-compat)
+(require 'mmm-vars)
+(require 'mmm-auto)
+
+(defvar mmm-cweb-section-tags
+  '("@ " "@*"))
+
+(defvar mmm-cweb-section-regexp
+  (concat "^" (mmm-regexp-opt mmm-cweb-section-tags t)))
+
+(defvar mmm-cweb-c-part-tags
+  '("@c" "@>=" "@>+=" "@p"))
+
+(defvar mmm-cweb-c-part-regexp
+  (concat (mmm-regexp-opt mmm-cweb-c-part-tags t)))
+
+(defun mmm-cweb-in-limbo (pos)
+  "Check to see if POS is in limbo, ie before any cweb sections."
+  (save-match-data
+    (save-excursion
+      (goto-char pos)
+      (not (re-search-backward mmm-cweb-section-regexp nil t)))))
+
+(defun mmm-cweb-verify-brief-c ()
+  "Verify function for cweb-brief-c class.
+Checks whether the match is in limbo."
+  (not (mmm-cweb-in-limbo (match-beginning 0))))
+
+;;}}}
+;;{{{ Add Classes
+
+(mmm-add-group
+ 'cweb
+ `(
+   (cweb-c-part
+    :submode c-mode
+    :front ,mmm-cweb-c-part-regexp
+    :back ,mmm-cweb-section-regexp)
+    (cweb-label
+     :submode tex-mode
+     :front "@<"
+     :back "@>"
+     :face mmm-comment-submode-face
+     :insert ((?l cweb-label nil @ "@<" @ "@>")))
+   (cweb-brief-c
+    :submode c-mode
+    :front "[^\\|]\\(|\\)[^|]"
+    :front-match 1
+    :front-verify mmm-cweb-verify-brief-c
+;    :front-offset -1
+    :back "[^\\|]\\(|\\)"
+    :back-match 1
+;    :back-offset 1
+    :end-not-begin t
+    :insert ((?| cweb-c-in-tex nil "|" @ "|")))
+    (cweb-comment
+     :submode tex-mode
+     :front "/[*]"
+     :back "[*]/"
+     :face mmm-comment-submode-face)
+))
+
+;; (add-to-list 'mmm-mode-ext-classes-alist
+;;                   '(plain-tex-mode "\\.w\\'" cweb))
+;; (add-to-list 'mmm-mode-ext-classes-alist
+;;                   '(latex-mode "\\.w\\'" cweb))
+;; (add-to-list 'auto-mode-alist '("\\.w\\'" . tex-mode))
+
+(provide 'mmm-cweb)
+
+;;; mmm-mason.el ends here
\ No newline at end of file
diff --git a/mmm-region.el b/mmm-region.el
index 29ae323..5159429 100644
--- a/mmm-region.el
+++ b/mmm-region.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2000 by Michael Abraham Shulman
 
 ;; Author: Michael Abraham Shulman <address@hidden>
-;; Version: $Id: mmm-region.el,v 1.32 2001/04/26 22:26:35 viritrilbia Exp $
+;; Version: $Id: mmm-region.el,v 1.33 2001/05/14 21:16:54 alanshutko Exp $
 
 ;;{{{ GPL
 
@@ -225,6 +225,24 @@ i.e. whether text inserted at the marker should be inside 
the region."
 ;;}}}
 ;;{{{ Make Submode Regions
 
+(defun mmm-valid-submode-region (submode beg end)
+  "Check if the region between BEGIN and END is valid for SUBMODE.
+Checks whether it overlaps other submode regions and whether SUBMODE
+is valid in the existing submode regions.
+Signals errors."
+  (let ((priority (length (mmm-overlays-at beg)))
+       (ovl (mmm-overlay-at beg)))
+    (if (< priority 1)
+       t
+      (if (not (eq (mmm-overlay-at beg)
+                  (mmm-overlay-at end)))
+         (signal 'mmm-subregion-crosses-parents nil)
+       (if (eq submode 
+               (if ovl (overlay-get ovl 'mmm-mode)))
+           (signal 'mmm-subregion-bad-parent)
+         t)))))
+               
+
 (defun* mmm-make-region
     (submode beg end &rest rest &key (front "") (back "")
              (beg-sticky t) (end-sticky t) face creation-hook
@@ -239,14 +257,10 @@ respectively, are sticky with respect to new insertion.  
CREATION-HOOK
 should be a function to run after the region is created.  All other
 keyword arguments are stored as properties of the overlay,
 un-keyword-ified."
+  (mmm-valid-submode-region submode beg end)
   (setq rest (append rest (list :front front :back back :beg-sticky
                                 beg-sticky :end-sticky end-sticky)))
   (mmm-mode-on)
-  ;; For now, complain about overlapping regions. Most callers should
-  ;; trap this and continue on. In future, submode regions will be
-  ;; allowed to sit inside others.
-  (when (mmm-overlays-in beg end)
-    (signal 'mmm-invalid-parent nil))
   (setq submode (mmm-modename->function submode))
   (when submode
     (mmm-update-mode-info submode))
@@ -256,6 +270,7 @@ un-keyword-ified."
     ;; Put our properties on the overlay
     (dolist (prop '(front back beg-sticky end-sticky))
       (overlay-put ovl prop (symbol-value prop)))
+    (overlay-put ovl 'priority (length (mmm-overlays-at beg)))
     ;; Put anything else the caller wants on the overlay
     (loop for (var val) on rest by #'cddr
           do (overlay-put ovl (intern (substring (symbol-name var) 1)) val))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]