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

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

[elpa] externals/marginalia 1a9b75f 1/2: Decompose marginalia-annotate-b


From: ELPA Syncer
Subject: [elpa] externals/marginalia 1a9b75f 1/2: Decompose marginalia-annotate-buffer
Date: Thu, 29 Jul 2021 08:57:13 -0400 (EDT)

branch: externals/marginalia
commit 1a9b75f7ef8dd5505d382524d3f5a37cc838733b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Decompose marginalia-annotate-buffer
---
 marginalia.el | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/marginalia.el b/marginalia.el
index aa76155..a234bf0 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -734,20 +734,21 @@ The string is transformed according to 
`marginalia-bookmark-type-transformers'."
   "Annotate coding system CAND with its description."
   (marginalia--documentation (coding-system-doc-string (intern cand))))
 
-(defun marginalia-annotate-buffer (cand)
-  "Annotate buffer CAND with modification status, file name and major mode."
-  (when-let (buffer (get-buffer cand))
-    (marginalia--fields
-     ((format-mode-line '((:propertize "%1*%1+%1@" face marginalia-modified)
-                          marginalia--separator
-                          (7 (:propertize "%I" face marginalia-size))
-                          marginalia--separator
-                          ;; InactiveMinibuffer has 18 letters, but there are 
longer names.
-                          ;; For example Org-Agenda produces very long mode 
names.
-                          ;; Therefore we have to truncate.
-                          (20 (-20 (:propertize mode-name face 
marginalia-mode))))
-                        nil nil buffer))
-     ((if-let (proc (get-buffer-process buffer))
+(defun marginalia--buffer-status (buffer)
+  "Return the status of BUFFER as a string."
+  (format-mode-line '((:propertize "%1*%1+%1@" face marginalia-modified)
+                      marginalia--separator
+                      (7 (:propertize "%I" face marginalia-size))
+                      marginalia--separator
+                      ;; InactiveMinibuffer has 18 letters, but there are 
longer names.
+                      ;; For example Org-Agenda produces very long mode names.
+                      ;; Therefore we have to truncate.
+                      (20 (-20 (:propertize mode-name face marginalia-mode))))
+                    nil nil buffer))
+
+(defun marginalia--buffer-file (buffer)
+  "Return the file or process name of BUFFER."
+  (if-let (proc (get-buffer-process buffer))
           (format "(%s %s) %s"
                   proc (process-status proc)
                   (abbreviate-file-name (buffer-local-value 'default-directory 
buffer)))
@@ -761,7 +762,14 @@ The string is transformed according to 
`marginalia-bookmark-type-transformers'."
                                    (buffer-local-value 'default-directory 
buffer))))
               ((local-variable-p 'list-buffers-directory buffer)
                (buffer-local-value 'list-buffers-directory buffer)))
-             "")))
+             ""))))
+
+(defun marginalia-annotate-buffer (cand)
+  "Annotate buffer CAND with modification status, file name and major mode."
+  (when-let (buffer (get-buffer cand))
+    (marginalia--fields
+     ((marginalia--buffer-status buffer))
+     ((marginalia--buffer-file buffer)
       :truncate (/ marginalia-truncate-width 2)
       :face 'marginalia-file-name))))
 



reply via email to

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