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

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

[elpa] externals/marginalia 5501c24f9f 1/2: marginalia-annotate-bookmark


From: ELPA Syncer
Subject: [elpa] externals/marginalia 5501c24f9f 1/2: marginalia-annotate-bookmark: Show location and rear context
Date: Fri, 15 Dec 2023 09:58:10 -0500 (EST)

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

    marginalia-annotate-bookmark: Show location and rear context
---
 marginalia.el | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/marginalia.el b/marginalia.el
index 91c3697f66..8c1d38e992 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -301,11 +301,9 @@ The value of `this-command' is used as key for the lookup."
 
 ;;;; Pre-declarations for external packages
 
-(declare-function project-current "project")
+(declare-function bookmark-prop-get "bookmark")
 
-(declare-function bookmark-get-handler "bookmark")
-(declare-function bookmark-get-filename "bookmark")
-(declare-function bookmark-get-front-context-string "bookmark")
+(declare-function project-current "project")
 
 (defvar package--builtins)
 (defvar package-archive-contents)
@@ -802,7 +800,7 @@ keybinding since CAND includes it."
 (defun marginalia--bookmark-type (bm)
   "Return bookmark type string of BM.
 The string is transformed according to `marginalia--bookmark-type-transforms'."
-  (let ((handler (or (bookmark-get-handler bm) 'bookmark-default-handler)))
+  (let ((handler (or (bookmark-prop-get bm 'handler) 
'bookmark-default-handler)))
     (and
      ;; Some libraries use lambda handlers instead of symbols. For
      ;; example the function `xwidget-webkit-bookmark-make-record' is
@@ -822,16 +820,18 @@ The string is transformed according to 
`marginalia--bookmark-type-transforms'."
 (defun marginalia-annotate-bookmark (cand)
   "Annotate bookmark CAND with its file name and front context string."
   (when-let ((bm (assoc cand (bound-and-true-p bookmark-alist))))
-    (let ((front (bookmark-get-front-context-string bm)))
-      (marginalia--fields
-       ((marginalia--bookmark-type bm) :width 10 :face 'marginalia-type)
-       ((bookmark-get-filename bm)
-        :truncate -0.5 :face 'marginalia-file-name)
-       ((unless (or (not front) (equal front ""))
-          (concat (string-clean-whitespace
-                   (string-replace "\n" "\\n" front))
-                  (marginalia--ellipsis)))
-        :truncate -0.3 :face 'marginalia-documentation)))))
+    (marginalia--fields
+     ((marginalia--bookmark-type bm) :width 10 :face 'marginalia-type)
+     ((or (bookmark-prop-get bm 'filename)
+          (bookmark-prop-get bm 'location))
+      :truncate (if (bookmark-prop-get bm 'filename) -0.5 0.5)
+      :face 'marginalia-file-name)
+     ((let ((front (or (bookmark-prop-get bm 'front-context-string) ""))
+            (rear (or (bookmark-prop-get bm 'rear-context-string) "")))
+        (unless (and (string-blank-p front) (string-blank-p rear))
+          (string-clean-whitespace
+           (concat front (marginalia--ellipsis) rear))))
+      :truncate 0.5 :face 'marginalia-documentation))))
 
 (defun marginalia-annotate-customize-group (cand)
   "Annotate customization group CAND with its documentation string."



reply via email to

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