2023-11-02 16:58:31 +01:00
|
|
|
;;; completion-preview.el --- Preview completion with inline overlay -*- lexical-binding: t; -*-
|
|
|
|
|
2025-01-01 07:39:17 +00:00
|
|
|
;; Copyright (C) 2023-2025 Free Software Foundation, Inc.
|
2023-11-02 16:58:31 +01:00
|
|
|
|
|
|
|
;; Author: Eshel Yaron <me@eshelyaron.com>
|
|
|
|
;; Maintainer: Eshel Yaron <me@eshelyaron.com>
|
|
|
|
;; Keywords: abbrev convenience
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; This library provides the Completion Preview mode. This minor mode
|
2023-11-20 12:45:11 +01:00
|
|
|
;; displays a completion suggestion for the symbol at point in an
|
2023-11-02 16:58:31 +01:00
|
|
|
;; overlay after point. Check out the customization group
|
|
|
|
;; `completion-preview' for user options that you may want to tweak.
|
|
|
|
;;
|
2023-11-20 12:45:11 +01:00
|
|
|
;; To enable Completion Preview mode, use `completion-preview-mode'.
|
2023-11-02 16:58:31 +01:00
|
|
|
;; To accept the completion suggestion, press TAB. If you want to
|
|
|
|
;; ignore a completion suggestion, just go on editing or moving around
|
|
|
|
;; the buffer. Completion Preview mode continues to update the
|
|
|
|
;; suggestion as you type according to the text around point.
|
|
|
|
;;
|
2025-02-26 21:14:37 +01:00
|
|
|
;; Completion Preview mode uses `completion-at-point-functions' to find
|
|
|
|
;; relevant completion suggestions, similarly to `completion-at-point'.
|
|
|
|
;; You can use `completion-at-point' with your favorite in-buffer
|
|
|
|
;; completion interface together with Completion Preview mode, just
|
|
|
|
;; invoke `completion-at-point' as usual when you want to see all
|
|
|
|
;; currently available completions. Another reason to invoke
|
|
|
|
;; `completion-at-point' is when you want non-prefix completion, since
|
|
|
|
;; Completion Preview mode only shows one prefix completion.
|
|
|
|
;;
|
2023-11-02 16:58:31 +01:00
|
|
|
;; The commands `completion-preview-next-candidate' and
|
|
|
|
;; `completion-preview-prev-candidate' allow you to cycle the
|
|
|
|
;; completion candidate that the preview suggests. These commands
|
|
|
|
;; don't have a default keybinding, but you can bind them, for
|
|
|
|
;; example, to M-n and M-p in `completion-preview-active-mode-map' to
|
|
|
|
;; have them handy whenever the preview is visible.
|
|
|
|
;;
|
2024-04-12 22:41:10 +02:00
|
|
|
;; When the completion candidate that the preview is showing shares a
|
|
|
|
;; common prefix with all other candidates, Completion Preview mode
|
|
|
|
;; underlines that common prefix. If you want to insert the common
|
|
|
|
;; prefix but with a different suffix than the one the preview is
|
|
|
|
;; showing, use the command `completion-preview-complete'. This command
|
|
|
|
;; inserts just the common prefix and lets you go on typing as usual.
|
|
|
|
;; If you invoke `completion-preview-complete' when there is no common
|
|
|
|
;; prefix (so nothing is underlined in the preview), it displays a list
|
|
|
|
;; of all matching completion candidates.
|
|
|
|
;;
|
2024-06-24 08:53:23 -07:00
|
|
|
;; You can also insert only the first word of the completion candidate
|
|
|
|
;; with the command `completion-preview-insert-word'. With a numeric
|
|
|
|
;; prefix argument, it inserts that many words instead of just the one.
|
|
|
|
;; This command is not bound by default, but you may want to bind it to
|
|
|
|
;; M-f (or remap `forward-word') in `completion-preview-active-mode-map'
|
|
|
|
;; since it's very much like a `forward-word' that also moves "into" the
|
2024-06-26 11:06:52 +02:00
|
|
|
;; completion preview. To define your own command that inserts part of
|
|
|
|
;; a completion candidate by moving "into" the completion preview, use
|
|
|
|
;; the function `completion-preview-partial-insert'. For example, you
|
|
|
|
;; can define a command that completes exactly one symbol as follows:
|
|
|
|
;;
|
|
|
|
;; (defun my-completion-preview-insert-symbol ()
|
|
|
|
;; (interactive)
|
|
|
|
;; (completion-preview-partial-insert #'forward-symbol 1))
|
|
|
|
;;
|
|
|
|
;; Similarly to `completion-preview-insert-word', the command
|
|
|
|
;; `completion-preview-insert-sexp' lets you complete by one or more
|
|
|
|
;; balanced expressions. The definition of this command is very similar
|
|
|
|
;; to the simple example above, expect it uses `forward-sexp' rather
|
|
|
|
;; than `forward-symbol'. This command can be useful when you're using
|
|
|
|
;; Completion Preview mode with long, complex completion candidates,
|
|
|
|
;; such as entire shell commands from the shell history.
|
2024-06-24 08:53:23 -07:00
|
|
|
;;
|
2023-11-02 16:58:31 +01:00
|
|
|
;; If you set the user option `completion-preview-exact-match-only' to
|
|
|
|
;; non-nil, Completion Preview mode only suggests a completion
|
|
|
|
;; candidate when its the only possible completion for the (partial)
|
|
|
|
;; symbol at point. The user option `completion-preview-commands'
|
|
|
|
;; says which commands should trigger the completion preview. The
|
|
|
|
;; user option `completion-preview-minimum-symbol-length' specifies a
|
|
|
|
;; minimum number of consecutive characters with word or symbol syntax
|
|
|
|
;; that should appear around point for Emacs to suggest a completion.
|
|
|
|
;; By default, this option is set to 3, so Emacs suggests a completion
|
|
|
|
;; if you type "foo", but typing just "fo" doesn't show the preview.
|
2024-06-05 10:23:56 +02:00
|
|
|
;; If you want the preview to appear also after non-symbol characters,
|
|
|
|
;; such as punctuation, set `completion-preview-minimum-symbol-length'
|
|
|
|
;; to nil. If you do so, you may want to customize the user option
|
|
|
|
;; `completion-preview-idle-delay' to have the preview appear only
|
|
|
|
;; when you pause typing for a short duration rather than after every
|
|
|
|
;; key. Try setting it to 0.2 seconds and see how that works for you.
|
2024-09-04 18:21:13 +02:00
|
|
|
;;
|
2025-01-09 12:22:03 +01:00
|
|
|
;; By default, Completion Preview mode automatically adapts the
|
|
|
|
;; background color of the preview overlay to match the background color
|
|
|
|
;; of the buffer text it's completing. If you prefer a distinct
|
|
|
|
;; background color for the preview, disable this feature by customizing
|
|
|
|
;; `completion-preview-adapt-background-color' to nil.
|
|
|
|
;;
|
2024-09-04 18:21:13 +02:00
|
|
|
;; Sometimes you may want to use Completion Preview mode alongside other
|
|
|
|
;; Emacs features that place an overlay after point, in a way that could
|
|
|
|
;; "compete" with the preview overlay. In such cases, you should give
|
|
|
|
;; the completion preview overlay a higher priority, so it properly
|
|
|
|
;; appears immediately after point, before other overlays. To do that,
|
|
|
|
;; set the variable `completion-preview-overlay-priority'. You can set
|
|
|
|
;; it buffer-locally if you only use competing overlays in some buffers.
|
|
|
|
;; In particular, an important use case for this variable is enabling
|
|
|
|
;; Completion Preview mode for `M-:' and other minibuffers that support
|
|
|
|
;; `completion-at-point'. In the minibuffer, some message are displayed
|
|
|
|
;; using an overlay that may, by default, conflict with the completion
|
|
|
|
;; preview overlay. Use `completion-preview-overlay-priority' to
|
|
|
|
;; resolve this conflict by giving the completion preview overlay a
|
|
|
|
;; higher priority:
|
|
|
|
;;
|
|
|
|
;; (add-hook 'eval-expression-minibuffer-setup-hook
|
|
|
|
;; (lambda ()
|
|
|
|
;; (setq-local completion-preview-overlay-priority 1200)
|
|
|
|
;; (completion-preview-mode)))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(defgroup completion-preview nil
|
|
|
|
"In-buffer completion preview."
|
|
|
|
:group 'completion)
|
|
|
|
|
|
|
|
(defcustom completion-preview-exact-match-only nil
|
|
|
|
"Whether to show completion preview only when there is an exact match.
|
|
|
|
|
|
|
|
If this option is non-nil, Completion Preview mode only shows the
|
|
|
|
preview when there is exactly one completion candidate that
|
|
|
|
matches the symbol at point. Otherwise, if this option is nil,
|
|
|
|
when there are multiple matching candidates the preview shows the
|
|
|
|
first candidate, and you can cycle between the candidates with
|
|
|
|
\\[completion-preview-next-candidate] and
|
|
|
|
\\[completion-preview-prev-candidate]."
|
|
|
|
:type 'boolean
|
|
|
|
:version "30.1")
|
|
|
|
|
|
|
|
(defcustom completion-preview-commands '(self-insert-command
|
|
|
|
insert-char
|
|
|
|
delete-backward-char
|
2023-11-16 11:29:58 +08:00
|
|
|
backward-delete-char-untabify
|
2024-04-12 22:41:10 +02:00
|
|
|
analyze-text-conversion
|
2024-06-24 08:53:23 -07:00
|
|
|
completion-preview-complete
|
|
|
|
completion-preview-insert-word
|
|
|
|
completion-preview-insert-sexp)
|
2023-11-02 16:58:31 +01:00
|
|
|
"List of commands that should trigger completion preview."
|
|
|
|
:type '(repeat (function :tag "Command" :value self-insert-command))
|
|
|
|
:version "30.1")
|
|
|
|
|
|
|
|
(defcustom completion-preview-minimum-symbol-length 3
|
2024-06-05 10:03:06 +02:00
|
|
|
"Minimum length of the symbol at point for showing completion preview.
|
|
|
|
|
|
|
|
If this is nil rather than a number of characters, show the preview also
|
|
|
|
after non-symbol characters, such as punctuation or whitespace."
|
|
|
|
:type '(choice (natnum :tag "Minimum number of symbol characters")
|
|
|
|
(const :tag "Disable minimum symbol length requirement" nil))
|
2023-11-02 16:58:31 +01:00
|
|
|
:version "30.1")
|
|
|
|
|
2023-11-26 17:00:32 +01:00
|
|
|
(defcustom completion-preview-message-format
|
|
|
|
"Completion suggestion %i out of %n"
|
|
|
|
"Message to show after cycling the completion preview suggestion.
|
|
|
|
|
|
|
|
If the value is a string, `completion-preview-next-candidate' and
|
|
|
|
`completion-preview-prev-candidate' display this string in the
|
|
|
|
echo area, after substituting \"%i\" with the 1-based index of
|
|
|
|
the completion suggestion that the preview is showing, and \"%n\"
|
|
|
|
with the total number of available completion suggestions for the
|
|
|
|
text around point.
|
|
|
|
|
|
|
|
If this option is nil, these commands do not display any message."
|
|
|
|
:type '(choice (string :tag "Message format")
|
|
|
|
(const :tag "No message" nil))
|
|
|
|
:version "30.1")
|
|
|
|
|
2024-06-05 10:23:56 +02:00
|
|
|
(defcustom completion-preview-idle-delay nil
|
|
|
|
"If non-nil, wait this many idle seconds before displaying completion preview.
|
|
|
|
|
|
|
|
If this is nil, display the completion preview without delay."
|
|
|
|
:type '(choice (number :tag "Delay duration in seconds")
|
|
|
|
(const :tag "No delay" nil))
|
|
|
|
:version "30.1")
|
|
|
|
|
2024-09-17 20:26:23 +02:00
|
|
|
(defcustom completion-preview-ignore-case nil
|
|
|
|
"Whether Completion Preview mode ignores case differences.
|
|
|
|
|
|
|
|
By default this option is nil, which says that case is significant, so a
|
|
|
|
completion candidate \"FooBar\" matches prefix \"Foo\", but not \"foo\".
|
|
|
|
If you set it to non-nil, then Completion Preview mode also suggests
|
|
|
|
completions that differ in case from the prefix that you type; for
|
|
|
|
example, it may suggest completing \"foo\" with the suffix \"Bar\" when
|
|
|
|
there's an available completion candidate \"FooBar\". Note that in this
|
|
|
|
case, when you insert the completion (with `completion-preview-insert'),
|
|
|
|
Completion Preview mode does not update the completed prefix according
|
|
|
|
to the capitalization of the completion candidate, instead it simply
|
|
|
|
ignores such case differences, so the resulting string is \"fooBar\".
|
|
|
|
|
|
|
|
See also `completion-ignore-case'."
|
|
|
|
:type 'boolean
|
|
|
|
:version "31.1")
|
|
|
|
|
2025-01-09 12:22:03 +01:00
|
|
|
(defcustom completion-preview-adapt-background-color 'completion-preview
|
|
|
|
"Control automatic adaptation of completion preview background color.
|
|
|
|
|
|
|
|
This is either a face name or a (possibly empty) list of face names,
|
|
|
|
which Completion Preview mode automatically remaps when showing the
|
|
|
|
preview, such that the background color of the face(s) matches the
|
|
|
|
background color at point.
|
|
|
|
|
|
|
|
By default, this option specifies the `completion-preview' face (which
|
|
|
|
also affects its descendent faces `completion-preview-common' and
|
|
|
|
`completion-preview-exact') so the completion preview uses the
|
|
|
|
background color at point.
|
|
|
|
|
|
|
|
This is especially useful when there are other overlays at point that
|
|
|
|
affect the background color, for example with `hl-line-mode'."
|
|
|
|
:type '(choice face
|
|
|
|
(repeat :tag "List of faces" face)
|
|
|
|
(const :tag "Disable" nil))
|
|
|
|
:version "31.1")
|
|
|
|
|
2025-02-28 12:07:31 +01:00
|
|
|
(defcustom completion-preview-sort-function #'minibuffer--sort-by-length-alpha
|
|
|
|
"Sort function to use for choosing a completion candidate to preview.
|
|
|
|
|
|
|
|
Completion Preview mode calls the function that this option specifies to
|
|
|
|
sort completion candidates. The function takes one argument, the list
|
|
|
|
of candidates, and returns the list sorted.
|
|
|
|
|
|
|
|
The default sort function sorts first by length, then alphabetically.
|
|
|
|
To disable sorting, set this option to `identity'.
|
|
|
|
|
|
|
|
If the completion table that produces the candidates already specifies a
|
|
|
|
sort function, it takes precedence over this option."
|
2025-02-28 18:59:11 +01:00
|
|
|
:type '(choice
|
|
|
|
(function-item :tag "Sort alphabetically"
|
|
|
|
minibuffer-sort-alphabetically)
|
|
|
|
(function-item :tag "First by length, then alphabetically"
|
|
|
|
minibuffer--sort-by-length-alpha)
|
|
|
|
(function-item :tag "Disable sorting" identity)
|
|
|
|
(function :tag "Custom sort function"))
|
2025-02-28 12:07:31 +01:00
|
|
|
:version "31.1")
|
2023-11-02 16:58:31 +01:00
|
|
|
|
|
|
|
(defface completion-preview
|
|
|
|
'((t :inherit shadow))
|
2024-04-12 22:41:10 +02:00
|
|
|
"Face for completion candidates in the completion preview overlay."
|
2023-11-02 16:58:31 +01:00
|
|
|
:version "30.1")
|
|
|
|
|
2024-04-12 22:41:10 +02:00
|
|
|
(defface completion-preview-common
|
2023-11-02 16:58:31 +01:00
|
|
|
'((((supports :underline t))
|
|
|
|
:underline t :inherit completion-preview)
|
|
|
|
(((supports :weight bold))
|
|
|
|
:weight bold :inherit completion-preview)
|
|
|
|
(t :background "gray"))
|
2024-04-12 22:41:10 +02:00
|
|
|
"Face for the longest common prefix in the completion preview."
|
|
|
|
:version "30.1")
|
|
|
|
|
|
|
|
(defface completion-preview-exact
|
|
|
|
;; An exact match is also the longest common prefix of all matches.
|
2024-04-27 20:39:19 +02:00
|
|
|
'((t :underline "#00aa00" :inherit completion-preview-common))
|
2024-04-12 22:41:10 +02:00
|
|
|
"Face for matches in the completion preview overlay."
|
2023-11-02 16:58:31 +01:00
|
|
|
:version "30.1")
|
|
|
|
|
2023-11-26 17:00:32 +01:00
|
|
|
(defface completion-preview-highlight
|
|
|
|
'((t :inherit highlight))
|
|
|
|
"Face for highlighting the completion preview when the mouse is over it."
|
|
|
|
:version "30.1")
|
|
|
|
|
2023-11-02 16:58:31 +01:00
|
|
|
(defvar-keymap completion-preview-active-mode-map
|
|
|
|
:doc "Keymap for Completion Preview Active mode."
|
|
|
|
"C-i" #'completion-preview-insert
|
2024-04-12 22:41:10 +02:00
|
|
|
;; FIXME: Should this have another/better binding by default?
|
|
|
|
"M-i" #'completion-preview-complete
|
2023-11-02 16:58:31 +01:00
|
|
|
;; "M-n" #'completion-preview-next-candidate
|
|
|
|
;; "M-p" #'completion-preview-prev-candidate
|
2024-06-24 08:53:23 -07:00
|
|
|
;; "<remap> <forward-word>" #'completion-preview-insert-word
|
|
|
|
;; "<remap> <forward-sexp>" #'completion-preview-insert-sexp
|
2023-11-02 16:58:31 +01:00
|
|
|
)
|
|
|
|
|
2024-04-14 09:21:03 +02:00
|
|
|
(defun completion-preview--ignore ()
|
|
|
|
"Do nothing, including updating the completion preview.
|
|
|
|
|
|
|
|
This is the same as `ignore', except that Completion Preview mode skips
|
|
|
|
hiding or updating the completion preview after this command runs."
|
|
|
|
(interactive)
|
|
|
|
nil)
|
|
|
|
|
|
|
|
(put 'completion-preview--ignore 'completion-predicate #'ignore)
|
|
|
|
|
2023-11-26 17:00:32 +01:00
|
|
|
(defvar-keymap completion-preview--mouse-map
|
|
|
|
:doc "Keymap for mouse clicks on the completion preview."
|
2024-04-14 09:21:03 +02:00
|
|
|
"<mouse-1>" #'completion-preview-insert
|
|
|
|
;; Ignore the corresponding button-down event.
|
|
|
|
"<down-mouse-1>" #'completion-preview--ignore
|
|
|
|
"C-<mouse-1>" #'completion-preview-complete
|
|
|
|
"C-<down-mouse-1>" #'completion-preview--ignore
|
|
|
|
"<mouse-2>" #'completion-preview-complete
|
|
|
|
"<down-mouse-2>" #'completion-preview--ignore
|
|
|
|
"<wheel-up>" #'completion-preview-prev-candidate
|
|
|
|
"<wheel-down>" #'completion-preview-next-candidate)
|
2023-11-26 17:00:32 +01:00
|
|
|
|
2023-11-02 16:58:31 +01:00
|
|
|
(defvar-local completion-preview--overlay nil)
|
|
|
|
|
|
|
|
(defvar completion-preview--internal-commands
|
2023-11-26 17:00:32 +01:00
|
|
|
'(completion-preview-next-candidate
|
|
|
|
completion-preview-prev-candidate
|
2024-04-14 09:21:03 +02:00
|
|
|
completion-preview--ignore
|
2023-11-26 17:00:32 +01:00
|
|
|
;; Don't dismiss or update the preview when the user scrolls.
|
|
|
|
mwheel-scroll)
|
|
|
|
"List of commands that manipulate the completion preview.
|
|
|
|
|
|
|
|
Completion Preview mode avoids updating the preview after these commands.")
|
2023-11-02 16:58:31 +01:00
|
|
|
|
2024-04-12 22:41:10 +02:00
|
|
|
(defvar-local completion-preview--inhibit-update-p nil
|
|
|
|
"Whether to inhibit updating the completion preview following this command.")
|
|
|
|
|
|
|
|
(defsubst completion-preview--inhibit-update ()
|
|
|
|
"Inhibit updating the completion preview following this command."
|
|
|
|
(setq completion-preview--inhibit-update-p t))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
|
|
|
(defsubst completion-preview-require-certain-commands ()
|
|
|
|
"Check if `this-command' is one of `completion-preview-commands'."
|
2024-04-12 22:41:10 +02:00
|
|
|
(memq this-command completion-preview-commands))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
|
|
|
(defun completion-preview-require-minimum-symbol-length ()
|
|
|
|
"Check if the length of symbol at point is at least above a certain threshold.
|
|
|
|
`completion-preview-minimum-symbol-length' determines that threshold."
|
2024-06-05 10:03:06 +02:00
|
|
|
(or (null completion-preview-minimum-symbol-length)
|
|
|
|
(let ((bounds (bounds-of-thing-at-point 'symbol)))
|
|
|
|
(and bounds (<= completion-preview-minimum-symbol-length
|
|
|
|
(- (cdr bounds) (car bounds)))))))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
|
|
|
(defun completion-preview-hide ()
|
|
|
|
"Hide the completion preview."
|
|
|
|
(when completion-preview--overlay
|
|
|
|
(delete-overlay completion-preview--overlay)
|
2024-04-12 22:41:10 +02:00
|
|
|
(setq completion-preview--overlay nil
|
|
|
|
completion-preview--inhibit-update-p nil)))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
2024-09-04 18:21:13 +02:00
|
|
|
(defvar completion-preview-overlay-priority nil
|
|
|
|
"Value of the `priority' property for the completion preview overlay.")
|
|
|
|
|
2025-01-09 12:22:03 +01:00
|
|
|
(defun completion-preview--bg-color (pos)
|
|
|
|
"Return background color at POS."
|
|
|
|
;; This takes into account face remappings and multiple overlays that
|
|
|
|
;; specify the `face' property, unlike `background-color-at-point'.
|
|
|
|
(catch 'found
|
|
|
|
(named-let rec ((spec (seq-keep (lambda (ov) (overlay-get ov 'face))
|
|
|
|
(overlays-at pos t)))
|
|
|
|
(trace nil))
|
|
|
|
(dolist (face (if (face-list-p spec) spec (list spec)))
|
|
|
|
(let (cur)
|
|
|
|
(if (and (setq cur (alist-get face face-remapping-alist))
|
2025-01-14 07:37:18 +01:00
|
|
|
(not (memq face trace)))
|
2025-01-09 12:22:03 +01:00
|
|
|
(rec cur (cons face trace))
|
|
|
|
(cond ((and face (symbolp face))
|
|
|
|
(let ((value (face-attribute face :background nil t)))
|
|
|
|
(unless (member value '(nil "unspecified-bg" unspecified))
|
|
|
|
(throw 'found value))))
|
|
|
|
((consp face)
|
|
|
|
(when-let* ((value (or (cdr (memq 'background-color face))
|
|
|
|
(cadr (memq :background face)))))
|
|
|
|
(throw 'found value)))))))
|
|
|
|
(unless trace
|
|
|
|
(save-excursion
|
|
|
|
(goto-char pos)
|
|
|
|
(font-lock-ensure (pos-bol) (pos-eol)))
|
|
|
|
(rec (or (and font-lock-mode
|
|
|
|
(get-text-property pos 'font-lock-face))
|
|
|
|
(get-text-property pos 'face))
|
|
|
|
'(nil))
|
|
|
|
(rec 'default '(nil))))))
|
|
|
|
|
|
|
|
(defvar completion-preview--face-remap-cookie-jar nil)
|
|
|
|
|
|
|
|
(declare-function face-remap-remove-relative "face-remap" (cookie))
|
|
|
|
|
2023-11-02 16:58:31 +01:00
|
|
|
(defun completion-preview--make-overlay (pos string)
|
2023-11-20 12:45:11 +01:00
|
|
|
"Make preview overlay showing STRING at POS, or move existing preview there."
|
2023-11-02 16:58:31 +01:00
|
|
|
(if completion-preview--overlay
|
|
|
|
(move-overlay completion-preview--overlay pos pos)
|
|
|
|
(setq completion-preview--overlay (make-overlay pos pos))
|
2024-09-04 18:21:13 +02:00
|
|
|
(overlay-put completion-preview--overlay 'priority
|
|
|
|
completion-preview-overlay-priority)
|
2023-11-02 16:58:31 +01:00
|
|
|
(overlay-put completion-preview--overlay 'window (selected-window)))
|
2024-04-12 22:41:10 +02:00
|
|
|
(add-text-properties 0 1 '(cursor 1) string)
|
|
|
|
(overlay-put completion-preview--overlay 'after-string string)
|
2025-01-09 12:22:03 +01:00
|
|
|
(mapc #'face-remap-remove-relative completion-preview--face-remap-cookie-jar)
|
|
|
|
(setq completion-preview--face-remap-cookie-jar
|
|
|
|
(when (and completion-preview-adapt-background-color (< (point-min) pos))
|
|
|
|
(mapcar (lambda (face)
|
|
|
|
(face-remap-add-relative
|
|
|
|
face `(:background ,(completion-preview--bg-color (1- pos)))))
|
|
|
|
(ensure-list completion-preview-adapt-background-color))))
|
2024-04-12 22:41:10 +02:00
|
|
|
completion-preview--overlay)
|
2023-11-02 16:58:31 +01:00
|
|
|
|
2025-02-26 20:41:09 +01:00
|
|
|
(defsubst completion-preview--propertize-for-mouse (str)
|
|
|
|
"`propertize' STR, a completion suggestion, with mouse-related properties."
|
|
|
|
(propertize str
|
|
|
|
'mouse-face 'completion-preview-highlight
|
|
|
|
'help-echo "click to accept, scroll to cycle"
|
|
|
|
'keymap completion-preview--mouse-map))
|
|
|
|
|
2023-11-20 12:45:11 +01:00
|
|
|
(defsubst completion-preview--get (prop)
|
2023-11-02 16:58:31 +01:00
|
|
|
"Return property PROP of the completion preview overlay."
|
|
|
|
(overlay-get completion-preview--overlay prop))
|
|
|
|
|
2023-12-05 21:04:43 +01:00
|
|
|
(defun completion-preview--window-selection-change (window)
|
|
|
|
"Hide completion preview in WINDOW after switching to another window.
|
|
|
|
Completion Preview mode adds this function to
|
|
|
|
`window-selection-change-functions', which see."
|
|
|
|
(unless (or (eq window (selected-window))
|
|
|
|
(eq window (minibuffer-selected-window)))
|
|
|
|
(with-current-buffer (window-buffer window)
|
|
|
|
(completion-preview-active-mode -1))))
|
|
|
|
|
2023-11-02 16:58:31 +01:00
|
|
|
(define-minor-mode completion-preview-active-mode
|
|
|
|
"Mode for when the completion preview is shown."
|
|
|
|
:interactive nil
|
2023-12-05 21:04:43 +01:00
|
|
|
(if completion-preview-active-mode
|
2024-11-17 16:55:30 +01:00
|
|
|
(progn
|
|
|
|
(add-hook 'window-selection-change-functions
|
|
|
|
#'completion-preview--window-selection-change nil t)
|
|
|
|
;; Give keymap precedence over other minor mode maps.
|
|
|
|
;; TODO: Use explicit minor mode precedence instead when
|
|
|
|
;; implemented (bug#74492).
|
|
|
|
(setf (alist-get 'completion-preview-active-mode
|
|
|
|
minor-mode-overriding-map-alist)
|
|
|
|
completion-preview-active-mode-map))
|
2023-12-05 21:04:43 +01:00
|
|
|
(remove-hook 'window-selection-change-functions
|
|
|
|
#'completion-preview--window-selection-change t)
|
|
|
|
(completion-preview-hide)))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
2024-04-11 19:16:26 +02:00
|
|
|
(defvar completion-preview-completion-styles '(basic)
|
|
|
|
"List of completion styles that Completion Preview mode uses.
|
|
|
|
|
|
|
|
Since Completion Preview mode shows prefix completion candidates, this
|
|
|
|
list should normally only include completion styles that perform prefix
|
|
|
|
completion, but other candidates are filtered out and cause no harm.
|
|
|
|
|
|
|
|
See also `completion-styles'.")
|
|
|
|
|
2023-11-19 10:55:15 +01:00
|
|
|
(defun completion-preview--try-table (table beg end props)
|
|
|
|
"Check TABLE for a completion matching the text between BEG and END.
|
|
|
|
|
|
|
|
PROPS is a property list with additional information about TABLE.
|
|
|
|
See `completion-at-point-functions' for more details.
|
|
|
|
|
2024-04-12 22:41:10 +02:00
|
|
|
If TABLE contains a matching candidate, return a list
|
|
|
|
\(BASE COMMON SUFFIXES) where BASE is a prefix of the text
|
|
|
|
between BEG and END that TABLE elided from the start of each candidate,
|
|
|
|
COMMON is the longest common prefix of all matching candidates,
|
|
|
|
SUFFIXES is a list of different suffixes that together with COMMON yield
|
|
|
|
the matching candidates. If TABLE does not contain matching
|
|
|
|
candidates or if there are multiple matching completions and
|
|
|
|
`completion-preview-exact-match-only' is non-nil, return nil instead."
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; | buffer text | preview | ;;
|
|
|
|
;; | | | ;;
|
|
|
|
;; beg end | ;;
|
|
|
|
;; |------+------|--+--------| Each of base, common and suffix ;;
|
|
|
|
;; | base | common | suffix | <- may be empty, except common and ;;
|
|
|
|
;; suffix cannot both be empty. ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2023-11-19 10:55:15 +01:00
|
|
|
(let* ((pred (plist-get props :predicate))
|
|
|
|
(string (buffer-substring beg end))
|
2024-09-17 20:26:23 +02:00
|
|
|
(completion-ignore-case completion-preview-ignore-case)
|
2025-03-02 08:03:04 +01:00
|
|
|
(completion-extra-properties props)
|
2023-11-19 10:55:15 +01:00
|
|
|
(md (completion-metadata string table pred))
|
|
|
|
(sort-fn (or (completion-metadata-get md 'cycle-sort-function)
|
|
|
|
(completion-metadata-get md 'display-sort-function)
|
|
|
|
completion-preview-sort-function))
|
2024-04-11 19:16:26 +02:00
|
|
|
(all (let ((completion-lazy-hilit t)
|
|
|
|
;; FIXME: This does not override styles prescribed
|
|
|
|
;; by the completion category via
|
|
|
|
;; e.g. `completion-category-defaults'.
|
|
|
|
(completion-styles completion-preview-completion-styles))
|
2023-11-19 10:55:15 +01:00
|
|
|
(completion-all-completions string table pred
|
|
|
|
(- (point) beg) md)))
|
|
|
|
(last (last all))
|
|
|
|
(base (or (cdr last) 0))
|
|
|
|
(prefix (substring string base)))
|
|
|
|
(when last
|
|
|
|
(setcdr last nil)
|
Mark if-let and when-let obsolete
* lisp/subr.el (if-let*, when-let*, if-let, when-let): Mark
if-let and when-let obsolete (bug#73853 and elsewhere). Move
docstring text around so that if-let* and when-let* descriptions
no longer refer to if-let and when-let.
* etc/NEWS: Announce the change.
* admin/admin.el (reminder-for-release-blocking-bugs):
* doc/misc/erc.texi (display-buffer):
* lisp/ansi-color.el (ansi-color-apply)
(ansi-color--face-vec-face):
* lisp/ansi-osc.el (ansi-osc-apply-on-region)
(ansi-osc-hyperlink):
* lisp/arc-mode.el (archive-goto-file)
(archive-next-file-displayer):
* lisp/auth-source-pass.el (auth-source-pass-search)
(auth-source-pass--parse-data)
(auth-source-pass--find-match-many):
* lisp/autorevert.el (auto-revert-notify-rm-watch):
* lisp/buff-menu.el (Buffer-menu-unmark-all-buffers)
(Buffer-menu-group-by-root):
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
* lisp/cedet/pulse.el (pulse-tick):
* lisp/comint.el (comint--fontify-input-ppss-flush-indirect)
(comint--intersect-regions):
* lisp/completion-preview.el (completion-preview--try-table)
(completion-preview--capf-wrapper, completion-preview--update):
* lisp/cus-edit.el (setopt--set)
(custom-dirlocals-maybe-update-cons, custom-dirlocals-validate):
* lisp/custom.el (load-theme):
* lisp/descr-text.el (describe-char):
* lisp/desktop.el (desktop--emacs-pid-running-p):
* lisp/dired-x.el (menu):
* lisp/dired.el (dired-font-lock-keywords)
(dired-insert-directory, dired--insert-disk-space, dired-mode):
* lisp/dnd.el (dnd-handle-multiple-urls):
* lisp/dom.el (dom-remove-attribute):
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
* lisp/emacs-lisp/bytecomp.el (bytecomp--custom-declare):
* lisp/emacs-lisp/comp-common.el (comp-function-type-spec):
* lisp/emacs-lisp/comp-cstr.el (comp--all-classes)
(comp-cstr-set-range-for-arithm, comp--cstr-union-1-no-mem)
(comp-cstr-intersection-no-mem, comp-cstr-fixnum-p)
(comp-cstr-type-p):
* lisp/emacs-lisp/comp-run.el (comp-subr-trampoline-install)
(native--compile-async):
* lisp/emacs-lisp/comp.el (comp--get-function-cstr)
(comp--function-pure-p, comp--intern-func-in-ctxt)
(comp--addr-to-bb-name, comp--emit-assume, comp--maybe-add-vmvar)
(comp--add-call-cstr, comp--compute-dominator-tree)
(comp--dom-tree-walker, comp--ssa-rename)
(comp--function-call-maybe-fold, comp--fwprop-call)
(comp--call-optim-func):
* lisp/emacs-lisp/edebug.el (edebug-global-prefix)
(edebug-remove-instrumentation):
* lisp/emacs-lisp/eieio.el (initialize-instance):
* lisp/emacs-lisp/ert-x.el (ert-resource-directory):
* lisp/emacs-lisp/ert.el (ert--expand-should-1)
(ert-test-location, ert-write-junit-test-report)
(ert-test--erts-test):
* lisp/emacs-lisp/icons.el (icon-complete-spec, icon-string)
(icons--create):
* lisp/emacs-lisp/lisp-mode.el (lisp--local-defform-body-p):
* lisp/emacs-lisp/loaddefs-gen.el
(loaddefs-generate--make-autoload)
(loaddefs-generate--parse-file):
* lisp/emacs-lisp/multisession.el
(multisession-edit-mode--revert, multisession-edit-value):
* lisp/emacs-lisp/package-vc.el (package-vc--read-archive-data)
(package-vc--version, package-vc--clone):
* lisp/emacs-lisp/package.el (package--reload-previously-loaded):
* lisp/emacs-lisp/pp.el (pp--insert-lisp):
* lisp/emacs-lisp/subr-x.el (add-display-text-property):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-print):
* lisp/emacs-lisp/timer.el (run-at-time):
* lisp/emacs-lisp/vtable.el (vtable-goto-table)
(vtable-goto-column, vtable-update-object, vtable--insert-line)
(vtable--compute-widths, vtable--make-keymap):
* lisp/emacs-lisp/warnings.el (display-warning):
* lisp/epa-file.el (epa-file-insert-file-contents):
* lisp/epa.el (epa-show-key):
* lisp/erc/erc-backend.el (erc--split-line, erc--conceal-prompt)
(PRIVMSG, erc--get-isupport-entry):
* lisp/erc/erc-button.el (erc-button-add-nickname-buttons)
(erc--button-next):
* lisp/erc/erc-common.el (erc--find-group):
* lisp/erc/erc-fill.el (erc-fill, erc-fill-static)
(erc-fill--wrap-escape-hidden-speaker)
(erc-fill--wrap-unmerge-on-date-stamp)
(erc-fill--wrap-massage-initial-message-post-clear)
(erc-fill-wrap, erc-fill--wrap-rejigger-region):
* lisp/erc/erc-goodies.el (erc--scrolltobottom-all)
(erc--keep-place-indicator-on-window-buffer-change)
(keep-place-indicator, erc--keep-place-indicator-adjust-on-clear)
(erc-keep-place-move, erc--command-indicator-display):
* lisp/erc/erc-ibuffer.el (erc-members):
* lisp/erc/erc-join.el (erc-join--remove-requested-channel)
(erc-autojoin--join):
* lisp/erc/erc-networks.el
(erc-networks--id-qualifying-init-parts, erc-networks--id-reload)
(erc-networks--id-ensure-comparable)
(erc-networks--reclaim-orphaned-target-buffers)
(erc-networks--server-select):
* lisp/erc/erc-nicks.el (erc-nicks-invert)
(erc-nicks--redirect-face-widget-link, erc-nicks--highlight)
(erc-nicks--highlight-button)
(erc-nicks--list-faces-help-button-action, erc-nicks-list-faces)
(erc-nicks-refresh, erc-nicks--colors-from-faces)
(erc-nicks--track-prioritize)
(erc-nicks--remember-face-for-track):
* lisp/erc/erc-notify.el (querypoll, erc--querypoll-get-next)
(erc--querypoll-on-352, erc--querypoll-send):
* lisp/erc/erc-sasl.el (erc-sasl--read-password):
* lisp/erc/erc-services.el
(erc-services-issue-ghost-and-retry-nick):
* lisp/erc/erc-speedbar.el (erc-speedbar--ensure, nickbar)
(erc-speedbar-toggle-nicknames-window-lock)
(erc-speedbar--compose-nicks-face):
* lisp/erc/erc-stamp.el (erc-stamp--recover-on-reconnect)
(erc-stamp-prefix-log-filter, erc--conceal-prompt)
(erc--insert-timestamp-left, erc-insert-timestamp-right)
(erc-stamp--defer-date-insertion-on-post-modify)
(erc-insert-timestamp-left-and-right)
(erc-stamp--redo-right-stamp-post-clear)
(erc-stamp--reset-on-clear, erc-stamp--dedupe-date-stamps):
* lisp/erc/erc-status-sidebar.el (bufbar)
(erc-status-sidebar-prefer-target-as-name)
(erc-status-sidebar-default-allsort, erc-status-sidebar-click):
* lisp/erc/erc-track.el (erc-track--shortened-names-get)
(erc-track--setup, erc-track--select-mode-line-face)
(erc-track-modified-channels, erc-track--collect-faces-in)
(erc-track--switch-buffer, erc-track--replace-killed-buffer):
* lisp/erc/erc-truncate.el (erc-truncate--setup)
(erc-truncate-buffer):
* lisp/erc/erc.el (erc--ensure-query-member)
(erc--ensure-query-members, erc--remove-channel-users-but)
(erc--cusr-change-status, erc--find-mode, erc--update-modules)
(erc-log-irc-protocol, erc--refresh-prompt)
(erc--restore-important-text-props)
(erc--order-text-properties-from-hash, erc-send-input-line)
(erc-cmd-IGNORE, erc--unignore-user, erc-cmd-QUERY)
(erc-cmd-BANLIST, erc--speakerize-nick)
(erc--format-speaker-input-message, erc-channel-receive-names)
(erc-send-current-line, erc-format-target-and/or-network)
(erc-kill-buffer-function, erc-restore-text-properties)
(erc--get-eq-comparable-cmd):
* lisp/eshell/em-alias.el (eshell-maybe-replace-by-alias--which)
(eshell-maybe-replace-by-alias):
* lisp/eshell/em-glob.el (eshell-glob-convert):
* lisp/eshell/em-pred.el (eshell-pred-user-or-group)
(eshell-pred-file-time, eshell-pred-file-type)
(eshell-pred-file-mode, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-prompt.el (eshell-forward-paragraph)
(eshell-next-prompt):
* lisp/eshell/esh-arg.el (eshell-resolve-current-argument):
* lisp/eshell/esh-cmd.el (eshell-do-eval, eshell/which)
(eshell-plain-command--which, eshell-plain-command):
* lisp/eshell/esh-io.el (eshell-duplicate-handles)
(eshell-protect-handles, eshell-get-target, eshell-close-target):
* lisp/eshell/esh-proc.el (eshell-sentinel):
* lisp/eshell/esh-var.el (eshell-parse-variable-ref)
(eshell-get-variable, eshell-set-variable):
* lisp/faces.el (face-at-point):
* lisp/ffap.el (ffap-in-project):
* lisp/filenotify.el (file-notify--rm-descriptor):
* lisp/files-x.el (read-dir-locals-file)
(connection-local-update-profile-variables)
(connection-local-value):
* lisp/files.el (file-remote-p, abbreviate-file-name)
(set-auto-mode, hack-local-variables)
(revert-buffer-restore-read-only):
* lisp/find-dired.el (find-dired-sort-by-filename):
* lisp/font-lock.el (font-lock--filter-keywords):
* lisp/gnus/gnus-art.el (article-emojize-symbols):
* lisp/gnus/gnus-int.el (gnus-close-server):
* lisp/gnus/gnus-search.el (gnus-search-transform)
(gnus-search-indexed-parse-output, gnus-search-server-to-engine):
* lisp/gnus/gnus-sum.el (gnus-collect-urls, gnus-shorten-url):
* lisp/gnus/gnus.el (gnus-check-backend-function):
* lisp/gnus/message.el (message-send-mail):
* lisp/gnus/mml.el (mml-generate-mime, mml-insert-mime-headers):
* lisp/gnus/nnatom.el (nnatom--read-feed, nnatom--read-article)
(nnatom--read-article-or-group-authors, nnatom--read-publish)
(nnatom--read-update, nnatom--read-links):
* lisp/gnus/nnfeed.el (nnfeed--read-server, nnfeed--write-server)
(nnfeed--parse-feed, nnfeed--group-data, nnfeed-retrieve-article)
(nnfeed-retrieve-headers, nnfeed--print-part)
(nnfeed-request-article, nnfeed-request-group)
(nnfeed-request-list, nnfeed--group-description)
(nnfeed-request-group-description)
(nnfeed-request-list-newsgroups, nnfeed-request-rename-group):
* lisp/gnus/nnmh.el (nnmh-update-gnus-unreads):
* lisp/help-fns.el (help-find-source)
(help-fns--insert-menu-bindings, help-fns--mention-first-release)
(help-fns--mention-shortdoc-groups)
(help-fns--customize-variable-version)
(help-fns--face-custom-version-info, describe-mode):
* lisp/help-mode.el (help-make-xrefs):
* lisp/help.el (help-key-description, help--describe-command):
* lisp/hfy-cmap.el (htmlfontify-load-rgb-file):
* lisp/ibuf-ext.el (ibuffer-jump-to-filter-group)
(ibuffer-kill-filter-group, ibuffer-kill-line)
(ibuffer-save-filter-groups, ibuffer-save-filters, filename)
(basename, file-extension, ibuffer-diff-buffer-with-file-1)
(ibuffer-mark-by-file-name-regexp)
(ibuffer-mark-by-content-regexp):
* lisp/ibuf-macs.el (ibuffer-aif, ibuffer-awhen):
* lisp/ibuffer.el (ibuffer-mouse-toggle-mark)
(ibuffer-toggle-marks, ibuffer-mark-interactive)
(ibuffer-compile-format, process, ibuffer-map-lines):
* lisp/image.el (image--compute-map)
(image--compute-original-map):
* lisp/image/exif.el (exif-parse-buffer):
* lisp/image/image-converter.el (image-convert-p, image-convert)
(image-converter--find-converter):
* lisp/image/image-dired-util.el
(image-dired-file-name-at-point):
* lisp/image/image-dired.el (image-dired-track-original-file)
(image-dired--on-file-in-dired-buffer)
(image-dired--with-thumbnail-buffer)
(image-dired-jump-original-dired-buffer)
(image-dired--slideshow-step, image-dired-display-image):
* lisp/image/wallpaper.el (wallpaper--init-action-kill)
(wallpaper--find-setter, wallpaper--find-command)
(wallpaper--find-command-args, wallpaper--x-monitor-name):
* lisp/info-look.el (info-lookup-interactive-arguments)
(info-complete)::(:mode):
* lisp/info.el (info-pop-to-buffer, Info-read-node-name-1):
* lisp/international/emoji.el (emoji--adjust-displayable-1)
(emoji--add-recent):
* lisp/jsonrpc.el (jsonrpc--call-deferred)
(jsonrpc--process-sentinel, jsonrpc--remove):
* lisp/keymap.el (keymap-local-lookup):
* lisp/mail/emacsbug.el (report-emacs-bug-hook)
(submit-emacs-patch):
* lisp/mail/ietf-drums.el (ietf-drums-parse-addresses):
* lisp/mail/mailclient.el (mailclient-send-it):
* lisp/mail/rfc6068.el (rfc6068-parse-mailto-url):
* lisp/mail/undigest.el (rmail-digest-parse-mixed-mime):
* lisp/minibuffer.el (completion-metadata-get)
(completions--after-change)
(minibuffer-visible-completions--filter):
* lisp/net/browse-url.el (browse-url-url-at-point)
(browse-url-file-url, browse-url-emacs):
* lisp/net/dbus.el (dbus-byte-array-to-string)
(dbus-monitor-goto-serial):
* lisp/net/dictionary.el (dictionary-search):
* lisp/net/eww.el (eww--download-directory)
(eww-auto-rename-buffer, eww-open-in-new-buffer, eww-submit)
(eww-follow-link, eww-read-alternate-url)
(eww-copy-alternate-url):
* lisp/net/goto-addr.el (goto-address-at-point):
* lisp/net/mailcap.el (mailcap-mime-info):
* lisp/net/rcirc.el (rcirc, rcirc-connect, rcirc-send-string)
(rcirc-kill-buffer-hook, rcirc-print, rcirc-when)
(rcirc-color-attributes, rcirc-handler-NICK)
(rcirc-handler-TAGMSG, rcirc-handler-BATCH):
* lisp/net/shr.el (shr-descend, shr-adaptive-fill-function)
(shr-correct-dom-case, shr-tag-a):
* lisp/net/sieve.el (sieve-manage-quit):
* lisp/outline.el (outline-cycle-buffer):
* lisp/pcmpl-git.el (pcmpl-git--tracked-file-predicate):
* lisp/proced.el (proced-auto-update-timer):
* lisp/progmodes/bug-reference.el
(bug-reference-try-setup-from-vc):
* lisp/progmodes/c-ts-common.el (c-ts-common--fill-paragraph):
* lisp/progmodes/c-ts-mode.el (c-ts-mode--preproc-offset)
(c-ts-mode--anchor-prev-sibling, c-ts-mode-indent-defun):
* lisp/progmodes/compile.el (compilation-error-properties)
(compilation-find-file-1):
* lisp/progmodes/eglot.el (eglot--check-object)
(eglot--read-server, eglot-upgrade-eglot)
(eglot-handle-notification, eglot--CompletionParams)
(eglot-completion-at-point, eglot--sig-info)
(eglot-register-capability):
* lisp/progmodes/elisp-mode.el
(emacs-lisp-native-compile-and-load)
(elisp-eldoc-var-docstring-with-value):
* lisp/progmodes/erts-mode.el (erts-mode--goto-start-of-test):
* lisp/progmodes/flymake.el (flymake--update-eol-overlays)
(flymake-eldoc-function):
* lisp/progmodes/gdb-mi.el (gdb-breakpoints-list-handler-custom)
(gdb-frame-handler):
* lisp/progmodes/go-ts-mode.el (go-ts-mode-docstring)
(go-ts-mode--comment-on-previous-line-p)
(go-ts-mode--get-test-regexp-at-point)
(go-ts-mode-test-this-file):
* lisp/progmodes/grep.el (lgrep, rgrep-default-command)
(grep-file-at-point):
* lisp/progmodes/perl-mode.el (perl--end-of-format-p):
* lisp/progmodes/php-ts-mode.el
(php-ts-mode--anchor-prev-sibling, php-ts-mode--indent-defun):
* lisp/progmodes/project.el (project--other-place-command)
(project--find-default-from, project--transplant-file-name)
(project-prefixed-buffer-name, project--remove-from-project-list)
(project-prompt-project-name, project-remember-projects-under)
(project--switch-project-command)
(project-uniquify-dirname-transform, project-mode-line-format):
* lisp/progmodes/python.el
(python-font-lock-keywords-maximum-decoration)
(python--treesit-fontify-union-types)
(python-shell-get-process-name, python-shell-restart)
(python-shell-completion-at-point, python-ffap-module-path)
(python-util-comint-end-of-output-p, python--import-sources)
(python-add-import, python-remove-import, python-fix-imports):
* lisp/progmodes/xref.el (xref--add-log-current-defun):
* lisp/repeat.el (repeat-echo-message-string):
* lisp/saveplace.el (save-place-dired-hook):
* lisp/server.el (server-save-buffers-kill-terminal):
* lisp/shadowfile.el (shadow-make-fullname)
(shadow-contract-file-name, shadow-define-literal-group):
* lisp/shell.el (shell-highlight-undef-mode):
* lisp/simple.el (command-completion-using-modes-p)
(command-execute, file-user-uid, file-group-gid)
(first-completion, last-completion, switch-to-completions):
* lisp/startup.el (startup--load-user-init-file):
* lisp/tab-line.el (tab-line-tabs-buffer-group-by-project):
* lisp/tar-mode.el (tar-goto-file, tar-next-file-displayer):
* lisp/term/android-win.el (android-encode-select-string)
(gui-backend-set-selection):
* lisp/term/haiku-win.el (haiku-dnd-convert-string)
(haiku-select-encode-xstring, haiku-select-encode-utf-8-string):
* lisp/textmodes/emacs-news-mode.el (emacs-news--buttonize):
* lisp/textmodes/ispell.el (ispell-completion-at-point):
* lisp/textmodes/sgml-mode.el (sgml-validate)
(html-mode--complete-at-point):
* lisp/textmodes/tex-mode.el (tex-recenter-output-buffer)
(xref-backend-references):
* lisp/thingatpt.el (thing-at-point-file-at-point)
(thing-at-point-face-at-point):
* lisp/thread.el (thread-list--get-status):
* lisp/time.el (world-clock-copy-time-as-kill, world-clock):
* lisp/touch-screen.el (touch-screen-handle-touch):
* lisp/treesit.el (treesit-language-at, treesit-node-at)
(treesit-node-on, treesit-buffer-root-node)
(treesit-node-field-name, treesit-local-parsers-at)
(treesit-local-parsers-on, treesit--cleanup-local-range-overlays)
(treesit-font-lock-recompute-features)
(treesit-font-lock-fontify-region, treesit-transpose-sexps)
(treesit-add-log-current-defun, treesit-major-mode-setup)
(treesit--explorer-refresh, treesit-install-language-grammar):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/vc/smerge-mode.el (smerge-diff):
* lisp/vc/vc-dir.el (vc-dir):
* lisp/vc/vc-dispatcher.el (vc-do-async-command):
* lisp/vc/vc-git.el (vc-git-dir--branch-headers)
(vc-git-dir--stash-headers, vc-git--log-edit-summary-check)
(vc-git-stash-list):
* lisp/vc/vc.el (vc-responsible-backend, vc-buffer-sync-fileset)
(vc-clone):
* lisp/visual-wrap.el (visual-wrap--apply-to-line):
* lisp/wid-edit.el (widget-text)
(widget-editable-list-insert-before):
* lisp/window-tool-bar.el
(window-tool-bar--keymap-entry-to-string):
* lisp/window.el (display-buffer, display-buffer-full-frame)
(window-point-context-set, window-point-context-use)
(window-point-context-use-default-function):
* lisp/xdg.el (xdg-current-desktop):
* lisp/xwidget.el (xwidget-webkit-callback):
* lisp/yank-media.el (yank-media--get-selection)
(yank-media-types):
* test/lisp/comint-tests.el
(comint-tests/test-password-function):
* test/lisp/completion-preview-tests.el
(completion-preview-tests--capf):
* test/lisp/cus-edit-tests.el (with-cus-edit-test):
* test/lisp/erc/erc-scenarios-base-local-modules.el
(-phony-sblm-):
* test/lisp/erc/erc-scenarios-stamp.el
(erc-scenarios-stamp--on-post-modify):
* test/lisp/erc/erc-services-tests.el
(erc-services-tests--asp-parse-entry):
* test/lisp/erc/erc-tests.el (erc-modules--internal-property)
(erc--find-mode, erc-tests--update-modules):
* test/lisp/erc/resources/erc-d/erc-d-i.el
(erc-d-i--parse-message):
* test/lisp/erc/resources/erc-d/erc-d-t.el
(erc-d-t-kill-related-buffers, erc-d-t-with-cleanup):
* test/lisp/erc/resources/erc-d/erc-d-tests.el
(erc-d-i--parse-message--irc-parser-tests):
* test/lisp/erc/resources/erc-d/erc-d-u.el
(erc-d-u--read-exchange-slowly):
* test/lisp/erc/resources/erc-d/erc-d.el (erc-d--expire)
(erc-d--finalize-done, erc-d--command-handle-all):
* test/lisp/erc/resources/erc-scenarios-common.el
(erc-scenarios-common-with-cleanup):
* test/lisp/erc/resources/erc-tests-common.el
(erc-tests--common-display-message)
(erc-tests-common-create-subprocess):
* test/lisp/ibuffer-tests.el (ibuffer-test-Bug25058):
* test/lisp/international/mule-tests.el
(mule-cmds-tests--ucs-names-missing-names):
* test/lisp/progmodes/python-tests.el
(python-tests-get-shell-interpreter)
(python-tests--get-interpreter-info):
* test/lisp/progmodes/ruby-ts-mode-tests.el
(ruby-ts-resource-file):
* test/lisp/replace-tests.el (replace-tests-with-undo):
* test/src/emacs-tests.el (emacs-tests--seccomp-debug):
* test/src/process-tests.el (process-tests--emacs-command)
(process-tests--emacs-binary, process-tests--dump-file):
* test/src/treesit-tests.el (treesit--ert-test-defun-navigation):
Replace use of the now-obsolete if-let and when-let.
2024-10-24 16:50:07 +08:00
|
|
|
(when-let* ((sorted (funcall sort-fn
|
|
|
|
(delete prefix (all-completions prefix all))))
|
|
|
|
(common (try-completion prefix sorted))
|
|
|
|
(lencom (length common))
|
|
|
|
(suffixes sorted))
|
2024-04-12 22:41:10 +02:00
|
|
|
(unless (and (cdr suffixes) completion-preview-exact-match-only)
|
|
|
|
;; Remove the common prefix from each candidate.
|
|
|
|
(while sorted
|
|
|
|
(setcar sorted (substring (car sorted) lencom))
|
|
|
|
(setq sorted (cdr sorted)))
|
|
|
|
(list (substring string 0 base) common suffixes))))))
|
2023-11-19 10:55:15 +01:00
|
|
|
|
|
|
|
(defun completion-preview--capf-wrapper (capf)
|
|
|
|
"Translate return value of CAPF to properties for completion preview overlay."
|
2023-11-20 12:45:11 +01:00
|
|
|
(let ((res (ignore-errors (funcall capf))))
|
|
|
|
(and (consp res)
|
|
|
|
(not (functionp res))
|
|
|
|
(seq-let (beg end table &rest plist) res
|
Mark if-let and when-let obsolete
* lisp/subr.el (if-let*, when-let*, if-let, when-let): Mark
if-let and when-let obsolete (bug#73853 and elsewhere). Move
docstring text around so that if-let* and when-let* descriptions
no longer refer to if-let and when-let.
* etc/NEWS: Announce the change.
* admin/admin.el (reminder-for-release-blocking-bugs):
* doc/misc/erc.texi (display-buffer):
* lisp/ansi-color.el (ansi-color-apply)
(ansi-color--face-vec-face):
* lisp/ansi-osc.el (ansi-osc-apply-on-region)
(ansi-osc-hyperlink):
* lisp/arc-mode.el (archive-goto-file)
(archive-next-file-displayer):
* lisp/auth-source-pass.el (auth-source-pass-search)
(auth-source-pass--parse-data)
(auth-source-pass--find-match-many):
* lisp/autorevert.el (auto-revert-notify-rm-watch):
* lisp/buff-menu.el (Buffer-menu-unmark-all-buffers)
(Buffer-menu-group-by-root):
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
* lisp/cedet/pulse.el (pulse-tick):
* lisp/comint.el (comint--fontify-input-ppss-flush-indirect)
(comint--intersect-regions):
* lisp/completion-preview.el (completion-preview--try-table)
(completion-preview--capf-wrapper, completion-preview--update):
* lisp/cus-edit.el (setopt--set)
(custom-dirlocals-maybe-update-cons, custom-dirlocals-validate):
* lisp/custom.el (load-theme):
* lisp/descr-text.el (describe-char):
* lisp/desktop.el (desktop--emacs-pid-running-p):
* lisp/dired-x.el (menu):
* lisp/dired.el (dired-font-lock-keywords)
(dired-insert-directory, dired--insert-disk-space, dired-mode):
* lisp/dnd.el (dnd-handle-multiple-urls):
* lisp/dom.el (dom-remove-attribute):
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
* lisp/emacs-lisp/bytecomp.el (bytecomp--custom-declare):
* lisp/emacs-lisp/comp-common.el (comp-function-type-spec):
* lisp/emacs-lisp/comp-cstr.el (comp--all-classes)
(comp-cstr-set-range-for-arithm, comp--cstr-union-1-no-mem)
(comp-cstr-intersection-no-mem, comp-cstr-fixnum-p)
(comp-cstr-type-p):
* lisp/emacs-lisp/comp-run.el (comp-subr-trampoline-install)
(native--compile-async):
* lisp/emacs-lisp/comp.el (comp--get-function-cstr)
(comp--function-pure-p, comp--intern-func-in-ctxt)
(comp--addr-to-bb-name, comp--emit-assume, comp--maybe-add-vmvar)
(comp--add-call-cstr, comp--compute-dominator-tree)
(comp--dom-tree-walker, comp--ssa-rename)
(comp--function-call-maybe-fold, comp--fwprop-call)
(comp--call-optim-func):
* lisp/emacs-lisp/edebug.el (edebug-global-prefix)
(edebug-remove-instrumentation):
* lisp/emacs-lisp/eieio.el (initialize-instance):
* lisp/emacs-lisp/ert-x.el (ert-resource-directory):
* lisp/emacs-lisp/ert.el (ert--expand-should-1)
(ert-test-location, ert-write-junit-test-report)
(ert-test--erts-test):
* lisp/emacs-lisp/icons.el (icon-complete-spec, icon-string)
(icons--create):
* lisp/emacs-lisp/lisp-mode.el (lisp--local-defform-body-p):
* lisp/emacs-lisp/loaddefs-gen.el
(loaddefs-generate--make-autoload)
(loaddefs-generate--parse-file):
* lisp/emacs-lisp/multisession.el
(multisession-edit-mode--revert, multisession-edit-value):
* lisp/emacs-lisp/package-vc.el (package-vc--read-archive-data)
(package-vc--version, package-vc--clone):
* lisp/emacs-lisp/package.el (package--reload-previously-loaded):
* lisp/emacs-lisp/pp.el (pp--insert-lisp):
* lisp/emacs-lisp/subr-x.el (add-display-text-property):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-print):
* lisp/emacs-lisp/timer.el (run-at-time):
* lisp/emacs-lisp/vtable.el (vtable-goto-table)
(vtable-goto-column, vtable-update-object, vtable--insert-line)
(vtable--compute-widths, vtable--make-keymap):
* lisp/emacs-lisp/warnings.el (display-warning):
* lisp/epa-file.el (epa-file-insert-file-contents):
* lisp/epa.el (epa-show-key):
* lisp/erc/erc-backend.el (erc--split-line, erc--conceal-prompt)
(PRIVMSG, erc--get-isupport-entry):
* lisp/erc/erc-button.el (erc-button-add-nickname-buttons)
(erc--button-next):
* lisp/erc/erc-common.el (erc--find-group):
* lisp/erc/erc-fill.el (erc-fill, erc-fill-static)
(erc-fill--wrap-escape-hidden-speaker)
(erc-fill--wrap-unmerge-on-date-stamp)
(erc-fill--wrap-massage-initial-message-post-clear)
(erc-fill-wrap, erc-fill--wrap-rejigger-region):
* lisp/erc/erc-goodies.el (erc--scrolltobottom-all)
(erc--keep-place-indicator-on-window-buffer-change)
(keep-place-indicator, erc--keep-place-indicator-adjust-on-clear)
(erc-keep-place-move, erc--command-indicator-display):
* lisp/erc/erc-ibuffer.el (erc-members):
* lisp/erc/erc-join.el (erc-join--remove-requested-channel)
(erc-autojoin--join):
* lisp/erc/erc-networks.el
(erc-networks--id-qualifying-init-parts, erc-networks--id-reload)
(erc-networks--id-ensure-comparable)
(erc-networks--reclaim-orphaned-target-buffers)
(erc-networks--server-select):
* lisp/erc/erc-nicks.el (erc-nicks-invert)
(erc-nicks--redirect-face-widget-link, erc-nicks--highlight)
(erc-nicks--highlight-button)
(erc-nicks--list-faces-help-button-action, erc-nicks-list-faces)
(erc-nicks-refresh, erc-nicks--colors-from-faces)
(erc-nicks--track-prioritize)
(erc-nicks--remember-face-for-track):
* lisp/erc/erc-notify.el (querypoll, erc--querypoll-get-next)
(erc--querypoll-on-352, erc--querypoll-send):
* lisp/erc/erc-sasl.el (erc-sasl--read-password):
* lisp/erc/erc-services.el
(erc-services-issue-ghost-and-retry-nick):
* lisp/erc/erc-speedbar.el (erc-speedbar--ensure, nickbar)
(erc-speedbar-toggle-nicknames-window-lock)
(erc-speedbar--compose-nicks-face):
* lisp/erc/erc-stamp.el (erc-stamp--recover-on-reconnect)
(erc-stamp-prefix-log-filter, erc--conceal-prompt)
(erc--insert-timestamp-left, erc-insert-timestamp-right)
(erc-stamp--defer-date-insertion-on-post-modify)
(erc-insert-timestamp-left-and-right)
(erc-stamp--redo-right-stamp-post-clear)
(erc-stamp--reset-on-clear, erc-stamp--dedupe-date-stamps):
* lisp/erc/erc-status-sidebar.el (bufbar)
(erc-status-sidebar-prefer-target-as-name)
(erc-status-sidebar-default-allsort, erc-status-sidebar-click):
* lisp/erc/erc-track.el (erc-track--shortened-names-get)
(erc-track--setup, erc-track--select-mode-line-face)
(erc-track-modified-channels, erc-track--collect-faces-in)
(erc-track--switch-buffer, erc-track--replace-killed-buffer):
* lisp/erc/erc-truncate.el (erc-truncate--setup)
(erc-truncate-buffer):
* lisp/erc/erc.el (erc--ensure-query-member)
(erc--ensure-query-members, erc--remove-channel-users-but)
(erc--cusr-change-status, erc--find-mode, erc--update-modules)
(erc-log-irc-protocol, erc--refresh-prompt)
(erc--restore-important-text-props)
(erc--order-text-properties-from-hash, erc-send-input-line)
(erc-cmd-IGNORE, erc--unignore-user, erc-cmd-QUERY)
(erc-cmd-BANLIST, erc--speakerize-nick)
(erc--format-speaker-input-message, erc-channel-receive-names)
(erc-send-current-line, erc-format-target-and/or-network)
(erc-kill-buffer-function, erc-restore-text-properties)
(erc--get-eq-comparable-cmd):
* lisp/eshell/em-alias.el (eshell-maybe-replace-by-alias--which)
(eshell-maybe-replace-by-alias):
* lisp/eshell/em-glob.el (eshell-glob-convert):
* lisp/eshell/em-pred.el (eshell-pred-user-or-group)
(eshell-pred-file-time, eshell-pred-file-type)
(eshell-pred-file-mode, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-prompt.el (eshell-forward-paragraph)
(eshell-next-prompt):
* lisp/eshell/esh-arg.el (eshell-resolve-current-argument):
* lisp/eshell/esh-cmd.el (eshell-do-eval, eshell/which)
(eshell-plain-command--which, eshell-plain-command):
* lisp/eshell/esh-io.el (eshell-duplicate-handles)
(eshell-protect-handles, eshell-get-target, eshell-close-target):
* lisp/eshell/esh-proc.el (eshell-sentinel):
* lisp/eshell/esh-var.el (eshell-parse-variable-ref)
(eshell-get-variable, eshell-set-variable):
* lisp/faces.el (face-at-point):
* lisp/ffap.el (ffap-in-project):
* lisp/filenotify.el (file-notify--rm-descriptor):
* lisp/files-x.el (read-dir-locals-file)
(connection-local-update-profile-variables)
(connection-local-value):
* lisp/files.el (file-remote-p, abbreviate-file-name)
(set-auto-mode, hack-local-variables)
(revert-buffer-restore-read-only):
* lisp/find-dired.el (find-dired-sort-by-filename):
* lisp/font-lock.el (font-lock--filter-keywords):
* lisp/gnus/gnus-art.el (article-emojize-symbols):
* lisp/gnus/gnus-int.el (gnus-close-server):
* lisp/gnus/gnus-search.el (gnus-search-transform)
(gnus-search-indexed-parse-output, gnus-search-server-to-engine):
* lisp/gnus/gnus-sum.el (gnus-collect-urls, gnus-shorten-url):
* lisp/gnus/gnus.el (gnus-check-backend-function):
* lisp/gnus/message.el (message-send-mail):
* lisp/gnus/mml.el (mml-generate-mime, mml-insert-mime-headers):
* lisp/gnus/nnatom.el (nnatom--read-feed, nnatom--read-article)
(nnatom--read-article-or-group-authors, nnatom--read-publish)
(nnatom--read-update, nnatom--read-links):
* lisp/gnus/nnfeed.el (nnfeed--read-server, nnfeed--write-server)
(nnfeed--parse-feed, nnfeed--group-data, nnfeed-retrieve-article)
(nnfeed-retrieve-headers, nnfeed--print-part)
(nnfeed-request-article, nnfeed-request-group)
(nnfeed-request-list, nnfeed--group-description)
(nnfeed-request-group-description)
(nnfeed-request-list-newsgroups, nnfeed-request-rename-group):
* lisp/gnus/nnmh.el (nnmh-update-gnus-unreads):
* lisp/help-fns.el (help-find-source)
(help-fns--insert-menu-bindings, help-fns--mention-first-release)
(help-fns--mention-shortdoc-groups)
(help-fns--customize-variable-version)
(help-fns--face-custom-version-info, describe-mode):
* lisp/help-mode.el (help-make-xrefs):
* lisp/help.el (help-key-description, help--describe-command):
* lisp/hfy-cmap.el (htmlfontify-load-rgb-file):
* lisp/ibuf-ext.el (ibuffer-jump-to-filter-group)
(ibuffer-kill-filter-group, ibuffer-kill-line)
(ibuffer-save-filter-groups, ibuffer-save-filters, filename)
(basename, file-extension, ibuffer-diff-buffer-with-file-1)
(ibuffer-mark-by-file-name-regexp)
(ibuffer-mark-by-content-regexp):
* lisp/ibuf-macs.el (ibuffer-aif, ibuffer-awhen):
* lisp/ibuffer.el (ibuffer-mouse-toggle-mark)
(ibuffer-toggle-marks, ibuffer-mark-interactive)
(ibuffer-compile-format, process, ibuffer-map-lines):
* lisp/image.el (image--compute-map)
(image--compute-original-map):
* lisp/image/exif.el (exif-parse-buffer):
* lisp/image/image-converter.el (image-convert-p, image-convert)
(image-converter--find-converter):
* lisp/image/image-dired-util.el
(image-dired-file-name-at-point):
* lisp/image/image-dired.el (image-dired-track-original-file)
(image-dired--on-file-in-dired-buffer)
(image-dired--with-thumbnail-buffer)
(image-dired-jump-original-dired-buffer)
(image-dired--slideshow-step, image-dired-display-image):
* lisp/image/wallpaper.el (wallpaper--init-action-kill)
(wallpaper--find-setter, wallpaper--find-command)
(wallpaper--find-command-args, wallpaper--x-monitor-name):
* lisp/info-look.el (info-lookup-interactive-arguments)
(info-complete)::(:mode):
* lisp/info.el (info-pop-to-buffer, Info-read-node-name-1):
* lisp/international/emoji.el (emoji--adjust-displayable-1)
(emoji--add-recent):
* lisp/jsonrpc.el (jsonrpc--call-deferred)
(jsonrpc--process-sentinel, jsonrpc--remove):
* lisp/keymap.el (keymap-local-lookup):
* lisp/mail/emacsbug.el (report-emacs-bug-hook)
(submit-emacs-patch):
* lisp/mail/ietf-drums.el (ietf-drums-parse-addresses):
* lisp/mail/mailclient.el (mailclient-send-it):
* lisp/mail/rfc6068.el (rfc6068-parse-mailto-url):
* lisp/mail/undigest.el (rmail-digest-parse-mixed-mime):
* lisp/minibuffer.el (completion-metadata-get)
(completions--after-change)
(minibuffer-visible-completions--filter):
* lisp/net/browse-url.el (browse-url-url-at-point)
(browse-url-file-url, browse-url-emacs):
* lisp/net/dbus.el (dbus-byte-array-to-string)
(dbus-monitor-goto-serial):
* lisp/net/dictionary.el (dictionary-search):
* lisp/net/eww.el (eww--download-directory)
(eww-auto-rename-buffer, eww-open-in-new-buffer, eww-submit)
(eww-follow-link, eww-read-alternate-url)
(eww-copy-alternate-url):
* lisp/net/goto-addr.el (goto-address-at-point):
* lisp/net/mailcap.el (mailcap-mime-info):
* lisp/net/rcirc.el (rcirc, rcirc-connect, rcirc-send-string)
(rcirc-kill-buffer-hook, rcirc-print, rcirc-when)
(rcirc-color-attributes, rcirc-handler-NICK)
(rcirc-handler-TAGMSG, rcirc-handler-BATCH):
* lisp/net/shr.el (shr-descend, shr-adaptive-fill-function)
(shr-correct-dom-case, shr-tag-a):
* lisp/net/sieve.el (sieve-manage-quit):
* lisp/outline.el (outline-cycle-buffer):
* lisp/pcmpl-git.el (pcmpl-git--tracked-file-predicate):
* lisp/proced.el (proced-auto-update-timer):
* lisp/progmodes/bug-reference.el
(bug-reference-try-setup-from-vc):
* lisp/progmodes/c-ts-common.el (c-ts-common--fill-paragraph):
* lisp/progmodes/c-ts-mode.el (c-ts-mode--preproc-offset)
(c-ts-mode--anchor-prev-sibling, c-ts-mode-indent-defun):
* lisp/progmodes/compile.el (compilation-error-properties)
(compilation-find-file-1):
* lisp/progmodes/eglot.el (eglot--check-object)
(eglot--read-server, eglot-upgrade-eglot)
(eglot-handle-notification, eglot--CompletionParams)
(eglot-completion-at-point, eglot--sig-info)
(eglot-register-capability):
* lisp/progmodes/elisp-mode.el
(emacs-lisp-native-compile-and-load)
(elisp-eldoc-var-docstring-with-value):
* lisp/progmodes/erts-mode.el (erts-mode--goto-start-of-test):
* lisp/progmodes/flymake.el (flymake--update-eol-overlays)
(flymake-eldoc-function):
* lisp/progmodes/gdb-mi.el (gdb-breakpoints-list-handler-custom)
(gdb-frame-handler):
* lisp/progmodes/go-ts-mode.el (go-ts-mode-docstring)
(go-ts-mode--comment-on-previous-line-p)
(go-ts-mode--get-test-regexp-at-point)
(go-ts-mode-test-this-file):
* lisp/progmodes/grep.el (lgrep, rgrep-default-command)
(grep-file-at-point):
* lisp/progmodes/perl-mode.el (perl--end-of-format-p):
* lisp/progmodes/php-ts-mode.el
(php-ts-mode--anchor-prev-sibling, php-ts-mode--indent-defun):
* lisp/progmodes/project.el (project--other-place-command)
(project--find-default-from, project--transplant-file-name)
(project-prefixed-buffer-name, project--remove-from-project-list)
(project-prompt-project-name, project-remember-projects-under)
(project--switch-project-command)
(project-uniquify-dirname-transform, project-mode-line-format):
* lisp/progmodes/python.el
(python-font-lock-keywords-maximum-decoration)
(python--treesit-fontify-union-types)
(python-shell-get-process-name, python-shell-restart)
(python-shell-completion-at-point, python-ffap-module-path)
(python-util-comint-end-of-output-p, python--import-sources)
(python-add-import, python-remove-import, python-fix-imports):
* lisp/progmodes/xref.el (xref--add-log-current-defun):
* lisp/repeat.el (repeat-echo-message-string):
* lisp/saveplace.el (save-place-dired-hook):
* lisp/server.el (server-save-buffers-kill-terminal):
* lisp/shadowfile.el (shadow-make-fullname)
(shadow-contract-file-name, shadow-define-literal-group):
* lisp/shell.el (shell-highlight-undef-mode):
* lisp/simple.el (command-completion-using-modes-p)
(command-execute, file-user-uid, file-group-gid)
(first-completion, last-completion, switch-to-completions):
* lisp/startup.el (startup--load-user-init-file):
* lisp/tab-line.el (tab-line-tabs-buffer-group-by-project):
* lisp/tar-mode.el (tar-goto-file, tar-next-file-displayer):
* lisp/term/android-win.el (android-encode-select-string)
(gui-backend-set-selection):
* lisp/term/haiku-win.el (haiku-dnd-convert-string)
(haiku-select-encode-xstring, haiku-select-encode-utf-8-string):
* lisp/textmodes/emacs-news-mode.el (emacs-news--buttonize):
* lisp/textmodes/ispell.el (ispell-completion-at-point):
* lisp/textmodes/sgml-mode.el (sgml-validate)
(html-mode--complete-at-point):
* lisp/textmodes/tex-mode.el (tex-recenter-output-buffer)
(xref-backend-references):
* lisp/thingatpt.el (thing-at-point-file-at-point)
(thing-at-point-face-at-point):
* lisp/thread.el (thread-list--get-status):
* lisp/time.el (world-clock-copy-time-as-kill, world-clock):
* lisp/touch-screen.el (touch-screen-handle-touch):
* lisp/treesit.el (treesit-language-at, treesit-node-at)
(treesit-node-on, treesit-buffer-root-node)
(treesit-node-field-name, treesit-local-parsers-at)
(treesit-local-parsers-on, treesit--cleanup-local-range-overlays)
(treesit-font-lock-recompute-features)
(treesit-font-lock-fontify-region, treesit-transpose-sexps)
(treesit-add-log-current-defun, treesit-major-mode-setup)
(treesit--explorer-refresh, treesit-install-language-grammar):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/vc/smerge-mode.el (smerge-diff):
* lisp/vc/vc-dir.el (vc-dir):
* lisp/vc/vc-dispatcher.el (vc-do-async-command):
* lisp/vc/vc-git.el (vc-git-dir--branch-headers)
(vc-git-dir--stash-headers, vc-git--log-edit-summary-check)
(vc-git-stash-list):
* lisp/vc/vc.el (vc-responsible-backend, vc-buffer-sync-fileset)
(vc-clone):
* lisp/visual-wrap.el (visual-wrap--apply-to-line):
* lisp/wid-edit.el (widget-text)
(widget-editable-list-insert-before):
* lisp/window-tool-bar.el
(window-tool-bar--keymap-entry-to-string):
* lisp/window.el (display-buffer, display-buffer-full-frame)
(window-point-context-set, window-point-context-use)
(window-point-context-use-default-function):
* lisp/xdg.el (xdg-current-desktop):
* lisp/xwidget.el (xwidget-webkit-callback):
* lisp/yank-media.el (yank-media--get-selection)
(yank-media-types):
* test/lisp/comint-tests.el
(comint-tests/test-password-function):
* test/lisp/completion-preview-tests.el
(completion-preview-tests--capf):
* test/lisp/cus-edit-tests.el (with-cus-edit-test):
* test/lisp/erc/erc-scenarios-base-local-modules.el
(-phony-sblm-):
* test/lisp/erc/erc-scenarios-stamp.el
(erc-scenarios-stamp--on-post-modify):
* test/lisp/erc/erc-services-tests.el
(erc-services-tests--asp-parse-entry):
* test/lisp/erc/erc-tests.el (erc-modules--internal-property)
(erc--find-mode, erc-tests--update-modules):
* test/lisp/erc/resources/erc-d/erc-d-i.el
(erc-d-i--parse-message):
* test/lisp/erc/resources/erc-d/erc-d-t.el
(erc-d-t-kill-related-buffers, erc-d-t-with-cleanup):
* test/lisp/erc/resources/erc-d/erc-d-tests.el
(erc-d-i--parse-message--irc-parser-tests):
* test/lisp/erc/resources/erc-d/erc-d-u.el
(erc-d-u--read-exchange-slowly):
* test/lisp/erc/resources/erc-d/erc-d.el (erc-d--expire)
(erc-d--finalize-done, erc-d--command-handle-all):
* test/lisp/erc/resources/erc-scenarios-common.el
(erc-scenarios-common-with-cleanup):
* test/lisp/erc/resources/erc-tests-common.el
(erc-tests--common-display-message)
(erc-tests-common-create-subprocess):
* test/lisp/ibuffer-tests.el (ibuffer-test-Bug25058):
* test/lisp/international/mule-tests.el
(mule-cmds-tests--ucs-names-missing-names):
* test/lisp/progmodes/python-tests.el
(python-tests-get-shell-interpreter)
(python-tests--get-interpreter-info):
* test/lisp/progmodes/ruby-ts-mode-tests.el
(ruby-ts-resource-file):
* test/lisp/replace-tests.el (replace-tests-with-undo):
* test/src/emacs-tests.el (emacs-tests--seccomp-debug):
* test/src/process-tests.el (process-tests--emacs-command)
(process-tests--emacs-binary, process-tests--dump-file):
* test/src/treesit-tests.el (treesit--ert-test-defun-navigation):
Replace use of the now-obsolete if-let and when-let.
2024-10-24 16:50:07 +08:00
|
|
|
(or (when-let* ((data (completion-preview--try-table
|
|
|
|
table beg end plist)))
|
2024-04-12 22:41:10 +02:00
|
|
|
`(,(+ beg (length (car data))) ,end ,plist ,@data))
|
2023-11-20 12:45:11 +01:00
|
|
|
(unless (eq 'no (plist-get plist :exclusive))
|
|
|
|
;; Return non-nil to exclude other capfs.
|
|
|
|
'(nil)))))))
|
2023-11-19 10:55:15 +01:00
|
|
|
|
2023-11-02 16:58:31 +01:00
|
|
|
(defun completion-preview--update ()
|
|
|
|
"Update completion preview."
|
2024-04-12 22:41:10 +02:00
|
|
|
(seq-let (beg end props base common suffixes)
|
2023-11-19 10:55:15 +01:00
|
|
|
(run-hook-wrapped
|
|
|
|
'completion-at-point-functions
|
|
|
|
#'completion-preview--capf-wrapper)
|
Mark if-let and when-let obsolete
* lisp/subr.el (if-let*, when-let*, if-let, when-let): Mark
if-let and when-let obsolete (bug#73853 and elsewhere). Move
docstring text around so that if-let* and when-let* descriptions
no longer refer to if-let and when-let.
* etc/NEWS: Announce the change.
* admin/admin.el (reminder-for-release-blocking-bugs):
* doc/misc/erc.texi (display-buffer):
* lisp/ansi-color.el (ansi-color-apply)
(ansi-color--face-vec-face):
* lisp/ansi-osc.el (ansi-osc-apply-on-region)
(ansi-osc-hyperlink):
* lisp/arc-mode.el (archive-goto-file)
(archive-next-file-displayer):
* lisp/auth-source-pass.el (auth-source-pass-search)
(auth-source-pass--parse-data)
(auth-source-pass--find-match-many):
* lisp/autorevert.el (auto-revert-notify-rm-watch):
* lisp/buff-menu.el (Buffer-menu-unmark-all-buffers)
(Buffer-menu-group-by-root):
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
* lisp/cedet/pulse.el (pulse-tick):
* lisp/comint.el (comint--fontify-input-ppss-flush-indirect)
(comint--intersect-regions):
* lisp/completion-preview.el (completion-preview--try-table)
(completion-preview--capf-wrapper, completion-preview--update):
* lisp/cus-edit.el (setopt--set)
(custom-dirlocals-maybe-update-cons, custom-dirlocals-validate):
* lisp/custom.el (load-theme):
* lisp/descr-text.el (describe-char):
* lisp/desktop.el (desktop--emacs-pid-running-p):
* lisp/dired-x.el (menu):
* lisp/dired.el (dired-font-lock-keywords)
(dired-insert-directory, dired--insert-disk-space, dired-mode):
* lisp/dnd.el (dnd-handle-multiple-urls):
* lisp/dom.el (dom-remove-attribute):
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
* lisp/emacs-lisp/bytecomp.el (bytecomp--custom-declare):
* lisp/emacs-lisp/comp-common.el (comp-function-type-spec):
* lisp/emacs-lisp/comp-cstr.el (comp--all-classes)
(comp-cstr-set-range-for-arithm, comp--cstr-union-1-no-mem)
(comp-cstr-intersection-no-mem, comp-cstr-fixnum-p)
(comp-cstr-type-p):
* lisp/emacs-lisp/comp-run.el (comp-subr-trampoline-install)
(native--compile-async):
* lisp/emacs-lisp/comp.el (comp--get-function-cstr)
(comp--function-pure-p, comp--intern-func-in-ctxt)
(comp--addr-to-bb-name, comp--emit-assume, comp--maybe-add-vmvar)
(comp--add-call-cstr, comp--compute-dominator-tree)
(comp--dom-tree-walker, comp--ssa-rename)
(comp--function-call-maybe-fold, comp--fwprop-call)
(comp--call-optim-func):
* lisp/emacs-lisp/edebug.el (edebug-global-prefix)
(edebug-remove-instrumentation):
* lisp/emacs-lisp/eieio.el (initialize-instance):
* lisp/emacs-lisp/ert-x.el (ert-resource-directory):
* lisp/emacs-lisp/ert.el (ert--expand-should-1)
(ert-test-location, ert-write-junit-test-report)
(ert-test--erts-test):
* lisp/emacs-lisp/icons.el (icon-complete-spec, icon-string)
(icons--create):
* lisp/emacs-lisp/lisp-mode.el (lisp--local-defform-body-p):
* lisp/emacs-lisp/loaddefs-gen.el
(loaddefs-generate--make-autoload)
(loaddefs-generate--parse-file):
* lisp/emacs-lisp/multisession.el
(multisession-edit-mode--revert, multisession-edit-value):
* lisp/emacs-lisp/package-vc.el (package-vc--read-archive-data)
(package-vc--version, package-vc--clone):
* lisp/emacs-lisp/package.el (package--reload-previously-loaded):
* lisp/emacs-lisp/pp.el (pp--insert-lisp):
* lisp/emacs-lisp/subr-x.el (add-display-text-property):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-print):
* lisp/emacs-lisp/timer.el (run-at-time):
* lisp/emacs-lisp/vtable.el (vtable-goto-table)
(vtable-goto-column, vtable-update-object, vtable--insert-line)
(vtable--compute-widths, vtable--make-keymap):
* lisp/emacs-lisp/warnings.el (display-warning):
* lisp/epa-file.el (epa-file-insert-file-contents):
* lisp/epa.el (epa-show-key):
* lisp/erc/erc-backend.el (erc--split-line, erc--conceal-prompt)
(PRIVMSG, erc--get-isupport-entry):
* lisp/erc/erc-button.el (erc-button-add-nickname-buttons)
(erc--button-next):
* lisp/erc/erc-common.el (erc--find-group):
* lisp/erc/erc-fill.el (erc-fill, erc-fill-static)
(erc-fill--wrap-escape-hidden-speaker)
(erc-fill--wrap-unmerge-on-date-stamp)
(erc-fill--wrap-massage-initial-message-post-clear)
(erc-fill-wrap, erc-fill--wrap-rejigger-region):
* lisp/erc/erc-goodies.el (erc--scrolltobottom-all)
(erc--keep-place-indicator-on-window-buffer-change)
(keep-place-indicator, erc--keep-place-indicator-adjust-on-clear)
(erc-keep-place-move, erc--command-indicator-display):
* lisp/erc/erc-ibuffer.el (erc-members):
* lisp/erc/erc-join.el (erc-join--remove-requested-channel)
(erc-autojoin--join):
* lisp/erc/erc-networks.el
(erc-networks--id-qualifying-init-parts, erc-networks--id-reload)
(erc-networks--id-ensure-comparable)
(erc-networks--reclaim-orphaned-target-buffers)
(erc-networks--server-select):
* lisp/erc/erc-nicks.el (erc-nicks-invert)
(erc-nicks--redirect-face-widget-link, erc-nicks--highlight)
(erc-nicks--highlight-button)
(erc-nicks--list-faces-help-button-action, erc-nicks-list-faces)
(erc-nicks-refresh, erc-nicks--colors-from-faces)
(erc-nicks--track-prioritize)
(erc-nicks--remember-face-for-track):
* lisp/erc/erc-notify.el (querypoll, erc--querypoll-get-next)
(erc--querypoll-on-352, erc--querypoll-send):
* lisp/erc/erc-sasl.el (erc-sasl--read-password):
* lisp/erc/erc-services.el
(erc-services-issue-ghost-and-retry-nick):
* lisp/erc/erc-speedbar.el (erc-speedbar--ensure, nickbar)
(erc-speedbar-toggle-nicknames-window-lock)
(erc-speedbar--compose-nicks-face):
* lisp/erc/erc-stamp.el (erc-stamp--recover-on-reconnect)
(erc-stamp-prefix-log-filter, erc--conceal-prompt)
(erc--insert-timestamp-left, erc-insert-timestamp-right)
(erc-stamp--defer-date-insertion-on-post-modify)
(erc-insert-timestamp-left-and-right)
(erc-stamp--redo-right-stamp-post-clear)
(erc-stamp--reset-on-clear, erc-stamp--dedupe-date-stamps):
* lisp/erc/erc-status-sidebar.el (bufbar)
(erc-status-sidebar-prefer-target-as-name)
(erc-status-sidebar-default-allsort, erc-status-sidebar-click):
* lisp/erc/erc-track.el (erc-track--shortened-names-get)
(erc-track--setup, erc-track--select-mode-line-face)
(erc-track-modified-channels, erc-track--collect-faces-in)
(erc-track--switch-buffer, erc-track--replace-killed-buffer):
* lisp/erc/erc-truncate.el (erc-truncate--setup)
(erc-truncate-buffer):
* lisp/erc/erc.el (erc--ensure-query-member)
(erc--ensure-query-members, erc--remove-channel-users-but)
(erc--cusr-change-status, erc--find-mode, erc--update-modules)
(erc-log-irc-protocol, erc--refresh-prompt)
(erc--restore-important-text-props)
(erc--order-text-properties-from-hash, erc-send-input-line)
(erc-cmd-IGNORE, erc--unignore-user, erc-cmd-QUERY)
(erc-cmd-BANLIST, erc--speakerize-nick)
(erc--format-speaker-input-message, erc-channel-receive-names)
(erc-send-current-line, erc-format-target-and/or-network)
(erc-kill-buffer-function, erc-restore-text-properties)
(erc--get-eq-comparable-cmd):
* lisp/eshell/em-alias.el (eshell-maybe-replace-by-alias--which)
(eshell-maybe-replace-by-alias):
* lisp/eshell/em-glob.el (eshell-glob-convert):
* lisp/eshell/em-pred.el (eshell-pred-user-or-group)
(eshell-pred-file-time, eshell-pred-file-type)
(eshell-pred-file-mode, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-prompt.el (eshell-forward-paragraph)
(eshell-next-prompt):
* lisp/eshell/esh-arg.el (eshell-resolve-current-argument):
* lisp/eshell/esh-cmd.el (eshell-do-eval, eshell/which)
(eshell-plain-command--which, eshell-plain-command):
* lisp/eshell/esh-io.el (eshell-duplicate-handles)
(eshell-protect-handles, eshell-get-target, eshell-close-target):
* lisp/eshell/esh-proc.el (eshell-sentinel):
* lisp/eshell/esh-var.el (eshell-parse-variable-ref)
(eshell-get-variable, eshell-set-variable):
* lisp/faces.el (face-at-point):
* lisp/ffap.el (ffap-in-project):
* lisp/filenotify.el (file-notify--rm-descriptor):
* lisp/files-x.el (read-dir-locals-file)
(connection-local-update-profile-variables)
(connection-local-value):
* lisp/files.el (file-remote-p, abbreviate-file-name)
(set-auto-mode, hack-local-variables)
(revert-buffer-restore-read-only):
* lisp/find-dired.el (find-dired-sort-by-filename):
* lisp/font-lock.el (font-lock--filter-keywords):
* lisp/gnus/gnus-art.el (article-emojize-symbols):
* lisp/gnus/gnus-int.el (gnus-close-server):
* lisp/gnus/gnus-search.el (gnus-search-transform)
(gnus-search-indexed-parse-output, gnus-search-server-to-engine):
* lisp/gnus/gnus-sum.el (gnus-collect-urls, gnus-shorten-url):
* lisp/gnus/gnus.el (gnus-check-backend-function):
* lisp/gnus/message.el (message-send-mail):
* lisp/gnus/mml.el (mml-generate-mime, mml-insert-mime-headers):
* lisp/gnus/nnatom.el (nnatom--read-feed, nnatom--read-article)
(nnatom--read-article-or-group-authors, nnatom--read-publish)
(nnatom--read-update, nnatom--read-links):
* lisp/gnus/nnfeed.el (nnfeed--read-server, nnfeed--write-server)
(nnfeed--parse-feed, nnfeed--group-data, nnfeed-retrieve-article)
(nnfeed-retrieve-headers, nnfeed--print-part)
(nnfeed-request-article, nnfeed-request-group)
(nnfeed-request-list, nnfeed--group-description)
(nnfeed-request-group-description)
(nnfeed-request-list-newsgroups, nnfeed-request-rename-group):
* lisp/gnus/nnmh.el (nnmh-update-gnus-unreads):
* lisp/help-fns.el (help-find-source)
(help-fns--insert-menu-bindings, help-fns--mention-first-release)
(help-fns--mention-shortdoc-groups)
(help-fns--customize-variable-version)
(help-fns--face-custom-version-info, describe-mode):
* lisp/help-mode.el (help-make-xrefs):
* lisp/help.el (help-key-description, help--describe-command):
* lisp/hfy-cmap.el (htmlfontify-load-rgb-file):
* lisp/ibuf-ext.el (ibuffer-jump-to-filter-group)
(ibuffer-kill-filter-group, ibuffer-kill-line)
(ibuffer-save-filter-groups, ibuffer-save-filters, filename)
(basename, file-extension, ibuffer-diff-buffer-with-file-1)
(ibuffer-mark-by-file-name-regexp)
(ibuffer-mark-by-content-regexp):
* lisp/ibuf-macs.el (ibuffer-aif, ibuffer-awhen):
* lisp/ibuffer.el (ibuffer-mouse-toggle-mark)
(ibuffer-toggle-marks, ibuffer-mark-interactive)
(ibuffer-compile-format, process, ibuffer-map-lines):
* lisp/image.el (image--compute-map)
(image--compute-original-map):
* lisp/image/exif.el (exif-parse-buffer):
* lisp/image/image-converter.el (image-convert-p, image-convert)
(image-converter--find-converter):
* lisp/image/image-dired-util.el
(image-dired-file-name-at-point):
* lisp/image/image-dired.el (image-dired-track-original-file)
(image-dired--on-file-in-dired-buffer)
(image-dired--with-thumbnail-buffer)
(image-dired-jump-original-dired-buffer)
(image-dired--slideshow-step, image-dired-display-image):
* lisp/image/wallpaper.el (wallpaper--init-action-kill)
(wallpaper--find-setter, wallpaper--find-command)
(wallpaper--find-command-args, wallpaper--x-monitor-name):
* lisp/info-look.el (info-lookup-interactive-arguments)
(info-complete)::(:mode):
* lisp/info.el (info-pop-to-buffer, Info-read-node-name-1):
* lisp/international/emoji.el (emoji--adjust-displayable-1)
(emoji--add-recent):
* lisp/jsonrpc.el (jsonrpc--call-deferred)
(jsonrpc--process-sentinel, jsonrpc--remove):
* lisp/keymap.el (keymap-local-lookup):
* lisp/mail/emacsbug.el (report-emacs-bug-hook)
(submit-emacs-patch):
* lisp/mail/ietf-drums.el (ietf-drums-parse-addresses):
* lisp/mail/mailclient.el (mailclient-send-it):
* lisp/mail/rfc6068.el (rfc6068-parse-mailto-url):
* lisp/mail/undigest.el (rmail-digest-parse-mixed-mime):
* lisp/minibuffer.el (completion-metadata-get)
(completions--after-change)
(minibuffer-visible-completions--filter):
* lisp/net/browse-url.el (browse-url-url-at-point)
(browse-url-file-url, browse-url-emacs):
* lisp/net/dbus.el (dbus-byte-array-to-string)
(dbus-monitor-goto-serial):
* lisp/net/dictionary.el (dictionary-search):
* lisp/net/eww.el (eww--download-directory)
(eww-auto-rename-buffer, eww-open-in-new-buffer, eww-submit)
(eww-follow-link, eww-read-alternate-url)
(eww-copy-alternate-url):
* lisp/net/goto-addr.el (goto-address-at-point):
* lisp/net/mailcap.el (mailcap-mime-info):
* lisp/net/rcirc.el (rcirc, rcirc-connect, rcirc-send-string)
(rcirc-kill-buffer-hook, rcirc-print, rcirc-when)
(rcirc-color-attributes, rcirc-handler-NICK)
(rcirc-handler-TAGMSG, rcirc-handler-BATCH):
* lisp/net/shr.el (shr-descend, shr-adaptive-fill-function)
(shr-correct-dom-case, shr-tag-a):
* lisp/net/sieve.el (sieve-manage-quit):
* lisp/outline.el (outline-cycle-buffer):
* lisp/pcmpl-git.el (pcmpl-git--tracked-file-predicate):
* lisp/proced.el (proced-auto-update-timer):
* lisp/progmodes/bug-reference.el
(bug-reference-try-setup-from-vc):
* lisp/progmodes/c-ts-common.el (c-ts-common--fill-paragraph):
* lisp/progmodes/c-ts-mode.el (c-ts-mode--preproc-offset)
(c-ts-mode--anchor-prev-sibling, c-ts-mode-indent-defun):
* lisp/progmodes/compile.el (compilation-error-properties)
(compilation-find-file-1):
* lisp/progmodes/eglot.el (eglot--check-object)
(eglot--read-server, eglot-upgrade-eglot)
(eglot-handle-notification, eglot--CompletionParams)
(eglot-completion-at-point, eglot--sig-info)
(eglot-register-capability):
* lisp/progmodes/elisp-mode.el
(emacs-lisp-native-compile-and-load)
(elisp-eldoc-var-docstring-with-value):
* lisp/progmodes/erts-mode.el (erts-mode--goto-start-of-test):
* lisp/progmodes/flymake.el (flymake--update-eol-overlays)
(flymake-eldoc-function):
* lisp/progmodes/gdb-mi.el (gdb-breakpoints-list-handler-custom)
(gdb-frame-handler):
* lisp/progmodes/go-ts-mode.el (go-ts-mode-docstring)
(go-ts-mode--comment-on-previous-line-p)
(go-ts-mode--get-test-regexp-at-point)
(go-ts-mode-test-this-file):
* lisp/progmodes/grep.el (lgrep, rgrep-default-command)
(grep-file-at-point):
* lisp/progmodes/perl-mode.el (perl--end-of-format-p):
* lisp/progmodes/php-ts-mode.el
(php-ts-mode--anchor-prev-sibling, php-ts-mode--indent-defun):
* lisp/progmodes/project.el (project--other-place-command)
(project--find-default-from, project--transplant-file-name)
(project-prefixed-buffer-name, project--remove-from-project-list)
(project-prompt-project-name, project-remember-projects-under)
(project--switch-project-command)
(project-uniquify-dirname-transform, project-mode-line-format):
* lisp/progmodes/python.el
(python-font-lock-keywords-maximum-decoration)
(python--treesit-fontify-union-types)
(python-shell-get-process-name, python-shell-restart)
(python-shell-completion-at-point, python-ffap-module-path)
(python-util-comint-end-of-output-p, python--import-sources)
(python-add-import, python-remove-import, python-fix-imports):
* lisp/progmodes/xref.el (xref--add-log-current-defun):
* lisp/repeat.el (repeat-echo-message-string):
* lisp/saveplace.el (save-place-dired-hook):
* lisp/server.el (server-save-buffers-kill-terminal):
* lisp/shadowfile.el (shadow-make-fullname)
(shadow-contract-file-name, shadow-define-literal-group):
* lisp/shell.el (shell-highlight-undef-mode):
* lisp/simple.el (command-completion-using-modes-p)
(command-execute, file-user-uid, file-group-gid)
(first-completion, last-completion, switch-to-completions):
* lisp/startup.el (startup--load-user-init-file):
* lisp/tab-line.el (tab-line-tabs-buffer-group-by-project):
* lisp/tar-mode.el (tar-goto-file, tar-next-file-displayer):
* lisp/term/android-win.el (android-encode-select-string)
(gui-backend-set-selection):
* lisp/term/haiku-win.el (haiku-dnd-convert-string)
(haiku-select-encode-xstring, haiku-select-encode-utf-8-string):
* lisp/textmodes/emacs-news-mode.el (emacs-news--buttonize):
* lisp/textmodes/ispell.el (ispell-completion-at-point):
* lisp/textmodes/sgml-mode.el (sgml-validate)
(html-mode--complete-at-point):
* lisp/textmodes/tex-mode.el (tex-recenter-output-buffer)
(xref-backend-references):
* lisp/thingatpt.el (thing-at-point-file-at-point)
(thing-at-point-face-at-point):
* lisp/thread.el (thread-list--get-status):
* lisp/time.el (world-clock-copy-time-as-kill, world-clock):
* lisp/touch-screen.el (touch-screen-handle-touch):
* lisp/treesit.el (treesit-language-at, treesit-node-at)
(treesit-node-on, treesit-buffer-root-node)
(treesit-node-field-name, treesit-local-parsers-at)
(treesit-local-parsers-on, treesit--cleanup-local-range-overlays)
(treesit-font-lock-recompute-features)
(treesit-font-lock-fontify-region, treesit-transpose-sexps)
(treesit-add-log-current-defun, treesit-major-mode-setup)
(treesit--explorer-refresh, treesit-install-language-grammar):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/vc/smerge-mode.el (smerge-diff):
* lisp/vc/vc-dir.el (vc-dir):
* lisp/vc/vc-dispatcher.el (vc-do-async-command):
* lisp/vc/vc-git.el (vc-git-dir--branch-headers)
(vc-git-dir--stash-headers, vc-git--log-edit-summary-check)
(vc-git-stash-list):
* lisp/vc/vc.el (vc-responsible-backend, vc-buffer-sync-fileset)
(vc-clone):
* lisp/visual-wrap.el (visual-wrap--apply-to-line):
* lisp/wid-edit.el (widget-text)
(widget-editable-list-insert-before):
* lisp/window-tool-bar.el
(window-tool-bar--keymap-entry-to-string):
* lisp/window.el (display-buffer, display-buffer-full-frame)
(window-point-context-set, window-point-context-use)
(window-point-context-use-default-function):
* lisp/xdg.el (xdg-current-desktop):
* lisp/xwidget.el (xwidget-webkit-callback):
* lisp/yank-media.el (yank-media--get-selection)
(yank-media-types):
* test/lisp/comint-tests.el
(comint-tests/test-password-function):
* test/lisp/completion-preview-tests.el
(completion-preview-tests--capf):
* test/lisp/cus-edit-tests.el (with-cus-edit-test):
* test/lisp/erc/erc-scenarios-base-local-modules.el
(-phony-sblm-):
* test/lisp/erc/erc-scenarios-stamp.el
(erc-scenarios-stamp--on-post-modify):
* test/lisp/erc/erc-services-tests.el
(erc-services-tests--asp-parse-entry):
* test/lisp/erc/erc-tests.el (erc-modules--internal-property)
(erc--find-mode, erc-tests--update-modules):
* test/lisp/erc/resources/erc-d/erc-d-i.el
(erc-d-i--parse-message):
* test/lisp/erc/resources/erc-d/erc-d-t.el
(erc-d-t-kill-related-buffers, erc-d-t-with-cleanup):
* test/lisp/erc/resources/erc-d/erc-d-tests.el
(erc-d-i--parse-message--irc-parser-tests):
* test/lisp/erc/resources/erc-d/erc-d-u.el
(erc-d-u--read-exchange-slowly):
* test/lisp/erc/resources/erc-d/erc-d.el (erc-d--expire)
(erc-d--finalize-done, erc-d--command-handle-all):
* test/lisp/erc/resources/erc-scenarios-common.el
(erc-scenarios-common-with-cleanup):
* test/lisp/erc/resources/erc-tests-common.el
(erc-tests--common-display-message)
(erc-tests-common-create-subprocess):
* test/lisp/ibuffer-tests.el (ibuffer-test-Bug25058):
* test/lisp/international/mule-tests.el
(mule-cmds-tests--ucs-names-missing-names):
* test/lisp/progmodes/python-tests.el
(python-tests-get-shell-interpreter)
(python-tests--get-interpreter-info):
* test/lisp/progmodes/ruby-ts-mode-tests.el
(ruby-ts-resource-file):
* test/lisp/replace-tests.el (replace-tests-with-undo):
* test/src/emacs-tests.el (emacs-tests--seccomp-debug):
* test/src/process-tests.el (process-tests--emacs-command)
(process-tests--emacs-binary, process-tests--dump-file):
* test/src/treesit-tests.el (treesit--ert-test-defun-navigation):
Replace use of the now-obsolete if-let and when-let.
2024-10-24 16:50:07 +08:00
|
|
|
(when-let* ((suffix (car suffixes)))
|
2024-04-12 22:41:10 +02:00
|
|
|
(set-text-properties 0 (length suffix)
|
|
|
|
(list 'face (if (cdr suffixes)
|
|
|
|
'completion-preview
|
|
|
|
'completion-preview-exact))
|
|
|
|
suffix)
|
|
|
|
(set-text-properties 0 (length common)
|
|
|
|
(list 'face (if (cdr suffixes)
|
|
|
|
'completion-preview-common
|
|
|
|
'completion-preview-exact))
|
|
|
|
common)
|
|
|
|
(let ((ov (completion-preview--make-overlay
|
2025-02-26 20:41:09 +01:00
|
|
|
end (completion-preview--propertize-for-mouse
|
|
|
|
(concat (substring common (- end beg)) suffix)))))
|
2023-11-19 10:55:15 +01:00
|
|
|
(overlay-put ov 'completion-preview-beg beg)
|
|
|
|
(overlay-put ov 'completion-preview-end end)
|
|
|
|
(overlay-put ov 'completion-preview-index 0)
|
2024-04-12 22:41:10 +02:00
|
|
|
(overlay-put ov 'completion-preview-suffixes suffixes)
|
|
|
|
(overlay-put ov 'completion-preview-common common)
|
2023-11-20 12:45:11 +01:00
|
|
|
(overlay-put ov 'completion-preview-base base)
|
2024-04-12 22:41:10 +02:00
|
|
|
(overlay-put ov 'completion-preview-props props)
|
2023-11-19 10:55:15 +01:00
|
|
|
(completion-preview-active-mode)))))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
2024-06-05 10:23:56 +02:00
|
|
|
(defun completion-preview--try-update ()
|
|
|
|
"Try to update completion preview, but give up as soon as input arrives."
|
|
|
|
(while-no-input (completion-preview--update)))
|
|
|
|
|
|
|
|
(defun completion-preview--update-from-timer (window buffer)
|
|
|
|
"Update completion preview if WINDOW and BUFFER are current."
|
|
|
|
(when (and (eq (selected-window) window) (eq (current-buffer) buffer))
|
|
|
|
(completion-preview--try-update)))
|
|
|
|
|
|
|
|
(defvar-local completion-preview--timer nil
|
|
|
|
"Idle timer for updating the completion preview.")
|
|
|
|
|
2023-11-02 16:58:31 +01:00
|
|
|
(defun completion-preview--show ()
|
|
|
|
"Show a new completion preview.
|
|
|
|
|
|
|
|
Call `completion-at-point-functions' in order to obtain and
|
|
|
|
display a completion candidate for the text around point.
|
|
|
|
|
|
|
|
If the preview is already shown, first check whether the
|
|
|
|
suggested candidate remains a valid completion for the text at
|
|
|
|
point. If so, update the preview according the new text at
|
|
|
|
point, otherwise hide it."
|
|
|
|
(when completion-preview-active-mode
|
|
|
|
;; We were already showing a preview before this command, so we
|
|
|
|
;; check if the text before point is still a prefix of the
|
|
|
|
;; candidate that the preview suggested, and if so we first update
|
|
|
|
;; existing preview according to the changes made by this command,
|
|
|
|
;; and only then try to get a new candidate. This ensures that we
|
|
|
|
;; never display a stale preview and that the preview doesn't
|
|
|
|
;; flicker, even with slow completion backends.
|
|
|
|
(let* ((beg (completion-preview--get 'completion-preview-beg))
|
2024-02-01 12:30:24 +01:00
|
|
|
(end (max (point) (overlay-start completion-preview--overlay)))
|
2024-04-12 22:41:10 +02:00
|
|
|
(sufs (completion-preview--get 'completion-preview-suffixes))
|
2023-11-02 16:58:31 +01:00
|
|
|
(index (completion-preview--get 'completion-preview-index))
|
2024-04-12 22:41:10 +02:00
|
|
|
(common (completion-preview--get 'completion-preview-common))
|
|
|
|
(suffix (nth index sufs))
|
|
|
|
(cand nil))
|
|
|
|
(set-text-properties 0 (length suffix)
|
|
|
|
(list 'face (if (cdr sufs)
|
|
|
|
'completion-preview
|
|
|
|
'completion-preview-exact))
|
|
|
|
suffix)
|
|
|
|
(setq cand (concat common (nth index sufs)))
|
2024-02-01 12:30:24 +01:00
|
|
|
(if (and (<= beg (point) end (1- (+ beg (length cand))))
|
|
|
|
(string-prefix-p (buffer-substring beg end) cand))
|
2023-11-02 16:58:31 +01:00
|
|
|
;; The previous preview is still applicable, update it.
|
|
|
|
(overlay-put (completion-preview--make-overlay
|
2025-02-26 20:41:09 +01:00
|
|
|
end (completion-preview--propertize-for-mouse
|
|
|
|
(substring cand (- end beg))))
|
2024-02-01 12:30:24 +01:00
|
|
|
'completion-preview-end end)
|
2023-11-02 16:58:31 +01:00
|
|
|
;; The previous preview is no longer applicable, hide it.
|
|
|
|
(completion-preview-active-mode -1))))
|
|
|
|
;; Run `completion-at-point-functions' to get a new candidate.
|
2024-06-05 10:23:56 +02:00
|
|
|
(if completion-preview-idle-delay
|
|
|
|
(setq completion-preview--timer
|
|
|
|
(run-with-idle-timer completion-preview-idle-delay
|
|
|
|
nil #'completion-preview--update-from-timer
|
|
|
|
(selected-window) (current-buffer)))
|
|
|
|
(completion-preview--try-update)))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
|
|
|
(defun completion-preview--post-command ()
|
|
|
|
"Create, update or delete completion preview post last command."
|
2024-04-12 22:41:10 +02:00
|
|
|
(let ((internal-p (or completion-preview--inhibit-update-p
|
|
|
|
(memq this-command
|
|
|
|
completion-preview--internal-commands))))
|
|
|
|
(setq completion-preview--inhibit-update-p nil)
|
|
|
|
|
2024-06-05 10:23:56 +02:00
|
|
|
(when (timerp completion-preview--timer)
|
|
|
|
(cancel-timer completion-preview--timer)
|
|
|
|
(setq completion-preview--timer nil))
|
|
|
|
|
2025-03-16 09:45:25 +01:00
|
|
|
(cond
|
|
|
|
(internal-p
|
|
|
|
;; `this-command' took care of updating the preview. Do nothing.
|
|
|
|
)
|
|
|
|
((and (completion-preview-require-certain-commands)
|
2025-03-16 20:16:05 +08:00
|
|
|
(completion-preview-require-minimum-symbol-length)
|
|
|
|
(not buffer-read-only))
|
2025-03-16 09:45:25 +01:00
|
|
|
;; All conditions met. Show or update the preview.
|
|
|
|
(completion-preview--show))
|
|
|
|
(completion-preview-active-mode
|
|
|
|
;; The preview is shown, but it shouldn't be. Hide it.
|
|
|
|
(completion-preview-active-mode -1)))))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
2024-06-26 11:06:52 +02:00
|
|
|
(defun completion-preview--barf-if-no-preview ()
|
|
|
|
"Signal a `user-error' if completion preview is not active."
|
|
|
|
(unless completion-preview-active-mode
|
|
|
|
(user-error "No current completion preview")))
|
|
|
|
|
2023-11-02 16:58:31 +01:00
|
|
|
(defun completion-preview-insert ()
|
2023-11-20 12:45:11 +01:00
|
|
|
"Insert the completion candidate that the preview is showing."
|
2025-02-26 20:11:20 +01:00
|
|
|
(interactive nil completion-preview-active-mode)
|
2024-06-26 11:06:52 +02:00
|
|
|
(completion-preview--barf-if-no-preview)
|
|
|
|
(let* ((pre (completion-preview--get 'completion-preview-base))
|
|
|
|
(end (completion-preview--get 'completion-preview-end))
|
|
|
|
(ind (completion-preview--get 'completion-preview-index))
|
|
|
|
(all (completion-preview--get 'completion-preview-suffixes))
|
|
|
|
(com (completion-preview--get 'completion-preview-common))
|
|
|
|
(efn (plist-get (completion-preview--get 'completion-preview-props)
|
|
|
|
:exit-function))
|
|
|
|
(aft (completion-preview--get 'after-string))
|
|
|
|
(str (concat pre com (nth ind all))))
|
|
|
|
(completion-preview-active-mode -1)
|
|
|
|
(goto-char end)
|
2024-06-29 11:51:10 +02:00
|
|
|
(insert-and-inherit (substring-no-properties aft))
|
2024-06-26 11:06:52 +02:00
|
|
|
(when (functionp efn) (funcall efn str 'finished))))
|
|
|
|
|
|
|
|
(defun completion-preview-partial-insert (fun &rest args)
|
|
|
|
"Insert part of the current completion preview candidate.
|
|
|
|
|
|
|
|
This function calls FUN with arguments ARGS, after temporarily inserting
|
|
|
|
the entire current completion preview candidate. FUN should move point:
|
|
|
|
if it moves point forward into the completion text, this function
|
|
|
|
inserts the prefix of the completion candidate up to that point.
|
|
|
|
Beyond moving point, FUN should not modify the current buffer."
|
|
|
|
(completion-preview--barf-if-no-preview)
|
|
|
|
(let* ((end (completion-preview--get 'completion-preview-end))
|
|
|
|
(aft (completion-preview--get 'after-string))
|
|
|
|
(eoc (+ end (length aft))))
|
2024-06-28 12:57:32 +02:00
|
|
|
;; Keep region active, if it is already. This lets commands that
|
|
|
|
;; call this function interact correctly with `shift-select-mode'.
|
|
|
|
(let ((deactivate-mark nil))
|
|
|
|
;; Partially insert current completion candidate.
|
|
|
|
(catch 'abort-atomic-change
|
|
|
|
(atomic-change-group
|
|
|
|
(let ((change-group (prepare-change-group)))
|
|
|
|
(save-excursion
|
|
|
|
(goto-char end)
|
|
|
|
;; Temporarily insert the full completion candidate.
|
2024-06-29 11:51:10 +02:00
|
|
|
(insert-and-inherit (substring-no-properties aft)))
|
2024-06-28 12:57:32 +02:00
|
|
|
;; Set point to the end of the prefix that we want to keep.
|
|
|
|
(apply fun args)
|
|
|
|
(unless (< end (point))
|
|
|
|
;; Point didn't advance into the completion, so abort change
|
|
|
|
;; to avoid littering `buffer-undo-list' with a nop entry.
|
|
|
|
(throw 'abort-atomic-change nil))
|
|
|
|
;; Delete the rest.
|
|
|
|
(delete-region (min (point) eoc) eoc)
|
|
|
|
;; Combine into one change group.
|
|
|
|
(undo-amalgamate-change-group change-group)))))
|
2024-06-26 11:06:52 +02:00
|
|
|
;; Cleanup.
|
|
|
|
(cond
|
|
|
|
;; If we kept the entire completion candidate, call :exit-function.
|
|
|
|
((<= eoc (point))
|
2023-11-20 12:45:11 +01:00
|
|
|
(let* ((pre (completion-preview--get 'completion-preview-base))
|
|
|
|
(ind (completion-preview--get 'completion-preview-index))
|
2024-04-12 22:41:10 +02:00
|
|
|
(all (completion-preview--get 'completion-preview-suffixes))
|
|
|
|
(com (completion-preview--get 'completion-preview-common))
|
2024-06-26 11:06:52 +02:00
|
|
|
(efn (plist-get
|
|
|
|
(completion-preview--get 'completion-preview-props)
|
|
|
|
:exit-function)))
|
2023-11-20 12:45:11 +01:00
|
|
|
(completion-preview-active-mode -1)
|
2024-06-26 11:06:52 +02:00
|
|
|
(when (functionp efn) (funcall efn (concat pre com (nth ind all))
|
|
|
|
'finished))))
|
|
|
|
;; If we kept anything, update preview overlay accordingly.
|
|
|
|
((< end (point))
|
|
|
|
(completion-preview--inhibit-update)
|
|
|
|
(overlay-put (completion-preview--make-overlay
|
|
|
|
(point)
|
2025-02-26 20:41:09 +01:00
|
|
|
(completion-preview--propertize-for-mouse
|
|
|
|
(substring aft (- (point) end))))
|
2024-06-26 11:06:52 +02:00
|
|
|
'completion-preview-end (point)))
|
|
|
|
;; If we kept nothing, do nothing.
|
|
|
|
)))
|
|
|
|
|
|
|
|
(defun completion-preview-insert-word (&optional n)
|
|
|
|
"Insert the first N words of the current completion preview candidate.
|
|
|
|
|
|
|
|
Interactively, N is the numeric prefix argument, and it defaults to 1."
|
2025-02-26 20:11:20 +01:00
|
|
|
(interactive "^p" completion-preview-active-mode)
|
2024-06-26 11:06:52 +02:00
|
|
|
(completion-preview-partial-insert #'forward-word n))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
2024-06-26 11:06:52 +02:00
|
|
|
(defun completion-preview-insert-sexp (&optional n)
|
|
|
|
"Insert the first N s-expressions of the current completion preview candidate.
|
2024-06-24 08:53:23 -07:00
|
|
|
|
2024-06-26 11:06:52 +02:00
|
|
|
Interactively, N is the numeric prefix argument, and it defaults to 1."
|
2025-02-26 20:11:20 +01:00
|
|
|
(interactive "^p" completion-preview-active-mode)
|
2024-06-26 11:06:52 +02:00
|
|
|
(completion-preview-partial-insert #'forward-sexp n 'interactive))
|
2024-06-24 08:53:23 -07:00
|
|
|
|
2024-04-12 22:41:10 +02:00
|
|
|
(defun completion-preview-complete ()
|
|
|
|
"Complete up to the longest common prefix of all completion candidates.
|
|
|
|
|
|
|
|
If you call this command twice in a row, or otherwise if there is no
|
|
|
|
common prefix to insert, it displays the list of matching completion
|
|
|
|
candidates unless `completion-auto-help' is nil. If you repeat this
|
|
|
|
command again when the completions list is visible, it scrolls the
|
|
|
|
completions list."
|
2025-02-26 20:11:20 +01:00
|
|
|
(interactive nil completion-preview-active-mode)
|
2024-06-26 11:06:52 +02:00
|
|
|
(completion-preview--barf-if-no-preview)
|
2024-04-12 22:41:10 +02:00
|
|
|
(let* ((beg (completion-preview--get 'completion-preview-beg))
|
|
|
|
(end (completion-preview--get 'completion-preview-end))
|
|
|
|
(com (completion-preview--get 'completion-preview-common))
|
|
|
|
(cur (completion-preview--get 'completion-preview-index))
|
|
|
|
(all (completion-preview--get 'completion-preview-suffixes))
|
|
|
|
(base (completion-preview--get 'completion-preview-base))
|
|
|
|
(props (completion-preview--get 'completion-preview-props))
|
|
|
|
(efn (plist-get props :exit-function))
|
|
|
|
(ins (substring-no-properties com (- end beg))))
|
|
|
|
(goto-char end)
|
|
|
|
(if (string-empty-p ins)
|
|
|
|
;; If there's nothing to insert, call `completion-at-point' to
|
|
|
|
;; show the completions list (or just display a message when
|
|
|
|
;; `completion-auto-help' is nil).
|
|
|
|
(let* ((completion-styles completion-preview-completion-styles)
|
|
|
|
(sub (substring-no-properties com))
|
|
|
|
(col (mapcar (lambda (suf)
|
|
|
|
(concat sub (substring-no-properties suf)))
|
|
|
|
(append (nthcdr cur all) (take cur all))))
|
|
|
|
;; The candidates are already in order.
|
|
|
|
(props (plist-put props :display-sort-function #'identity))
|
|
|
|
;; The :exit-function might be slow, e.g. when the
|
|
|
|
;; backend is Eglot, so we ensure that the preview is
|
|
|
|
;; hidden before any original :exit-function is called.
|
|
|
|
(props (plist-put props :exit-function
|
|
|
|
(when (functionp efn)
|
|
|
|
(lambda (string status)
|
|
|
|
(completion-preview-active-mode -1)
|
|
|
|
(funcall efn string status)))))
|
|
|
|
;; The predicate is meant for the original completion
|
|
|
|
;; candidates, which may be symbols or cons cells, but
|
2024-06-04 22:13:47 -07:00
|
|
|
;; now we only have strings, so it might not be applicable.
|
2024-04-12 22:41:10 +02:00
|
|
|
(props (plist-put props :predicate nil))
|
|
|
|
(completion-at-point-functions
|
|
|
|
(list (lambda () `(,beg ,end ,col ,@props)))))
|
|
|
|
(completion-preview--inhibit-update)
|
|
|
|
(completion-at-point))
|
|
|
|
;; Otherwise, insert the common prefix and update the preview.
|
2024-06-29 11:51:10 +02:00
|
|
|
(insert-and-inherit ins)
|
2024-04-12 22:41:10 +02:00
|
|
|
(let ((suf (nth cur all))
|
|
|
|
(pos (point)))
|
|
|
|
(if (or (string-empty-p suf) (null suf))
|
|
|
|
;; If we've inserted a full candidate, let the post-command
|
|
|
|
;; hook update the completion preview in case the candidate
|
|
|
|
;; can be completed further.
|
|
|
|
(when (functionp efn)
|
2025-02-27 15:34:24 +01:00
|
|
|
;; Remove stale preview since `efn' can make arbitrary
|
|
|
|
;; text and point modifications that might interfere with
|
|
|
|
;; a subsequent preview update. See bug#76606.
|
|
|
|
(completion-preview-active-mode -1)
|
2024-04-12 22:41:10 +02:00
|
|
|
(funcall efn (concat base com) (if (cdr all) 'exact 'finished)))
|
|
|
|
;; Otherwise, remove the common prefix from the preview.
|
|
|
|
(completion-preview--inhibit-update)
|
|
|
|
(overlay-put (completion-preview--make-overlay
|
2025-02-26 20:41:09 +01:00
|
|
|
pos (completion-preview--propertize-for-mouse suf))
|
2024-04-12 22:41:10 +02:00
|
|
|
'completion-preview-end pos))))))
|
|
|
|
|
2024-04-12 23:19:13 +02:00
|
|
|
(defun completion-preview-prev-candidate (n)
|
|
|
|
"Cycle the candidate the preview is showing N candidates backward.
|
|
|
|
|
|
|
|
If N is negative, cycle -N candidates forward. Interactively, N is the
|
|
|
|
prefix argument and defaults to 1."
|
2025-02-26 20:11:20 +01:00
|
|
|
(interactive "p" completion-preview-active-mode)
|
2024-04-12 23:19:13 +02:00
|
|
|
(completion-preview-next-candidate (- n)))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
2024-04-12 23:19:13 +02:00
|
|
|
(defun completion-preview-next-candidate (n)
|
|
|
|
"Cycle the candidate the preview is showing N candidates forward.
|
2023-11-02 16:58:31 +01:00
|
|
|
|
2024-04-12 23:19:13 +02:00
|
|
|
If N is negative, cycle -N candidates backward. Interactively, N is the
|
2023-11-02 16:58:31 +01:00
|
|
|
prefix argument and defaults to 1."
|
2025-02-26 20:11:20 +01:00
|
|
|
(interactive "p" completion-preview-active-mode)
|
2023-11-02 16:58:31 +01:00
|
|
|
(when completion-preview-active-mode
|
|
|
|
(let* ((beg (completion-preview--get 'completion-preview-beg))
|
2024-02-01 12:30:24 +01:00
|
|
|
(end (completion-preview--get 'completion-preview-end))
|
2024-04-12 22:41:10 +02:00
|
|
|
(all (completion-preview--get 'completion-preview-suffixes))
|
|
|
|
(com (completion-preview--get 'completion-preview-common))
|
2023-11-02 16:58:31 +01:00
|
|
|
(cur (completion-preview--get 'completion-preview-index))
|
|
|
|
(len (length all))
|
2024-04-12 23:19:13 +02:00
|
|
|
(new (mod (+ cur n) len))
|
2024-04-12 22:41:10 +02:00
|
|
|
(suf (nth new all))
|
|
|
|
(lencom (length com)))
|
|
|
|
;; Skip suffixes that are no longer applicable. This may happen
|
|
|
|
;; when the user continues typing and immediately runs this
|
|
|
|
;; command, before the completion backend returns an updated set
|
|
|
|
;; of completions for the new (longer) prefix, so we still have
|
|
|
|
;; the previous (larger) set of candidates at hand.
|
|
|
|
(while (or (<= (+ beg lencom (length suf)) end)
|
|
|
|
(not (string-prefix-p (buffer-substring beg end)
|
|
|
|
(concat com suf))))
|
2024-04-12 23:19:13 +02:00
|
|
|
(setq new (mod (+ new n) len)
|
2024-04-12 22:41:10 +02:00
|
|
|
suf (nth new all)))
|
|
|
|
(set-text-properties 0 (length suf)
|
|
|
|
(list 'face (if (cdr all)
|
|
|
|
'completion-preview
|
|
|
|
'completion-preview-exact))
|
|
|
|
suf)
|
2025-02-26 20:41:09 +01:00
|
|
|
(let ((aft (completion-preview--propertize-for-mouse
|
|
|
|
(substring (concat com suf) (- end beg)))))
|
2023-11-02 16:58:31 +01:00
|
|
|
(add-text-properties 0 1 '(cursor 1) aft)
|
|
|
|
(overlay-put completion-preview--overlay 'completion-preview-index new)
|
2023-11-26 17:00:32 +01:00
|
|
|
(overlay-put completion-preview--overlay 'after-string aft))
|
|
|
|
(when completion-preview-message-format
|
|
|
|
(message (format-spec completion-preview-message-format
|
|
|
|
`((?i . ,(1+ new)) (?n . ,len))))))))
|
|
|
|
|
2024-06-26 11:06:52 +02:00
|
|
|
(defun completion-preview-active-p (_symbol buffer)
|
|
|
|
"Check if the completion preview is currently shown in BUFFER.
|
|
|
|
|
|
|
|
The first argument, SYMBOL, is ignored. You can use this function as
|
|
|
|
the `completion-predicate' property of commands that you define that
|
|
|
|
should only be available when the completion preview is active."
|
2025-02-26 20:11:20 +01:00
|
|
|
(declare
|
|
|
|
(obsolete "check for `completion-preview-active-mode' instead." "31.1"))
|
2023-11-26 17:00:32 +01:00
|
|
|
(buffer-local-value 'completion-preview-active-mode buffer))
|
|
|
|
|
2023-11-02 16:58:31 +01:00
|
|
|
;;;###autoload
|
|
|
|
(define-minor-mode completion-preview-mode
|
2023-11-20 12:45:11 +01:00
|
|
|
"Show in-buffer completion suggestions in a preview as you type.
|
|
|
|
|
|
|
|
This mode automatically shows and updates the completion preview
|
|
|
|
according to the text around point.
|
|
|
|
\\<completion-preview-active-mode-map>\
|
2024-04-12 22:41:10 +02:00
|
|
|
When the preview is visible, \\[completion-preview-insert] accepts the
|
|
|
|
completion suggestion, \\[completion-preview-complete] completes up to
|
|
|
|
the longest common prefix of all completion candidates,
|
2023-11-20 12:45:11 +01:00
|
|
|
\\[completion-preview-next-candidate] cycles forward to the next
|
2024-04-12 22:41:10 +02:00
|
|
|
completion suggestion, and \\[completion-preview-prev-candidate] cycles
|
|
|
|
backward."
|
2023-11-02 16:58:31 +01:00
|
|
|
:lighter " CP"
|
|
|
|
(if completion-preview-mode
|
|
|
|
(add-hook 'post-command-hook #'completion-preview--post-command nil t)
|
|
|
|
(remove-hook 'post-command-hook #'completion-preview--post-command t)
|
2024-06-05 10:23:56 +02:00
|
|
|
(when completion-preview-active-mode (completion-preview-active-mode -1))
|
|
|
|
(when (timerp completion-preview--timer)
|
|
|
|
(cancel-timer completion-preview--timer)
|
|
|
|
(setq completion-preview--timer nil))))
|
2023-11-02 16:58:31 +01:00
|
|
|
|
2024-04-03 08:35:18 +02:00
|
|
|
;;;###autoload
|
2024-03-26 22:34:51 +01:00
|
|
|
(define-globalized-minor-mode global-completion-preview-mode
|
|
|
|
completion-preview-mode completion-preview-mode
|
2024-05-01 18:59:45 +02:00
|
|
|
:predicate '((not archive-mode
|
|
|
|
calc-mode
|
|
|
|
compilation-mode
|
2024-04-24 19:27:15 +02:00
|
|
|
diff-mode
|
|
|
|
dired-mode
|
2024-05-01 18:59:45 +02:00
|
|
|
image-mode
|
2024-04-24 19:27:15 +02:00
|
|
|
minibuffer-mode
|
|
|
|
minibuffer-inactive-mode
|
2024-05-01 18:59:45 +02:00
|
|
|
org-agenda-mode
|
2024-04-24 19:27:15 +02:00
|
|
|
special-mode
|
|
|
|
wdired-mode)
|
|
|
|
t))
|
2024-03-26 22:34:51 +01:00
|
|
|
|
2023-11-02 16:58:31 +01:00
|
|
|
(provide 'completion-preview)
|
|
|
|
;;; completion-preview.el ends here
|