unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25858: 25.1.91; js.el should use font-lock-doc-face
@ 2017-02-24  7:40 Tom Tromey
  2017-02-24 10:58 ` Dmitry Gutov
  2017-02-25 21:04 ` bug#25858: done Tom Tromey
  0 siblings, 2 replies; 5+ messages in thread
From: Tom Tromey @ 2017-02-24  7:40 UTC (permalink / raw)
  To: 25858


I think js-mode should recognize "/**"-style jsdoc comments and fontify
them using font-lock-doc-face.  Some other programming modes do this
already.

Tom




In GNU Emacs 25.1.91.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.7)
 of 2017-02-02 built on bapiya
Repository revision: 7e02a477bbcabb4e65aeecade79b67357c0b9dae
Windowing system distributor 'Fedora Project', version 11.0.11901000
System Description:	Fedora release 25 (Twenty Five)

Configured using:
 'configure --prefix=/home/tromey/Emacs/install/ --with-modules'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES

Important settings:
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  shell-dirtrack-mode: t
  diff-auto-refine-mode: t
  flyspell-mode: t
  which-function-mode: t
  erc-services-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-networks-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-match-mode: t
  erc-netsplit-mode: t
  erc-hl-nicks-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  savehist-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  auto-fill-function: do-auto-fill
  transient-mark-mode: t

Recent messages:
Saving Gnus registry (size 13198) to ~/.gnus.registry.eieio...done
Saving file /home/tromey/.newsrc...
Wrote /home/tromey/.newsrc
Saving /home/tromey/.newsrc.eld...
Saving file /home/tromey/.newsrc.eld...
Wrote /home/tromey/.newsrc.eld
Saving /home/tromey/.newsrc.eld...done
scroll-down-command: Beginning of buffer
Making completion list...
Type C-x 1 to delete the help window.

Load-path shadows:
/home/tromey/.emacs.d/elpa/debbugs-0.12/debbugs-gnu hides /home/tromey/.emacs.d/elpa/debbugs-0.6/debbugs-gnu
/home/tromey/.emacs.d/elpa/debbugs-0.12/debbugs hides /home/tromey/.emacs.d/elpa/debbugs-0.6/debbugs
/home/tromey/.emacs.d/elpa/debbugs-0.12/debbugs-pkg hides /home/tromey/.emacs.d/elpa/debbugs-0.6/debbugs-pkg
/home/tromey/.emacs.d/elpa/debbugs-0.12/debbugs-autoloads hides /home/tromey/.emacs.d/elpa/debbugs-0.6/debbugs-autoloads
/home/tromey/.emacs.d/elpa/debbugs-0.12/debbugs-org hides /home/tromey/.emacs.d/elpa/debbugs-0.6/debbugs-org
/home/tromey/.emacs.d/elpa/bubbles-0.5/bubbles hides /home/tromey/Emacs/install/share/emacs/25.1.91/lisp/play/bubbles
/home/tromey/.emacs.d/elpa/soap-client-3.1.1/soap-inspect hides /home/tromey/Emacs/install/share/emacs/25.1.91/lisp/net/soap-inspect
/home/tromey/.emacs.d/elpa/soap-client-3.1.1/soap-client hides /home/tromey/Emacs/install/share/emacs/25.1.91/lisp/net/soap-client

