From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.bugs Subject: bug#25858: 25.1.91; js.el should use font-lock-doc-face Date: Sat, 25 Feb 2017 10:28:28 -0700 Message-ID: <878touuqmb.fsf@tromey.com> References: <87d1e8vxyb.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1488043910 14747 195.159.176.226 (25 Feb 2017 17:31:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 25 Feb 2017 17:31:50 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux) Cc: Tom Tromey , 25858@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 25 18:31:46 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1chgC4-0002ss-AE for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Feb 2017 18:31:40 +0100 Original-Received: from localhost ([::1]:43676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chgCA-00065L-5q for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Feb 2017 12:31:46 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chg9a-0003Rb-3U for bug-gnu-emacs@gnu.org; Sat, 25 Feb 2017 12:29:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chg9W-0007IK-Tj for bug-gnu-emacs@gnu.org; Sat, 25 Feb 2017 12:29:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57751) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1chg9W-0007IB-Ly for bug-gnu-emacs@gnu.org; Sat, 25 Feb 2017 12:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1chg9W-0003oy-DX for bug-gnu-emacs@gnu.org; Sat, 25 Feb 2017 12:29:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tom Tromey Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Feb 2017 17:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25858 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25858-submit@debbugs.gnu.org id=B25858.148804372414661 (code B ref 25858); Sat, 25 Feb 2017 17:29:02 +0000 Original-Received: (at 25858) by debbugs.gnu.org; 25 Feb 2017 17:28:44 +0000 Original-Received: from localhost ([127.0.0.1]:55950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1chg9E-0003oP-FH for submit@debbugs.gnu.org; Sat, 25 Feb 2017 12:28:44 -0500 Original-Received: from gproxy8-pub.mail.unifiedlayer.com ([67.222.33.93]:38340) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1chg9C-0003oB-QJ for 25858@debbugs.gnu.org; Sat, 25 Feb 2017 12:28:43 -0500 Original-Received: (qmail 23359 invoked by uid 0); 25 Feb 2017 17:28:34 -0000 Original-Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy8.mail.unifiedlayer.com with SMTP; 25 Feb 2017 17:28:34 -0000 Original-Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id p5UV1u01T2f2jeq015UYWz; Sat, 25 Feb 2017 10:28:34 -0700 X-Authority-Analysis: v=2.1 cv=H5NInYoi c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=n2v9WMKugxEA:10 a=vaJtXVxTAAAA:8 a=9GPtz0nih86XkTCqSTkA:9 a=zstS-IiYAAAA:8 a=4mfU5Zsja8ni8F5c4wAA:9 a=hCt-GehETBxEYQOojhlW:22 a=4G6NA9xxw8l3yy4pmD5M:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=zKMB+God8pXUpsU7+xEA1W1wl+5PDuSZpt91ouorYco=; b=BCEdIF/53qtzjZ6X7PRPvuBvKg tXcooRt4ainDGF33S0hpi9wGBJGrktW3+CA+GJJbv1+O5+5h+3SCIaLK+ovIY1mfDqb09SEQ2bx0f Z0S4KhVpGrAa4hSNsW9lUvpWZ; Original-Received: from 174-16-128-54.hlrn.qwest.net ([174.16.128.54]:39146 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1chg8z-00083T-Ot; Sat, 25 Feb 2017 10:28:29 -0700 X-Attribution: Tom In-Reply-To: (Dmitry Gutov's message of "Fri, 24 Feb 2017 12:58:09 +0200") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box522.bluehost.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.16.128.54 X-Exim-ID: 1chg8z-00083T-Ot X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-128-54.hlrn.qwest.net (bapiya) [174.16.128.54]:39146 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:129792 Archived-At: --=-=-= Content-Type: text/plain >>>>> "Dmitry" == Dmitry Gutov writes: Dmitry> Agreed. An implementation like Python's should work well, I think. How's this? Tom --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=P Content-Description: patch commit d825891eaf1480fe82d4f5c51b2a921dda6e9cf7 Author: Tom Tromey Date: Sat Feb 25 10:27:48 2017 -0700 Use font-lock-doc-face in js-mode Bug#25858: * lisp/progmodes/js.el (js-font-lock-syntactic-face-function): New defun. (js-mode): Use it. * test/lisp/progmodes/js-tests.el (js-mode-doc-comment-face): New test. diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 65325a8..aed42a8 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -1687,6 +1687,16 @@ js--font-lock-keywords js--font-lock-keywords-3) "Font lock keywords for `js-mode'. See `font-lock-keywords'.") +(defun js-font-lock-syntactic-face-function (state) + "Return syntactic face given STATE." + (if (nth 3 state) + font-lock-string-face + (if (save-excursion + (goto-char (nth 8 state)) + (looking-at "/\\*\\*")) + font-lock-doc-face + font-lock-comment-face))) + (defconst js--syntax-propertize-regexp-regexp (rx ;; Start of regexp. @@ -3828,7 +3838,10 @@ js-mode (setq-local beginning-of-defun-function #'js-beginning-of-defun) (setq-local end-of-defun-function #'js-end-of-defun) (setq-local open-paren-in-column-0-is-defun-start nil) - (setq-local font-lock-defaults (list js--font-lock-keywords)) + (setq-local font-lock-defaults + (list js--font-lock-keywords nil nil nil nil + '(font-lock-syntactic-face-function + . js-font-lock-syntactic-face-function))) (setq-local syntax-propertize-function #'js-syntax-propertize) (setq-local prettify-symbols-alist js--prettify-symbols-alist) diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el index 07e659a..e030675 100644 --- a/test/lisp/progmodes/js-tests.el +++ b/test/lisp/progmodes/js-tests.el @@ -128,6 +128,18 @@ ;; Any success is ok here. (should t))) +(ert-deftest js-mode-doc-comment-face () + (dolist (test '(("/*" "*/" font-lock-comment-face) + ("//" "\n" font-lock-comment-face) + ("/**" "*/" font-lock-doc-face) + ("\"" "\"" font-lock-string-face))) + (with-temp-buffer + (js-mode) + (insert (car test) " he") + (save-excursion (insert "llo " (cadr test))) + (font-lock-ensure) + (should (eq (get-text-property (point) 'face) (caddr test)))))) + (provide 'js-tests) ;;; js-tests.el ends here --=-=-=--