emacs-devel
[Top][All Lists]
Advanced

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

Re: html, css, and js modes working together


From: Stefan Monnier
Subject: Re: html, css, and js modes working together
Date: Fri, 10 Feb 2017 15:05:49 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Regarding the mode's name.  You could rename html-mode to html-only-mode
(or html-basic-mode?) and then use html-mode for that new mode.
Ideally, you could even make html-only-mode a parameter so that your new
html-mode could be used with other "basic" html editing modes such as
nxml-mode or psgml-mode.

> @@ -1455,7 +1457,7 @@ smie-indent-bob
>    ;; Start the file at column 0.
>    (save-excursion
>      (forward-comment (- (point)))
> -    (if (bobp) 0)))
> +    (if (bobp) (prog-first-column))))
 
This looks good.

> +(defmacro smie-with-rules (spec &rest body)
> +  "Temporarily set up SMIE indentation and evaluate BODY.
> +SPEC is of the form (GRAMMAR RULES-FUNCTION &rest KEYWORDS); see 
> `smie-setup'.
> +BODY is evaluated with the relevant SMIE variables temporarily bound."
> +  (declare (indent 1))
> +  `(smie-funcall-with-rules (list ,@spec) (lambda () . ,body)))
> +
> +(defun smie-funcall-with-rules (spec fun)
> +  (let ((smie-rules-function smie-rules-function)
> +        (smie-grammar smie-grammar)
> +        (forward-sexp-function forward-sexp-function)
> +        (smie-forward-token-function smie-forward-token-function)
> +        (smie-backward-token-function smie-backward-token-function))
> +    (smie--basic-setup (car spec) (cadr spec) (cddr spec))
> +    (funcall fun)))

The use of buffer-local-variables+progv should make this unnecessary.

> -     ("\\.[sx]?html?\\(\\.[a-zA-Z_]+\\)?\\'" . html-mode)
> +     ("\\.[sx]?html?\\(\\.[a-zA-Z_]+\\)?\\'" . mhtml-mode)

FWIW, I think that html-mode should not belong to any html mode package
in particular (maybe it should use `define-alternatives`).


        Stefan




reply via email to

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