From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Combine multiple (straight-)use-package commands into one. Date: Sun, 13 Jun 2021 09:29:34 +0800 Message-ID: References: <87sg1nrrpz.fsf@omarpolo.com> 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="33511"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Omar Polo Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 13 03:30:22 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 1lsExB-0008Ub-Im for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 13 Jun 2021 03:30:21 +0200 Original-Received: from localhost ([::1]:53672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsEx9-00030J-Gw for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 12 Jun 2021 21:30:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsEwf-000307-Tg for help-gnu-emacs@gnu.org; Sat, 12 Jun 2021 21:29:49 -0400 Original-Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]:36739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsEwd-0002O4-VT for help-gnu-emacs@gnu.org; Sat, 12 Jun 2021 21:29:49 -0400 Original-Received: by mail-lj1-x229.google.com with SMTP id 131so14900840ljj.3 for ; Sat, 12 Jun 2021 18:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=7Rr/KRntwra9nfCm6ioB8MwnpWMJ/MmhOYZ0r/J8/Go=; b=cl48o1yHzb0CItIQg71fMdcbPAGmLCW5mvPZ001ua3ZJxAnOcDPpo+kzz6ED+YluIl s2S3aCc65p0iKpli5IUjpVCDKSU1eVaX8h3E5n0tS0yDOYNDPYGz7KRHXbV3mW61H6mN Qts9ytVwiXs7/4s8Nw6ZoJ+rH0tD4BuR9oIsP0ZghefXzMmbFK1X9wstY8l/ijTwzZh7 bkfuFYA2iVTNLuaiGYE9bZZbNWbsk/GGjBOrma+iSj4Wo/rV0A3mbNdXLLIKwYUxQ+T1 6WvyNVurb2AiUTgISs3Jpm79wtq4oEBBiVVkr59vDB9WVLf6G4l2sKt4237oDMIbWz9/ aMKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=7Rr/KRntwra9nfCm6ioB8MwnpWMJ/MmhOYZ0r/J8/Go=; b=nZOW9Nb+ZzA/Ya+FHX14Gz/95dc+br9BY3xDKOZRkl3/feORC4PiG6BFTzRVsyKji1 aCxznHkDO9nllSY+4+QH1pS/eL97e4qrRlhNZeRkZo5nFPAOS5OVCHuHTbTZl3NByHdd mSu8ML9j+UBAHXKJvxAxS+b1ZZ4Fl2v1J25D4LMWtsRYSDhFYTWqT6JBCCZuZlf3wGK+ /iMuPN8WGglh14yQK/4yGA83+SRp1P9tEUtkjnL9AnGvtZnWTJLz5bzMKYek3UzIp7DT OtOY6SfR+QWtSr44Yw4np9ggV5KAn5ssU3sQdDjI1C/KCsNmTVcvPYLZnRutHjdIkrQC 22gQ== X-Gm-Message-State: AOAM532VGqrZeQbvTIaha3v1uYv1PmDvoEoNdn7AbO6ea9rEOG0U+9fy 6XhOxNpx7lPWWTQbL1jGMN8DkRGgojUKCmcd7In0GYYWP1+uy2qZfPw= X-Google-Smtp-Source: ABdhPJyQs45UWDClHkmP1ry+WP8sgk11Rh6O+XVGxscq19pOfChM7cLJDFIMLX92d/23YuLN709wUE+S1N0Zki9qjgg= X-Received: by 2002:a2e:3c08:: with SMTP id j8mr8675384lja.481.1623547785741; Sat, 12 Jun 2021 18:29:45 -0700 (PDT) In-Reply-To: <87sg1nrrpz.fsf@omarpolo.com> Received-SPF: pass client-ip=2a00:1450:4864:20::229; envelope-from=hongyi.zhao@gmail.com; helo=mail-lj1-x229.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:130787 Archived-At: On Sun, Jun 13, 2021 at 12:08 AM Omar Polo wrote: > > > Hongyi Zhao writes: > > > On Sat, Jun 12, 2021 at 5:57 PM Hongyi Zhao wro= te: > >> > >> On Ubuntu 20.04, according to the instruction > >> [here](https://github.com/raxod502/straight.el/issues/786#issuecomment= -859155336), > >> 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/devel= op/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 = :straight > >> ;; keyword in use-package declarations unless you want to add/extend t= he 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 There is typo: (use-multiple-packages foo > bar > baz > ...) > -------->8-------- Thank you. It works like a charm. > > 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. --=20 Assoc. Prof. Hongyi Zhao Theory and Simulation of Materials Hebei Vocational University of Technology and Engineering NO. 552 North Gangtie Road, Xingtai, China