aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2018-03-27 16:01:30 -0400
committerEli Zaretskii2018-04-01 12:21:29 +0300
commit748f0fdd5a682d3bea79e3d30782686eae6d24df (patch)
treedb57fdb4b599658c132e47ac30fcffcac35ba862
parentaf1624f29bc264fe0cff31c46b25b0b0c90e24bf (diff)
downloademacs-748f0fdd5a682d3bea79e3d30782686eae6d24df.tar.gz
emacs-748f0fdd5a682d3bea79e3d30782686eae6d24df.zip
(completion-at-point-functions): Improve doc
(cherry picked from commit b56c56f203f8b066dd71e6ae6a254121b3ac3f08)
-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 7302fff4584..ced0ce64b50 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2076,7 +2076,12 @@ Currently supported properties are all the properties that can appear in
2076 match the text at point, then instead of reporting a completion 2076 match the text at point, then instead of reporting a completion
2077 failure, the completion should try the next completion function. 2077 failure, the completion should try the next completion function.
2078As is the case with most hooks, the functions are responsible for 2078As is the case with most hooks, the functions are responsible for
2079preserving things like point and current buffer.") 2079preserving things like point and current buffer.
2080
2081NOTE: These functions should be cheap to run since they're sometimes run from
2082`post-command-hook' and they should ideally only choose which kind of
2083completion table to use and not pre-filter it based on the current text between
2084START and END (e.g. that would not obey `completion-styles').")
2080 2085
2081(defvar completion--capf-misbehave-funs nil 2086(defvar completion--capf-misbehave-funs nil
2082 "List of functions found on `completion-at-point-functions' that misbehave. 2087 "List of functions found on `completion-at-point-functions' that misbehave.