completion.d.elv 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #elvdoc:var completion:arg-completer
  2. #
  3. # A map containing argument completers.
  4. #elvdoc:var completion:binding
  5. #
  6. # Keybinding for the completion mode.
  7. #elvdoc:var completion:matcher
  8. #
  9. # A map mapping from context names to matcher functions. See the
  10. # [Matcher](#matcher) section.
  11. #elvdoc:fn complete-filename
  12. #
  13. # ```elvish
  14. # edit:complete-filename $args...
  15. # ```
  16. #
  17. # Produces a list of filenames found in the directory of the last argument. All
  18. # other arguments are ignored. If the last argument does not contain a path
  19. # (either absolute or relative to the current directory), then the current
  20. # directory is used. Relevant files are output as `edit:complex-candidate`
  21. # objects.
  22. #
  23. # This function is the default handler for any commands without
  24. # explicit handlers in `$edit:completion:arg-completer`. See [Argument
  25. # Completer](#argument-completer).
  26. #
  27. # Example:
  28. #
  29. # ```elvish-transcript
  30. # ~> edit:complete-filename ''
  31. # ▶ (edit:complex-candidate Applications &code-suffix=/ &style='01;34')
  32. # ▶ (edit:complex-candidate Books &code-suffix=/ &style='01;34')
  33. # ▶ (edit:complex-candidate Desktop &code-suffix=/ &style='01;34')
  34. # ▶ (edit:complex-candidate Docsafe &code-suffix=/ &style='01;34')
  35. # ▶ (edit:complex-candidate Documents &code-suffix=/ &style='01;34')
  36. # ...
  37. # ~> edit:complete-filename .elvish/
  38. # ▶ (edit:complex-candidate .elvish/aliases &code-suffix=/ &style='01;34')
  39. # ▶ (edit:complex-candidate .elvish/db &code-suffix=' ' &style='')
  40. # ▶ (edit:complex-candidate .elvish/epm-installed &code-suffix=' ' &style='')
  41. # ▶ (edit:complex-candidate .elvish/lib &code-suffix=/ &style='01;34')
  42. # ▶ (edit:complex-candidate .elvish/rc.elv &code-suffix=' ' &style='')
  43. # ```
  44. #elvdoc:fn complex-candidate
  45. #
  46. # ```elvish
  47. # edit:complex-candidate $stem &display='' &code-suffix=''
  48. # ```
  49. #
  50. # Builds a complex candidate. This is mainly useful in [argument
  51. # completers](#argument-completer).
  52. #
  53. # The `&display` option controls how the candidate is shown in the UI. It can
  54. # be a string or a [styled](builtin.html#styled) text. If it is empty, `$stem`
  55. # is used.
  56. #
  57. # The `&code-suffix` option affects how the candidate is inserted into the code
  58. # when it is accepted. By default, a quoted version of `$stem` is inserted. If
  59. # `$code-suffix` is non-empty, it is added to that text, and the suffix is not
  60. # quoted.
  61. #elvdoc:fn match-prefix
  62. #
  63. # ```elvish
  64. # edit:match-prefix $seed $inputs?
  65. # ```
  66. #
  67. # For each input, outputs whether the input has $seed as a prefix. Uses the
  68. # result of `to-string` for non-string inputs.
  69. #
  70. # Roughly equivalent to the following Elvish function, but more efficient:
  71. #
  72. # ```elvish
  73. # use str
  74. # fn match-prefix {|seed @input|
  75. # each {|x| str:has-prefix (to-string $x) $seed } $@input
  76. # }
  77. # ```
  78. #elvdoc:fn match-subseq
  79. #
  80. # ```elvish
  81. # edit:match-subseq $seed $inputs?
  82. # ```
  83. #
  84. # For each input, outputs whether the input has $seed as a
  85. # [subsequence](https://en.wikipedia.org/wiki/Subsequence). Uses the result of
  86. # `to-string` for non-string inputs.
  87. #elvdoc:fn match-substr
  88. #
  89. # ```elvish
  90. # edit:match-substr $seed $inputs?
  91. # ```
  92. #
  93. # For each input, outputs whether the input has $seed as a substring. Uses the
  94. # result of `to-string` for non-string inputs.
  95. #
  96. # Roughly equivalent to the following Elvish function, but more efficient:
  97. #
  98. # ```elvish
  99. # use str
  100. # fn match-substr {|seed @input|
  101. # each {|x| str:has-contains (to-string $x) $seed } $@input
  102. # }
  103. # ```
  104. #elvdoc:fn completion:start
  105. #
  106. # ```elvish
  107. # edit:completion:start
  108. # ```
  109. #
  110. # Start the completion mode.
  111. #elvdoc:fn completion:smart-start
  112. #
  113. # ```elvish
  114. # edit:completion:smart-start
  115. # ```
  116. #
  117. # Starts the completion mode. However, if all the candidates share a non-empty
  118. # prefix and that prefix starts with the seed, inserts the prefix instead.
  119. #elvdoc:fn completion:close
  120. #
  121. # ```elvish
  122. # edit:completion:close
  123. # ```
  124. #
  125. # Closes the completion mode UI.