Valery Ushakov <u...@stderr.spb.ru> writes:
> On Tue, Oct 08, 2024 at 12:58:18 +1100, Van Ly wrote: > >> The way NetBSD does >> >> "man -k output" >> >> is different enough to cause hiccups on Emacs autocompletes. This is >> being looked at by the emacs-devs. > > Arrange for APROPOS="-l" in the environment. Cf. apropos(1) > Thanks uwe and Martin, $ env APROPOS="-l" emacs -Q and the icomplete-vertical autocomplete behaves as expected. The Edebug was landing on line 16 below after each character was entered for chdir. 1 (defun Man-parse-man-k () 2 "Parse \"man -k\" output and return the list of page names. 3 4 The current buffer should contain the output of a command of the 5 form \"man -k keyword\", which is traditionally also available with 6 apropos(1). 7 8 While POSIX man(1p) is a bit vague about what to expect here, 9 this function tries to parse some commonly used formats, which 10 can be described in the following informal way, with square brackets 11 indicating optional parts and whitespace being interpreted 12 somewhat loosely. 13 14 foo[, bar [, ...]] [other stuff] (sec) - description 15 foo(sec)[, bar(sec) [, ...]] [other stuff] - description" 16 (goto-char (point-min)) 17 ;; See man-tests for data about which systems use which format (hopefully we 18 ;; will be able to simplify the code if/when some of those formats aren't 19 ;; used any more). 20 (let (table) 21 (while (search-forward-regexp "^\\([^ \t,\n]+\\)\\(.*?\\)\ 22 \\(?:[ \t]\\(([^ \t,\n]+?)\\)\\)?\\(?:[ \t]+- ?\\(.*\\)\\)?$" nil t) 23 (let ((section (match-string 3)) 24 (description (match-string 4)) 25 (bound (match-end 2))) 26 (goto-char (match-end 1)) 27 (while 28 (progn 29 ;; The first regexp grouping may already match the section 30 ;; tacked on to the name, which is ok since for the formats we 31 ;; claim to support the third (non-shy) grouping does not 32 ;; match in this case, i.e., section is nil. 33 (push (propertize (concat (match-string 1) section) 34 'help-echo description) 35 table) 36 (search-forward-regexp "\\=, *\\([^ \t,]+\\)" bound t))))) 37 (nreverse table))) -- vl