diff options
| author | Stefan Monnier | 2018-03-27 16:01:30 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2018-03-27 16:01:30 -0400 |
| commit | b56c56f203f8b066dd71e6ae6a254121b3ac3f08 (patch) | |
| tree | d632f48b3d5394d914fd5ee764848f68e30b8c3d | |
| parent | c13cd74322be25293e78412b8957fe639f560c54 (diff) | |
| download | emacs-b56c56f203f8b066dd71e6ae6a254121b3ac3f08.tar.gz emacs-b56c56f203f8b066dd71e6ae6a254121b3ac3f08.zip | |
(completion-at-point-functions): Improve doc
| -rw-r--r-- | doc/lispref/minibuf.texi | 17 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 7 |
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 | |||
| 1877 | point. It can be used by major modes to provide mode-specific | 1877 | point. It can be used by major modes to provide mode-specific |
| 1878 | completion tables (@pxref{Major Mode Conventions}). | 1878 | completion tables (@pxref{Major Mode Conventions}). |
| 1879 | 1879 | ||
| 1880 | When the command @code{completion-at-point} runs, it calls the | 1880 | When the command @code{completion-at-point} runs, it calls the functions in the |
| 1881 | functions in the list one by one, without any argument. Each function | 1881 | list one by one, without any argument. Each function should return @code{nil} |
| 1882 | should return @code{nil} if it is unable to produce a completion table | 1882 | unless it can and wants to take responsibility for the completion data for the |
| 1883 | for the text at point. Otherwise it should return a list of the form | 1883 | text 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 | |||
| 1910 | reporting a completion failure. | 1910 | reporting a completion failure. |
| 1911 | @end table | 1911 | @end table |
| 1912 | 1912 | ||
| 1913 | The functions on this hook should generally return quickly, since they may be | ||
| 1914 | called very often (e.g., from @code{post-command-hook}). | ||
| 1913 | Supplying a function for @var{collection} is strongly recommended if | 1915 | Supplying a function for @var{collection} is strongly recommended if |
| 1914 | generating the list of completions is an expensive operation. Emacs | 1916 | generating the list of completions is an expensive operation. Emacs |
| 1915 | may internally call functions in @code{completion-at-point-functions} | 1917 | may 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 | ||
| 1937 | Additionally, the @var{collection} should generally not be pre-filtered based | ||
| 1938 | on the current text between @var{start} and @var{end}, because that is the | ||
| 1939 | responsibility of the caller of @code{completion-at-point-functions} to do that | ||
| 1940 | according to the completion styles it decides to use. | ||
| 1941 | |||
| 1935 | A function in @code{completion-at-point-functions} may also return a | 1942 | A function in @code{completion-at-point-functions} may also return a |
| 1936 | function instead of a list as described above. In that case, that | 1943 | function instead of a list as described above. In that case, that |
| 1937 | returned function is called, with no argument, and it is entirely | 1944 | returned function is called, with no argument, and it is entirely |
| 1938 | responsible for performing the completion. We discourage this usage; | 1945 | responsible for performing the completion. We discourage this usage; |
| 1939 | it is intended to help convert old code to using | 1946 | it is only intended to help convert old code to using |
| 1940 | @code{completion-at-point}. | 1947 | @code{completion-at-point}. |
| 1941 | 1948 | ||
| 1942 | The first function in @code{completion-at-point-functions} to return a | 1949 | The 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. |
| 2074 | As is the case with most hooks, the functions are responsible for | 2074 | As is the case with most hooks, the functions are responsible for |
| 2075 | preserving things like point and current buffer.") | 2075 | preserving things like point and current buffer. |
| 2076 | |||
| 2077 | NOTE: 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 | ||
| 2079 | completion table to use and not pre-filter it based on the current text between | ||
| 2080 | START 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. |