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

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

[elpa] master b171ba0 324/433: Merge pull request #17 from dgutov/retro


From: Dmitry Gutov
Subject: [elpa] master b171ba0 324/433: Merge pull request #17 from dgutov/retro
Date: Thu, 15 Mar 2018 19:44:28 -0400 (EDT)

branch: master
commit b171ba04e032168fa0c685bedda367bff82fd455
Merge: a0b1ecc e848ef1
Author: Steve Purcell <address@hidden>
Commit: Steve Purcell <address@hidden>

    Merge pull request #17 from dgutov/retro
    
    A few fixes for some my old commits
---
 mmm-class.el  |  3 +--
 mmm-region.el | 46 ++++++++++++++++++++++++++--------------------
 mmm-vars.el   | 11 ++++++-----
 3 files changed, 33 insertions(+), 27 deletions(-)

diff --git a/mmm-class.el b/mmm-class.el
index 05e1d6a..b3e48ed 100644
--- a/mmm-class.el
+++ b/mmm-class.el
@@ -112,8 +112,7 @@ error once all classes have been applied."
 The classes come from mode/ext, `mmm-classes', `mmm-global-classes',
 and interactive history."
   (mmm-clear-overlays start stop 'strict)
-  (let ((font-lock-mode))
-    (mmm-apply-classes (mmm-get-all-classes t) :start start :stop stop))
+  (mmm-apply-classes (mmm-get-all-classes t) :start start :stop stop)
   (mmm-update-submode-region)
   (mmm-refontify-maybe start stop))
 
diff --git a/mmm-region.el b/mmm-region.el
index 7d94b75..69b62ea 100644
--- a/mmm-region.el
+++ b/mmm-region.el
@@ -565,9 +565,7 @@ is non-nil, don't quit if the info is already there."
       (if region-entry
           (setcdr region-entry region-vars)
         (push (cons mode region-vars)
-              mmm-region-saved-locals-defaults))
-      ;; The temp buffer stuff above wipes fontification.
-      (mmm-refontify-maybe))))
+              mmm-region-saved-locals-defaults)))))
 
 ;;}}}
 ;;{{{ Updating Hooks
@@ -771,23 +769,31 @@ of the REGIONS covers START to STOP."
 
 (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 '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)))
-  ;; It's in `post-command-hook' too, but that's executed before font-lock,
-  ;; so the latter messes up local vars (such as line-indent-function)
-  ;; until after the next command.
-  (mmm-update-submode-region)
+  (let ((saved-mode mmm-current-submode)
+        (saved-pos (and mmm-current-overlay
+                        (overlay-start 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-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 
'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))))
+      (save-excursion
+        ;; `post-command-hook' contains `mmm-update-submode-region',
+        ;; but jit-lock runs later, so we need to restore local vars now.
+        (goto-char (or saved-pos (point-min)))
+        (mmm-set-current-submode saved-mode)
+        ;; This looks for the current overlay at point to set region locals.
+        (mmm-set-local-variables saved-mode))))
   (when loudly (message nil)))
 
 (defun mmm-fontify-region-list (mode regions)
diff --git a/mmm-vars.el b/mmm-vars.el
index 6ce964b..35076d6 100644
--- a/mmm-vars.el
+++ b/mmm-vars.el
@@ -801,11 +801,12 @@ than it solves, but some modes require it.")
                              #'mmm-mode-idle-reparse (current-buffer))))
 
 (defun mmm-mode-idle-reparse (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))))
+  (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)))))
 
 ;;}}}
 



reply via email to

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