diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/progmodes/js.el | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 1484b79739f..e84215d4301 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el | |||
| @@ -1771,6 +1771,24 @@ This performs fontification according to `js--class-styles'." | |||
| 1771 | ;; return NaN anyway. Shouldn't be a problem. | 1771 | ;; return NaN anyway. Shouldn't be a problem. |
| 1772 | (memq (char-before) '(?, ?} ?{)))))))) | 1772 | (memq (char-before) '(?, ?} ?{)))))))) |
| 1773 | 1773 | ||
| 1774 | (defun js--find-newline-backward () | ||
| 1775 | "Move backward to the nearest newline that is not in a block comment." | ||
| 1776 | (let ((continue t) | ||
| 1777 | (result t)) | ||
| 1778 | (while continue | ||
| 1779 | (setq continue nil) | ||
| 1780 | (if (search-backward "\n" nil t) | ||
| 1781 | (let ((parse (syntax-ppss))) | ||
| 1782 | ;; We match the end of a // comment but not a newline in a | ||
| 1783 | ;; block comment. | ||
| 1784 | (when (nth 4 parse) | ||
| 1785 | (goto-char (nth 8 parse)) | ||
| 1786 | ;; If we saw a block comment, keep trying. | ||
| 1787 | (unless (nth 7 parse) | ||
| 1788 | (setq continue t)))) | ||
| 1789 | (setq result nil))) | ||
| 1790 | result)) | ||
| 1791 | |||
| 1774 | (defun js--continued-expression-p () | 1792 | (defun js--continued-expression-p () |
| 1775 | "Return non-nil if the current line continues an expression." | 1793 | "Return non-nil if the current line continues an expression." |
| 1776 | (save-excursion | 1794 | (save-excursion |
| @@ -1780,7 +1798,7 @@ This performs fontification according to `js--class-styles'." | |||
| 1780 | (progn | 1798 | (progn |
| 1781 | (forward-comment (- (point))) | 1799 | (forward-comment (- (point))) |
| 1782 | (not (memq (char-before) '(?, ?\[ ?\())))) | 1800 | (not (memq (char-before) '(?, ?\[ ?\())))) |
| 1783 | (and (js--re-search-backward "\n" nil t) | 1801 | (and (js--find-newline-backward) |
| 1784 | (progn | 1802 | (progn |
| 1785 | (skip-chars-backward " \t") | 1803 | (skip-chars-backward " \t") |
| 1786 | (or (bobp) (backward-char)) | 1804 | (or (bobp) (backward-char)) |