From 7c3ffdaf4b17e9f93aa929fc9a5c154e8e68e5fb Mon Sep 17 00:00:00 2001 From: Jackson Ray Hamilton Date: Mon, 8 Apr 2019 22:27:41 -0700 Subject: [PATCH] =?utf8?q?Move=20curly=20functions=20closer=20to=20where?= =?utf8?q?=20they=E2=80=99re=20used?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 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. --- lisp/progmodes/js.el | 40 ++++++++++++++++++++-------------------- 1 file 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." (setq tag-stack (1+ tag-stack)))) (setq last-pos (point))))))) -(defun js-jsx--enclosing-curly-pos () - "Return position of enclosing “{” in a “{/}” pair about point." - (let ((parens (reverse (nth 9 (syntax-ppss)))) paren-pos curly-pos) - (while - (and - (setq paren-pos (car parens)) - (not (when (= (char-after paren-pos) ?{) - (setq curly-pos paren-pos))) - (setq parens (cdr parens)))) - curly-pos)) - -(defun js-jsx--goto-outermost-enclosing-curly (limit) - "Set point to enclosing “{” at or closest after LIMIT." - (let (pos) - (while - (and - (setq pos (js-jsx--enclosing-curly-pos)) - (if (>= pos limit) (goto-char pos)) - (> pos limit))))) - (defun js-jsx--enclosing-tag-pos () "Return beginning and end of a JSXElement about point. Look backward for a JSXElement that both starts before point and @@ -2646,6 +2626,26 @@ The column calculation is based off of `sgml-calculate-indent'." )) +(defun js-jsx--enclosing-curly-pos () + "Return position of enclosing “{” in a “{/}” pair about point." + (let ((parens (reverse (nth 9 (syntax-ppss)))) paren-pos curly-pos) + (while + (and + (setq paren-pos (car parens)) + (not (when (= (char-after paren-pos) ?{) + (setq curly-pos paren-pos))) + (setq parens (cdr parens)))) + curly-pos)) + +(defun js-jsx--goto-outermost-enclosing-curly (limit) + "Set point to enclosing “{” at or closest after LIMIT." + (let (pos) + (while + (and + (setq pos (js-jsx--enclosing-curly-pos)) + (if (>= pos limit) (goto-char pos)) + (> pos limit))))) + (defun js-jsx--expr-attribute-pos (start limit) "Look back from START to LIMIT for a JSXAttribute." (save-excursion -- 2.39.2