[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a9c086a 130/433: (mmm-ify, mmm-match-region, mmm-match->po
From: |
Dmitry Gutov |
Subject: |
[elpa] master a9c086a 130/433: (mmm-ify, mmm-match-region, mmm-match->point): Added new values for |
Date: |
Thu, 15 Mar 2018 19:43:49 -0400 (EDT) |
branch: master
commit a9c086ad20816b5fd1277de680ab5c0c3f368fd0
Author: mas <mas>
Commit: mas <mas>
(mmm-ify, mmm-match-region, mmm-match->point): Added new values for
front- and back-offset.
---
mmm-class.el | 98 ++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 56 insertions(+), 42 deletions(-)
diff --git a/mmm-class.el b/mmm-class.el
index 00221bb..9709d42 100644
--- a/mmm-class.el
+++ b/mmm-class.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2000 by Michael Abraham Shulman
;; Author: Michael Abraham Shulman <address@hidden>
-;; Version: $Id: mmm-class.el,v 1.8 2000/07/21 00:51:40 mas Exp $
+;; Version: $Id: mmm-class.el,v 1.9 2000/07/29 17:26:54 mas Exp $
;;{{{ GPL
@@ -115,7 +115,9 @@ and interactive history."
front back save-matches (case-fold-search t)
(beg-sticky (not (number-or-marker-p front)))
(end-sticky (not (number-or-marker-p back)))
- (front-offset 0) (back-offset 0) front-verify back-verify
+ include-front include-back
+ (front-offset 0) (back-offset 0)
+ front-verify back-verify
front-form back-form creation-hook match-submode
;insert
&allow-other-keys
@@ -138,58 +140,70 @@ the rest of the arguments are for an actual class being
applied. See
(t
(mmm-save-all
(goto-char start)
- (loop for (beg end matched-front matched-back matched-submode) =
- (apply #'mmm-match-region :start (point)
- (mmm-save-keywords
- front back stop save-matches front-offset
- back-offset front-verify back-verify front-form
- back-form match-submode))
+ (loop for (beg end matched-front matched-back matched-submode back-to) =
+ (apply #'mmm-match-region :start (point) all)
while beg
while (or (not end) (/= beg end)) ; Sanity check
if end do ; match-submode, if present, succeeded.
(condition-case nil
- (mmm-make-region
- (or matched-submode submode) beg end
- :front matched-front :back matched-back
- :beg-sticky beg-sticky :end-sticky end-sticky
- :face face :creation-hook creation-hook)
- ;; If our region is invalid, go back to the end of the front
- ;; match and continue on.
- (mmm-invalid-parent (goto-char (- beg front-offset))))
- else do
- ;; If match-submode was unable to find a match, go back
- ;; to the end of the front match and continue on.
- (goto-char (- beg front-offset))
+ (progn
+ (apply #'mmm-make-region (or matched-submode submode)
+ beg end :front matched-front :back matched-back
+ all)
+ (goto-char end))
+ ;; If our region is invalid, go back to the end of the
+ ;; front match and continue on.
+ (mmm-invalid-parent (goto-char back-to)))
+ ;; If match-submode was unable to find a match, go back to
+ ;; the end of the front match and continue on.
+ else do (goto-char back-to)
)))))
;;}}}
;;{{{ Match Regions
(defun* mmm-match-region
- (&key front back start stop front-verify back-verify front-offset
- back-offset save-matches front-form back-form match-submode)
+ (&key start stop front back front-verify back-verify
+ include-front include-back front-offset back-offset
+ front-form back-form save-matches match-submode
+ &allow-other-keys)
"Find the first valid region between point and STOP.
-Return \(BEG END FRONT-FORM BACK-FORM SUBMODE) specifying the region.
-See `mmm-match-and-verify' for the valid values of FRONT and BACK
-\(markers, regexps, or functions). A nil value for END means that
-MATCH-SUBMODE failed to find a valid submode."
+Return \(BEG END FRONT-FORM BACK-FORM SUBMODE BACK-TO) specifying the
+region. See `mmm-match-and-verify' for the valid values of FRONT and
+BACK \(markers, regexps, or functions). A nil value for END means
+that MATCH-SUBMODE failed to find a valid submode. BACK-TO is the
+point at which the search should continue if the region is invalid."
(when (mmm-match-and-verify front start stop front-verify)
- (let* ((beg (+ (match-end 0) front-offset))
- (front-form (mmm-get-form front-form))
- (submode (if match-submode
- (condition-case nil
- (mmm-save-all
- (funcall match-submode front-form))
- (mmm-no-matching-submode
- (return-from
- mmm-match-region
- (values beg nil nil nil nil))))
- nil)))
- (when (mmm-match-and-verify (mmm-format-matches back save-matches)
- beg stop back-verify)
- (let ((end (+ (match-beginning 0) back-offset))
- (back-form (mmm-get-form back-form)))
- (values beg end front-form back-form submode))))))
+ (let ((beg (mmm-match->point include-front front-offset))
+ (back-to (match-end 0))
+ (front-form (mmm-get-form front-form)))
+ (let ((submode (if match-submode
+ (condition-case nil
+ (mmm-save-all
+ (funcall match-submode front-form))
+ (mmm-no-matching-submode
+ (return-from
+ mmm-match-region
+ (values nil nil nil nil nil back-to))))
+ nil)))
+ (when (mmm-match-and-verify
+ (mmm-format-matches back save-matches)
+ beg stop back-verify)
+ (let ((end (mmm-match->point (not include-back) back-offset))
+ (back-form (mmm-get-form back-form)))
+ (values beg end front-form back-form submode back-to)))))))
+
+(defun mmm-match->point (beginp offset)
+ "Find a point of starting or stopping from the match data.
+If BEGINP, start at \(match-beginning 0), else \(match-end 0), and
+move OFFSET. Handles all values for OFFSET--see `mmm-classes-alist'."
+ (save-excursion
+ (goto-char (if beginp (match-beginning 0) (match-end 0)))
+ (dolist (spec (if (listp offset) offset (list offset)))
+ (if (numberp spec)
+ (forward-char (or spec 0))
+ (funcall spec)))
+ (point)))
(defun mmm-match-and-verify (pos start stop &optional verify)
"Find first match for POS between point and STOP satisfying VERIFY.
- [elpa] master e947f88 107/433: # Updated., (continued)
- [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, 2018/03/15
- [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 <=
- [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
- [elpa] master e111833 149/433: # Updated, Dmitry Gutov, 2018/03/15
- [elpa] master 6cba9ad 164/433: (mmm-save-local-variables): Added `mode-popup-menu' for XEmacs., Dmitry Gutov, 2018/03/15
- [elpa] master b7ddfb1 145/433: # Commented on improvement of here-doc class., Dmitry Gutov, 2018/03/15
- [elpa] master e18bbf0 172/433: (mmm-display-insertion-key): Prevented (nthcdr -1 ...); breaks in XEmacs., Dmitry Gutov, 2018/03/15
- [elpa] master c8e7b80 168/433: (mmm-make-region): Explicitly set keyword defaults in &rest parameter., Dmitry Gutov, 2018/03/15
- [elpa] master 6c89465 154/433: (mmm-set-font-lock-defaults): Made into a macro., Dmitry Gutov, 2018/03/15
- [elpa] master f7ab3b2 148/433: (mmm-update-mode-info): Used compatibility wrapper for font-lock defaults., Dmitry Gutov, 2018/03/15
- [elpa] master 26fe946 147/433: (mmm-set-font-lock-defaults): Added compatibility wrapper function., Dmitry Gutov, 2018/03/15