[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e848ef1 323/433: * mmm-fontify-region: Save and restore su
From: |
Dmitry Gutov |
Subject: |
[elpa] master e848ef1 323/433: * mmm-fontify-region: Save and restore submode, overlay and local vars |
Date: |
Thu, 15 Mar 2018 19:44:28 -0400 (EDT) |
branch: master
commit e848ef181e347c4d1484349047e3ea0003b16783
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
* mmm-fontify-region: Save and restore submode, overlay and local vars
This function is called from different positions, so just calling
`mmm-update-submode-region' at the end is not enough.
---
mmm-region.el | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/mmm-region.el b/mmm-region.el
index 1c86422..69b62ea 100644
--- a/mmm-region.el
+++ b/mmm-region.el
@@ -769,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)
- [elpa] master 7661968 415/433: Merge pull request #74 from AdamNiederer/master, (continued)
- [elpa] master 7661968 415/433: Merge pull request #74 from AdamNiederer/master, Dmitry Gutov, 2018/03/15
- [elpa] master 6812418 424/433: Add a FIXME, Dmitry Gutov, 2018/03/15
- [elpa] master 93cd2cf 412/433: Add function for narrowed indentation, Dmitry Gutov, 2018/03/15
- [elpa] master 16d937d 019/433: Added files required by automake., Dmitry Gutov, 2018/03/15
- [elpa] master 8e205dd 400/433: Don't use version.texi at all, Dmitry Gutov, 2018/03/15
- [elpa] master 2ca7e6a 300/433: Add header comment, provide description, Dmitry Gutov, 2018/03/15
- [elpa] master 956354f 375/433: Fix missing var declaration, Dmitry Gutov, 2018/03/15
- [elpa] master fff25f6 311/433: Note that 'autogen.sh' should be run to generate 'configure' and 'Makefile.in' (see #11), Dmitry Gutov, 2018/03/15
- [elpa] master 3fb2964 416/433: Update Michael's email address to an active one, Dmitry Gutov, 2018/03/15
- [elpa] master 6c5d442 425/433: Fix copyright entry, Dmitry Gutov, 2018/03/15
- [elpa] master e848ef1 323/433: * mmm-fontify-region: Save and restore submode, overlay and local vars,
Dmitry Gutov <=
- [elpa] master 004a618 370/433: Fix #23, Dmitry Gutov, 2018/03/15
- [elpa] master 53524db 389/433: Remove version.texi from the repo, Dmitry Gutov, 2018/03/15
- [elpa] master 2c9532b 326/433: Simplify mmm-update-mode-info, Dmitry Gutov, 2018/03/15
- [elpa] master e767fa2 265/433: Added script and documentation for installing from CVS, Dmitry Gutov, 2018/03/15
- [elpa] master 7965887 279/433: Fix error in mmm-mode when Emacs 23 immediately evaporates zero-width submode regions, Dmitry Gutov, 2018/03/15
- [elpa] master 7da80fb 422/433: Add cl-lib package dependency, Dmitry Gutov, 2018/03/15
- [elpa] master cd66bdd 316/433: Improve mmm-erb usage instructions, Dmitry Gutov, 2018/03/15
- [elpa] master 2e06d3d 356/433: Remove the useless CVS $Id tags, Dmitry Gutov, 2018/03/15
- [elpa] master 68fe94d 274/433: (mmm-ify): Change defaults for front-delim and, Dmitry Gutov, 2018/03/15
- [elpa] master 28d51d2 312/433: Note availability of Melpa packages, Dmitry Gutov, 2018/03/15