线索是两个命令
FrontEndTokenExecute[nb, "ExpandSelection"]
FrontEndTokenExecute[nb, "SelectionOpenAllGroups"]
但是,在这两个命令之后,必须再次重新应用我最初的帖子中提到的方法。
Sample Select Last Celle Programatically.nb
nb = EvaluationNotebook[];
SelectionMove[nb, All, Notebook] (* \
this one selects all cells in this notebook *)
SelectionMove[nb, After, Cell] \
(* this one moves the insertion point below everything *)
SelectionMove[nb, Previous, Cell,
AutoScroll ->
True] (* if the last cell is part of a closed group, the selection stays \
invisible *)
FrontEndTokenExecute[nb, "ExpandSelection"] (* this one \
selects the group enclosing the last cell *)
FrontEndTokenExecute[nb, "SelectionOpenAllGroups"] (* this one opens it *)
\
SelectionMove[nb, After, Cell] \
(* like command 4 steps above, this one moves the insertion point below \
everything *)
SelectionMove[nb, Previous, Cell,
AutoScroll ->
True] (* now it is no longer part of a closed group, therefore it becomes \
visible *)
10 outmost group: Several groups are stacked one ontop the next. All cells groups are closed individually. This is a test case for the program above.
9 intermediate group
8 intermediate group
7 intermediate group
6 intermediate group
5 intermediate group
4 intermediate group
3 intermediate group
2 intermediate group
1 innermost group
f /@ Range[3]
{f[1], f[2], f[3]}
(我把这一切都放在笔记本上,但我找不到上传它的方法......将所有这些复制到笔记本后,将所有内容设置为手动分组,然后将最后一个单元格逐个嵌套在上面的下一行然后关闭所有子组。)
随附的笔记本显示了它是如何完成的,它还包含一个测试示例,该示例在选择的最后一个单元格组的深度嵌套。但是,仍然缺少证明这始终有效且永不失败的证据,因为我既没有 ExpandSelection 也没有 SelectionOpenAllGroups 的“公理”描述。
我希望帮助系统中有更多“另见”链接,尤其是关于前端相关功能的链接。