From 85c9d3070c6d87695f57613ed51a43e7ebd5bafa Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 29 Aug 2021 17:35:59 -0500 Subject: [PATCH 1/2] * elpa-admin.el (elpaa--get-section): Add docstring, rename vars --- elpa-admin.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/elpa-admin.el b/elpa-admin.el index 4c84360..ac72f2f 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -1167,25 +1167,28 @@ Rename DIR/ to PKG-VERS/, and return the descriptor." (insert-file-contents mainsrcfile) (lm-header prop)))))) -(defun elpaa--get-section (hsection fsection srcdir pkg-spec) - (when (consp fsection) - (while (cdr-safe fsection) - (setq fsection - (if (file-readable-p (expand-file-name (car fsection) srcdir)) - (car fsection) - (cdr fsection)))) - (when (consp fsection) (setq fsection (car fsection)))) +(defun elpaa--get-section (header file srcdir pkg-spec) + "Return specified section as a string from SRCDIR for PKG-SPEC. +If FILE is readable in SRCDIR, return its contents. Otherwise +return section under HEADER in package's main file." + (when (consp file) + (while (cdr-safe file) + (setq file + (if (file-readable-p (expand-file-name (car file) srcdir)) + (car file) + (cdr file)))) + (when (consp file) (setq file (car file)))) (cond - ((file-readable-p (expand-file-name fsection srcdir)) + ((file-readable-p (expand-file-name file srcdir)) (with-temp-buffer - (insert-file-contents (expand-file-name fsection srcdir)) + (insert-file-contents (expand-file-name file srcdir)) (buffer-string))) ((file-readable-p (expand-file-name (elpaa--main-file pkg-spec) srcdir)) (with-temp-buffer (insert-file-contents (expand-file-name (elpaa--main-file pkg-spec) srcdir)) - (emacs-lisp-mode) ;lm-section-start needs the outline-mode setting. - (let ((start (lm-section-start hsection))) + (emacs-lisp-mode) ;lm-section-start needs the outline-mode setting. + (let ((start (lm-section-start header))) (when start ;; FIXME: Emacs<28 had a bug in `lm-section-end', so cook up ;; our own ad-hoc replacement. -- 2.7.4