From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: html, css, and js modes working together Date: Fri, 10 Feb 2017 15:05:49 -0500 Message-ID: References: <87o9ynarz3.fsf@tromey.com> <877f4z6i8n.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1486757176 29891 195.159.176.226 (10 Feb 2017 20:06:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 10 Feb 2017 20:06:16 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 10 21:06:11 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ccHSM-0007Lz-UL for ged-emacs-devel@m.gmane.org; Fri, 10 Feb 2017 21:06:11 +0100 Original-Received: from localhost ([::1]:45764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccHSS-0002lt-Hx for ged-emacs-devel@m.gmane.org; Fri, 10 Feb 2017 15:06:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccHSH-0002kT-Qe for emacs-devel@gnu.org; Fri, 10 Feb 2017 15:06:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ccHSE-0001i3-M2 for emacs-devel@gnu.org; Fri, 10 Feb 2017 15:06:05 -0500 Original-Received: from [195.159.176.226] (port=54062 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ccHSE-0001hc-Fg for emacs-devel@gnu.org; Fri, 10 Feb 2017 15:06:02 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1ccHS2-0006Cz-IB for emacs-devel@gnu.org; Fri, 10 Feb 2017 21:05:50 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 41 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:MxTZo6yt/5/ujcoGXlIBriXFvy0= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:212214 Archived-At: 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