emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/marginalia feca4f1 100/241: add support for project.el


From: Stefan Monnier
Subject: [elpa] externals/marginalia feca4f1 100/241: add support for project.el
Date: Fri, 28 May 2021 20:49:05 -0400 (EDT)

branch: externals/marginalia
commit feca4f198efb7e90fa6355440c2f6e142a73c3e1
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>

    add support for project.el
    
    This adds a new heavy annotator for the category project-file used,
    for instance, by project-find-file. The annotations are the same as
    the annotations we already have for files.
---
 marginalia.el | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/marginalia.el b/marginalia.el
index 55f3045..e99595e 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -86,6 +86,7 @@ See also `marginalia-annotators-heavy'."
 (defcustom marginalia-annotators-heavy
   (append
    '((file . marginalia-annotate-file)
+     (project-file . marginalia-annotate-project-file)
      (buffer . marginalia-annotate-buffer)
      (virtual-buffer . marginalia-annotate-virtual-buffer-full)
      (command . marginalia-annotate-command))
@@ -210,6 +211,9 @@ determine it."
 (declare-function package-installed-p "package")
 (declare-function package-version-join "package")
 
+(declare-function project-current "project")
+(declare-function project-root "project")
+
 ;;;; Marginalia mode
 
 (defvar marginalia--separator "    "
@@ -510,7 +514,7 @@ using `minibuffer-force-complete' on the candidate CAND."
     cand))
 
 (defun marginalia-annotate-file (cand)
-  "Annotate file CAND with its size and modification time."
+  "Annotate file CAND with its size, modification time and other attributes."
   (when-let ((attributes (file-attributes (marginalia--full-candidate cand) 
'string)))
     (marginalia--fields
      ((file-attribute-modes attributes) :face 'marginalia-file-modes)
@@ -523,6 +527,13 @@ using `minibuffer-force-complete' on the candidate CAND."
        "%b %d %H:%M"
        (file-attribute-modification-time attributes)) :face 
'marginalia-date))))
 
+(defun marginalia-annotate-project-file (cand)
+  "Annotate file CAND with its size, modification time and other attributes."  
+  (when-let ((project (project-current))
+             (root (project-root project))
+             (file (expand-file-name cand root)))
+    (marginalia-annotate-file file)))
+
 (defun marginalia-classify-by-command-name ()
   "Lookup category for current command."
   (and marginalia--this-command



reply via email to

[Prev in Thread] Current Thread [Next in Thread]