ProofGeneral / PG

This repo is the new home of Proof General
https://proofgeneral.github.io
GNU General Public License v3.0
491 stars 88 forks source link

Please remove bundled mmm-mode libraries #171

Closed tarsius closed 7 years ago

tarsius commented 7 years ago

As part of my work on the Emacsmirror I try to resolve feature conflicts between mirrored packages. I noticed that PG bundles mmm-mode. That package is now maintained in its own right again (https://github.com/purcell/mmm-mode) and you should remove the bundled copy.

The two versions seem to be very similar. Most differences are only whitespace fixes and dropped XEmacs support. There are also some new libraries. Below you can see the diff.

I would have created a pr to remove the bundled libraries, but I suspect you might also have to make some small adjustments to the build scripts, to teach them that mmm-mode is no longer bundled.

```diff diff -u coq/mmm-auto.el mmm/mmm-auto.el --- coq/mmm-auto.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-auto.el 2017-03-16 17:32:06.168017107 +0100 @@ -3,7 +3,6 @@ ;; Copyright (C) 2000 by Michael Abraham Shulman ;; Author: Michael Abraham Shulman -;; Version: $Id$ ;;{{{ GPL @@ -66,7 +65,8 @@ (defvar mmm-autoloaded-classes '((mason "mmm-mason" nil) - (embedded-css "mmm-sample" nil) + (myghty "mmm-myghty" nil) + (html-css "mmm-sample" nil) (html-js "mmm-sample" nil) (here-doc "mmm-sample" nil) (embperl "mmm-sample" nil) @@ -94,7 +94,7 @@ ;; Don't autoload already defined classes (unless (assq class mmm-classes-alist) (add-to-list 'mmm-autoloaded-classes - (list class file private)))) + (list class file private)))) ;;}}} ;;{{{ Autoload Functions @@ -148,16 +148,16 @@ (dolist (buffer mmm-changed-buffers-list) (when (buffer-live-p buffer) (with-current-buffer buffer - (mmm-run-major-mode-hook)))) + (mmm-run-major-mode-hook)))) (setq mmm-changed-buffers-list '())) (defun mmm-mode-on-maybe () "Conditionally turn on MMM Mode. -Turn on MMM Mode if `global-mmm-mode' is non-nil and there are classes -to apply, or always if `global-mmm-mode' is t." +Turn on MMM Mode if `mmm-global-mode' is non-nil and there are classes +to apply, or always if `mmm-global-mode' is t." (cond ((eq mmm-global-mode t) (mmm-mode-on)) - ((not mmm-global-mode)) - ((mmm-get-all-classes nil) (mmm-mode-on))) + ((not mmm-global-mode)) + ((mmm-get-all-classes nil) (mmm-mode-on))) (when mmm-mode (mmm-update-font-lock-buffer))) @@ -174,4 +174,4 @@ (provide 'mmm-auto) -;;; mmm-auto.el ends here \ No newline at end of file +;;; mmm-auto.el ends here diff -u coq/mmm-class.el mmm/mmm-class.el --- coq/mmm-class.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-class.el 2017-03-16 17:32:06.172016758 +0100 @@ -3,7 +3,6 @@ ;; Copyright (C) 2000, 2004 by Michael Abraham Shulman ;; Author: Michael Abraham Shulman -;; Version: $Id$ ;;{{{ GPL @@ -44,14 +43,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 +63,9 @@ "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 +80,8 @@ ;; 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 +95,11 @@ (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)))) @@ -114,6 +113,8 @@ (mmm-clear-overlays start stop 'strict) (mmm-apply-classes (mmm-get-all-classes t) :start start :stop stop) (mmm-update-submode-region) + (syntax-ppss-flush-cache start) + (syntax-propertize stop) (mmm-refontify-maybe start stop)) ;;}}} @@ -124,33 +125,33 @@ (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 +172,15 @@ (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 +193,25 @@ :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 + front-delim back-delim + 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 @@ -220,65 +222,62 @@ and OK-RESUME if the region is valid." (when (mmm-match-and-verify front start stop front-verify) (let ((beg (mmm-match->point include-front front-offset front-match)) - (front-pos (with-no-warnings ; da: front-delim dyn scope? - (if front-delim + (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))) - (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)) + (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)) (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 (with-no-warnings ; da: as above - (if back-delim - (mmm-match->point nil back-delim back-match) - nil))) + (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 BEGINP, start at \(match-beginning MATCH), else \(match-end MATCH), and move OFFSET. Handles all values of OFFSET--see `mmm-classes-alist'." (save-excursion - (goto-char (with-no-warnings ; da: front/back-match dyn binding? - (if beginp - (match-beginning front-match) - (match-end back-match)))) + (goto-char (if beginp + (match-beginning match) + (match-end 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) @@ -299,7 +298,7 @@ ;; 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)))) @@ -314,9 +313,9 @@ 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))) @@ -325,4 +324,4 @@ (provide 'mmm-class) -;;; mmm-class.el ends here \ No newline at end of file +;;; mmm-class.el ends here diff -u coq/mmm-cmds.el mmm/mmm-cmds.el --- coq/mmm-cmds.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-cmds.el 2017-03-16 17:32:06.172016758 +0100 @@ -3,7 +3,6 @@ ;; Copyright (C) 2000 by Michael Abraham Shulman ;; Author: Michael Abraham Shulman -;; Version: $Id$ ;;{{{ GPL @@ -30,6 +29,7 @@ ;;; Code: +(require 'cl) (require 'font-lock) (require 'mmm-compat) (require 'mmm-vars) @@ -42,16 +42,16 @@ "Add submode regions according to an existing submode class." (interactive (list (intern - (completing-read - "Submode Class: " - (remove-duplicates - (mapcar #'(lambda (spec) (list (symbol-name (car spec)))) - (append - (remove-if #'(lambda (spec) (plist-get (cdr spec) :private)) - mmm-classes-alist) - (remove-if #'caddr mmm-autoloaded-classes))) - :test #'equal) - nil t)))) + (completing-read + "Submode Class: " + (remove-duplicates + (mapcar #'(lambda (spec) (list (symbol-name (car spec)))) + (append + (remove-if #'(lambda (spec) (plist-get (cdr spec) :private)) + mmm-classes-alist) + (remove-if #'caddr mmm-autoloaded-classes))) + :test #'equal) + nil t)))) (unless (eq class (intern "")) (mmm-apply-class class) (mmm-add-to-history class) @@ -65,7 +65,7 @@ (interactive "aSubmode: \nr") (mmm-ify :submode submode :front front :back back) (setq front (mmm-make-marker front t nil) - back (mmm-make-marker back nil nil)) + back (mmm-make-marker back nil nil)) (mmm-add-to-history `(:submode ,submode :front ,front :back ,back)) (mmm-enable-font-lock submode)) @@ -77,14 +77,14 @@ "Add SUBMODE regions to the buffer delimited by FRONT and BACK. With prefix argument, prompts for all additional keywords arguments. See `mmm-classes-alist'." - (interactive "aSubmode: -sFront Regexp: -nOffset from Front Regexp: -sBack Regexp: -nOffset from Back Regexp: + (interactive "aSubmode: +sFront Regexp: +nOffset from Front Regexp: +sBack Regexp: +nOffset from Back Regexp: nNumber of matched substrings to save: ") (let ((args (mmm-save-keywords submode front back front-offset - back-offset save-matches))) + back-offset save-matches))) (apply #'mmm-ify args) (mmm-add-to-history args)) (mmm-enable-font-lock submode)) @@ -132,13 +132,13 @@ (defun mmm-get-block (lines) (let ((inhibit-point-motion-hooks t)) (list (save-excursion - (forward-line (- lines)) - (beginning-of-line) - (point)) - (save-excursion - (forward-line lines) - (end-of-line) - (point))))) + (forward-line (- lines)) + (beginning-of-line) + (point)) + (save-excursion + (forward-line lines) + (end-of-line) + (point))))) ;;}}} ;;{{{ Reparse Current Region @@ -150,14 +150,14 @@ (let ((ovl (mmm-overlay-at (point) 'all))) (when ovl (let ((beg (save-excursion - (goto-char (mmm-front-start ovl)) - (forward-line -1) - (point))) - (end (save-excursion - (goto-char (mmm-back-end ovl)) - (forward-line 1) - (point)))) - (mmm-parse-region beg end))))) + (goto-char (mmm-front-start ovl)) + (forward-line -1) + (point))) + (end (save-excursion + (goto-char (mmm-back-end ovl)) + (forward-line 1) + (point)))) + (mmm-parse-region beg end))))) ;;}}} ;;{{{ Clear Submode Regions @@ -197,22 +197,22 @@ (let ((ovl (mmm-overlay-at))) (when ovl (combine-after-change-calls - (save-match-data - (save-excursion - (when (mmm-match-back ovl) - (if arg - (replace-match "") - (return-from mmm-end-current-region))))) - (let ((back (overlay-get ovl 'back))) - (cond ((stringp back) - (save-excursion - (unless arg (goto-char (overlay-end ovl))) - (save-excursion (insert back)) - (move-overlay ovl (overlay-start ovl) (point)))) - ((functionp back) - (funcall back ovl (if arg 'middle t)))))) + (save-match-data + (save-excursion + (when (mmm-match-back ovl) + (if arg + (replace-match "") + (return-from mmm-end-current-region))))) + (let ((back (overlay-get ovl 'back))) + (cond ((stringp back) + (save-excursion + (unless arg (goto-char (overlay-end ovl))) + (save-excursion (insert back)) + (move-overlay ovl (overlay-start ovl) (point)))) + ((functionp back) + (funcall back ovl (if arg 'middle t)))))) (mmm-refontify-maybe (save-excursion (forward-line -1) (point)) - (save-excursion (forward-line 1) (point)))))) + (save-excursion (forward-line 1) (point)))))) ;;}}} ;;{{{ Narrow to Region @@ -246,14 +246,14 @@ prefix and modifiers) will insert a <%perl>... region." (interactive "P") (let* ((seq (this-command-keys)) - (event (aref seq (1- (length seq)))) - (mods (event-modifiers event)) - (key (mmm-event-key event))) + (event (aref seq (1- (length seq)))) + (mods (event-modifiers event)) + (key (mmm-event-key event))) (if (subsetp mmm-insert-modifiers mods) - (mmm-insert-by-key - (append (set-difference mods mmm-insert-modifiers) - key) - arg)))) + (mmm-insert-by-key + (append (set-difference mods mmm-insert-modifiers) + key) + arg)))) (defun mmm-insert-by-key (key &optional arg) "Insert a submode region based on event KEY. @@ -268,18 +268,15 @@ (multiple-value-bind (class skel str) (mmm-get-insertion-spec key) (when skel (let ((after-change-functions nil) - (old-undo buffer-undo-list) undo - ;; da: Proof General patch for compatibility with holes.el, - ;; bind this variable to prevent inserting holes here. - mmm-inside-insert-by-key) - ;; XEmacs' skeleton doesn't manage positions by itself, so we - ;; have to do it. - (if mmm-xemacs (setq skeleton-positions nil)) - (skeleton-proxy-new skel str arg) - (destructuring-bind (back end beg front) skeleton-positions - ;; TODO: Find a way to trap invalid-parent signals from - ;; make-region and undo the skeleton insertion. - (let ((match-submode (plist-get class :match-submode)) + (old-undo buffer-undo-list) undo) + ;; XEmacs' skeleton doesn't manage positions by itself, so we + ;; have to do it. + (if mmm-xemacs (setq skeleton-positions nil)) + (skeleton-proxy-new skel str arg) + (destructuring-bind (back end beg front) skeleton-positions + ;; TODO: Find a way to trap invalid-parent signals from + ;; make-region and undo the skeleton insertion. + (let ((match-submode (plist-get class :match-submode)) (match-face (plist-get class :match-face)) (match-name (plist-get class :match-name)) (front-form (regexp-quote (buffer-substring front beg))) @@ -291,13 +288,13 @@ (mmm-save-all (funcall match-submode front-form)) (plist-get class :submode)))) (setq face - (cond ((functionp match-face) - (mmm-save-all - (funcall match-face front-form))) - (match-face - (cdr (assoc front-form match-face))) - (t - (plist-get class :face)))) + (cond ((functionp match-face) + (mmm-save-all + (funcall match-face front-form))) + (match-face + (cdr (assoc front-form match-face))) + (t + (plist-get class :face)))) (setq name (cond ((plist-get class :skel-name) ;; Optimize the name to the user-supplied str @@ -318,8 +315,8 @@ (t ;; No, just use it as-is match-name))) - (mmm-make-region - submode beg end + (mmm-make-region + submode beg end :face face :name name :front front :back back @@ -327,17 +324,17 @@ :evaporation 'front ;;; :beg-sticky (plist-get class :beg-sticky) ;;; :end-sticky (plist-get class :end-sticky) - :beg-sticky t :end-sticky t - :creation-hook (plist-get class :creation-hook)) - (mmm-enable-font-lock submode))) - ;; Now get rid of intermediate undo boundaries, so that the entire - ;; insertion can be undone as one action. This should really be - ;; skeleton's job, but it doesn't do it. - (setq undo buffer-undo-list) - (while (not (eq (cdr undo) old-undo)) - (when (eq (cadr undo) nil) - (setcdr undo (cddr undo))) - (setq undo (cdr undo))))))) + :beg-sticky t :end-sticky t + :creation-hook (plist-get class :creation-hook)) + (mmm-enable-font-lock submode))) + ;; Now get rid of intermediate undo boundaries, so that the entire + ;; insertion can be undone as one action. This should really be + ;; skeleton's job, but it doesn't do it. + (setq undo buffer-undo-list) + (while (not (eq (cdr undo) old-undo)) + (when (eq (cadr undo) nil) + (setcdr undo (cddr undo))) + (setq undo (cdr undo))))))) (defun mmm-get-insertion-spec (key &optional classlist) "Get the insertion info for KEY from all classes in CLASSLIST. @@ -346,22 +343,20 @@ CLASSLIST defaults to the return value of `mmm-get-all-classes', including global classes." (loop for classname in (or classlist (mmm-get-all-classes t)) - for class = (mmm-get-class-spec classname) - for inserts = (plist-get class :insert) - for skel = (cddr (assoc key inserts)) - with str - ;; If SKEL is a dotted pair, it means call another key's - ;; insertion spec with an argument. - unless (consp (cdr skel)) - do (setq str (cdr skel) - skel (cddr (assoc (car skel) inserts))) - if skel return (list class skel str) - ;; If we have a group class, recurse. - if (plist-get class :classes) - if (mmm-get-insertion-spec key it) - return it - else - return nil)) + for class = (mmm-get-class-spec classname) + for inserts = (plist-get class :insert) + for skel = (cddr (assoc key inserts)) + with str + ;; If SKEL is a dotted pair, it means call another key's + ;; insertion spec with an argument. + unless (consp (cdr skel)) + do (setq str (cdr skel) + skel (cddr (assoc (car skel) inserts))) + if skel return (list class skel str) + ;; If we have a group class, recurse. + if (plist-get class :classes) + if (mmm-get-insertion-spec key it) + return it)) ;;}}} ;;{{{ Help on Insertion @@ -374,20 +369,20 @@ (princ "Key Inserts\n") (princ "--- -------\n\n") (mapcar #'mmm-display-insertion-key - (mmm-get-all-insertion-keys)))) + (mmm-get-all-insertion-keys)))) (defun mmm-display-insertion-key (spec) "Print an insertion binding to standard output. SPEC should be \(KEY NAME ...) where KEY is an insertion key and NAME is a symbol naming the insertion." (let* ((str (make-string 16 ?\ )) - ;; This gets us a dotted list, because of the way insertion - ;; keys are specified. - (key (append mmm-insert-modifiers (car spec))) - (lastkey (nthcdr (max (1- (safe-length key)) 0) key))) + ;; This gets us a dotted list, because of the way insertion + ;; keys are specified. + (key (append mmm-insert-modifiers (car spec))) + (lastkey (nthcdr (max (1- (safe-length key)) 0) key))) ;; Now we make it a true list (if (consp key) - (setcdr lastkey (list (cdr lastkey))) + (setcdr lastkey (list (cdr lastkey))) (setq key (list key))) ;; Get the spacing right (store-substring str 0 @@ -404,12 +399,12 @@ NAME is a symbol naming the insertion." (remove-duplicates (loop for classname in (or classlist (mmm-get-all-classes t)) - for class = (mmm-get-class-spec classname) - append (plist-get class :insert) into keys - ;; If we have a group class, recurse. - if (plist-get class :classes) - do (setq keys (append keys (mmm-get-all-insertion-keys it))) - finally return keys) + for class = (mmm-get-class-spec classname) + append (plist-get class :insert) into keys + ;; If we have a group class, recurse. + if (plist-get class :classes) + do (setq keys (append keys (mmm-get-all-insertion-keys it))) + finally return keys) :test #'equal :key #'(lambda (x) (cons (car x) (cadr x))) :from-end t)) @@ -446,4 +441,4 @@ (provide 'mmm-cmds) -;;; mmm-cmds.el ends here \ No newline at end of file +;;; mmm-cmds.el ends here diff -u coq/mmm-compat.el mmm/mmm-compat.el --- coq/mmm-compat.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-compat.el 2017-03-16 17:32:06.172016758 +0100 @@ -3,7 +3,6 @@ ;; Copyright (C) 2000 by Michael Abraham Shulman ;; Author: Michael Abraham Shulman -;; Version: $Id$ ;;{{{ GPL @@ -28,8 +27,8 @@ ;; This file provides a number of hacks that are necessary for MMM ;; Mode to function in different Emacsen. MMM Mode is designed for -;; FSF Emacs 20 and 21, but these hacks usually enable it to work -;; almost perfectly in Emacs 19 and XEmacs 20 or 21. +;; FSF Emacs, but these hacks usually enable it to work +;; almost perfectly in XEmacs 21. ;;; Code: @@ -41,59 +40,11 @@ "Whether we are running XEmacs.") ;;}}} -;;{{{ Keywords (Emacs 19) - -;; Emacs 19 doesn't automatically set keyword variables to themselves. -;; We shouldn't have to do any more than these, since CL automatically -;; defines all keywords used for function arguments. -(defvar mmm-keywords-used - '(:group :regexp :region :function :insert :classes :private) - "List of extra keywords used by MMM Mode.") - -(dolist (keyword mmm-keywords-used) - (set keyword keyword)) - -;;}}} -;;{{{ Customization (Emacs 19) - -(condition-case () - (require 'custom) - (error nil)) - -(unless (and (featurep 'custom) - (fboundp 'custom-declare-variable)) - (defmacro defgroup (&rest args) - nil) - ;; da: backquote syntax updated, so not Emacs <19.29 compatible - (defmacro defface (var values doc &rest args) - `(make-face (quote ,var))) - (defmacro defcustom (var value doc &rest args) - `(defvar ,var ,value ,doc))) - -;;}}} -;;{{{ Regexp-Opt (Emacs 19) - -(condition-case () - (require 'regexp-opt) - (error nil)) - -(unless (and (featurep 'regexp-opt) - (fboundp 'regexp-opt)) - ;; No regexp-opt; create one - (defun regexp-opt (strings &optional paren) - (concat (if paren "\\(" "") - (mapconcat 'regexp-quote strings "\\|") - (if paren "\\)" "")))) - -;;}}} ;;{{{ Regexp-Opt (XEmacs) -(defmacro mmm-regexp-opt (strings paren) - "Act like FSF Emacs' `regexp-opt', whichever Emacs we're in. -XEmacs' `regexp-opt' requires an extra parameter to do grouping." - (if (featurep 'xemacs) - `(regexp-opt ,strings ,paren t) - `(regexp-opt ,strings ,paren))) +;; As of XEmacs' xemacs-base package version 1.82, +;; the regexp-opt API is compatible with GNU Emacs. +(defalias 'mmm-regexp-opt 'regexp-opt) ;;}}} ;;{{{ Overlays (XEmacs) @@ -151,44 +102,21 @@ (defvar skeleton-further-elements ()) (not (assoc '@ skeleton-further-elements)) (add-to-list 'skeleton-further-elements - '(@ ''(push (point) skeleton-positions))))) + '(@ ''(push (point) skeleton-positions))))) ;;}}} ;;{{{ Make Temp Buffers (XEmacs) (defmacro mmm-make-temp-buffer (buffer name) - "Return a buffer called NAME including the text of BUFFER. + "Return a buffer with name based on NAME including the text of BUFFER. This text should not be modified." (if (fboundp 'make-indirect-buffer) - `(make-indirect-buffer ,buffer ,name) + `(make-indirect-buffer ,buffer (generate-new-buffer-name ,name)) `(save-excursion - (set-buffer (get-buffer-create ,name)) + (set-buffer (generate-new-buffer ,name)) (insert-buffer ,buffer) (current-buffer)))) -;;}}} -;;{{{ Font Lock Available (Emacs w/o X) - -(defvar mmm-font-lock-available-p (or window-system mmm-xemacs) - "Whether font-locking is available. -Emacs 19 and 20 only provide font-lock with a window system in use.") - -;;}}} -;;{{{ Font Lock Defaults (XEmacs) - -(defmacro mmm-set-font-lock-defaults () - "Set font-lock defaults without trying to turn font-lock on. -In XEmacs, `font-lock-set-defaults' calls `font-lock-set-defaults-1' -to do the real work but then `turn-on-font-lock', which in turn calls -`font-lock-mode', which unsets the defaults if running in a hidden -buffer \(name begins with a space). So in XEmacs, we just call -`font-lock-set-defaults-1' directly." - (if mmm-xemacs - `(font-lock-set-defaults-1) - `(font-lock-set-defaults))) - -;;}}} - (provide 'mmm-compat) -;;; mmm-compat.el ends here \ No newline at end of file +;;; mmm-compat.el ends here diff -u coq/mmm-cweb.el mmm/mmm-cweb.el --- coq/mmm-cweb.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-cweb.el 2017-03-16 17:32:06.172016758 +0100 @@ -3,7 +3,6 @@ ;; Copyright (C) 2001 by Alan Shutko ;; Author: Alan Shutko -;; Version: $Id$ ;;{{{ GPL @@ -98,4 +97,4 @@ (provide 'mmm-cweb) -;;; mmm-cweb.el ends here \ No newline at end of file +;;; mmm-cweb.el ends here Only in mmm: mmm-defaults.el Only in mmm: mmm-erb.el diff -u coq/mmm-mason.el mmm/mmm-mason.el --- coq/mmm-mason.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-mason.el 2017-03-16 17:32:06.172016758 +0100 @@ -3,7 +3,6 @@ ;; Copyright (C) 2000 by Michael Abraham Shulman ;; Author: Michael Abraham Shulman -;; Version: $Id$ ;;{{{ GPL @@ -76,7 +75,7 @@ :front "<%text>" :back "" :insert ((?t mason-<%text> nil @ "<%text>" @ "\n" - _ "\n" @ "" @))) + _ "\n" @ "" @))) (mason-doc :submode text-mode :face mmm-comment-submode-face @@ -84,29 +83,29 @@ :back "" :face nil :insert ((?d mason-<%doc> nil @ "<%doc>" @ "\n" - _ "\n" @ "" @))) + _ "\n" @ "" @))) (mason-perl :submode perl :match-face (("<%perl>" . mmm-code-submode-face) - ("<%init>" . mmm-init-submode-face) - ("<%cleanup>" . mmm-cleanup-submode-face) - ("<%once>" . mmm-init-submode-face) - ("<%filter>" . mmm-special-submode-face) - ("<%shared>" . mmm-init-submode-face)) + ("<%init>" . mmm-init-submode-face) + ("<%cleanup>" . mmm-cleanup-submode-face) + ("<%once>" . mmm-init-submode-face) + ("<%filter>" . mmm-special-submode-face) + ("<%shared>" . mmm-init-submode-face)) :front ,mmm-mason-perl-tags-regexp :back "" :save-matches 1 :match-name "~1" :save-name 1 :insert ((?, mason-<%TAG> "Perl section: " @ "<%" str ">" @ - ";\n" _ "\n" @ "" @) - (?< mason-<%TAG> ?, . nil) - (?p mason-<%perl> ?, . "perl") - (?i mason-<%init> ?, . "init") - (?c mason-<%cleanup> ?, . "cleanup") - (?o mason-<%once> ?, . "once") - (?l mason-<%filter> ?, . "filter") - (?s mason-<%shared> ?, . "shared"))) + ";\n" _ "\n" @ "" @) + (?< mason-<%TAG> ?, . nil) + (?p mason-<%perl> ?, . "perl") + (?i mason-<%init> ?, . "init") + (?c mason-<%cleanup> ?, . "cleanup") + (?o mason-<%once> ?, . "once") + (?l mason-<%filter> ?, . "filter") + (?s mason-<%shared> ?, . "shared"))) (mason-pseudo-perl :submode perl :face mmm-declaration-submode-face @@ -114,11 +113,11 @@ :back "" :save-matches 1 :insert ((?. mason-pseudo-<%TAG> "Pseudo-perl section: " @ "<%" str ">" @ - "\n" _ "\n" @ "" @) - (?> mason-pseudo-<%TAG> ?, . nil) - (?a mason-<%args> ?. . "args") - (?f mason-<%flags> ?. . "flags") - (?r mason-<%attr> ?. . "attr"))) + "\n" _ "\n" @ "" @) + (?> mason-pseudo-<%TAG> ?, . nil) + (?a mason-<%args> ?. . "args") + (?f mason-<%flags> ?. . "flags") + (?r mason-<%attr> ?. . "attr"))) (mason-inline :submode perl :face mmm-output-submode-face @@ -126,29 +125,29 @@ :front-verify mmm-mason-verify-inline :back "%>" :insert ((?% mason-<%-%> nil @ "<%" @ " " _ " " @ "%>" @) - (?5 mason-<%-%> ?% . nil))) + (?5 mason-<%-%> ?% . nil))) (mason-call :submode perl :face mmm-special-submode-face :front "<&" :back "&>" :insert ((?& mason-<&-&> nil @ "<&" @ " " _ " " @ "&>" @) - (?7 mason-<&-&> ?% . nil))) + (?7 mason-<&-&> ?% . nil))) (mason-one-line-comment :submode text-mode :face mmm-comment-submode-face :front "^%#" :back "\n" :insert ((?# mason-%-comment nil (mmm-mason-start-line) - @ "%" @ "# " _ @ '(mmm-mason-end-line) "\n" @) - (?3 mason-%-comment ?# . nil))) + @ "%" @ "# " _ @ '(mmm-mason-end-line) "\n" @) + (?3 mason-%-comment ?# . nil))) (mason-one-line :submode perl :face mmm-code-submode-face :front "^%" :back "\n" :insert ((return mason-%-line nil (mmm-mason-start-line) - @ "%" @ " " _ @ '(mmm-mason-end-line) "\n" @))))) + @ "%" @ " " _ @ '(mmm-mason-end-line) "\n" @))))) ;;}}} ;;{{{ One-line Sections @@ -173,4 +172,4 @@ (provide 'mmm-mason) -;;; mmm-mason.el ends here \ No newline at end of file +;;; mmm-mason.el ends here diff -u coq/mmm-mode.el mmm/mmm-mode.el --- coq/mmm-mode.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-mode.el 2017-03-16 17:32:06.172016758 +0100 @@ -1,14 +1,15 @@ ;;; mmm-mode.el --- Allow Multiple Major Modes in a buffer ;; Copyright (C) 1999, 2004 by Michael Abraham Shulman +;; Copyright (C) 2013-2015 by Dmitry Gutov ;; Emacs Lisp Archive Entry ;; Package: mmm-mode ;; Author: Michael Abraham Shulman +;; Maintainer: Dmitry Gutov +;; URL: https://github.com/purcell/mmm-mode ;; Keywords: convenience, faces, languages, tools -;; Version: 0.4.8 - -;; Revision: $Id$ +;; Version: 0.5.4 ;;{{{ GPL @@ -116,17 +117,17 @@ a background color for ease of recognition. While the point is in a submode region, the following changes \(are supposed to) occur: -1. The local keymap is that of the submode. +1. The local keymap and the syntax table are that of the submode. 2. The mode line changes to show what submode region is active. 3. The major mode menu and mouse popup menu are that of the submode. 4. Some local variables of the submode shadow the default mode's. -5. The syntax table and indentation are those of the submode. -6. Font-lock fontifies correctly for the submode. +5. Font-lock fontifies correctly for the submode. +6. Indentation function dispatches to the appropriate submode. For further information, including installation and configuration instructions, see the Info file mmm.info which is included with the distribution of MMM Mode. Many of MMM's configuration variables are -available through M-x customize under Programming | Tools | Mmm." +available through M-x customize-group RET mmm." (interactive "P") (if (if arg (> (prefix-numeric-value arg) 0) (not mmm-mode)) (mmm-mode-on) @@ -151,29 +152,30 @@ (c-make-styles-buffer-local t)) (mmm-update-mode-info major-mode) (setq mmm-region-saved-locals-for-dominant - (list* (list 'font-lock-cache-state nil) - (list 'font-lock-cache-position (make-marker)) - (copy-tree (cdr (assq major-mode mmm-region-saved-locals-defaults))))) + ;; FIXME: Neither is defined in recent Emacs. + (list* (list 'font-lock-cache-state nil) + (list 'font-lock-cache-position (make-marker)) + (copy-tree (cdr (assq major-mode mmm-region-saved-locals-defaults))))) ;; Without the next line, the (make-marker) above gets replaced ;; with the starting value of nil, and all comes to naught. - (mmm-set-local-variables major-mode) + (mmm-set-local-variables major-mode nil) (mmm-add-hooks) (mmm-fixup-skeleton) (make-local-variable 'font-lock-fontify-region-function) - ;(make-local-variable 'font-lock-beginning-of-syntax-function) - (make-local-variable 'syntax-beginning-function) - (setq font-lock-fontify-region-function 'mmm-fontify-region - ; font-lock-beginning-of-syntax-function 'mmm-beginning-of-syntax - syntax-begin-function 'mmm-beginning-of-syntax) + (setq font-lock-fontify-region-function 'mmm-fontify-region) + (set (make-local-variable 'syntax-begin-function) nil) + (set (make-local-variable 'syntax-propertize-function) + 'mmm-syntax-propertize-function) + (set (make-local-variable 'indent-line-function) mmm-indent-line-function) (setq mmm-mode t) (condition-case err - (mmm-apply-all) + (mmm-apply-all) (mmm-error - ;; Complain, but don't die, since we want files to go ahead - ;; and be opened anyway, and the mode to go ahead and be - ;; turned on. Should we delete all previously made submode - ;; regions when we find an invalid one? - (message "%s" (error-message-string err)))) + ;; Complain, but don't die, since we want files to go ahead + ;; and be opened anyway, and the mode to go ahead and be + ;; turned on. Should we delete all previously made submode + ;; regions when we find an invalid one? + (message "%s" (error-message-string err)))) (run-hooks 'mmm-mode-hook) (mmm-run-major-hook)))) @@ -191,10 +193,9 @@ (mmm-clear-local-variables) (mmm-update-submode-region) (setq font-lock-fontify-region-function - (get mmm-primary-mode 'mmm-fontify-region-function) - ; font-lock-beginning-of-syntax-function - syntax-begin-function - (get mmm-primary-mode 'mmm-beginning-of-syntax-function)) + (get mmm-primary-mode 'mmm-fontify-region-function)) + (set 'syntax-begin-function + (get mmm-primary-mode 'mmm-beginning-of-syntax-function)) (mmm-update-font-lock-buffer) (mmm-refontify-maybe) (setq mmm-mode nil) @@ -296,4 +297,4 @@ (provide 'mmm-mode) -;;; mmm-mode.el ends here \ No newline at end of file +;;; mmm-mode.el ends here Only in mmm: mmm-mode.spec Only in mmm: mmm-myghty.el Only in mmm: mmm-noweb.el diff -u coq/mmm-region.el mmm/mmm-region.el --- coq/mmm-region.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-region.el 2017-03-16 17:32:06.176016442 +0100 @@ -1,9 +1,9 @@ ;;; mmm-region.el --- Manipulating and behavior of MMM submode regions ;; Copyright (C) 2000 by Michael Abraham Shulman +;; Copyright (C) 2012, 2013 by Dmitry Gutov ;; Author: Michael Abraham Shulman -;; Version: $Id$ ;;{{{ GPL @@ -149,8 +149,8 @@ (defun mmm-sort-overlays (overlays) "Sort OVERLAYS in order of decreasing priority." (sort (copy-list overlays) - #'(lambda (x y) (> (or (overlay-get x 'priority) 0) - (or (overlay-get y 'priority) 0))))) + #'(lambda (x y) (> (or (overlay-get x 'priority) 0) + (or (overlay-get y 'priority) 0))))) ;;}}} ;;{{{ Current Submode @@ -188,24 +188,17 @@ (mmm-overlays-at pos))) (let ((ovl (mmm-overlay-at pos))) (if (eq ovl mmm-current-overlay) - nil - (setq mmm-previous-overlay mmm-current-overlay - mmm-previous-submode mmm-current-submode) - (setq mmm-current-overlay ovl - mmm-current-submode (if ovl (overlay-get ovl 'mmm-mode))) + nil + (mmm-set-current-pair (if ovl (overlay-get ovl 'mmm-mode)) ovl) t))) -;; This function is, I think, mostly for hacking font-lock. -(defun mmm-set-current-submode (mode &optional pos) - "Set the current submode to MODE and the current region to whatever -region of that mode is present at POS, or nil if none." +(defun mmm-set-current-pair (mode ovl) + "Set the current submode to MODE, the current overlay to OVL +and update the saved previous values." (setq mmm-previous-overlay mmm-current-overlay - mmm-previous-submode mmm-current-submode) + mmm-previous-submode mmm-current-submode) (setq mmm-current-submode mode - mmm-current-overlay - (find-if #'(lambda (ovl) - (eq (overlay-get ovl 'mmm-mode) mode)) - (mmm-overlays-at (or pos (point)) 'all)))) + mmm-current-overlay ovl)) (defun mmm-submode-at (&optional pos type) "Return the submode at POS \(or point), or NIL if none. @@ -308,9 +301,9 @@ delimiter-mode front-face back-face display-name (match-front "") (match-back "") - (beg-sticky t) (end-sticky t) + (beg-sticky t) (end-sticky t) name creation-hook - ) + ) "Make a submode region from BEG to END of SUBMODE. BEG and END are buffer positions or markers with BEG <= END \(although @@ -370,8 +363,8 @@ with point at the start of the new region." ;; Check placement of region and delimiters (unless (if (eq evaporation t) - (< beg end) - (<= beg end)) + (< beg end) + (<= beg end)) (signal 'mmm-subregion-invalid-placement (list beg end))) (when front (unless (listp front) @@ -398,7 +391,9 @@ ;; Save evaporation type for checking later (overlay-put region-ovl 'mmm-evap evaporation) ;; Calculate priority to supersede anything already there. - (overlay-put region-ovl 'priority (length (mmm-overlays-at beg))) + ;; XXX: Actually, don't, in order not to hide the region highlighting. + ;; Let's try omitting the priorities and see if any problems crop up. + ;; (overlay-put region-ovl 'priority (length (mmm-overlays-at beg))) ;; Make overlays for the delimiters, with appropriate pointers. (when front (let ((front-ovl @@ -416,15 +411,14 @@ (overlay-put back-ovl 'match match-back))) ;; Update everything and run all the hooks (mmm-save-all - (goto-char (overlay-start region-ovl)) - (mmm-set-current-submode submode) - (mmm-set-local-variables submode) + ;; Can be nil when a zero-width region is immediately evaporated + (when (overlay-start region-ovl) + (goto-char (overlay-start region-ovl))) + (mmm-set-current-pair submode region-ovl) + (mmm-set-local-variables submode region-ovl) (mmm-run-submode-hook submode) (when creation-hook - (funcall creation-hook)) - (mmm-save-changed-local-variables region-ovl submode)) - (setq mmm-previous-submode submode - mmm-previous-overlay region-ovl) + (funcall creation-hook))) (mmm-update-submode-region) region-ovl)) @@ -471,11 +465,11 @@ "Clears all MMM overlays overlapping START and STOP. If STRICT, only clear those entirely included in that region." (mapc #'delete-overlay - (if strict - (mmm-overlays-contained-in (or start (point-min)) - (or stop (point-max))) - (mmm-overlays-overlapping (or start (point-min)) - (or stop (point-max))))) + (if strict + (mmm-overlays-contained-in (or start (point-min)) + (or stop (point-max))) + (mmm-overlays-overlapping (or start (point-min)) + (or stop (point-max))))) (mmm-update-submode-region)) ;;}}} @@ -492,79 +486,54 @@ which is set here as well. See `mmm-save-local-variables'. If FORCE is non-nil, don't quit if the info is already there." (let ((buffer-entry (assq mode mmm-buffer-saved-locals)) - (region-entry (assq mode mmm-region-saved-locals-defaults)) - global-vars buffer-vars region-vars - ;; kludge for XEmacs 20 - (html-helper-build-new-buffer nil)) + (region-entry (assq mode mmm-region-saved-locals-defaults)) + global-vars buffer-vars region-vars + ;; http://debbugs.gnu.org/13836 + buffer-file-truename) (unless (and (not force) - (get mode 'mmm-local-variables) - buffer-entry - region-entry) - (save-excursion - (let ((filename (buffer-file-name))) - ;; On errors, the temporary buffers don't get deleted, so here - ;; we get rid of any old ones that may be hanging around. - (when (buffer-live-p (get-buffer mmm-temp-buffer-name)) - (with-current-buffer (get-buffer mmm-temp-buffer-name) - (set-buffer-modified-p nil) - (kill-buffer (current-buffer)))) - ;; Now make a new temporary buffer. - (set-buffer (mmm-make-temp-buffer (current-buffer) - mmm-temp-buffer-name)) - ;; Handle stupid modes that need the file name set - (if (memq mode mmm-set-file-name-for-modes) - (setq buffer-file-name filename))) - (funcall mode) - (when (featurep 'font-lock) - ;; XEmacs doesn't have global-font-lock-mode (or rather, it - ;; has nothing but global-font-lock-mode). - (when (or mmm-xemacs - ;; Code copied from font-lock.el to detect when font-lock - ;; should be on via global-font-lock-mode. - (and (or font-lock-defaults - (with-no-warnings - (assq major-mode font-lock-defaults-alist)) - (assq major-mode font-lock-keywords-alist)) - (or (eq font-lock-global-modes t) - (if (eq (car-safe font-lock-global-modes) 'not) - (not (memq major-mode - (cdr font-lock-global-modes))) - (memq major-mode font-lock-global-modes))))) - ;; Don't actually fontify in the temp buffer, but note - ;; that we should fontify when we use this mode. - (put mode 'mmm-font-lock-mode t)) - ;; Get the font-lock variables - (when mmm-font-lock-available-p - ;; To fool `font-lock-add-keywords' - (let ((font-lock-mode t)) - (mmm-set-font-lock-defaults))) - ;; These can't be in the local variables list, because we - ;; replace their actual values, but we want to use their - ;; original values elsewhere. - (unless (and mmm-xemacs (= emacs-major-version 20)) - ;; XEmacs 20 doesn't have this variable. This effectively - ;; prevents the MMM font-lock support from working, but we - ;; just ignore it and go on, to prevent an error message. - (put mode 'mmm-fontify-region-function - font-lock-fontify-region-function)) - (put mode 'mmm-beginning-of-syntax-function - ;font-lock-beginning-of-syntax-function)) - syntax-begin-function)) - ;; Get variables - (setq global-vars (mmm-get-locals 'global) - buffer-vars (mmm-get-locals 'buffer) - region-vars (mmm-get-locals 'region)) - (put mode 'mmm-mode-name mode-name) - (set-buffer-modified-p nil) - (kill-buffer (current-buffer))) + (get mode 'mmm-local-variables) + buffer-entry + region-entry) + (let ((temp-buffer (mmm-make-temp-buffer (current-buffer) + mmm-temp-buffer-name)) + (filename (buffer-file-name)) + (mmm-in-temp-buffer t) + ;; Don't try to use jit-lock, it's automatically disabled + ;; starting with 24.4 anyway. + font-lock-support-mode) + (unwind-protect + (with-current-buffer temp-buffer + ;; Handle stupid modes that need the file name set. + (when (memq mode mmm-set-file-name-for-modes) + (setq buffer-file-name filename)) + (funcall mode) + (when (featurep 'font-lock) + (put mode 'mmm-font-lock-mode font-lock-mode) + ;; These can't be in the local variables list, because we + ;; replace their actual values, but we want to use their + ;; original values elsewhere. + (put mode 'mmm-fontify-region-function + font-lock-fontify-region-function) + (put mode 'mmm-beginning-of-syntax-function + syntax-begin-function) + (put mode 'mmm-syntax-propertize-function + (and (boundp 'syntax-propertize-function) + syntax-propertize-function)) + (put mode 'mmm-indent-line-function indent-line-function)) + ;; Get variables + (setq global-vars (mmm-get-locals 'global) + buffer-vars (mmm-get-locals 'buffer) + region-vars (mmm-get-locals 'region)) + (put mode 'mmm-mode-name mode-name)) + (kill-buffer temp-buffer))) (put mode 'mmm-local-variables global-vars) (if buffer-entry - (setcdr buffer-entry buffer-vars) - (push (cons mode buffer-vars) mmm-buffer-saved-locals)) + (setcdr buffer-entry buffer-vars) + (push (cons mode buffer-vars) mmm-buffer-saved-locals)) (if region-entry - (setcdr region-entry region-vars) - (push (cons mode region-vars) - mmm-region-saved-locals-defaults))))) + (setcdr region-entry region-vars) + (push (cons mode region-vars) + mmm-region-saved-locals-defaults))))) ;;}}} ;;{{{ Updating Hooks @@ -574,11 +543,11 @@ This function and those it calls do the actual work of setting the different keymaps, syntax tables, local variables, etc. for submodes." (when (mmm-update-current-submode) - (mmm-save-changed-local-variables mmm-previous-overlay - mmm-previous-submode) + (mmm-save-changed-local-variables mmm-previous-submode + mmm-previous-overlay) (let ((mode (or mmm-current-submode mmm-primary-mode))) (mmm-update-mode-info mode) - (mmm-set-local-variables mode) + (mmm-set-local-variables mode mmm-current-overlay) (mmm-enable-font-lock mode)) (mmm-set-mode-line) (dolist (func (if mmm-current-overlay @@ -587,10 +556,17 @@ (ignore-errors (funcall func))))) (defun mmm-add-hooks () - (add-hook 'post-command-hook 'mmm-update-submode-region nil 'local)) + (if (featurep 'xemacs) + (make-local-hook 'post-command-hook)) + (add-hook 'post-command-hook 'mmm-update-submode-region nil t) + (when mmm-parse-when-idle + (add-hook 'pre-command-hook 'mmm-mode-reset-timer nil t) + (add-hook 'after-change-functions 'mmm-mode-edit nil t))) (defun mmm-remove-hooks () - (remove-hook 'post-command-hook 'mmm-update-submode-region 'local)) + (remove-hook 'post-command-hook 'mmm-update-submode-region t) + (remove-hook 'pre-command-hook 'mmm-mode-reset-timer t) + (remove-hook 'after-change-functions 'mmm-mode-edit t)) ;;}}} ;;{{{ Local Variables @@ -600,81 +576,101 @@ Return a list \(VAR ...). In some cases, VAR will be a cons cell \(GETTER . SETTER) -- see `mmm-save-local-variables'." (mapcan #'(lambda (element) - (and (if (and (consp element) - (cdr element) - (cadr element)) - (eq (cadr element) type) - (eq type 'global)) - (if (and (consp element) - (cddr element) - (not (eq (caddr element) t))) - (if (functionp (caddr element)) - (funcall (caddr element)) - (member mode (caddr element))) - t) - (list (if (consp element) (car element) element)))) - mmm-save-local-variables)) + (and (if (and (consp element) + (cdr element) + (cadr element)) + (eq (cadr element) type) + (eq type 'global)) + (if (and (consp element) + (cddr element) + (not (eq (caddr element) t))) + (if (functionp (caddr element)) + (funcall (caddr element)) + (member mode (caddr element))) + t) + (list (if (consp element) (car element) element)))) + mmm-save-local-variables)) (defun mmm-get-locals (type) "Get the local variables and values for TYPE from this buffer. Return \((VAR VALUE) ...). In some cases, VAR will be of the form \(GETTER . SETTER) -- see `mmm-save-local-variables'." (mapcan #'(lambda (var) - (if (consp var) - `((,var ,(funcall (car var)))) - (and (boundp var) - ;; This seems logical, but screws things up. - ;;(local-variable-p var) - `((,var ,(symbol-value var)))))) - (mmm-get-local-variables-list type major-mode))) - -(defun mmm-get-saved-local (mode var) - "Get the value of the local variable VAR saved for MODE, if any." - (cadr (assq var (mmm-get-saved-local-variables mode)))) - -(defun mmm-set-local-variables (mode) - "Set all the local variables saved for MODE. -Looks up both global, buffer, and region saves." + (if (consp var) + `((,var ,(funcall (car var)))) + (and (boundp var) + ;; This seems logical, but screws things up. + ;;(local-variable-p var) + `((,var ,(symbol-value var)))))) + (mmm-get-local-variables-list type major-mode))) + +;; FIXME: Has no callers. Used for debugging? +(defun mmm-get-saved-local (mode ovl var) + "Get the value of the local variable VAR saved for MODE and OVL, if any." + (cadr (assq var (mmm-get-saved-local-variables ovl mode)))) + +;; FIXME: It's too easy to accidentally pass nil as MODE here. +;; We probably should call this from `mmm-set-current-pair', and not +;; rely on its callers to default to the primary mode when appropriate. +;; Also, incorporate the opmimization from `mmm-fontify-region-list'. +(defun mmm-set-local-variables (mode ovl) + "Set all the local variables saved for MODE and OVL. +Looks up global, buffer and region saves. When MODE is nil, just +the region ones." (mapcar #'(lambda (var) - ;; (car VAR) may be (GETTER . SETTER) - (if (consp (car var)) - (funcall (cdar var) (cadr var)) - (make-local-variable (car var)) - (set (car var) (cadr var)))) - (mmm-get-saved-local-variables mode))) + ;; (car VAR) may be (GETTER . SETTER) + (if (consp (car var)) + (funcall (cdar var) (cadr var)) + (make-local-variable (car var)) + (set (car var) (cadr var)))) + (mmm-get-saved-local-variables mode ovl))) + +;; Used for debugging. +(defun mmm-diff-local-variables (mode ovl) + (let (res) + (mapc (lambda (var) + (let ((current-value (if (consp (car var)) + (funcall (caar var)) + (symbol-value (car var))))) + (unless (equal current-value (cadr var)) + (push + (message "var: %s, current: %s, saved: %s" (car var) + current-value (cadr var)) + res)))) + (mmm-get-saved-local-variables mode ovl)) + res)) -(defun mmm-get-saved-local-variables (mode) +(defun mmm-get-saved-local-variables (mode ovl) (append (get mode 'mmm-local-variables) - (cdr (assq mode mmm-buffer-saved-locals)) - (let ((ovl (mmm-overlay-at (point)))) - (if ovl - (overlay-get ovl 'mmm-local-variables) - mmm-region-saved-locals-for-dominant)))) - -(defun mmm-save-changed-local-variables (ovl mode) - "Save by-buffer and by-region variables for OVL and MODE. -Called when we move to a new submode region, with OVL and MODE the + (cdr (assq mode mmm-buffer-saved-locals)) + (if ovl + (overlay-get ovl 'mmm-local-variables) + mmm-region-saved-locals-for-dominant))) + +(defun mmm-save-changed-local-variables (mode ovl) + "Save by-buffer and by-region variables for MODE and OVL. +Called when we move to a new submode region, with MODE and OVL the region and mode for the previous position." (let ((buffer-vars (cdr (assq (or mode mmm-primary-mode) - mmm-buffer-saved-locals))) - (region-vars (if ovl - (overlay-get ovl 'mmm-local-variables) - mmm-region-saved-locals-for-dominant)) - (set-local-value - #'(lambda (var) - (setcar (cdr var) - ;; (car VAR) may be (GETTER . SETTER) - (if (consp (car var)) - (funcall (caar var)) - (symbol-value (car var))))))) + mmm-buffer-saved-locals))) + (region-vars (if ovl + (overlay-get ovl 'mmm-local-variables) + mmm-region-saved-locals-for-dominant)) + (set-local-value + #'(lambda (var) + (setcar (cdr var) + ;; (car VAR) may be (GETTER . SETTER) + (if (consp (car var)) + (funcall (caar var)) + (symbol-value (car var))))))) (mapc set-local-value buffer-vars) (mapc set-local-value region-vars))) (defun mmm-clear-local-variables () "Clear all buffer- and region-saved variables for current buffer." (setq mmm-buffer-saved-locals () - mmm-region-saved-locals-defaults () - mmm-region-saved-locals-for-dominant ())) + mmm-region-saved-locals-defaults () + mmm-region-saved-locals-for-dominant ())) ;;}}} @@ -684,31 +680,29 @@ (defun mmm-enable-font-lock (mode) "Turn on font lock if it is not already on and MODE enables it." (mmm-update-mode-info mode) - (and mmm-font-lock-available-p - (not font-lock-mode) + (and (not font-lock-mode) (get mode 'mmm-font-lock-mode) (font-lock-mode 1))) (defun mmm-update-font-lock-buffer () - "Turn on font lock iff any mode in the buffer enables it." - (when mmm-font-lock-available-p - (if (some #'(lambda (mode) - (get mode 'mmm-font-lock-mode)) - (cons mmm-primary-mode - (mapcar #'(lambda (ovl) - (overlay-get ovl 'mmm-mode)) - (mmm-overlays-overlapping - (point-min) (point-max))))) - (font-lock-mode 1) - (font-lock-mode 0)))) + "Turn on font lock if any mode in the buffer enables it." + (if (some #'(lambda (mode) + (get mode 'mmm-font-lock-mode)) + (cons mmm-primary-mode + (mapcar #'(lambda (ovl) + (overlay-get ovl 'mmm-mode)) + (mmm-overlays-overlapping + (point-min) (point-max))))) + (font-lock-mode 1) + (font-lock-mode 0))) (defun mmm-refontify-maybe (&optional start stop) "Re-fontify from START to STOP, or entire buffer, if enabled." (and font-lock-mode (if (or start stop) - (font-lock-fontify-region (or start (point-min)) - (or stop (point-max))) - (font-lock-fontify-buffer)))) + (font-lock-fontify-region (or start (point-min)) + (or stop (point-max))) + (font-lock-fontify-buffer)))) ;;}}} ;;{{{ Get Submode Regions @@ -720,99 +714,173 @@ (defun mmm-submode-changes-in (start stop) "Return a list of all submode-change positions from START to STOP. The list is sorted in order of increasing buffer position." - (sort (remove-duplicates - (list* start stop - (mapcan #'(lambda (ovl) - `(,(overlay-start ovl) - ,(overlay-end ovl))) - (mmm-overlays-overlapping start stop)))) - #'<)) + (let ((changes (sort (remove-duplicates + (mapcan #'(lambda (ovl) + `(,(overlay-start ovl) + ,(overlay-end ovl))) + (mmm-overlays-overlapping start stop))) + #'<))) + (when (or (not changes) (< start (car changes))) + (push start changes)) + (let ((last (last changes))) + (when (> stop (car last)) + (setcdr last (list stop)))) + changes)) -(defun mmm-regions-in (start stop &optional flag delim) - "Return a list of regions of the form (MODE BEG END) whose disjoint +(defun mmm-regions-in (start stop) + "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)))) - (mmm-submode-changes-in start stop)))) - (setcdr (last regions 2) nil) - regions)) - + (when (> stop start) + (let ((regions + (maplist #'(lambda (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))) - (mapcar #'(lambda (mode) - (cons mode - (mapcan #'(lambda (region) - (if (eq mode (car region)) - (list (cdr region)))) - regions))) - ;; All the modes - (remove-duplicates (mapcar #'car regions))))) + (let ((regions (mmm-regions-in start stop)) + alist) + (mapc (lambda (region) + (let* ((mode (car region)) + (elem (cdr region)) + (kv (assoc mode alist))) + (if kv + (push elem (cdr kv)) + (push (cons mode (list elem)) alist)))) + regions) + (mapcar (lambda (kv) + (cons (car kv) (nreverse (cdr kv)))) + alist))) ;;}}} ;;{{{ Fontify Regions (defun mmm-fontify-region (start stop &optional loudly) "Fontify from START to STOP keeping track of submodes correctly." - (when loudly - (message "Fontifying %s with submode regions..." (buffer-name))) - ;; Necessary to catch changes in font-lock cache state and position. - (mmm-save-changed-local-variables - mmm-current-overlay mmm-current-submode) - ;; For some reason `font-lock-fontify-block' binds this to nil, thus - ;; preventing `mmm-beginning-of-syntax' from doing The Right Thing. - ;; I don't know why it does this, but let's undo it here. - (let ((;font-lock-beginning-of-syntax-function - syntax-begin-function 'mmm-beginning-of-syntax)) - (mapc #'(lambda (elt) - (when (get (car elt) 'mmm-font-lock-mode) - (mmm-fontify-region-list (car elt) (cdr elt)))) - (mmm-regions-alist start stop))) - ;; With jit-lock, this causes blips in the mode line and menus. - ;; Shouldn't be necessary here, since it's in post-command-hook too. - ;;(mmm-update-submode-region) + (let ((saved-mode mmm-current-submode) + (saved-ovl mmm-current-overlay)) + (unwind-protect + (progn + (when loudly + (message "Fontifying %s with submode regions..." (buffer-name))) + ;; Necessary to catch changes in font-lock cache state and position. + (mmm-save-changed-local-variables + mmm-current-submode mmm-current-overlay) + (mapc #'(lambda (elt) + (when (get (car elt) 'mmm-font-lock-mode) + (mmm-fontify-region-list (car elt) (cdr elt)))) + (mmm-regions-alist start stop))) + ;; `post-command-hook' contains `mmm-update-submode-region', + ;; but jit-lock runs later, so we need to restore local vars now. + (mmm-set-current-pair saved-mode saved-ovl) + (mmm-set-local-variables (or saved-mode mmm-primary-mode) saved-ovl))) (when loudly (message nil))) (defun mmm-fontify-region-list (mode regions) "Fontify REGIONS, each like \(BEG END), in mode MODE." (save-excursion - (let (;(major-mode mode) - (func (get mode 'mmm-fontify-region-function))) + (let ((func (get mode 'mmm-fontify-region-function)) + font-lock-extend-region-functions) (mapc #'(lambda (reg) - (goto-char (car reg)) - ;; Here we do the same sort of thing that - ;; `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-submode mode) - (mmm-set-local-variables mode) - (funcall func (car reg) (cadr reg) nil) - ;; Catch changes in font-lock cache. - (mmm-save-changed-local-variables - mmm-current-overlay mmm-current-submode)) - regions)))) - -;;}}} -;;{{{ Beginning of Syntax - -(defun mmm-beginning-of-syntax () - (goto-char - (let ((ovl (mmm-overlay-at (point))) - (func (get (or mmm-current-submode mmm-primary-mode) - 'mmm-beginning-of-syntax-function))) - (max (if ovl (overlay-start ovl) (point-min)) - (if func (progn (funcall func) (point)) (point-min)) - (point-min))))) + (destructuring-bind (beg end ovl) reg + (goto-char beg) + ;; Here we do the same sort of thing that + ;; `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 ovl) + (mmm-set-local-variables (unless (eq mmm-previous-submode mode) + mode) + mmm-current-overlay) + (save-restriction + (let ((font-lock-dont-widen t) + syntax-ppss-last syntax-ppss-cache) + ;; TODO: Remove this conditional when cc-mode + ;; respects submode boundaries. + (when (and ovl (not (memq mode mmm-c-derived-modes))) + (narrow-to-region beg end)) + (funcall func beg end nil))) + ;; Catch changes in font-lock cache. + (mmm-save-changed-local-variables + mmm-current-submode mmm-current-overlay))) + regions)))) + +;;}}} +;;{{{ Syntax + +(defvar mmm-after-syntax-propertize-functions nil + "List of functions to call after applying `syntax-table' text +properties to a submode region. It is passed four arguments: the +region overlay, the submode and the bounds of the region.") + +(defun mmm-syntax-propertize-function (start stop) + "Composite function that applies `syntax-table' text properties. +It iterates over all submode regions between START and STOP and +calls each respective submode's `syntax-propertize-function'." + (let ((saved-mode mmm-current-submode) + (saved-ovl mmm-current-overlay)) + (mmm-save-changed-local-variables + mmm-current-submode mmm-current-overlay) + (unwind-protect + (mapc #'(lambda (elt) + (let* ((mode (car elt)) + (func (get mode 'mmm-syntax-propertize-function)) + (beg (cadr elt)) (end (caddr elt)) + (ovl (cadddr elt)) + syntax-ppss-cache + syntax-ppss-last) + (goto-char beg) + (mmm-set-current-pair mode ovl) + (mmm-set-local-variables mode mmm-current-overlay) + (save-restriction + (when mmm-current-overlay + (narrow-to-region (overlay-start mmm-current-overlay) + (overlay-end mmm-current-overlay))) + (cond + (func + (funcall func beg end)) + (font-lock-syntactic-keywords + (let ((syntax-propertize-function nil)) + (font-lock-fontify-syntactic-keywords-region beg end)))) + (run-hook-with-args 'mmm-after-syntax-propertize-functions + mmm-current-overlay mode beg end)))) + (mmm-regions-in start stop)) + (mmm-set-current-pair saved-mode saved-ovl) + (mmm-set-local-variables (or saved-mode mmm-primary-mode) saved-ovl)))) + +;;}}} +;;{{{ Indentation + +(defvar mmm-indent-line-function 'mmm-indent-line + "The function to call to indent a line. +This will be the value of `indent-line-function' for the whole +buffer. It's supposed to delegate to the appropriate submode's +indentation function. See `mmm-indent-line' as the starting point.") + +(defun mmm-indent-line () + (interactive) + (funcall + (save-excursion + (back-to-indentation) + (mmm-update-submode-region) + (get + (if (and mmm-current-overlay + (> (overlay-end mmm-current-overlay) (point))) + mmm-current-submode + mmm-primary-mode) + 'mmm-indent-line-function)))) ;;}}} - (provide 'mmm-region) -;;; mmm-region.el ends here \ No newline at end of file +;;; mmm-region.el ends here diff -u coq/mmm-rpm.el mmm/mmm-rpm.el --- coq/mmm-rpm.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-rpm.el 2017-03-16 17:32:06.176016442 +0100 @@ -3,7 +3,6 @@ ;; Copyright (C) 2000 by Marcus Harnisch ;; Author: Marcus Harnisch -;; Version: $Id$ ;;{{{ GPL @@ -78,4 +77,4 @@ (provide 'mmm-rpm) -;;; mmm-rpm.el ends here \ No newline at end of file +;;; mmm-rpm.el ends here diff -u coq/mmm-sample.el mmm/mmm-sample.el --- coq/mmm-sample.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-sample.el 2017-03-16 17:32:06.176016442 +0100 @@ -3,7 +3,6 @@ ;; Copyright (C) 2003, 2004 by Michael Abraham Shulman ;; Author: Michael Abraham Shulman -;; Version: $Id$ ;;{{{ GPL @@ -27,48 +26,72 @@ ;;; Commentary: ;; This file contains several sample submode classes for use with MMM -;; Mode. For a more detailed and useful example, see `mmm-mason.el'. +;; Mode. For a more detailed, advanced example, see `mmm-mason.el'. + +;; In order to use any of classes defined here, just require `mmm-auto' and +;; add the respective (major mode -> class <- file extension) associations +;; with `mmm-add-mode-ext-class'. ;;; Code: +(require 'cl) (require 'mmm-auto) (require 'mmm-vars) -;;{{{ CSS embedded in HTML +;;{{{ in httpd.conf ;; This is the simplest example. Many applications will need no more ;; than a simple regexp. +;; +;; Usage: (mmm-add-mode-ext-class 'apache-generic-mode nil 'httpd-conf-perl) + (mmm-add-classes - '((embedded-css - :submode css - :face mmm-declaration-submode-face + '((httpd-conf-perl + :submode perl :delimiter-mode nil - :front "]*>" - :back ""))) + :front "" + :back ""))) ;;}}} -;;{{{ Javascript in HTML +;;{{{ JavaScript in HTML + +;; We use two classes here, both for code in a " - :insert ((?j js-tag nil @ "" @)) - ) - (js-inline - :submode javascript + :front "]*>[ \t\n]*\\(//\\)?[ \t\n]*") + (js-script + :submode js-mode :face mmm-code-submode-face - :delimiter-mode nil - :front "on\\w+=\"" - :back "\""))) + :front "]*>[ \t]*\n?" + :back "[ \t]*" + :insert ((?j js-tag nil @ "" @))))) + +;;}}} +;;{{{ CSS in HTML + +(mmm-add-group + 'html-css + '((css-cdata + :submode css + :face mmm-code-submode-face + :front "]*>[ \t\n]*\\(//\\)?[ \t\n]*") + (css + :submode css + :face mmm-code-submode-face + :front "]*>[ \t]*\n?" + :back "[ \t]*" + :insert ((?c css-tag nil @ "" @))))) ;;}}} ;;{{{ Here-documents @@ -96,35 +119,35 @@ (or (mmm-ensure-modename ;; First try the user override variable. (some #'(lambda (pair) - (if (string-match (car pair) string) (cdr pair) nil)) - mmm-here-doc-mode-alist)) + (if (string-match (car pair) string) (cdr pair) nil)) + mmm-here-doc-mode-alist)) (let ((words (split-string (downcase string) "[_-]+"))) - (or (mmm-ensure-modename - ;; Try the whole name, stopping at "mode" if present. - (intern - (mapconcat #'identity - (nconc (ldiff words (member "mode" words)) - (list "mode")) - "-"))) - ;; Try each word by itself (preference list) - (some #'(lambda (word) - (mmm-ensure-modename (intern word))) - words) - ;; Try each word with -mode tacked on - (some #'(lambda (word) - (mmm-ensure-modename - (intern (concat word "-mode")))) - words) - ;; Try each pair of words with -mode tacked on - (loop for (one two) on words - if (mmm-ensure-modename - (intern (concat one two "-mode"))) - return it) - ;; I'm unaware of any modes whose names, minus `-mode', - ;; are more than two words long, and if the entire mode - ;; name (perhaps minus `-mode') doesn't occur in the - ;; here-document name, we can give up. - (signal 'mmm-no-matching-submode nil))))) + (or (mmm-ensure-modename + ;; Try the whole name, stopping at "mode" if present. + (intern + (mapconcat #'identity + (nconc (ldiff words (member "mode" words)) + (list "mode")) + "-"))) + ;; Try each word by itself (preference list) + (some #'(lambda (word) + (mmm-ensure-modename (intern word))) + words) + ;; Try each word with -mode tacked on + (some #'(lambda (word) + (mmm-ensure-modename + (intern (concat word "-mode")))) + words) + ;; Try each pair of words with -mode tacked on + (loop for (one two) on words + if (mmm-ensure-modename + (intern (concat one two "-mode"))) + return it) + ;; I'm unaware of any modes whose names, minus `-mode', + ;; are more than two words long, and if the entire mode + ;; name (perhaps minus `-mode') doesn't occur in the + ;; here-document name, we can give up. + (signal 'mmm-no-matching-submode nil))))) (mmm-add-classes '((here-doc @@ -135,7 +158,7 @@ :delimiter-mode nil :match-submode mmm-here-doc-get-mode :insert ((?d here-doc "Here-document Name: " @ "<<" str _ "\n" - @ "\n" @ str "\n" @)) + @ "\n" @ str "\n" @)) ))) ;;}}} @@ -150,18 +173,18 @@ :save-matches 1 :match-name "embperl" :match-face (("[+" . mmm-output-submode-face) - ("[-" . mmm-code-submode-face) - ("[!" . mmm-init-submode-face) - ("[*" . mmm-code-submode-face) - ("[$" . mmm-special-submode-face)) + ("[-" . mmm-code-submode-face) + ("[!" . mmm-init-submode-face) + ("[*" . mmm-code-submode-face) + ("[$" . mmm-special-submode-face)) :insert ((?p embperl "Region Type (Character): " @ "[" str - @ " " _ " " @ str "]" @) - (?+ embperl+ ?p . "+") - (?- embperl- ?p . "-") - (?! embperl! ?p . "!") - (?* embperl* ?p . "*") - (?$ embperl$ ?p . "$") - ) + @ " " _ " " @ str "]" @) + (?+ embperl+ ?p . "+") + (?- embperl- ?p . "-") + (?! embperl! ?p . "!") + (?* embperl* ?p . "*") + (?$ embperl$ ?p . "$") + ) ) (embperl-comment :submode text-mode @@ -189,8 +212,8 @@ :back "_?:>" :match-name "eperl" :insert ((?p eperl-code nil @ "<:" @ " " _ " " @ ":>" @) - (?: eperl-code ?p . nil) - (?_ eperl-code_ nil @ "<:" @ " " _ " " @ "_:>" @))) + (?: eperl-code ?p . nil) + (?_ eperl-code_ nil @ "<:" @ " " _ " " @ "_:>" @))) (eperl-comment :submode text :face mmm-comment-submode-face @@ -210,24 +233,24 @@ ;; buffer-local variable with markers for positions, but the trick ;; is knowing when to expire the cache. (let ((bounds - (save-excursion - (save-match-data - (goto-char (point-max)) - (backward-page) - (and (re-search-forward "^\\(.*\\)Local Variables:" nil t) - (list (match-string 1) - (progn (end-of-line) (point)) - (and (search-forward - (format "%sEnd:" (match-string 1)) - nil t) - (progn (beginning-of-line) - (point))))))))) + (save-excursion + (save-match-data + (goto-char (point-max)) + (backward-page) + (and (re-search-forward "^\\(.*\\)Local Variables:" nil t) + (list (match-string 1) + (progn (end-of-line) (point)) + (and (search-forward + (format "%sEnd:" (match-string 1)) + nil t) + (progn (beginning-of-line) + (point))))))))) (and bounds (caddr bounds) - (save-match-data - (string-match (format "^%s" (regexp-quote (car bounds))) - (match-string 0))) - (> (match-beginning 0) (cadr bounds)) - (< (match-end 0) (caddr bounds))))) + (save-match-data + (string-match (format "^%s" (regexp-quote (car bounds))) + (match-string 0))) + (> (match-beginning 0) (cadr bounds)) + (< (match-end 0) (caddr bounds))))) (defun mmm-file-variables-find-back (bound) (forward-sexp) @@ -258,14 +281,14 @@ (jsp-code :submode java :match-face (("<%!" . mmm-declaration-submode-face) - ("<%=" . mmm-output-submode-face) - ("<%" . mmm-code-submode-face)) + ("<%=" . mmm-output-submode-face) + ("<%" . mmm-code-submode-face)) :front "<%[!=]?" :back "%>" :match-name "jsp" :insert ((?% jsp-code nil @ "<%" @ " " _ " " @ "%>" @) - (?! jsp-declaration nil @ "<%!" @ " " _ " " @ "%>" @) - (?= jsp-expression nil @ "<%=" @ " " _ " " @ "%>" @)) + (?! jsp-declaration nil @ "<%!" @ " " _ " " @ "%>" @) + (?= jsp-expression nil @ "<%=" @ " " _ " " @ "%>" @)) ) (jsp-directive :submode text-mode @@ -290,19 +313,6 @@ :back "]>"))) ;;}}} -;;{{{ in httpd.conf - -(mmm-add-classes - '((httpd-conf-perl - :submode perl - :delimiter-mode nil - :front "" - :back ""))) - -;; Suggested Use: -;; (mmm-add-mode-ext-class 'apache-generic-mode nil 'httpd-conf-perl) - -;;}}} ;;{{{ PHP in HTML (mmm-add-group 'html-php @@ -310,7 +320,7 @@ :submode php-mode :face mmm-output-submode-face :front "<\\?php *echo " - :back "\\?>" + :back "\\(\\?>\\|\\'\\)" :include-front t :front-offset 5 :insert ((?e php-echo nil @ "" @)) @@ -319,9 +329,9 @@ :submode php-mode :face mmm-code-submode-face :front "<\\?\\(php\\)?" - :back "\\?>" + :back "\\(\\?>\\|\\'\\)" :insert ((?p php-section nil @ "" @) - (?b php-block nil @ "" @)) + (?b php-block nil @ "" @)) ))) ;;}}} @@ -371,4 +381,4 @@ (provide 'mmm-sample) -;;; mmm-sample.el ends here \ No newline at end of file +;;; mmm-sample.el ends here diff -u coq/mmm.texinfo mmm/mmm.texinfo --- coq/mmm.texinfo 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm.texinfo 2017-03-16 17:32:06.176016442 +0100 @@ -11,11 +11,7 @@ * MMM-Mode: (mmm). Multiple Major Modes for Emacs @end direntry -@include version.texi - @ifinfo -This is edition @value{EDITION} of the MMM Mode Manual, last updated -@value{UPDATED}. It documents version @value{VERSION} of MMM Mode. Copyright 2000 Michael Abraham Shulman. @@ -47,8 +43,6 @@ @titlepage @title MMM Mode Manual @subtitle Multiple Major Modes for Emacs -@subtitle Edition @value{EDITION} -@subtitle @value{UPDATED} @author Michael Abraham Shulman @page @vskip 0pt plus 1filll @@ -79,9 +73,6 @@ MMM Mode is a minor mode for Emacs which allows Multiple Major Modes to coexist in a single buffer. -This is edition @value{EDITION} of the MMM Mode Manual, last updated -@value{UPDATED}, which documents version @value{VERSION} of MMM Mode. - @end ifinfo @menu diff -u coq/mmm-univ.el mmm/mmm-univ.el --- coq/mmm-univ.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-univ.el 2017-03-16 17:32:06.176016442 +0100 @@ -39,17 +39,17 @@ (string-match "[a-zA-Z-]+" string) (setq string (match-string 0 string)) (let ((modestr (intern (if (string-match "mode\\'" string) - string - (concat string "-mode"))))) + string + (concat string "-mode"))))) (or (mmm-ensure-modename modestr) - (signal 'mmm-no-matching-submode nil)))) + (signal 'mmm-no-matching-submode nil)))) (mmm-add-classes `((universal :front "{%\\([a-zA-Z-]+\\)%}" :back "{%/~1%}" :insert ((?/ universal "Submode: " @ "{%" str "%}" @ "\n" _ "\n" - @ "{%/" str "%}" @)) + @ "{%/" str "%}" @)) :match-submode mmm-univ-get-mode :save-matches 1 ))) @@ -61,4 +61,4 @@ ;;; mmm-global-classes: nil ;;; End: -;;; mmm-univ.el ends here \ No newline at end of file +;;; mmm-univ.el ends here diff -u coq/mmm-utils.el mmm/mmm-utils.el --- coq/mmm-utils.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-utils.el 2017-03-16 17:32:06.176016442 +0100 @@ -3,7 +3,6 @@ ;; Copyright (C) 2000 by Michael Abraham Shulman ;; Author: Michael Abraham Shulman -;; Version: $Id$ ;;{{{ GPL @@ -31,8 +30,7 @@ ;;; Code: -(eval-when-compile - (require 'cl)) +(require 'cl) ;;{{{ Valid Buffer @@ -44,12 +42,10 @@ means not hidden, not a minibuffer, not in batch mode, and not in of `mmm-never-modes'." `(unless (or (eq (aref (buffer-name) 0) ?\ ) - (window-minibuffer-p (selected-window)) - (memq major-mode mmm-never-modes) - noninteractive - ;; Unnecessary as now hidden -;;; (equal (buffer-name) mmm-temp-buffer-name) - ) + (window-minibuffer-p (selected-window)) + (memq major-mode mmm-never-modes) + noninteractive + mmm-in-temp-buffer) ,@body)) ;;;(def-edebug-spec mmm-valid-buffer t) @@ -64,7 +60,7 @@ `(save-excursion (save-restriction (save-match-data - ,@body)))) + ,@body)))) ;;;(def-edebug-spec mmm-save-all t) @@ -78,8 +74,12 @@ (let ((case-fold-search nil)) (save-match-data (dolist (pair arg-pairs) - (while (string-match (car pair) string) - (setq string (replace-match (cdr pair) t t string)))))) + (while (string-match (car pair) string) + (setq string (replace-match + (if (fboundp 'format-mode-line) + (format-mode-line (cdr pair)) + (cdr pair)) + t t string)))))) string) (defun mmm-format-matches (string &optional on-string) @@ -91,11 +91,11 @@ `string-match' on that string, rather than the global match data." (when (stringp string) (let ((old-data (match-data)) - subexp) + subexp) (save-match-data - (while (string-match "~\\([0-9]\\)" string) - (setq subexp (string-to-number (match-string-no-properties 1 string)) - string (replace-match + (while (string-match "~\\([0-9]\\)" string) + (setq subexp (string-to-number (match-string-no-properties 1 string)) + string (replace-match (save-match-data (set-match-data old-data) (match-string-no-properties subexp on-string)) @@ -120,8 +120,8 @@ PARAMS, but less readable when there are only a few. Also best used only when it is important that nil values disappear." `(append ,@(mapcar #'(lambda (param) - (macroexpand `(mmm-save-keyword ,param))) - params))) + (macroexpand `(mmm-save-keyword ,param))) + params))) ;;}}} ;;{{{ Looking Back At @@ -134,10 +134,10 @@ string." (eq (point) (save-excursion - (and (re-search-backward regexp - (- (point) (or bound (length regexp))) - t) - (match-end 0))))) + (and (re-search-backward regexp + (- (point) (or bound (length regexp))) + t) + (match-end 0))))) ;;}}} ;;{{{ Markers @@ -156,4 +156,4 @@ (provide 'mmm-utils) -;;; mmm-utils.el ends here \ No newline at end of file +;;; mmm-utils.el ends here diff -u coq/mmm-vars.el mmm/mmm-vars.el --- coq/mmm-vars.el 2017-03-16 17:31:55.648570731 +0100 +++ mmm/mmm-vars.el 2017-03-16 17:32:06.176016442 +0100 @@ -1,9 +1,9 @@ ;;; mmm-vars.el --- Variables for MMM Mode ;; Copyright (C) 2000, 2004 by Michael Abraham Shulman +;; Copyright (C) 2012, 2013 by Dmitry Gutov ;; Author: Michael Abraham Shulman -;; Version: $Id$ ;;{{{ GPL @@ -32,9 +32,8 @@ ;;; Code: -(require 'cl) (require 'mmm-compat) -(require 'mmm-utils) +(require 'cl) ;; MISCELLANEOUS ;;{{{ Shut up the Byte Compiler @@ -42,7 +41,6 @@ ;; Otherwise it complains about undefined variables. (eval-when-compile (defvar mmm-current-submode) - (defvar mmm-current-overlay) (defvar mmm-save-local-variables) (defvar mmm-mode-string) (defvar mmm-submode-mode-line-format) @@ -50,10 +48,8 @@ (defvar mmm-mode-prefix-key) (defvar mmm-global-mode) (defvar mmm-primary-mode) - (defvar mmm-classes-alist) - (defvar mmm-current-submode)) - (declare-function mmm-set-class-parameter "mmm-class") - (declare-function mmm-get-class-parameter "mmm-class") + (defvar mmm-classes-alist)) + ;;}}} ;;{{{ Error Conditions @@ -124,16 +120,18 @@ comment-line-break-function sentence-end ,@(when mmm-xemacs - '(mode-popup-menu - (((lambda () current-menubar) . set-buffer-menubar)) - )) - font-lock-keywords + '(mode-popup-menu + (((lambda () current-menubar) . set-buffer-menubar)) + )) + (font-lock-keywords buffer) + font-lock-set-defaults + font-lock-major-mode font-lock-keywords-only font-lock-keywords-case-fold-search font-lock-syntax-table font-lock-mark-block-function ; Override this? font-lock-syntactic-keywords - indent-line-function + font-lock-syntactic-face-function parse-sexp-ignore-comments ; Fixes indentation in PHP-mode? ;; Can be different in different buffers (c-basic-offset @@ -150,54 +148,58 @@ ,@(mapcar #'(lambda (var) (list var nil mmm-c-derived-modes)) '(c++-template-syntax-table - c-<-op-cont-regexp + c-<-op-cont-regexp c->-op-cont-regexp + c-after-brace-list-key c-after-suffixed-type-decl-key c-after-suffixed-type-maybe-decl-key c-any-class-key - c-any-class-key c-asm-stmt-kwds c-assignment-op-regexp c-backslash-column c-basic-offset + c-before-context-fontification-functions c-bitfield-kwds c-block-comment-prefix c-block-decls-with-vars - c-block-stmt-1-key + c-block-prefix-charset + c-block-stmt-1-2-key c-block-stmt-1-key c-block-stmt-1-kwds c-block-stmt-2-key - c-block-stmt-2-key c-block-stmt-2-kwds c-brace-list-key - c-cast-parens - c-class-key + c-case-kwds-regexp + c-cast-parens c-class-key c-class-kwds c-cleanup-list - c-colon-type-list-re + c-colon-type-list-re c-comment-only-line-offset c-comment-prefix-regexp c-comment-start-regexp - c-comment-start-regexp c-cpp-defined-fns c-current-comment-prefix c-decl-block-key - c-decl-block-key + c-decl-hangon-key + c-decl-prefix-or-start-re c-decl-prefix-re c-decl-spec-kwds + c-decl-start-kwds + c-decl-start-re c-doc-comment-start-regexp c-expr-kwds c-file-offsets c-file-style + c-not-primitive-type-keywords-regexp c-hanging-braces-alist c-hanging-colons-alist c-hanging-comment-ender-p c-hanging-comment-starter-p c-hanging-semi\&comma-criteria - c-identifier-key + c-identifier-key c-identifier-last-sym-match - c-identifier-start + c-identifier-start c-identifier-syntax-modifications c-identifier-syntax-table c-in-comment-lc-prefix @@ -209,100 +211,108 @@ c-keywords c-keywords-obarray c-keywords-regexp - c-keywords-regexp c-known-type-key - c-label-key - c-label-key - c-label-kwds - c-label-kwds-regexp + c-label-kwds c-label-kwds-regexp c-label-minimum-indentation c-lambda-kwds - c-literal-start-regexp - c-nonsymbol-chars + c-literal-start-regexp + c-macro-with-semi-re + c-nonlabel-token-key + c-nonlabel-token-2-key + c-nonsymbol-chars c-nonsymbol-token-regexp c-not-decl-init-keywords c-offsets-alist - c-opt-<>-arglist-start + c-opt-<>-arglist-start c-opt-<>-arglist-start-in-paren - c-opt-<>-sexp-key + c-opt-<>-sexp-key c-opt-access-key - c-opt-access-key - c-opt-asm-stmt-key c-opt-asm-stmt-key c-opt-bitfield-key - c-opt-bitfield-key c-opt-block-decls-with-vars-key c-opt-block-stmt-key - c-opt-block-stmt-key - c-opt-cpp-prefix - c-opt-cpp-start + c-opt-cpp-prefix + c-opt-cpp-start c-opt-decl-spec-key c-opt-friend-key - c-opt-friend-key c-opt-identifier-concat-key c-opt-inexpr-block-key - c-opt-inexpr-block-key c-opt-inexpr-brace-list-key c-opt-inexpr-class-key - c-opt-inexpr-class-key - c-opt-lambda-key c-opt-lambda-key c-opt-method-key - c-opt-method-key c-opt-postfix-decl-spec-key c-opt-type-component-key - c-opt-type-concat-key - c-opt-type-modifier-key - c-opt-type-suffix-key - c-other-decl-block-key + c-opt-type-concat-key + c-opt-type-modifier-key + c-opt-type-suffix-key c-other-decl-block-key c-other-decl-block-kwds c-other-decl-kwds c-overloadable-operators-regexp - c-paragraph-separate - c-paragraph-start - c-paren-stmt-key - c-primary-expr-regexp - c-primitive-type-key + c-paragraph-separate + c-paragraph-start + c-paren-stmt-key + c-primary-expr-regexp + c-primitive-type-key c-primitive-type-kwds c-protection-kwds - c-recognize-<>-arglists + c-postfix-decl-spec-key + c-recognize-<>-arglists c-recognize-knr-p - c-recognize-knr-p - c-recognize-paren-inits + c-recognize-paren-inits c-recognize-typeless-decls c-regular-keywords-regexp - c-simple-stmt-key + c-simple-stmt-key c-simple-stmt-kwds c-special-brace-lists - c-special-brace-lists - c-specifier-key + c-specifier-key c-specifier-kwds - c-stmt-delim-chars + c-stmt-delim-chars c-stmt-delim-chars-with-comma + c-symbol-char-key c-symbol-key - c-symbol-key - c-symbol-start + c-symbol-start c-syntactic-eol - c-syntactic-ws-end - c-syntactic-ws-start - c-type-decl-prefix-key - c-type-decl-suffix-key + c-syntactic-ws-end + c-syntactic-ws-start + c-type-decl-prefix-key + c-type-decl-suffix-key c-type-prefix-key - comment-end - comment-start + c-typeof-key + c-prefix-spec-kwds-re + c-typedef-key + c-typedef-decl-key + comment-end + comment-start comment-start-skip)) + ,@(mapcar + (lambda (var) (list var nil '(js-mode))) + '(js--quick-match-re + js--quick-match-re-func)) ;; Skeleton insertion skeleton-transformation ;; Abbrev mode abbrev-mode local-abbrev-table ;; And finally the syntax table and local map. - ((syntax-table . set-syntax-table)) + ((syntax-table . set-syntax-table) buffer) ((current-local-map . use-local-map) buffer) paragraph-separate paragraph-start + (whitespace-active-style buffer) + (whitespace-display-table buffer) + (whitespace-display-table-was-local buffer) + (whitespace-font-lock buffer) + (whitespace-font-lock-mode buffer) + (whitespace-font-lock-keywords buffer) + (whitespace-mode buffer) + forward-sexp-function + smie-rules-function + smie-grammar + smie-forward-token-function + smie-backward-token-function ) "Which local variables to save for major mode regions. Each element has the form \(VARIABLE [TYPE [MODES]]), causing VARIABLE @@ -380,38 +390,54 @@ specify a face." :group 'mmm-faces :type '(choice (const :tag "None" 0) - (const :tag "Low" 1) - (const :tag "High" 2))) + (const :tag "Low" 1) + (const :tag "High" 2))) -(defface mmm-init-submode-face '((t (:background "Pink"))) +(defface mmm-init-submode-face '((((background light)) (:background "Pink")) + (((background dark)) (:background "MediumOrchid")) + (t (:background "Pink"))) "Face used for submodes containing initialization code." :group 'mmm-faces) -(defface mmm-cleanup-submode-face '((t (:background "Wheat"))) +(defface mmm-cleanup-submode-face '((((background light)) (:background "Wheat")) + (((background dark)) (:background "peru")) + (t (:background "Wheat"))) "Face used for submodes containing cleanup code." :group 'mmm-faces) -(defface mmm-declaration-submode-face '((t (:background "Aquamarine"))) +(defface mmm-declaration-submode-face '((((background light)) (:background "Aquamarine")) + (((background dark)) (:background "DarkTurquoise")) + (t (:background "Aquamarine"))) "Face used for submodes containing declarations." :group 'mmm-faces) -(defface mmm-comment-submode-face '((t (:background "SkyBlue"))) +(defface mmm-comment-submode-face '((((background light)) (:background "SkyBlue")) + (((background dark)) (:background "SteelBlue")) + (t (:background "SkyBlue"))) "Face used for submodes containing comments and documentation." :group 'mmm-faces) -(defface mmm-output-submode-face '((t (:background "Plum"))) +(defface mmm-output-submode-face '((((background light)) (:background "Plum")) + (((background dark)) (:background "MediumVioletRed")) + (t (:background "Plum"))) "Face used for submodes containing expression that are output." :group 'mmm-faces) -(defface mmm-special-submode-face '((t (:background "MediumSpringGreen"))) +(defface mmm-special-submode-face '((((background light)) (:background "MediumSpringGreen")) + (((background dark)) (:background "ForestGreen")) + (t (:background "MediumSpringGreen"))) "Face used for special submodes not fitting any other category." :group 'mmm-faces) -(defface mmm-code-submode-face '((t (:background "LightGray"))) +(defface mmm-code-submode-face '((((background light)) (:background "LightGray")) + (((background dark)) (:background "DimGray")) + (t (:background "LightGray"))) "Face used for submodes containing ordinary code." :group 'mmm-faces) -(defface mmm-default-submode-face '((t (:background "gray85"))) +(defface mmm-default-submode-face '((((background light)) (:background "gray85")) + (((background dark)) (:background "gray20")) + (t (:background "gray85"))) "Face used for all submodes at decoration level 1. Also used at decoration level 2 for submodes not specifying a type." :group 'mmm-faces) @@ -508,8 +534,8 @@ See `mmm-global-mode'." :group 'mmm :type '(repeat (list (symbol :tag "Major Mode") - (string :tag "Filename Regexp") - (symbol :tag "Class"))) + (string :tag "Filename Regexp") + (symbol :tag "Class"))) :require 'mmm-mode) (defun mmm-add-mode-ext-class (mode ext class) @@ -523,6 +549,7 @@ (defcustom mmm-major-mode-preferences '((perl cperl-mode perl-mode) + (python python-mode python-mode) (javascript javascript-mode c++-mode) (java jde-mode java-mode c++-mode) (css css-mode c++-mode)) @@ -535,23 +562,23 @@ which will always be available." :group 'mmm :type '(repeat (cons symbol - (repeat - (restricted-sexp :match-alternatives - (fboundp)))))) + (repeat + (restricted-sexp :match-alternatives + (fboundp)))))) (defun mmm-add-to-major-mode-preferences (language mode &optional default) - "Set the preferred major mode for LANGUAGE to MODE. -This sets the value of `mmm-major-mode-preferences'. If DEFAULT is -nil or unsupplied, MODE is added at the front of the list of modes for -LANGUAGE. If DEFAULT is non-nil, then it is added at the end. This -may be used by packages to ensure that some mode is present, but not -override any user-specified mode." + "Add major mode MODE as acceptable for LANGUAGE. +This sets the value of `mmm-major-mode-preferences'. If DEFAULT +is non-nil, MODE is added at the front of the list of modes for +LANGUAGE. Otherwise, it is added at the end. This may be used by +packages to ensure that some mode is present, but not override +any user-specified mode." (let ((pair (assq language mmm-major-mode-preferences))) (if pair - ;; Existing mode preferences - (if default - (setcdr pair (cons mode (cdr pair))) - (setcdr pair (append (cdr pair) (list mode)))) + ;; Existing mode preferences + (if default + (setcdr pair (cons mode (cdr pair))) + (setcdr pair (append (cdr pair) (list mode)))) ;; No existing mode preference (add-to-list 'mmm-major-mode-preferences (list language mode))))) @@ -560,7 +587,7 @@ Valid submode names are either `fboundp' or present as the `car' of an element in `mmm-major-mode-preferences'." (if (or (fboundp symbol) - (assq symbol mmm-major-mode-preferences)) + (assq symbol mmm-major-mode-preferences)) symbol nil)) @@ -572,8 +599,8 @@ (if (fboundp mode) mode (car (remove-if-not - #'fboundp - (cdr (assq mode mmm-major-mode-preferences)))))) + #'fboundp + (cdr (assq mode mmm-major-mode-preferences)))))) ;;}}} ;;{{{ Delimiter Regions @@ -635,7 +662,7 @@ (defun mmm-use-old-command-keys () "Use the old command keys \(no control modifer) in MMM Mode." (setq mmm-command-modifiers '() - mmm-insert-modifiers '(control))) + mmm-insert-modifiers '(control))) ;;}}} ;;{{{ MMM Hooks @@ -664,8 +691,8 @@ "Run the hook named `mmm---hook', if it exists. If SUFFIX is nil or unsupplied, run `mmm--hook' instead." (let ((hook (intern-soft (if suffix - (format "mmm-%s-%s-hook" body suffix) - (format "mmm-%s-hook" body))))) + (format "mmm-%s-%s-hook" body suffix) + (format "mmm-%s-hook" body))))) (if hook (run-hooks hook)))) (defun mmm-run-major-hook () @@ -736,8 +763,8 @@ `mmm-mode-ext-classes-alist' for more information." :group 'mmm :type '(choice (const :tag "Always" t) - (const :tag "Never" nil) - (other :tag "Maybe" maybe)) + (const :tag "Never" nil) + (other :tag "Maybe" maybe)) :require 'mmm-mode) ;; These are not traditional editing modes, so mmm makes no sense, and @@ -767,6 +794,45 @@ than it solves, but some modes require it.") ;;}}} +;;{{{ Idle Parsing + +(defcustom mmm-parse-when-idle nil + "Non-nil to automatically reparse the buffer when it has some + modifications and Emacs has been idle for `mmm-idle-timer-delay'." + :type 'boolean + :group 'mmm) + +(defcustom mmm-idle-timer-delay 0.2 + "Delay in secs before re-parsing after user makes changes." + :type 'number + :group 'mmm) +(make-variable-buffer-local 'mmm-idle-timer-delay) + +(defvar mmm-mode-parse-timer nil "Private variable.") +(make-variable-buffer-local 'mmm-mode-parse-timer) +(defvar mmm-mode-buffer-dirty nil "Private variable.") +(make-variable-buffer-local 'mmm-mode-buffer-dirty) + +(defun mmm-mode-edit (beg end len) + (setq mmm-mode-buffer-dirty t) + (mmm-mode-reset-timer)) + +(defun mmm-mode-reset-timer () + (when mmm-mode-parse-timer + (cancel-timer mmm-mode-parse-timer)) + (setq mmm-mode-parse-timer + (run-with-idle-timer mmm-idle-timer-delay nil + #'mmm-mode-idle-reparse (current-buffer)))) + +(defun mmm-mode-idle-reparse (buffer) + (when (buffer-live-p buffer) + (with-current-buffer buffer + (when mmm-mode-buffer-dirty + (mmm-apply-all) + (setq mmm-mode-buffer-dirty nil) + (setq mmm-mode-parse-timer nil))))) + +;;}}} ;; NON-USER VARIABLES ;;{{{ Mode Variable @@ -945,6 +1011,7 @@ or internal class, usually one invoked by another class via :classes, and is not for the user to see.") +;;;###autoload (defun mmm-add-classes (classes) "Add the submode classes CLASSES to `mmm-classes-alist'." (dolist (class classes) @@ -954,19 +1021,19 @@ "Add CLASSES and a \"grouping class\" named GROUP which calls them all. The CLASSES are all made private, i.e. non-user-visible." (mmm-add-classes (mapcar #'(lambda (class) - (append class - '(:private t))) - classes)) + (append class + '(:private t))) + classes)) (add-to-list 'mmm-classes-alist - (list group :classes (mapcar #'first classes)))) + (list group :classes (mapcar #'first classes)))) (defun mmm-add-to-group (group classes) "Add CLASSES to the \"grouping class\" named GROUP. The CLASSES are all made private, i.e. non-user-visible." (mmm-add-classes (mapcar #'(lambda (class) - (append class - '(:private t))) - classes)) + (append class + '(:private t))) + classes)) (mmm-set-class-parameter group :classes (append (mmm-get-class-parameter group :classes) (mapcar #'first classes)))) @@ -974,7 +1041,7 @@ ;;}}} ;;{{{ Version Number -(defconst mmm-version "0.4.8" +(defconst mmm-version "0.5.4" "Current version of MMM Mode.") (defun mmm-version () @@ -984,8 +1051,13 @@ ;;}}} ;;{{{ Temp Buffer Name -(defvar mmm-temp-buffer-name " *mmm-temp*" - "Name for temporary buffers created by MMM Mode.") +(defvar mmm-temp-buffer-name "mmm-temp-buffer" + "Name for temporary buffers created by MMM Mode. +Using non-special name, so that font-lock-mode will be enabled +automatically when appropriate, and will set all related vars.") + +(defvar mmm-in-temp-buffer nil + "Bound to t when working in the temp buffer.") ;;}}} ;;{{{ Interactive History @@ -1017,9 +1089,9 @@ Uses `mmm-mode-ext-classes-alist' to find submode classes." (or mmm-mode-ext-classes (setq mmm-mode-ext-classes - (mapcar #'third - (remove-if-not #'mmm-mode-ext-applies - mmm-mode-ext-classes-alist))))) + (mapcar #'third + (remove-if-not #'mmm-mode-ext-applies + mmm-mode-ext-classes-alist))))) (defun mmm-clear-mode-ext-classes () "Clear classes added by major mode and filename." @@ -1028,25 +1100,25 @@ (defun mmm-mode-ext-applies (element) (destructuring-bind (mode ext class) element (and (if mode - (eq mode - ;; If MMM is on in this buffer, use the primary mode, - ;; otherwise use the normal indicator. - (or mmm-primary-mode major-mode)) - t) - (if ext - (and (buffer-file-name) - (save-match-data - (string-match ext (buffer-file-name)))) - t)))) + (eq mode + ;; If MMM is on in this buffer, use the primary mode, + ;; otherwise use the normal indicator. + (or mmm-primary-mode major-mode)) + t) + (if ext + (and (buffer-file-name) + (save-match-data + (string-match ext (buffer-file-name)))) + t)))) (defun mmm-get-all-classes (global) "Return a list of all classes applicable to the current buffer. These come from mode/ext associations, `mmm-classes', and interactive history, as well as `mmm-global-classes' if GLOBAL is non-nil." (append mmm-interactive-history - (if (listp mmm-classes) mmm-classes (list mmm-classes)) - (if global mmm-global-classes ()) - (mmm-get-mode-ext-classes))) + (if (listp mmm-classes) mmm-classes (list mmm-classes)) + (if global mmm-global-classes ()) + (mmm-get-mode-ext-classes))) ;;}}} ```
hendriktews commented 7 years ago

For the Proof General Debian package I removed mmm-mode already (because it is packaged separately in Debian). The patch was rather simple:

Description: don't install contrib/mmm mmm-mode is available as package and added to the dependencies Author: Hendrik Tews hendrik@askra.de --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ DEST_PREFIX=$(DESTDIR)/usr

PROVERS=coq hol-light -OTHER_ELISP=generic lib contrib/mmm +OTHER_ELISP=generic lib ELISP_DIRS=${PROVERS} ${OTHER_ELISP} ELISP_EXTRAS= EXTRA_DIRS = images

tarsius commented 7 years ago

Do you want me to submit a pr?

Also there are two more bundled libraries maths-menu.el and texi-docstring-magic.el. But both are not available from Melpa yet. I am gonna look into that a bit more.

cpitclaudel commented 7 years ago

Thanks so much @tarsius for this. Dropping mmm was indeed on the roadmap, so this will help. I'll try to look into this this week-end, if no one beats me to it. I also expect that you'll find https://github.com/ProofGeneral/PG/pull/157 relevant to this.

tarsius commented 7 years ago
cpitclaudel commented 7 years ago

Thanks; we should also check whether these are still useful in PG.

tarsius commented 7 years ago

I'll wait until you have done that before I move forward.

cpitclaudel commented 7 years ago

Thanks! This week end for sure.

psteckler commented 7 years ago

N.B.: I'll mirror whatever changes occur in the PG/xml fork.

On Thu, Mar 16, 2017 at 3:49 PM, Clément Pit-Claudel < notifications@github.com> wrote:

Thanks! This week end for sure.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ProofGeneral/PG/issues/171#issuecomment-287171429, or mute the thread https://github.com/notifications/unsubscribe-auth/ACJAKGQr-MHB1EtSSGvwlz4H5e-Yyv-zks5rmZJhgaJpZM4Mflh7 .

psteckler commented 7 years ago

I'm removing mmm from PG/xml, although it doesn't seem to have happened in the master branch yet.

cpitclaudel commented 7 years ago

Can you do it in master too, and merge back?

psteckler commented 7 years ago

Should I remove ML4PG in master, too?

psteckler commented 7 years ago

I've created PR #185, so others can validate these changes.

Once that's merged, I'll merge back to PG/xml.

psteckler commented 7 years ago

Closing, mmm has been removed.

tarsius commented 7 years ago

Thanks!