[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master bcc5adf 351/433: Define mmm-indent-line-function and its d
From: |
Dmitry Gutov |
Subject: |
[elpa] master bcc5adf 351/433: Define mmm-indent-line-function and its default value |
Date: |
Thu, 15 Mar 2018 19:44:34 -0400 (EDT) |
branch: master
commit bcc5adfe2490719f27ba1ab50938bd759eb0401b
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Define mmm-indent-line-function and its default value
* Now html-erb-mode can just set mmm-indent-line-function.
* Easier access to the submode's indent-line-function. No need to hack
around.
* mmm-indent-line indents according to the submode at the indentation,
which is more
consistent than previously.
---
mmm-erb.el | 17 +++--------------
mmm-mode.el | 9 +++++----
mmm-region.el | 20 +++++++++++++++++++-
mmm-vars.el | 1 -
4 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/mmm-erb.el b/mmm-erb.el
index f7dd566..c850ba4 100644
--- a/mmm-erb.el
+++ b/mmm-erb.el
@@ -109,19 +109,10 @@
(?= ejs-expression nil @ "<%=" @ " " _ " " @ "%>" @))
:creation-hook mmm-erb-mark-as-special)))
-(pushnew '(indent-line-function buffer) mmm-save-local-variables)
-
;;;###autoload
(define-derived-mode html-erb-mode html-mode "ERB-HTML"
(setq sgml-unclosed-tags nil) ; Simplifies indentation logic.
- (add-hook 'mmm-html-erb-mode-hook 'mmm-erb-process-submode nil t)
- (add-hook 'mmm-ruby-mode-submode-hook 'mmm-erb-process-submode nil t)
- (add-hook 'mmm-css-mode-submode-hook 'mmm-erb-process-submode nil t)
- (add-hook 'mmm-js-mode-submode-hook 'mmm-erb-process-submode nil t))
-
-(defun mmm-erb-process-submode ()
- "Hook function to run after primary or submode major mode function."
- (setq indent-line-function 'mmm-erb-indent-line))
+ (set (make-local-variable 'mmm-indent-line-function) 'mmm-erb-indent-line))
(defun mmm-erb-mark-as-special ()
"Hook function to run in ERB and EJS tag regions."
@@ -245,7 +236,7 @@
((re-search-forward " *{ *" limit t) 'open)))
(defun mmm-erb-orig-indent-function (mode)
- (cadr (assoc 'indent-line-function (get mode 'mmm-local-variables))))
+ (get mode 'mmm-indent-line-function))
(defvar mmm-erb-offset-var-alist
'((html-erb-mode . sgml-basic-offset)
@@ -257,9 +248,7 @@
;;;###autoload
(define-derived-mode nxml-web-mode nxml-mode "nXML-Web"
- (add-hook 'mmm-nxml-web-mode-hook 'mmm-erb-process-submode nil t)
- (add-hook 'mmm-css-mode-submode-hook 'mmm-erb-process-submode nil t)
- (add-hook 'mmm-js-mode-submode-hook 'mmm-erb-process-submode nil t))
+ (set (make-local-variable 'mmm-indent-line-function) 'mmm-erb-indent-line))
(provide 'mmm-erb)
diff --git a/mmm-mode.el b/mmm-mode.el
index 0565eab..e6e83f7 100644
--- a/mmm-mode.el
+++ b/mmm-mode.el
@@ -117,17 +117,17 @@ over certain regions. The submode regions are usually
highlighted by
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)
@@ -168,6 +168,7 @@ available through M-x customize under Programming | Tools |
Mmm."
'mmm-beginning-of-syntax)
(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)
diff --git a/mmm-region.el b/mmm-region.el
index 927b56e..ca87d98 100644
--- a/mmm-region.el
+++ b/mmm-region.el
@@ -511,7 +511,8 @@ is non-nil, don't quit if the info is already there."
font-lock-beginning-of-syntax-function))
(put mode 'mmm-syntax-propertize-function
(and (boundp 'syntax-propertize-function)
- 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)
@@ -821,7 +822,24 @@ of the REGIONS covers START to STOP."
(mmm-set-local-variables saved-mode saved-ovl))))
;;}}}
+;;{{{ Indentation
+
+(defvar mmm-indent-line-function 'mmm-indent-line
+ "The function to call to indent inside a primary mode region.
+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 (or mmm-current-submode mmm-primary-mode)
+ 'mmm-indent-line-function))))
+;;}}}
(provide 'mmm-region)
;;; mmm-region.el ends here
diff --git a/mmm-vars.el b/mmm-vars.el
index 8b8ea0a..c48e72d 100644
--- a/mmm-vars.el
+++ b/mmm-vars.el
@@ -131,7 +131,6 @@
font-lock-syntax-table
font-lock-mark-block-function ; Override this?
font-lock-syntactic-keywords
- indent-line-function
parse-sexp-ignore-comments ; Fixes indentation in PHP-mode?
;; Can be different in different buffers
(c-basic-offset
- [elpa] master 0cb75f0 299/433: Correctly restore pre-indent position, (continued)
- [elpa] master 0cb75f0 299/433: Correctly restore pre-indent position, Dmitry Gutov, 2018/03/15
- [elpa] master 9674355 328/433: Merge pull request #18 from prakashk/master, Dmitry Gutov, 2018/03/15
- [elpa] master 05a787e 291/433: Fix further compilation warnings in recent Emacsen, Dmitry Gutov, 2018/03/15
- [elpa] master e269a47 305/433: Require 'mmm-region from 'mmm-erb, avoiding compilation warnings about free variable references, Dmitry Gutov, 2018/03/15
- [elpa] master 961a127 263/433: Prevent bounds from going outside buffer (XEmacs complains), Dmitry Gutov, 2018/03/15
- [elpa] master 66b47cd 218/433: Released 0.4.7, Dmitry Gutov, 2018/03/15
- [elpa] master 07b35d4 250/433: Added mmm-noweb to autoload (Joe Kelsey), Dmitry Gutov, 2018/03/15
- [elpa] master b554efb 287/433: After fontifying the region, restore local vars, Dmitry Gutov, 2018/03/15
- [elpa] master 0922481 254/433: Added narrow to submode region (Joe Kelsey), Dmitry Gutov, 2018/03/15
- [elpa] master b72e44c 369/433: Released 0.5.1, Dmitry Gutov, 2018/03/15
- [elpa] master bcc5adf 351/433: Define mmm-indent-line-function and its default value,
Dmitry Gutov <=
- [elpa] master 8ab7041 297/433: Adjust indentation in primary mode for ERB blocks, Dmitry Gutov, 2018/03/15
- [elpa] master 68b2135 282/433: Fix obsolete backquotes, Dmitry Gutov, 2018/03/15
- [elpa] master e3ef1f8 267/433: Collapsed undo of insertion into one command., Dmitry Gutov, 2018/03/15
- [elpa] master 6dcd817 337/433: * mmm-syntax-propertize-function: Use font-lock-syntactic-keywords, Dmitry Gutov, 2018/03/15
- [elpa] master ea8a1b8 342/433: Rebinding syntax-propertize-chunk-size is pointless, Dmitry Gutov, 2018/03/15
- [elpa] master 970b52a 298/433: Check for EJS "blocks", Dmitry Gutov, 2018/03/15
- [elpa] master 20e65af 372/433: Primary mode spf should see the whole buffer, Dmitry Gutov, 2018/03/15
- [elpa] master 2590b31 401/433: Update the checklist, Dmitry Gutov, 2018/03/15
- [elpa] master 5f80383 364/433: Fix typo: global-mmm-mode -> mmm-global-mode, Dmitry Gutov, 2018/03/15
- [elpa] master 7422b45 341/433: * mmm-regions-in: Keep overlay references in the return value, Dmitry Gutov, 2018/03/15