minad / consult

:mag: consult.el - Consulting completing-read
GNU General Public License v3.0
1.12k stars 98 forks source link

[feature request] preselect the item that is most close to current point in consult-imenu and consult-outline #963

Closed QiangF closed 2 months ago

QiangF commented 2 months ago

The use case is quick move to outline and imenu heading near point.

minad commented 2 months ago

See https://github.com/minad/consult/wiki#pre-select-nearest-heading-for-consult-org-heading-and-consult-outline-using-vertico.

QiangF commented 2 months ago

consult-imenu is missing in the snippet on the wiki link. Look like it is more difficult for consult-imenu. Can you provide an example for the suggested solution in https://github.com/minad/consult/issues/482

"to iterate over all the items and find the nearest item. You could then use this item as the :default for the completion."

https://github.com/minad/consult/issues/609 https://github.com/minad/consult/issues/462 https://github.com/minad/consult/issues/366

QiangF commented 2 months ago

There is an alternative function to get the imenu items

 (lispy--fetch-tags (list (buffer-file-name)))