GNU bug report logs -
#21568
[PATCH] Add prettify-symbols-alist for js-mode
Previous Next
Reported by: Simen Heggestøyl <simenheg <at> gmail.com>
Date: Sat, 26 Sep 2015 11:51:02 UTC
Severity: normal
Tags: patch
Done: Simen Heggestøyl <simenheg <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Sun, 27 Sep 2015 10:10:55 +0200
with message-id <1443341455.1929.0 <at> smtp.gmail.com>
and subject line Re: bug#21568: [PATCH] Add prettify-symbols-alist for js-mode
has caused the debbugs.gnu.org bug report #21568,
regarding [PATCH] Add prettify-symbols-alist for js-mode
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
21568: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21568
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
With the introduction of the fat arrow (=>) function notation in
ECMAScript 6, why not make them prettier by default when
prettify-symbols-mode is turned on?
I propose the following patch, which also adds pretty versions of >=
and <= while we're at it:
From fa37953359f50748801717d259350d7e352cff60 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <simenheg <at> gmail.com>
Date: Wed, 23 Sep 2015 21:49:24 +0200
Subject: [PATCH] Add prettify-symbols-alist for js-mode
* lisp/progmodes/js.el (js--prettify-symbols-alist): New defconst.
(js-mode): Use it.
---
lisp/progmodes/js.el | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 6a800f8..f214015 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1724,6 +1724,12 @@ This performs fontification according to
`js--class-styles'."
(js-syntax-propertize-regexp end))))))
(point) end))
+(defconst js--prettify-symbols-alist
+ '(("=>" . ?⇒)
+ (">=" . ?≥)
+ ("<=" . ?≤))
+ "Alist of symbol prettifications for JavaScript.")
+
;;; Indentation
(defconst js--possibly-braceless-keyword-re
@@ -3495,6 +3501,7 @@ If one hasn't been set, or if it's stale, prompt
for a new one."
(setq-local open-paren-in-column-0-is-defun-start nil)
(setq-local font-lock-defaults (list js--font-lock-keywords))
(setq-local syntax-propertize-function #'js-syntax-propertize)
+ (setq-local prettify-symbols-alist js--prettify-symbols-alist)
(setq-local parse-sexp-ignore-comments t)
(setq-local parse-sexp-lookup-properties t)
--
2.5.1
[Message part 4 (text/html, inline)]
[Message part 5 (message/rfc822, inline)]
[Message part 6 (text/plain, inline)]
On Sun, Sep 27, 2015 at 8:12 AM, Dmitry Gutov <dgutov <at> yandex.ru> wrote:
> Thanks. Simen, please install.
Done!
-- Simen
[Message part 7 (text/html, inline)]
This bug report was last modified 9 years and 240 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.