From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Omar Polo Newsgroups: gmane.emacs.help Subject: Re: Combine multiple (straight-)use-package commands into one. Date: Sat, 12 Jun 2021 18:08:08 +0200 Message-ID: <87sg1nrrpz.fsf@omarpolo.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25169"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.15; emacs 28.0.50 Cc: help-gnu-emacs@gnu.org To: Hongyi Zhao Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 12 18:10:44 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ls6Db-0006L4-46 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 12 Jun 2021 18:10:43 +0200 Original-Received: from localhost ([::1]:53734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ls6DZ-0004bq-NF for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 12 Jun 2021 12:10:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ls6BY-0004YK-0K for help-gnu-emacs@gnu.org; Sat, 12 Jun 2021 12:08:36 -0400 Original-Received: from mail.omarpolo.com ([144.91.116.244]:56646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ls6BU-00039X-LG for help-gnu-emacs@gnu.org; Sat, 12 Jun 2021 12:08:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omarpolo.com; s=20200327; t=1623514103; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DvKb2tIE4/20kfkC5su3xDPOwyGN2qTAOaAAfBzCCSU=; b=jwvR8M+NMikM7fOjyOZ/e7H5z2880elaaoMGOh45nk3M8UcQzqxISJt26sgTSvEsTSGB6A TebZYhLmvRChPksYblLbd3j0dmGNb5SYy30xYx0RraKC60KTQSnJsUZjkuKsmSZ8IF3jxF ac44xoDSh0I0ZYaVv2vHSmR0drrIfsE= Original-Received: from localhost (host-79-44-237-248.retail.telecomitalia.it [79.44.237.248]) by mail.omarpolo.com (OpenSMTPD) with ESMTPSA id 8ab359d2 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 12 Jun 2021 18:08:20 +0200 (CEST) Original-Received: from venera (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 2b591351; Sat, 12 Jun 2021 18:08:08 +0200 (CEST) In-reply-to: Received-SPF: pass client-ip=144.91.116.244; envelope-from=op@omarpolo.com; helo=mail.omarpolo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:130778 Archived-At: Hongyi Zhao writes: > On Sat, Jun 12, 2021 at 5:57 PM Hongyi Zhao wrote: >> >> On Ubuntu 20.04, according to the instruction >> [here](https://github.com/raxod502/straight.el/issues/786#issuecomment-8= 59155336), >> I use the following settings in my Emacs init file: >> >> ``` >> ;;Bootstrap straight >> (defvar bootstrap-version) >> (let ((bootstrap-file >> (expand-file-name "straight/repos/straight.el/bootstrap.el" >> user-emacs-directory)) >> (bootstrap-version 5)) >> (unless (file-exists-p bootstrap-file) >> (with-current-buffer >> (url-retrieve-synchronously >> "https://raw.githubusercontent.com/raxod502/straight.el/develop= /install.el" >> 'silent 'inhibit-cookies) >> (goto-char (point-max)) >> (eval-print-last-sexp))) >> (load bootstrap-file nil 'nomessage)) >> >> ;; Install use-package via straight >> (straight-use-package 'use-package) >> >> ;; Setting this to `t' makes it so that you don't need to include the :s= traight >> ;; keyword in use-package declarations unless you want to add/extend the= package >> ;; installation recipe. >> >> (setq straight-use-package-by-default t) ; straight's equivalent of >> `use-package-always-ensure'. >> ``` >> Now, I want to install multiple package hosted in recipe repositories >> (such as MELPA) as shown below with only one (straight-)use-package >> command, is it possible? >> ``` >> (use-package flycheck) >> (use-package lsp-mode) >> (use-package dash) >> (use-package posframe) >> (use-package s) >> (use-package ein) >> (use-package smartparens) >> (use-package valign) >> (use-package multi-term) >> ``` > > Based on the code snippets at > , > I figured out the following solution with `straight-use-package' > command: > > (defvar package-list) > (setq package-list '( > flycheck lsp-mode dash posframe > s ein smartparens valign > multi-term > )) > > (mapc (lambda(package-name) > (straight-use-package package-name)) package-list) > > But I still don't know the corresponding implementation with > `use-package' command. C-h f use-package RET says that > use-package is a Lisp macro in =E2=80=98use-package-core.el=E2=80=99. being a macro and not a function[0], it means that it follows different rule for the evaluation. (use-package foo ...) is something that gets *expanded* at *compile time* in some other lisp code, it's not something you can pass to mapc. You need to expand the loop *at compile* time to load multiple packages, something like the following (untested) --------8<-------- (defmacro use-multiple-packages (&rest packages) `(progn ,@(mapcar (lambda (p) `(use-package ,p)) packages))) (use-multiple-pacakges foo bar baz ...) -------->8-------- but it becomes not useful, since the main point of use-package is IMHO the syntax sugar for adding hooks, bindings etc. If you don't care about that stuff, a simple loop over package-install/package-installed-p is probably enough. > Regards [0]: see (info "(elisp)macros") for more information about how elisp macros works.