Skip to content

Commit

Permalink
Port of patch to filter JS comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
balajis committed Jul 2, 2013
1 parent 55a9c7c commit d5077c0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion .emacs.d/js-comint.el
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ is run).
;;;###autoload
(defun remove-newlines (mystr) (replace-regexp-in-string "\n" " " mystr))

;;;###autoload
(defun starts-with-js-comment (line)
(equal 0 (string-match "^[[:space:]]*//" line)))

;;;###autoload
(defun remove-js-comments (mystr)
"Remove lines starting with // and return as single line of JS code.
See: http://www.emacswiki.org/emacs/ElispCookbook
"
(mapconcat 'identity
(remove-if 'starts-with-js-comment
(split-string mystr "\n"))
" "
))

;;;###autoload
(defun js-send-region (start end)
"Send the current region to the inferior Javascript process."
Expand All @@ -146,7 +161,7 @@ is run).
(run-js inferior-js-program-command t)

(setq curwindow (selected-window))
(save-excursion (let ((jscode (remove-newlines (buffer-substring start end))))
(save-excursion (let ((jscode (remove-js-comments (buffer-substring start end))))
(set-buffer "*js*")
(insert jscode)
(comint-send-input)
Expand Down

0 comments on commit d5077c0

Please sign in to comment.