[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/marginalia 4ba9804 031/241: Fix bug: file annotations w
From: |
Stefan Monnier |
Subject: |
[elpa] externals/marginalia 4ba9804 031/241: Fix bug: file annotations were only shown for current directory |
Date: |
Fri, 28 May 2021 20:48:51 -0400 (EDT) |
branch: externals/marginalia
commit 4ba98045dd33bcf1396a888dbbae2dc801dce7c5
Author: Omar AntolÃn Camarena <omar.antolin@gmail.com>
Commit: Omar AntolÃn Camarena <omar.antolin@gmail.com>
Fix bug: file annotations were only shown for current directory
The file annotations where only being displayed for files in the
current directory. This was because the candidates in file completion
are not the full path, but rather just the last path component.
The function file-attributes wants either a full path or a path
relative to the current directory.
To fix this bug I added a general function to calculate the "full
candidate", i.e, what the minibuffer contents would be if a given
candidate is chosen. For most types of completion, the completion
candidates are already full candidates. The main exception is file
name completion, where the candidates are one path component of the
full candidate, which is a full path. (There are other exceptions,
such as environment variable name completion inside file name
completion.)
---
marginalia.el | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/marginalia.el b/marginalia.el
index 9ae5354..862867a 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -262,9 +262,29 @@ determine it."
"")
marginalia-file-name-width))))
+(defun marginalia--full-candidate (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
+example, during file name completion the candidates are one path
+component of a full file path.
+
+This function returns what would be the minibuffer contents after
+using `minibuffer-force-complete' on the candidate CAND."
+ (let* ((contents (minibuffer-contents))
+ (pt (- (point) (minibuffer-prompt-end)))
+ (bounds (completion-boundaries
+ (substring contents 0 pt)
+ minibuffer-completion-table
+ minibuffer-completion-predicate
+ (substring contents pt))))
+ (concat (substring contents 0 (car bounds))
+ cand
+ (substring contents (+ pt (cdr bounds))))))
+
(defun marginalia-annotate-file (cand)
"Annotate file CAND with its size and modification time."
- (when-let (attributes (file-attributes cand))
+ (when-let ((attributes (file-attributes (marginalia--full-candidate cand))))
(concat
(marginalia--align 7 ;; size
marginalia-separator-width
- [elpa] externals/marginalia 5802a5d 118/241: readme: configuration example for selectrum refresh after marginalia-cycle, (continued)
- [elpa] externals/marginalia 5802a5d 118/241: readme: configuration example for selectrum refresh after marginalia-cycle, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia cf9f411 125/241: marginalia: always run annotators in the original window context, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia c574a26 054/241: more colors!, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 2b85b73 130/241: fix marginalia--full-candidate, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 3ec73cd 138/241: Merry Christmas, MELPA!, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 5129917 150/241: fix readme, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 2f849d8 013/241: Simplify marginalia--completion-metadata-get, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia c97911b 021/241: All classifiers from Embark have been imported, remove TODO, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 0cb98a0 023/241: Remove default value from prompt before matching, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 7fe8f71 027/241: improve buffer annotation formatting, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 4ba9804 031/241: Fix bug: file annotations were only shown for current directory,
Stefan Monnier <=
- [elpa] externals/marginalia 78023eb 038/241: update readme, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia b6d2e22 037/241: fix typo, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 472b47a 041/241: add comment to marginalia-toggle-annotators, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 85a2693 053/241: marginalia-annotate-package: show package archive, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia dfbaa7f 061/241: marginalia-annotate-package: show installed status instead of archive, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 17d539c 059/241: whitespace and comment adjustments, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 4a5ada6 063/241: smaller variable field, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 2f1bb7c 064/241: do not overwrite the face weights as per recommendation by @purcell, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 785297d 075/241: Indicate advised functions with an asterisk, Stefan Monnier, 2021/05/28
- [elpa] externals/marginalia 0bd8061 077/241: marginalia--fields: allow alignment to the right by using a negative width, Stefan Monnier, 2021/05/28