From: Randy Taylor Date: Mon, 12 Dec 2022 01:50:54 +0000 (-0500) Subject: Improve dockerfile-ts-mode imenu generation (Bug#59979) X-Git-Tag: emacs-29.0.90~1212 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c0fe6c72cec477fdd2494bf3d26ab75790d2f720;p=emacs.git Improve dockerfile-ts-mode imenu generation (Bug#59979) * lisp/progmodes/dockerfile-ts-mode.el (treesit-node-child-by-field-name): Declare. (dockerfile-ts-mode--imenu-1): Use stage name if available. --- diff --git a/lisp/progmodes/dockerfile-ts-mode.el b/lisp/progmodes/dockerfile-ts-mode.el index 544e0f82d6d..40d90cc2dfc 100644 --- a/lisp/progmodes/dockerfile-ts-mode.el +++ b/lisp/progmodes/dockerfile-ts-mode.el @@ -33,6 +33,7 @@ (declare-function treesit-parser-create "treesit.c") (declare-function treesit-induce-sparse-tree "treesit.c") (declare-function treesit-node-child "treesit.c") +(declare-function treesit-node-child-by-field-name "treesit.c") (declare-function treesit-node-start "treesit.c") (declare-function treesit-node-type "treesit.c") @@ -117,8 +118,10 @@ the subtrees." children)) (name (when ts-node (pcase (treesit-node-type ts-node) - ("from_instruction" (treesit-node-text - (treesit-node-child ts-node 1) t))))) + ("from_instruction" + (treesit-node-text + (or (treesit-node-child-by-field-name ts-node "as") + (treesit-node-child ts-node 1)) t))))) (marker (when ts-node (set-marker (make-marker) (treesit-node-start ts-node)))))