[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/marginalia b6994e0 203/241: Attempt to fix full candida
From: |
Stefan Monnier |
Subject: |
[elpa] externals/marginalia b6994e0 203/241: Attempt to fix full candidate function for files (#65) |
Date: |
Fri, 28 May 2021 20:49:27 -0400 (EDT) |
branch: externals/marginalia
commit b6994e0ebca6488f379914a1506af833a1abd928
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Attempt to fix full candidate function for files (#65)
Currently the function is only used for files, we don't need a general
version.
Instead of the completion-boundaries one actually needs the completion base
position as returned in the last cdr by completion-all-completions.
Unfortunately I don't know how we can compute this cheaply, therefore I
manipulate the path by hand.
---
marginalia.el | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/marginalia.el b/marginalia.el
index f78e2fc..d815dc8 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -30,7 +30,7 @@
;;; Code:
(require 'subr-x)
-(eval-when-compile (require 'cl-lib))
+(require 'cl-lib)
;;;; Customization
@@ -640,7 +640,7 @@ The string is transformed according to
`marginalia-bookmark-type-transformers'."
;; is a function `completion-boundaries' to compute them, and in (info
"(elisp)Programmed
;; Completion") it is documented how a completion table should respond to
boundaries requests.
;; See the discussion at
https://github.com/minad/marginalia/commit/4ba98045dd33bcf1396a888dbbae2dc801dce7c5
-(defun marginalia--full-candidate (cand)
+(defun marginalia--full-file (cand)
"Return completion candidate CAND in full.
For some completion tables, the completion candidates offered are
meant to be only a part of the full minibuffer contents. For
@@ -652,15 +652,19 @@ using `minibuffer-force-complete' on the candidate CAND."
(if-let (win (active-minibuffer-window))
(with-current-buffer (window-buffer win)
(let* ((contents (minibuffer-contents-no-properties))
- (pt (- (point) (minibuffer-prompt-end)))
(bounds (completion-boundaries
- (substring contents 0 pt)
+ contents
minibuffer-completion-table
minibuffer-completion-predicate
- (substring contents pt))))
- (concat (substring contents 0 (car bounds))
- cand
- (substring contents (+ pt (cdr bounds))))))
+ ""))
+ (components (split-string (substring contents 0 (car bounds))
"/")))
+ (string-join (append
+ (cl-subseq components 0 (max 0
+ (- (length components)
+ (if (string-suffix-p
"/" cand)
+ (cl-count ?/ cand)
+ (1+ (cl-count ?/
cand))))))
+ (list cand)) "/")))
;; no minibuffer is active, trust that cand already conveys all
;; necessary information (there's not much else we can do)
cand))
@@ -677,7 +681,7 @@ These annotations are skipped for remote paths."
(with-current-buffer (window-buffer win)
(marginalia--remote-p (minibuffer-contents-no-properties)))))
(marginalia--fields ("*Remote*" :face 'marginalia-documentation))
- (when-let (attributes (file-attributes (substitute-in-file-name
(marginalia--full-candidate cand)) 'string))
+ (when-let (attributes (file-attributes (substitute-in-file-name
(marginalia--full-file cand)) 'string))
(marginalia--fields
((file-attribute-modes attributes) :face 'marginalia-file-modes)
((format "%s:%s"
@@ -720,11 +724,8 @@ These annotations are skipped for remote paths."
This runs through the `marginalia-prompt-categories' alist
looking for a regexp that matches the prompt."
(when-let (prompt (minibuffer-prompt))
- (setq prompt
- (replace-regexp-in-string "(.*default.*)\\|\\[.*\\]" "" prompt))
- (cl-loop for (regexp . category) in marginalia-prompt-categories
- when (string-match-p regexp prompt)
- return category)))
+ (setq prompt (replace-regexp-in-string "(.*default.*)\\|\\[.*\\]" ""
prompt))
+ (cdr (cl-find-if (lambda (x) (string-match-p (car x) prompt))
marginalia-prompt-categories))))
(defmacro marginalia--context (metadata &rest body)
"Setup annotator context with completion METADATA around BODY."
- [elpa] externals/marginalia 55bfd5f 176/241: do not unnecessarily use defsubst, (continued)
- [elpa] externals/marginalia 55bfd5f 176/241: do not unnecessarily use defsubst, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia dcdcd5d 179/241: consistently use \` and \' for regexps, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 51f7509 184/241: Fix #57 - protect marginalia--symbol-class equality check, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 3e061a0 185/241: marginalia-annotate-bookmark: Handle non-symbol bookmark handlers, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 58f397d 187/241: update readme, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia c93b1b3 188/241: marginalia--full-candidate: Do not switch entire window, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia e54aa0c 193/241: Revert "Revert "fix #46: affixation suffix must not be nil, it must be a string"", Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 153417a 192/241: marginalia-annotate-file: Use substitute-in-file-name, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 2d19497 208/241: marginalia--full-file: Ensure that pt >= 0 if cursor is moved into the prompt, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia f263745 201/241: marginalia-annotate-color: Use readable-foreground-color, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia b6994e0 203/241: Attempt to fix full candidate function for files (#65),
Stefan Monnier <=
- [elpa] externals/marginalia f3eaa1a 197/241: Add annotator for the embark-keybinding category, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 9559819 209/241: Add link to upstream bug, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia c476b6c 212/241: Track completion base position for marginalia--full-candidate, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 1120eff 210/241: Revert b6994e0ebca6488f379914a1506af833a1abd928 and 06ae3b4c466801962b7611c851e62bf0c749fbbf, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia dca1cb5 213/241: marginalia--base-position: Minor changes, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 1d3af0a 219/241: Merge branch 'base-position' into main, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 7fe1a03 218/241: Fix retrieving full paths under Selectrum, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia cd28764 232/241: marginalia-annotator-registry: Use more precise type, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 624028c 235/241: Silence bytecode compiler warning regarding project-roots (Fix #79), Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia ac4ab98 227/241: Implement individual cycling per completion category (Fix #73), Stefan Monnier, 2021/05/28