Update pkgusr.el to deal with multi-line install group.
authorSteve Youngs <steve@steveyoungs.com>
Fri, 12 Feb 2021 06:22:57 +0000 (16:22 +1000)
committerSteve Youngs <steve@steveyoungs.com>
Fri, 12 Feb 2021 06:22:57 +0000 (16:22 +1000)
* lisp/pkgusr.el (pkgusr-all-pkgs): Allow for the install
  group being split across multiple lines.

Signed-off-by: Steve Youngs <steve@steveyoungs.com>
lisp/pkgusr.el

index d6a9ac1..6ca4146 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author:     Steve Youngs <steve@sxemacs.org>
 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
 ;; Created:    <2007-07-13>
-;; Time-stamp: <Monday Mar 17, 2014 22:33:38 steve>
+;; Time-stamp: <Friday Feb 12, 2021 16:19:09 steve>
 ;; Homepage:   N/A
 ;; Keywords:   utils package-management
 
 
 (defun pkgusr-all-pkgs ()
   "Return a list of all installed packages."
-  (let ((lst (with-temp-buffer
-              (insert-file-contents "/etc/group")
-              (re-search-forward "^install:x:9999:" nil t)
-              (narrow-to-region (point) (point-at-eol))
-              (split-string-by-char (buffer-string) ?,))))
-    lst))
+  (let ((pkgs ""))
+    (with-temp-buffer
+      (insert-file-contents "/etc/group")
+      (catch 'done
+       (while t
+         (if (re-search-forward "^install:x:9999:" nil t)
+             (setq pkgs (concat pkgs
+                                (buffer-substring (point)
+                                                  (point-at-eol))
+                                ","))
+           (throw 'done nil))))
+      (split-string-by-char (substring pkgs 0 -1) ?,))))
 
 (defvar pkgusr-all-pkgs (pkgusr-all-pkgs)
   "A list of all installed packages.")