Features:
(cmake-mode pcmpl-unix pcmpl-gnu autoconf autoconf-mode tramp-cache
markdown-mode ffap dired-aux nndoc gnus-dup debbugs-gnu debbugs
soap-client rng-xsd rng-dt rng-util xsd-regexp autoload tar-mode
cus-edit highlight-refontification tabify man shadow emacsbug conf-mode
two-column iso-transl perl-mode sh-script executable cal-move nnregistry
python tramp-sh tramp tramp-compat tramp-loaddefs trampver ucs-normalize
make-mode etags cursor-sensor mhtml-mode org-bullets org-element
org-rmail org-mhe org-irc org-info org-gnus org-docview doc-view
image-mode org-bibtex bibtex org-bbdb org-w3m org org-macro org-footnote
org-pcomplete org-list org-faces org-entities org-version ob-emacs-lisp
ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint
ob-core ob-eval org-compat org-macs org-loaddefs gnus-fun gnus-draft
noutline outline ido skeleton css-mode smie eww url-queue trace
find-dired descr-text gdb-shell lisp-mnt url-handlers url-http url-gw
url-auth lex edebug debug m4-mode bbdb-sc supercite regi xref project
log-edit js json map sgml-mode flow-fill gnus-html xml url-cache mm-url
url url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf eieio-opt speedbar sb-image ezimage dframe find-func
whitespace tcl log-view pcvs-util vc-annotate term/xterm xterm
smerge-mode goto-addr shell find-file idutils derived bug-reference
cc-mode cc-fonts cc-guess cc-menus cc-cmds jka-compr mailalias mail-hist
nnir sort gnus-cite smiley shr-color url-util url-parse url-vars shr dom
subr-x browse-url mm-archive gnus-async gnus-bcklg qp gnus-ml disp-table
gnus-topic nndraft nnmh nnfolder utf-7 bbdb-gnus bbdb-mua bbdb-com crm
network-stream nsm starttls gnus-agent gnus-srvr gnus-score score-mode
nnvirtual gnus-msg nntp gnus-cache gnus-registry registry eieio-compat
eieio-base gnus-art mm-uu mml2015 mm-view mml-smime smime dig mailcap
gnus-sum gnus-group gnus-undo smtpmail gnus-start gnus-cloud nnimap
nnmail mail-source tls gnutls utf7 netrc nnoo parse-time gnus-spec
gnus-int gnus-range gnus-win gnus gnus-ems nnheader bbdb-message
sendmail mail-extr message idna dired rfc822 mml mml-sec epg mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev mail-utils gmm-utils mailheader gud dwarf-mode copyright
dabbrev misearch multi-isearch vc-mtn vc-hg vc-bzr vc-src vc-sccs vc-svn
vc-cvs vc-rcs add-log rx vc-git diff-mode easy-mmode rust-mode flyspell
ispell diminish edmacro kmacro projectile grep compile ibuf-ext ibuffer
dash appt diary-lib diary-loaddefs cal-menu calendar cal-loaddefs
which-func imenu minimap autorevert filenotify cus-start cus-load status
erc-services erc-list erc-menu erc-join erc-ring erc-networks
erc-pcomplete pcomplete erc-track erc-match erc-netsplit erc-hl-nicks
color erc-button erc-fill erc-stamp wid-edit erc-goodies erc erc-backend
erc-compat format-spec auth-source eieio gnus-util mm-util help-fns
mail-prsvr password-cache thingatpt pp warnings advice vc-dir ewoc vc
vc-dispatcher cc-styles cc-align cc-engine cc-vars cc-defs bbdb
bbdb-site timezone ange-ftp comint ansi-color ring server savehist
finder-inf dwarf-mode-autoloads gdb-shell-autoloads eieio-core
lisppaste-autoloads pydoc-info-autoloads info-look cl-seq cl-macs cl
weblogger-autoloads info package epg-config seq byte-opt gv bytecomp
byte-compile cl-extra help-mode easymenu cconv cl-loaddefs pcase cl-lib
bbdb-loaddefs time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 3390375 558178)
 (symbols 48 149617 336)
 (miscs 40 38197 18258)
 (strings 32 612251 197376)
 (string-bytes 1 18927351)
 (vectors 16 139866)
 (vector-slots 8 3014610 102546)
 (floats 8 3855 1441)
 (intervals 56 439788 4203)
 (buffers 976 532))





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

* bug#25858: 25.1.91; js.el should use font-lock-doc-face
  2017-02-24  7:40 bug#25858: 25.1.91; js.el should use font-lock-doc-face Tom Tromey
@ 2017-02-24 10:58 ` Dmitry Gutov
  2017-02-25 17:28   ` Tom Tromey
  2017-02-25 21:04 ` bug#25858: done Tom Tromey
  1 sibling, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2017-02-24 10:58 UTC (permalink / raw)
  To: Tom Tromey, 25858

On 24.02.2017 09:40, Tom Tromey wrote:
> 
> I think js-mode should recognize "/**"-style jsdoc comments and fontify
> them using font-lock-doc-face.  Some other programming modes do this
> already.

Agreed. An implementation like Python's should work well, I think.





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

* bug#25858: 25.1.91; js.el should use font-lock-doc-face
  2017-02-24 10:58 ` Dmitry Gutov
@ 2017-02-25 17:28   ` Tom Tromey
  2017-02-25 19:54     ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2017-02-25 17:28 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Tom Tromey, 25858

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

>>>>> "Dmitry" == Dmitry Gutov <dgutov@yandex.ru> writes:

Dmitry> Agreed. An implementation like Python's should work well, I think.

How's this?

Tom


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 2483 bytes --]

commit d825891eaf1480fe82d4f5c51b2a921dda6e9cf7
Author: Tom Tromey <tom@tromey.com>
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

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

* bug#25858: 25.1.91; js.el should use font-lock-doc-face
  2017-02-25 17:28   ` Tom Tromey
@ 2017-02-25 19:54     ` Dmitry Gutov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Gutov @ 2017-02-25 19:54 UTC (permalink / raw)
  To: Tom Tromey; +Cc: 25858

On 25.02.2017 19:28, Tom Tromey wrote:

> How's this?

Good, thanks!






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

* bug#25858: done
  2017-02-24  7:40 bug#25858: 25.1.91; js.el should use font-lock-doc-face Tom Tromey
  2017-02-24 10:58 ` Dmitry Gutov
@ 2017-02-25 21:04 ` Tom Tromey
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2017-02-25 21:04 UTC (permalink / raw)
  To: 25858-done

Patch checked in.

Tom





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

end of thread, other threads:[~2017-02-25 21:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-24  7:40 bug#25858: 25.1.91; js.el should use font-lock-doc-face Tom Tromey
2017-02-24 10:58 ` Dmitry Gutov
2017-02-25 17:28   ` Tom Tromey
2017-02-25 19:54     ` Dmitry Gutov
2017-02-25 21:04 ` bug#25858: done Tom Tromey

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).