From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.help Subject: Re: package-installed-p issue. Date: Sat, 9 Jan 2021 19:02:56 +0100 Message-ID: References: <20210109024756.en34g7b7ol45qtqs.ref@Ergus> <20210109024756.en34g7b7ol45qtqs@Ergus> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4503"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Ergus Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 09 19:03:54 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 1kyIag-0000q8-IZ for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Jan 2021 19:03:54 +0100 Original-Received: from localhost ([::1]:57532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyIaf-0001lI-Kh for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Jan 2021 13:03:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyIa3-0001lC-Mp for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 13:03:15 -0500 Original-Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]:38744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kyIZx-0007ho-ON for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 13:03:14 -0500 Original-Received: by mail-oo1-xc2e.google.com with SMTP id i18so3187517ooh.5 for ; Sat, 09 Jan 2021 10:03:08 -0800 (PST) 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; bh=+oukS8Qvg1d2BIUscE9sUzGYr4mtCsnUwCxDBAig5gc=; b=h2ZhwVFN0ThDv/gxslq59K/8xA9NGNjWNuTXyPai3tAd3CSqVklaG0fc5zRnBDDBLp Uid/5T2Ngt9PzTz7hUxKdsrTXAgsEfDEfRsG2cAkL2AXdw9ZvyQ6w0LeL7iijUuE/R6P wReJbv2HDJ+mJmz5+gduF/uPmU84UBhxTeLORh5wlg6xeiTsmB70CitYIpWs9UGbWWeu ylMeB270QCh/H+fvl7ZyQl/lPvWJykuopDwjDhOLjxE6MUFQJLHhw3OPfEW7ExBKelL7 1Xg6hja7NPPyekBIWMVqwdKTrIvjIBfS9EDb1euIQjpVRglsLRxRH7gyzJpBS83AcZ7v 2nlA== 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; bh=+oukS8Qvg1d2BIUscE9sUzGYr4mtCsnUwCxDBAig5gc=; b=EZkPvcCWEOXG/BGIz3rX+MQYbpVB9kJi+whK/M1ivraZvPoXzELRE1KNnPZxRps9Ry v8VfNMMkqmRwbmk1qiajj6Kprr5JRfzt2ZNYCkT5WS++plSbPqY5OPo+M2S4YmurF4G3 WIuXcwypINEdNec7dcASQFhzKqF9dX3VhYUUVrZRH5wOf+SG7K3sH3u+0DFcFAT32/HF SPdS+yUgK40d6L5s/R1aULSIyXHf1GST2nCN6U4NhmuPFAVqEwr3u1oWQ8HtW0Hej3Dx Yu2NvS8AFo5j0Bd3w2/h9iMnb8OX5RK4wHdyG52g2LoxMGst1Bli0pibvGcn9vv4Wk63 ULxA== X-Gm-Message-State: AOAM532V3V+2r0YXuQljZrRWcSbt3ZTsVlL14exE+DiY64iTway6EipC vFJ/fj+UrC1obWbg63eS99Jd8biYUrzYfQRm05I= X-Google-Smtp-Source: ABdhPJyHqDSEpXDxsVPqxHTKObM755kR3sNlZoKUaFlsInV6QN/HKTcMqJ66/ChwU8TZafPPgyVkeCUx+YYILmaUhW0= X-Received: by 2002:a4a:b082:: with SMTP id k2mr7858772oon.60.1610215387233; Sat, 09 Jan 2021 10:03:07 -0800 (PST) In-Reply-To: <20210109024756.en34g7b7ol45qtqs@Ergus> Received-SPF: pass client-ip=2607:f8b0:4864:20::c2e; envelope-from=p.stephani2@gmail.com; helo=mail-oo1-xc2e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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:127141 Archived-At: Am Sa., 9. Jan. 2021 um 03:48 Uhr schrieb Ergus : > > Hi I'm trying to simplify some of my code in the init file and > something like: > > (package-installed-p 'use-package) > > Triggers an error so I need to do something like: > > (unless (fboundp 'package-installed-p) > (require 'package)) > > (unless (package-installed-p 'use-package) > ... > ) > > My question is: Shouldn't package-installed-p be an autoload? > > Is there a reason why it is not an autoload? > Most functions should not be autoloaded. Autoloads are useful for high-level interactive commands in optional libraries, so that e.g. users can start ERT with `M-x ert' without having to load `ert' explicitly. In code (including ~/.emacs), just use `require' to load the required library. There's no need to surround it with `unless' - `require' is idempotent.