all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#21568: [PATCH] Add prettify-symbols-alist for js-mode
@ 2015-09-26 11:49 Simen Heggestøyl
  2015-09-26 13:32 ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Simen Heggestøyl @ 2015-09-26 11:49 UTC (permalink / raw)
  To: 21568

[-- Attachment #1: Type: text/plain, Size: 1655 bytes --]

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@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



[-- Attachment #2: Type: text/html, Size: 2297 bytes --]

^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-09-28 22:54 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-26 11:49 bug#21568: [PATCH] Add prettify-symbols-alist for js-mode Simen Heggestøyl
2015-09-26 13:32 ` Eli Zaretskii
2015-09-26 15:59   ` Simen Heggestøyl
2015-09-27  0:39     ` Xue Fuqiao
2015-09-27  2:01       ` Dmitry Gutov
2015-09-27  6:04         ` Eli Zaretskii
2015-09-27  6:12           ` Dmitry Gutov
2015-09-27  7:28             ` Eli Zaretskii
2015-09-27  8:21               ` Dmitry Gutov
2015-09-27  8:39                 ` Eli Zaretskii
2015-09-27  8:50                   ` Dmitry Gutov
2015-09-27 10:03                     ` Eli Zaretskii
2015-09-27 14:11                       ` Dmitry Gutov
2015-09-27 18:37                         ` Eli Zaretskii
2015-09-27 19:13                           ` Dmitry Gutov
2015-09-27 19:46                             ` Eli Zaretskii
2015-09-27 20:18                               ` Dmitry Gutov
2015-09-27 21:01                                 ` Eli Zaretskii
2015-09-28  4:16                                   ` Explicit encoding cookie in Elisp files, was: " Dmitry Gutov
2015-09-28  7:27                                     ` Explicit encoding cookie in Elisp files " Eli Zaretskii
2015-09-28  7:53                                       ` Dmitry Gutov
2015-09-28  8:24                                         ` Eli Zaretskii
2015-09-28 22:54                                           ` Dmitry Gutov
2015-09-27  8:10             ` bug#21568: [PATCH] " Simen Heggestøyl
2015-09-27 14:28         ` Xue Fuqiao

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.