branch: master
commit 7422b45d32e1aa75785f3dd40206f68d4a127fd7
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>
* mmm-regions-in: Keep overlay references in the return value
* mmm-fontify-region-list, mmm-syntax-propertize-function: Use them.
* mmm-erb-scan-region: Same.
* mmm-submode-overlay-at: Remove, not used anymore.
And bump the version, this is a change in the API.
Hopefuly, a relatively safe one.
---
mmm-erb.el | 4 ++--
mmm-mode.el | 2 +-
mmm-region.el | 29 ++++++++++++-----------------
3 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/mmm-erb.el b/mmm-erb.el
index f563a5a..f7dd566 100644
--- a/mmm-erb.el
+++ b/mmm-erb.el
@@ -214,12 +214,12 @@
(defun mmm-erb-scan-region (region)
(when region ; Can be nil if a line is empty, for example.
- (destructuring-bind (submode beg end) region
+ (destructuring-bind (submode beg end ovl) region
(let ((scan-fn (plist-get '(ruby-mode mmm-erb-scan-erb
js-mode mmm-erb-scan-ejs)
submode)))
(and scan-fn
- (overlay-get (mmm-overlay-at beg) 'mmm-special-tag)
+ (overlay-get ovl 'mmm-special-tag)
(save-excursion
(goto-char beg)
(skip-syntax-forward "-")
diff --git a/mmm-mode.el b/mmm-mode.el
index 26984d0..296e7c2 100644
--- a/mmm-mode.el
+++ b/mmm-mode.el
@@ -6,7 +6,7 @@
;; Package: mmm-mode
;; Author: Michael Abraham Shulman <[email protected]>
;; Keywords: convenience, faces, languages, tools
-;; Version: 0.4.8
+;; Version: 0.5.0
;; Revision: $Id: mmm-mode.el,v 1.17 2004/06/16 14:14:18 alanshutko Exp $
diff --git a/mmm-region.el b/mmm-region.el
index 04ba779..ae7986f 100644
--- a/mmm-region.el
+++ b/mmm-region.el
@@ -200,15 +200,6 @@ and update the saved previous values."
(setq mmm-current-submode mode
mmm-current-overlay ovl))
-;; TODO: Only used in `mmm-fontify-region-list', so far.
-;; Might be worth eliminating by making `mmm-regions-alist' include overlay
-;; references, not just the bounds of regions.
-(defun mmm-submode-overlay-at (mode &optional pos)
- "Return the highest priority region of MODE at POS or point, if any."
- (find-if #'(lambda (ovl)
- (eq (overlay-get ovl 'mmm-mode) mode))
- (mmm-overlays-at pos 'all)))
-
(defun mmm-submode-at (&optional pos type)
"Return the submode at POS \(or point), or NIL if none.
See `mmm-included-p' for values of TYPE."
@@ -704,21 +695,24 @@ The list is sorted in order of increasing buffer
position."
#'<))
(defun mmm-regions-in (start stop)
- "Return a list of regions of the form (MODE BEG END) whose disjoint
+ "Return a list of regions of the form (MODE BEG END OVL) whose disjoint
union covers the region from START to STOP, including delimiters."
(let ((regions
(maplist #'(lambda (pos-list)
- (if (cdr pos-list)
- (list (or (mmm-submode-at (car pos-list) 'beg)
- mmm-primary-mode)
- (car pos-list) (cadr pos-list))))
+ (when (cdr pos-list)
+ (let ((ovl (mmm-overlay-at (car pos-list) 'beg)))
+ (list (if ovl
+ (overlay-get ovl 'mmm-mode)
+ mmm-primary-mode)
+ (car pos-list) (cadr pos-list)
+ ovl))))
(mmm-submode-changes-in start stop))))
(setcdr (last regions 2) nil)
regions))
(defun mmm-regions-alist (start stop)
"Return a list of lists of the form \(MODE . REGIONS) where REGIONS
-is a list of elements of the form \(BEG END). The disjoint union all
+is a list of elements of the form \(BEG END OVL). The disjoint union all
of the REGIONS covers START to STOP."
(let ((regions (mmm-regions-in start stop))
alist)
@@ -773,7 +767,7 @@ of the REGIONS covers START to STOP."
;; `mmm-update-submode-region' does, but we force it
;; to use a specific mode, and don't save anything,
;; fontify, or change the mode line.
- (mmm-set-current-pair mode (mmm-submode-overlay-at mode))
+ (mmm-set-current-pair mode (caddr reg))
(mmm-set-local-variables (unless (eq mmm-previous-submode
mode)
mode)
mmm-current-overlay)
@@ -805,9 +799,10 @@ of the REGIONS covers START to STOP."
(let* ((mode (car elt))
(func (get mode 'mmm-syntax-propertize-function))
(beg (cadr elt)) (end (caddr elt))
+ (ovl (cadddr elt))
(syntax-propertize-chunk-size (- end beg)))
(goto-char beg)
- (mmm-set-current-pair mode (mmm-submode-overlay-at mode))
+ (mmm-set-current-pair mode ovl)
(mmm-set-local-variables mode mmm-current-overlay)
(save-restriction
(if mmm-current-overlay