aboutsummaryrefslogtreecommitdiffhomepage
path: root/mmm/mmm-class.el
diff options
context:
space:
mode:
Diffstat (limited to 'mmm/mmm-class.el')
-rw-r--r--mmm/mmm-class.el162
1 files changed, 81 insertions, 81 deletions
diff --git a/mmm/mmm-class.el b/mmm/mmm-class.el
index d79cdbbf..f1078883 100644
--- a/mmm/mmm-class.el
+++ b/mmm/mmm-class.el
@@ -44,14 +44,14 @@
CLASS can be either a symbol to look up in `mmm-classes-alist' or a
class specifier itself."
(cond ((symbolp class) ; A symbol must be looked up
- (or (cdr (assq class mmm-classes-alist))
- (and (cadr (assq class mmm-autoloaded-classes))
- (load (cadr (assq class mmm-autoloaded-classes)))
- (cdr (assq class mmm-classes-alist)))
- (signal 'mmm-invalid-submode-class (list class))))
- ((listp class) ; A list must be a class spec
- class)
- (t (signal 'mmm-invalid-submode-class (list class)))))
+ (or (cdr (assq class mmm-classes-alist))
+ (and (cadr (assq class mmm-autoloaded-classes))
+ (load (cadr (assq class mmm-autoloaded-classes)))
+ (cdr (assq class mmm-classes-alist)))
+ (signal 'mmm-invalid-submode-class (list class))))
+ ((listp class) ; A list must be a class spec
+ class)
+ (t (signal 'mmm-invalid-submode-class (list class)))))
;;}}}
;;{{{ Get and Set Class Parameters
@@ -64,9 +64,9 @@ class specifier itself."
"Set the value of the parameter PARAM for CLASS to VALUE.
Creates a new parameter if one is not present."
(let* ((spec (mmm-get-class-spec class))
- (current (member param spec)))
+ (current (member param spec)))
(if current
- (setcar (cdr current) value)
+ (setcar (cdr current) value)
(nconc spec (list param value)))))
;;}}}
@@ -81,8 +81,8 @@ none is specified by CLASS."
;; MMM Mode without applying any classes.
(unless (eq class t)
(apply #'mmm-ify :start start :stop stop
- (append (mmm-get-class-spec class)
- (list :face face)))
+ (append (mmm-get-class-spec class)
+ (list :face face)))
(mmm-run-class-hook class)
;; Hack in case class hook sets mmm-buffer-mode-display-name etc.
(mmm-set-mode-line)))
@@ -96,11 +96,11 @@ error once all classes have been applied."
(let (invalid-classes)
(dolist (class classes)
(condition-case err
- (mmm-apply-class class start stop face)
- (mmm-invalid-submode-class
- ;; Save the name of the invalid class, so we can report them
- ;; all together at the end.
- (add-to-list 'invalid-classes (second err)))))
+ (mmm-apply-class class start stop face)
+ (mmm-invalid-submode-class
+ ;; Save the name of the invalid class, so we can report them
+ ;; all together at the end.
+ (add-to-list 'invalid-classes (second err)))))
(when invalid-classes
(signal 'mmm-invalid-submode-class invalid-classes))))
@@ -124,33 +124,33 @@ and interactive history."
(defun* mmm-ify
(&rest all &key classes handler
submode match-submode
- (start (point-min)) (stop (point-max))
- front back save-matches (case-fold-search t)
- (beg-sticky (not (number-or-marker-p front)))
- (end-sticky (not (number-or-marker-p back)))
- include-front include-back
- (front-offset 0) (back-offset 0)
+ (start (point-min)) (stop (point-max))
+ front back save-matches (case-fold-search t)
+ (beg-sticky (not (number-or-marker-p front)))
+ (end-sticky (not (number-or-marker-p back)))
+ include-front include-back
+ (front-offset 0) (back-offset 0)
(front-delim nil) (back-delim nil)
(delimiter-mode mmm-delimiter-mode)
front-face back-face
- front-verify back-verify
- front-form back-form
+ front-verify back-verify
+ front-form back-form
creation-hook
- face match-face
+ face match-face
save-name match-name
(front-match 0) (back-match 0)
end-not-begin
- ;insert private
- &allow-other-keys
- )
+ ;insert private
+ &allow-other-keys
+ )
"Create submode regions from START to STOP according to arguments.
If CLASSES is supplied, it must be a list of valid CLASSes. Otherwise,
the rest of the arguments are for an actual class being applied. See
`mmm-classes-alist' for information on what they all mean."
;; Make sure we get the default values in the `all' list.
(setq all (append
- all
- (list :start start :stop stop
+ all
+ (list :start start :stop stop
:beg-sticky beg-sticky :end-sticky end-sticky
:front-offset front-offset :back-offset back-offset
:front-delim front-delim :back-delim back-delim
@@ -171,15 +171,15 @@ the rest of the arguments are for an actual class being applied. See
(mmm-save-all
(goto-char start)
(loop for (beg end front-pos back-pos matched-front matched-back
- matched-submode matched-face matched-name
- invalid-resume ok-resume) =
- (apply #'mmm-match-region :start (point) all)
- while beg
- if end ; match-submode, if present, succeeded.
- do
- (condition-case nil
- (progn
- (mmm-make-region
+ matched-submode matched-face matched-name
+ invalid-resume ok-resume) =
+ (apply #'mmm-match-region :start (point) all)
+ while beg
+ if end ; match-submode, if present, succeeded.
+ do
+ (condition-case nil
+ (progn
+ (mmm-make-region
(or matched-submode submode) beg end
:face (or matched-face face)
:front front-pos :back back-pos
@@ -192,24 +192,24 @@ the rest of the arguments are for an actual class being applied. See
:creation-hook creation-hook
)
(goto-char ok-resume))
- ;; If our region is invalid, go back to the end of the
- ;; front match and continue on.
- (mmm-error (goto-char invalid-resume)))
- ;; 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 invalid-resume)
- )))))
+ ;; If our region is invalid, go back to the end of the
+ ;; front match and continue on.
+ (mmm-error (goto-char invalid-resume)))
+ ;; 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 invalid-resume)
+ )))))
;;}}}
;;{{{ Match Regions
(defun* mmm-match-region
(&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 match-face
+ include-front include-back front-offset back-offset
+ front-form back-form save-matches match-submode match-face
front-match back-match end-not-begin
save-name match-name
- &allow-other-keys)
+ &allow-other-keys)
"Find the first valid region between point and STOP.
Return \(BEG END FRONT-POS BACK-POS FRONT-FORM BACK-FORM SUBMODE FACE
NAME INVALID-RESUME OK-RESUME) specifying the region. See
@@ -223,46 +223,46 @@ and OK-RESUME if the region is valid."
(front-pos (if front-delim
(mmm-match->point t front-delim front-match)
nil))
- (invalid-resume (match-end front-match))
- (front-form (mmm-get-form front-form)))
+ (invalid-resume (match-end front-match))
+ (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 beg nil nil nil nil nil nil nil nil
- invalid-resume nil))))
- nil))
+ (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 nil nil nil
+ invalid-resume nil))))
+ nil))
(name (cond ((functionp match-name)
(mmm-save-all (funcall match-name front-form)))
((stringp match-name)
(if save-name
(mmm-format-matches match-name)
match-name))))
- (face (cond ((functionp match-face)
- (mmm-save-all
- (funcall match-face front-form)))
- (match-face
- (cdr (assoc front-form match-face))))))
- (when (mmm-match-and-verify
- (if save-matches
- (mmm-format-matches back)
- back)
- beg stop back-verify)
- (let* ((end (mmm-match->point (not include-back)
+ (face (cond ((functionp match-face)
+ (mmm-save-all
+ (funcall match-face front-form)))
+ (match-face
+ (cdr (assoc front-form match-face))))))
+ (when (mmm-match-and-verify
+ (if save-matches
+ (mmm-format-matches back)
+ back)
+ beg stop back-verify)
+ (let* ((end (mmm-match->point (not include-back)
back-offset back-match))
(back-pos (if back-delim
(mmm-match->point nil back-delim back-match)
nil))
(back-form (mmm-get-form back-form))
- (ok-resume (if end-not-begin
+ (ok-resume (if end-not-begin
(match-end back-match)
end)))
- (values beg end front-pos back-pos front-form back-form
+ (values beg end front-pos back-pos front-form back-form
submode face name
- invalid-resume ok-resume)))))))
+ invalid-resume ok-resume)))))))
(defun mmm-match->point (beginp offset match)
"Find a point of starting or stopping from the match data. If
@@ -274,8 +274,8 @@ and move OFFSET. Handles all values of OFFSET--see `mmm-classes-alist'."
(match-end back-match)))
(dolist (spec (if (listp offset) offset (list offset)))
(if (numberp spec)
- (forward-char (or spec 0))
- (funcall spec)))
+ (forward-char (or spec 0))
+ (funcall spec)))
(point)))
(defun mmm-match-and-verify (pos start stop &optional verify)
@@ -296,7 +296,7 @@ unless POS is a regexp."
;; Strings are searched for as regexps.
((stringp pos)
(loop always (re-search-forward pos stop 'limit)
- until (or (not verify) (mmm-save-all (funcall verify)))))
+ until (or (not verify) (mmm-save-all (funcall verify)))))
;; Otherwise it must be a function.
((functionp pos)
(funcall pos stop))))
@@ -311,9 +311,9 @@ return it. If FORM is a function, call it. If FORM is a list, return
its `car' \(usually in this case, FORM is a one-element list
containing a function to be used as the delimiter form."
(cond ((stringp form) form)
- ((not form) (mmm-default-get-form))
- ((functionp form) (mmm-save-all (funcall form)))
- ((listp form) (car form))))
+ ((not form) (mmm-default-get-form))
+ ((functionp form) (mmm-save-all (funcall form)))
+ ((listp form) (car form))))
(defun mmm-default-get-form ()
(regexp-quote (match-string 0)))