Skip to content

Commit

Permalink
minor fixes, add consult-completion-in-region to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
minad committed Dec 6, 2020
1 parent 114210e commit a00aa13
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,15 @@ information (e.g. `M-x`, `describe-face`, `describe-symbol`, `helpful-function`,
and recursive editing of the preview.
* `consult-outline`: Jump to a heading of the outline. Supports live preview
and recursive editing of the preview.
* `consult-multi-occur`: Replacement for `multi-occur`.

### Miscellaneous

* `consult-multi-occur`: Replacement for `multi-occur` which uses `completing-read-multiple`.
* `consult-completion-in-region`: Function which can be used as `completion-in-region-function`.
This way, the minibuffer completion UI will be used for `completion-at-point`.
This function is particularily useful in combination with Icomplete-vertical,
since Icomplete does not provide its own `completion-in-region-function`.
In contrast, Selectrum already comes with its own function.
* `consult-minor-mode`: Enable/disable minor mode.
* `consult-theme`: Select a theme and disable all currently enabled themes.
Supports live preview of the theme while scrolling through the candidates.
Expand Down
6 changes: 5 additions & 1 deletion consult.el
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ BODY are the body expressions."
`(if ,enabled
(let ((,(car args))
(,@(cdr args) ,save))
(ignore ,@args) ;; Disable unused variable warnings
(push (lambda (,(car args)) ,preview) consult--preview-stack)
(unwind-protect
(setq ,(car args) ,(if (cdr body) `(progn ,@body) (car body)))
Expand Down Expand Up @@ -594,7 +595,10 @@ This command obeys narrowing. Optionally INITIAL input can be provided."
;; Use minibuffer completion as the UI for completion-at-point
(defun consult-completion-in-region (start end collection &optional predicate)
"Prompt for completion of region in the minibuffer if non-unique.
Use as a value for `completion-in-region-function'."
The function is called with 4 arguments: START END COLLECTION PREDICATE.
The arguments and expected return value are as specified for
`completion-in-region'. Use as a value for `completion-in-region-function'."
(let* ((initial (buffer-substring-no-properties start end))
(limit (car (completion-boundaries initial collection predicate "")))
(metadata (completion-metadata initial collection predicate))
Expand Down

0 comments on commit a00aa13

Please sign in to comment.