aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJackson Ray Hamilton2019-04-08 22:27:41 -0700
committerJackson Ray Hamilton2019-04-08 22:48:25 -0700
commit7c3ffdaf4b17e9f93aa929fc9a5c154e8e68e5fb (patch)
treef9491f2a3301242c9eafd7a926ab2cff15855d1d
parent9545519572d47b4712f27e53e7b64bf88d473877 (diff)
downloademacs-7c3ffdaf4b17e9f93aa929fc9a5c154e8e68e5fb.tar.gz
emacs-7c3ffdaf4b17e9f93aa929fc9a5c154e8e68e5fb.zip
Move curly functions closer to where they’re used
* lisp/progmodes/js.el (js-jsx--enclosing-curly-pos) (js-jsx--goto-outermost-enclosing-curly): As the code evolved, these functions’ definitions ended up being far away from the only places where they were used. Move them there.
-rw-r--r--lisp/progmodes/js.el40
1 files changed, 20 insertions, 20 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 1cec41d9270..a1f5e694ede 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1956,26 +1956,6 @@ the match. Return nil if a match can’t be found."
1956 (setq tag-stack (1+ tag-stack)))) 1956 (setq tag-stack (1+ tag-stack))))
1957 (setq last-pos (point))))))) 1957 (setq last-pos (point)))))))
1958 1958
1959(defun js-jsx--enclosing-curly-pos ()
1960 "Return position of enclosing “{” in a “{/}” pair about point."
1961 (let ((parens (reverse (nth 9 (syntax-ppss)))) paren-pos curly-pos)
1962 (while
1963 (and
1964 (setq paren-pos (car parens))
1965 (not (when (= (char-after paren-pos) ?{)
1966 (setq curly-pos paren-pos)))
1967 (setq parens (cdr parens))))
1968 curly-pos))
1969
1970(defun js-jsx--goto-outermost-enclosing-curly (limit)
1971 "Set point to enclosing “{” at or closest after LIMIT."
1972 (let (pos)
1973 (while
1974 (and
1975 (setq pos (js-jsx--enclosing-curly-pos))
1976 (if (>= pos limit) (goto-char pos))
1977 (> pos limit)))))
1978
1979(defun js-jsx--enclosing-tag-pos () 1959(defun js-jsx--enclosing-tag-pos ()
1980 "Return beginning and end of a JSXElement about point. 1960 "Return beginning and end of a JSXElement about point.
1981Look backward for a JSXElement that both starts before point and 1961Look backward for a JSXElement that both starts before point and
@@ -2646,6 +2626,26 @@ The column calculation is based off of `sgml-calculate-indent'."
2646 2626
2647 )) 2627 ))
2648 2628
2629(defun js-jsx--enclosing-curly-pos ()
2630 "Return position of enclosing “{” in a “{/}” pair about point."
2631 (let ((parens (reverse (nth 9 (syntax-ppss)))) paren-pos curly-pos)
2632 (while
2633 (and
2634 (setq paren-pos (car parens))
2635 (not (when (= (char-after paren-pos) ?{)
2636 (setq curly-pos paren-pos)))
2637 (setq parens (cdr parens))))
2638 curly-pos))
2639
2640(defun js-jsx--goto-outermost-enclosing-curly (limit)
2641 "Set point to enclosing “{” at or closest after LIMIT."
2642 (let (pos)
2643 (while
2644 (and
2645 (setq pos (js-jsx--enclosing-curly-pos))
2646 (if (>= pos limit) (goto-char pos))
2647 (> pos limit)))))
2648
2649(defun js-jsx--expr-attribute-pos (start limit) 2649(defun js-jsx--expr-attribute-pos (start limit)
2650 "Look back from START to LIMIT for a JSXAttribute." 2650 "Look back from START to LIMIT for a JSXAttribute."
2651 (save-excursion 2651 (save-excursion