From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Greg Minshall Newsgroups: gmane.emacs.devel Subject: Re: Emacs script options Date: Thu, 23 Nov 2023 20:22:56 -0800 Message-ID: <448988.1700799776@archlinux> References: <1325582.1700277236@archlinux> <8734x2zwnc.fsf@whxvd.name> <7953.1700336960@archlinux> <24ea16b3-e3e7-457b-99b9-3f3805de3f66@vodafonemail.de> <58266.1700443175@archlinux> <5eac9978-270e-40b2-8272-dabb29ec5daa@vodafonemail.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17795"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Sebastian Miele , emacs-devel@gnu.org To: Jens Schmidt Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 24 05:24:09 2023 Return-path: Envelope-to: ged-emacs-devel@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 1r6Njd-0004Pw-0j for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Nov 2023 05:24:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6Nih-0007ds-6o; Thu, 23 Nov 2023 23:23:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r6Nif-0007dZ-0W for emacs-devel@gnu.org; Thu, 23 Nov 2023 23:23:09 -0500 Original-Received: from relay-egress-host.us-east-2.a.mail.umich.edu ([18.219.209.13] helo=winning-amaethon.relay-egress.a.mail.umich.edu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r6Nid-0001Hp-Bv for emacs-devel@gnu.org; Thu, 23 Nov 2023 23:23:08 -0500 Original-Received: from perfect-cyclops.authn-relay.a.mail.umich.edu (ip-10-0-72-219.us-east-2.compute.internal [10.0.72.219]) by winning-amaethon.relay-egress.a.mail.umich.edu with ESMTPS id 65602525.2E9AC36F.848B45E.1291715; Thu, 23 Nov 2023 23:23:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=relay-2018-08-29; t=1700799781; bh=rxU5SE0AY0sASTLCONP0OpOG2T8rNAceXgOBQtX6p7c=; h=To:cc:From:Subject:In-reply-to:References:Date; b=KbKw9ZWbYVvAltXSm/4WOBUb0QkPU8oH2rD5KbVd2uKU4uH+aRpCPesCZyOseOZ1l HtlkTqqeT5xIr07aCRxIFHYSwmTWpqrbo9qINkoJUSefrMD2X3rCrHonydSgLUgT57 G5fVgf9sW2EnlJiC3VXN60n+7rwbTXNMxRZ53orbASb0GeUF0tl8EaiDVfE0iukSpf goh0f6AnP/ebljuzWa2qunBwq2R+GRbMkegNd/Vi8x5U+pwUI6CGcXijP5I6oH+oBl xiAjJoF8Bq+9v3i2ZURkEbbtrYotBw803CQdDQzsHkDVB8gyWpKe6QCG8Nil/+Yg4p g3PIbO/QYB7DA== Authentication-Results: perfect-cyclops.authn-relay.a.mail.umich.edu; iprev=pass policy.iprev=134.16.93.10 (134-016-093-010.res.spectrum.com); auth=pass smtp.auth=minshall Original-Received: from localhost (134-016-093-010.res.spectrum.com [134.16.93.10]) by perfect-cyclops.authn-relay.a.mail.umich.edu with ESMTPSA id 65602524.15571338.577827AE.678464; Thu, 23 Nov 2023 23:23:00 -0500 In-reply-to: <5eac9978-270e-40b2-8272-dabb29ec5daa@vodafonemail.de> Comments: In-reply-to Jens Schmidt message dated "Tue, 21 Nov 2023 22:13:22 +0100." X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 30.0.50 Content-ID: <448987.1700799776.1@archlinux> Received-SPF: pass client-ip=18.219.209.13; envelope-from=minshall@umich.edu; helo=winning-amaethon.relay-egress.a.mail.umich.edu X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:313167 Archived-At: Jens, > While there are surely other methods to achieve what below code > does, supposedly also more stable ones, I wanted to go for > brevity to keep the non-script overhead small: yes, i would say the below code *is* sufficiently hacky! but, i would go back to my suggestion for "-x". i think it would be a real benefit to those wanting to write general purpose scripts using Emacs as the "engine" (or whatever). cheers, Greg > ------------------------- escript ------------------------- > #!/bin/sh > : ; exec emacs --script "$0" -- "$@" #; -*- lexical-binding: t -*- > > ;; Work around `eval-buffer' not recognizing the lexical-binding > ;; stanza when the comment containing it does not start at first > ;; column (bug#67321). > (unless (ignore-errors (funcall (let ((v t)) (lambda () v)))) > (with-current-buffer (car eval-buffer-list) > (goto-char (point-min)) (search-forward "; -*-") > (delete-region (point-min) (match-beginning 0)) > (eval-buffer))) > > ;; Script payload. > (message "%S:%S" lexical-binding command-line-args-left) > > ;; Explicitly exit Emacs to not return from the second-level > ;; `eval-buffer'. > (kill-emacs 0) > > ;;; Local Variables: > ;;; mode: emacs-lisp > ;;; End: > ------------------------- escript -------------------------