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

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

[elpa] externals/marginalia 5767b6ff49: marginalia-annotate-library: Use


From: ELPA Syncer
Subject: [elpa] externals/marginalia 5767b6ff49: marginalia-annotate-library: Use zcat for decompression (Fix #132)
Date: Sat, 26 Feb 2022 07:57:32 -0500 (EST)

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

    marginalia-annotate-library: Use zcat for decompression (Fix #132)
    
    By not going through the Emacs decompression facilities, the annotation 
function
    will be simpler, more robust and more efficient. The Emacs decompressor also
    uses zcat/gunzip behind the scenes.
---
 marginalia.el | 48 +++++++++++++++++++-----------------------------
 1 file changed, 19 insertions(+), 29 deletions(-)

diff --git a/marginalia.el b/marginalia.el
index 20341eebbf..136ae13075 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -514,8 +514,8 @@ t cl-type"
                                  advertised-signature-table t)))
        tmp)
       ((setq tmp (help-split-fundoc
-                 (ignore-errors (documentation sym t))
-                 sym))
+                  (ignore-errors (documentation sym t))
+                  sym))
        (substitute-command-keys (car tmp)))
       ((setq tmp (help-function-arglist sym))
        (and
@@ -990,39 +990,29 @@ These annotations are skipped for remote paths."
   (replace-regexp-in-string "\\(\\.gz\\|\\.elc?\\)+\\'" ""
                             (file-name-nondirectory file)))
 
-(defun marginalia--library-kill ()
-  "Kill temporary buffer."
-  (ignore-errors (kill-buffer " *marginalia library*"))
-  (remove-hook 'minibuffer-exit-hook #'marginalia--library-kill))
-
 (defun marginalia--library-doc (file)
   "Return library documentation string for FILE."
   (let ((doc (get-text-property 0 'marginalia--library-doc file)))
     (unless doc
       ;; Extract documentation string. We cannot use `lm-summary' here,
       ;; since it decompresses the whole file, which is slower.
-      (let ((str (with-current-buffer
-                     (or (get-buffer " *marginalia library*")
-                         (progn
-                           (add-hook 'minibuffer-exit-hook 
#'marginalia--library-kill)
-                           (get-buffer-create " *marginalia library*")))
-                   (erase-buffer)
-                   (let ((inhibit-message t) (message-log-max nil))
-                     (insert-file-contents file nil 0 200))
-                   (buffer-substring (point-min) (line-end-position)))))
-        (cond
-         ((string-match "\\`(define-package\\s-+\"\\([^\"]+\\)\"" str)
-          (setq doc (format "Generated package description from %s.el"
-                            (match-string 1 str))))
-         ((string-match "\\`;+\\s-*" str)
-          (setq doc (substring str (match-end 0)))
-          (when (string-match "\\`[^ \t]+\\s-+-+\\s-+" doc)
-            (setq doc (substring doc (match-end 0))))
-          (when (string-match "\\s-*-\\*-" doc)
-            (setq doc (substring doc 0 (match-beginning 0)))))
-         (t (setq doc "")))
-        ;; Add the documentation string to the cache
-        (put-text-property 0 1 'marginalia--library-doc doc file)))
+      (setq doc (or (ignore-errors
+                      (shell-command-to-string
+                       (format "zcat -f %s | head -n1" (shell-quote-argument 
file))))
+                 ""))
+      (cond
+       ((string-match "\\`(define-package\\s-+\"\\([^\"]+\\)\"" doc)
+        (setq doc (format "Generated package description from %s.el"
+                          (match-string 1 doc))))
+       ((string-match "\\`;+\\s-*" doc)
+        (setq doc (substring doc (match-end 0)))
+        (when (string-match "\\`[^ \t]+\\s-+-+\\s-+" doc)
+          (setq doc (substring doc (match-end 0))))
+        (when (string-match "\\s-*-\\*-" doc)
+          (setq doc (substring doc 0 (match-beginning 0)))))
+       (t (setq doc "")))
+      ;; Add the documentation string to the cache
+      (put-text-property 0 1 'marginalia--library-doc doc file))
     doc))
 
 (defun marginalia-annotate-library (cand)



reply via email to

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