Subject: bug#38614: 26.3; Info completions in reverse order

From: Howard Melman <[email-masked]>
Date: Fri, 3 Jan 2020 14:27:03 -0500

I wrote on Sat, 14 Dec 2019:

> When using ivy mode, Info-index shows me the list of
> completions in reverse alphabetical order. Info-menu does too.
> Both Info-index and Info-menu use completing-read with
> Info-complete-menu-item as the collections argument. It
> seems to generate the list in reverse order.
> 
> Sorry this isn't a formatted patch, but a one line fix solves it for me.
> 
> If after this line in Info-complete-menu-item:
> 		    (setq completions (delete-dups completions))
> I add this line:
> 		    (setq completions (nreverse completions))
> the index and menus are shown in alphabetical order.

My original fix was in the wrong place. It only worked for info files that had a single index node (e.g., elisp.info). To work more generally with files with several index nodes (e.g., emacs.info) the new line should be just before the cache is updated:

              (setq completions (nreverse completions))  ; added fix
              ;; Update the cache.
              (setq Info-complete-cache
		    (list Info-current-file Info-current-node
			  Info-complete-next-re string completions
			  Info-complete-nodes)))
		
I still hope this is considered. The cost of the nreverse here is small, and if completion mechanisms sort the list later, they'll find an already sorted list will sort faster than the degenerate case of sorting a list already in reverse order.

Howard