aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2018-03-27 16:01:30 -0400
committerStefan Monnier2018-03-27 16:01:30 -0400
commitb56c56f203f8b066dd71e6ae6a254121b3ac3f08 (patch)
treed632f48b3d5394d914fd5ee764848f68e30b8c3d
parentc13cd74322be25293e78412b8957fe639f560c54 (diff)
downloademacs-b56c56f203f8b066dd71e6ae6a254121b3ac3f08.tar.gz
emacs-b56c56f203f8b066dd71e6ae6a254121b3ac3f08.zip
(completion-at-point-functions): Improve doc
-rw-r--r--doc/lispref/minibuf.texi17
-rw-r--r--lisp/minibuffer.el7
2 files changed, 18 insertions, 6 deletions
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index 0ef81858ea9..b01ebb26b69 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -1877,10 +1877,10 @@ are used to compute a completion table for completing the text at
1877point. It can be used by major modes to provide mode-specific 1877point. It can be used by major modes to provide mode-specific
1878completion tables (@pxref{Major Mode Conventions}). 1878completion tables (@pxref{Major Mode Conventions}).
1879 1879
1880When the command @code{completion-at-point} runs, it calls the 1880When the command @code{completion-at-point} runs, it calls the functions in the
1881functions in the list one by one, without any argument. Each function 1881list one by one, without any argument. Each function should return @code{nil}
1882should return @code{nil} if it is unable to produce a completion table 1882unless it can and wants to take responsibility for the completion data for the
1883for the text at point. Otherwise it should return a list of the form 1883text at point. Otherwise it should return a list of the form
1884 1884
1885@example 1885@example
1886(@var{start} @var{end} @var{collection} . @var{props}) 1886(@var{start} @var{end} @var{collection} . @var{props})
@@ -1910,6 +1910,8 @@ next function in @code{completion-at-point-functions} instead of
1910reporting a completion failure. 1910reporting a completion failure.
1911@end table 1911@end table
1912 1912
1913The functions on this hook should generally return quickly, since they may be
1914called very often (e.g., from @code{post-command-hook}).
1913Supplying a function for @var{collection} is strongly recommended if 1915Supplying a function for @var{collection} is strongly recommended if
1914generating the list of completions is an expensive operation. Emacs 1916generating the list of completions is an expensive operation. Emacs
1915may internally call functions in @code{completion-at-point-functions} 1917may internally call functions in @code{completion-at-point-functions}
@@ -1932,11 +1934,16 @@ can defer generating completions until necessary. You can use
1932 (my-make-completions))))) 1934 (my-make-completions)))))
1933@end smallexample 1935@end smallexample
1934 1936
1937Additionally, the @var{collection} should generally not be pre-filtered based
1938on the current text between @var{start} and @var{end}, because that is the
1939responsibility of the caller of @code{completion-at-point-functions} to do that
1940according to the completion styles it decides to use.
1941
1935A function in @code{completion-at-point-functions} may also return a 1942A function in @code{completion-at-point-functions} may also return a
1936function instead of a list as described above. In that case, that 1943function instead of a list as described above. In that case, that
1937returned function is called, with no argument, and it is entirely 1944returned function is called, with no argument, and it is entirely
1938responsible for performing the completion. We discourage this usage; 1945responsible for performing the completion. We discourage this usage;
1939it is intended to help convert old code to using 1946it is only intended to help convert old code to using
1940@code{completion-at-point}. 1947@code{completion-at-point}.
1941 1948
1942The first function in @code{completion-at-point-functions} to return a 1949The first function in @code{completion-at-point-functions} to return a
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 3227917494e..6eded9c58fe 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2072,7 +2072,12 @@ Currently supported properties are all the properties that can appear in
2072 match the text at point, then instead of reporting a completion 2072 match the text at point, then instead of reporting a completion
2073 failure, the completion should try the next completion function. 2073 failure, the completion should try the next completion function.
2074As is the case with most hooks, the functions are responsible for 2074As is the case with most hooks, the functions are responsible for
2075preserving things like point and current buffer.") 2075preserving things like point and current buffer.
2076
2077NOTE: These functions should be cheap to run since they're sometimes run from
2078`post-command-hook' and they should ideally only choose which kind of
2079completion table to use and not pre-filter it based on the current text between
2080START and END (e.g. that would not obey `completion-styles').")
2076 2081
2077(defvar completion--capf-misbehave-funs nil 2082(defvar completion--capf-misbehave-funs nil
2078 "List of functions found on `completion-at-point-functions' that misbehave. 2083 "List of functions found on `completion-at-point-functions' that misbehave.