From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Daniel_Mart=C3=ADn?= Newsgroups: gmane.emacs.help Subject: Re: Better way to make sure external command exists in the system? Date: Fri, 19 Mar 2021 14:57:34 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30986"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) Cc: Help GNU Emacs To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 19 14:59:39 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 1lNFf8-0007yX-KC for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 19 Mar 2021 14:59:38 +0100 Original-Received: from localhost ([::1]:41956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNFf7-00084c-LT for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 19 Mar 2021 09:59:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNFdI-0006Cn-U8 for help-gnu-emacs@gnu.org; Fri, 19 Mar 2021 09:57:46 -0400 Original-Received: from sonic301-21.consmr.mail.ir2.yahoo.com ([77.238.176.98]:38551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNFdG-0004PJ-DT for help-gnu-emacs@gnu.org; Fri, 19 Mar 2021 09:57:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1616162257; bh=j8O1VAQIL7hbWNgGaqXLKmDZlYUXxnXUn77FwDAzblo=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=ifXS96xWlFHvVPNA3M2CUOzZRdr3cdK7+rv1HJ/AOZLC0JeNCJKaGvP0eYYYk8VKd97RopnSpaiUthtAA7Tngw49fZwxPngaDOG7ksCaz6mNa6FerY6qJASmBMG396MMdilL9L1zFLlbKZwB66KS0HLte/9L2pmyYdkTR5e48qavho3U9Vnln0r8gKp0byzvA1m45/DaW+7XkNFNV5P2c03t3MHd5o0cRuFqEOAa09Hv+q+hOAp/MfyOPoFhp2hRnWNuLEnIL0zsd2VdUOHXqwo1YbMiUKcLihKAU15t1wxDf2zHNTa0NiZHphaFkCa5nJJiBmvS12ws8nelwtHJww== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1616162257; bh=EU1hvzx7X2esfSpIjp/ZX8dB+Lyr5fqpv0Zts7pUvGQ=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=bcqwTV55T5LsDA0Z7K6jIOjM1TDI4GR566Wy5WC/s9EIeBa/JlA3Mga7FUm0yCR7/SmwfjvlfqOKqzoSo6TgdW0l7GjHI25oxI6LzdtO7tiHtr4Sh5lpbRZ7QDe4etnnJVukblI2AF40bF7n7HfGdF6D8ayWyp8o1aS5rO3atbIXclCh4i+s3xtnfqoV2IN1EUYKg4PuGMU5W77E/m7n/LmasmAF5fb48p21q9RS/HZDz3sofH3n2cqcLYKDflnHqqoSvl1FpN/5McNPs7vZT8NgEpf8y2YGXlT99gA4gim+ibPtPt0W3JWoRBgMRG17FBGazNUA/mwq6NNxWB8C5w== X-YMail-OSG: nBb9KW8VM1k8s7rkYGpx.fQ98__JSm5eSijNV5e4Eef8mSVIG34ajn3WGYgGlVr 1KAXFDE13rHy49vIaPryAQk0A25ujXfkj1Haw3PuS4B_46w64.TOBRrtsuV2Uy6ZHEnnVjn8kUBu 42TkCZNFc94TPZ57yCOPhtHY7VpN5WMV.A0yvGiYtpPfFTGdg9B8gFC18sxQWlq1Y.2U8FQtJU15 OhTo32OqZo56h480nNc5xZ1q8SVsuW3ewKv8WxHYFbBWdNxZ7Engng9Xz1P3G4lmwLYg1HAJeilu 54d54dr9dKIF9yCPghAd2AlrqtcvZ1EKB6N2OtwmBjeZ3PW47tPv05BaGf3DAp4ZOL1eINji7cq9 pDR8gGZXRHuODje58FKPdKkqSoajI7WpsBgLTzSi_zCMNXi.nsH8Yh55T5lIfAGmnfGIVDHY.w8R gejMI33aRZXHnbGyyjFiL2C7gkXAtc0LUVLW2sMO59prJUt47BDPeBHdV5XGGwpN5iRPhbirXchq eTtJXTVFSt3TPc3WOWtHNHMrAjPzPB5WsyaboMschr1egv0BPZxT.jciMcOb7irBnwKbrz9dX7Cv r_.JglC.9am2RfZwFj6TT6U2gHaKHnWsuij7VUCpx3OeL4.yHt82WOBf0_3_VsdvQm4fTgvxxx87 JTFjpUHQ8ZyOezVJp3yZKlYfB0sC1g2GVvadSDO9HgBAB0LPELWSNv0EVp8Bsg8oXkj3o_Z3L9UK 65mZ7cg9tmlnS0DCeS2ShBrcEky01yNwV4FoLiaEWaFt9lwRTL4rC6ybGpbY6VGiKo0D2DxMzhk6 3BqPtPUtGiGMC6dOnk2ywajvfRn1qTwlCuDlrj24VL X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ir2.yahoo.com with HTTP; Fri, 19 Mar 2021 13:57:37 +0000 Original-Received: by smtp409.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 3b64d5a0db9f873a1c802cf382e809d5; Fri, 19 Mar 2021 13:57:35 +0000 (UTC) In-Reply-To: (Jean Louis's message of "Thu, 18 Mar 2021 15:13:02 +0300") X-Mailer: WebService/1.1.17936 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Apache-HttpAsyncClient/4.1.4 (Java/11.0.9.1) Received-SPF: pass client-ip=77.238.176.98; envelope-from=mardani29@yahoo.es; helo=sonic301-21.consmr.mail.ir2.yahoo.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, RCVD_IN_MSPIKE_H2=-0.001, 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:128452 Archived-At: Jean Louis writes: > I have changed the OS on one computer and noticed that my Emacs Lisp > programs use external commands like: mailutils, mail, pandoc, > markdown, and others. Sometimes I was hard coding the path names like > /usr/local/bin and now some commands changed to /usr/bin > > And some functions should not even run if external command does not > exist. I would even like to stop loading the .el program if necessary > external programs do not exist in the system. > > For that reason I would do some changes: > > - instead of hard coding the program name within quotes, I will use > variable. Instead of (shell-command "mogrify ...") I will rather use > something like (shell-command (format "%s ..." mogrify-command)) > > - variables for commands I would place at beginning of programs > Yes, I think that using a variable instead of a hardcoded string is recommended. > - before variables get defined, I would use `executable-find' but I > would like for the program loading to fail if those external > programs cannot be found. Why do you think that checking for the existence of programs on load is better? I think it would slow down loading the module, and the benefits are not clear to me. For example, the Elisp module may still be useful even if it cannot call external programs. Why is it better than simply calling `executable-find' when invoking a command that depends on an external program?