From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.devel Subject: Re: [Feature Request] Add Zsh-style range and list iteration syntax to Eshell Date: Wed, 4 Dec 2024 10:44:01 -0800 Message-ID: <2b5fa0f5-cc07-7a09-a66f-e478f8898e33@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2314"; mail-complaints-to="usenet@ciao.gmane.io" To: the_wurfkreuz , "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 04 19:45:14 2024 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 1tIuN8-0000VK-KI for ged-emacs-devel@m.gmane-mx.org; Wed, 04 Dec 2024 19:45:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIuMD-0004iu-UI; Wed, 04 Dec 2024 13:44:18 -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 1tIuLz-0004iU-RL for emacs-devel@gnu.org; Wed, 04 Dec 2024 13:44:04 -0500 Original-Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIuLy-00083H-AY for emacs-devel@gnu.org; Wed, 04 Dec 2024 13:44:03 -0500 Original-Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-7252fba4de1so168144b3a.0 for ; Wed, 04 Dec 2024 10:44:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733337840; x=1733942640; darn=gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=ONGUe9/7VI5iJLTB4284JACPhYEwewSiwS4QWEIYkTo=; b=AS716aHHUGidQJg9YtKCn2J1C1zJMy7HhTRI8qNKYzRceELKfEOFqeF9n9UicJ0l/m p5ZyDTzIhI8kkXjbvgGatSVntuv7ncMKvW86f5qX7ndQ2F5UxkgsSIIb4ph7/9KDdWGq KKn/KmwdKyuz0eKKGZcxFoOdvZIvb9OW3x4Yl8I5+k0MLIZQlla7KVBEV/6soydJZiu9 nwq/slDRJir8ZA/qX22Vvy33IP1xRFojShUx0XKh8C7++7H2W8moAiOlrZkQwyusDkeS Z8P4+8gbh98ISv+mORkimvsPQpDlHZeLd1/AoB9mWfOVFbicptUMZRp0TYMuFfvpVRR/ W/yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733337840; x=1733942640; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ONGUe9/7VI5iJLTB4284JACPhYEwewSiwS4QWEIYkTo=; b=at5VRGHo2OrO5Gbmu8SjC0rKK+UUxNRsHw7OH6TpA38Z4tlBSOKyqh2VFjAoakbvEx bzVSApfrajNNQscrifX6GlEtPfIPjkbcXwh/Tww9NhV79rCte+f2I/HPyCM9mB7jjoLY 2bEy0n9X1/9G5kBA1Dy+ei/Ojg6/9kb1OXwGUUgj/pNZBURAdpg1FQjDXQklJ/BRv8QZ ccHQbOEuQS3lZCgDCb9O0i7E22MReNy63xBRQn+v6CIyC2GdM4vFWe3UYV4dxfA0IZv1 APX+suryPDIa2iAlOhH2n1kRcWLATeKu40giY/4DG7Ib1e6I1NcJi4ixuir9td6bqbLB V8dA== X-Forwarded-Encrypted: i=1; AJvYcCWRPMEuEnmdy9xySsEcYMq9jaWgJ/roDq6RT40ZUlM9DCMAIiMLQGcopdbx3zI031SgR+3PeDhrK8jTbw==@gnu.org X-Gm-Message-State: AOJu0YxlrmtkEJdhwiudpmVG0o0Ttow+NmMvlVRybZv3m3FHZkVSX1dB sxkYqBwS3dzl9pqUNv/3c7i8TOHb0kN+FKeRLsfPdsoWw4Nuhjqy X-Gm-Gg: ASbGncthZCMcsIDkyqRBf7IC1j+uA711Q8XfeIm4T39q0l7LqbkeSrhN2chEPH3hAYt QKThJZvioMgWjAPrPs38axVKqCwn47EFnwPqULdZLzDqVlB1soDAvjJgxSy3ClXSdaPoqaFJcHE ddum2PcwqrXiQ2802UL6IZYpMHATBSCEV6715MaCOjNKzAboWBXQHIiuV5IBaprffwDsgB0yBIg 1mNpLWo2f53SlIwJwbZGoqZs2mdzde0Xx9nK2HlMW5Vb4U0oIsjAvWTqG1geUlomsieD1aGAUYa TEWlnycAxZJU+iQMEA8f5ofhS1s= X-Google-Smtp-Source: AGHT+IF+Rk5XZO6SD3MrEBPd9JCQEnIF2RSbgMme8gY9ecJtYjOwbAivr01y4/iQPGzYpacJoqR0tw== X-Received: by 2002:a05:6a00:180a:b0:724:f10b:e663 with SMTP id d2e1a72fcca58-7257f9689f3mr10660806b3a.0.1733337840561; Wed, 04 Dec 2024 10:44:00 -0800 (PST) Original-Received: from [192.168.1.2] (syn-023-240-098-037.res.spectrum.com. [23.240.98.37]) by smtp.googlemail.com with ESMTPSA id 41be03b00d2f7-7fd096c9786sm1371993a12.71.2024.12.04.10.43.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Dec 2024 10:44:00 -0800 (PST) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=jporterbugs@gmail.com; helo=mail-pf1-x42c.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: 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:326048 Archived-At: On 12/4/2024 9:15 AM, the_wurfkreuz via Emacs development discussions. wrote: > Zsh has an ability to quickly iterate over ranges and lists like this: > > touch file{1,3} > > creates: file1, file3 Thanks for the suggestion. However, I'd prefer not to add even more meanings for punctuation to Eshell; it's pretty complicated as it is, since it tries to combine both shell-like syntax with Lisp-like syntax. (I've been maintaining Eshell for the last couple years and still haven't fixed all the corner cases in the existing syntax.) In this case though, I think you could make a helper function that gets you a fair amount of the way there: (defun eshell/expand (fmt list) (mapcar (lambda (i) (format fmt i)) list)) Then in Eshell: touch $@{expand file%s `(1 3)} It's a bit more typing than Zsh, but less than writing a for loop. You could also write an external Eshell module that parses syntax like this. em-pred.el could probably serve as some inspiration, as well as some examples of how it's tricky to get this right (for example, em-pred.el only supports predicates at the *end* of a word). You might also be able to add a custom argument modifier that works somewhat like "expand" above. See 'eshell-modifier-alist'. > It would be handy to have something similar in eshell instead of > explicitly writing a loop: > > for i in (number-sequence 1 5) { >     touch (format "file%d" i) > } As of Emacs 31, you could shorten this to: for i in 1..5 { touch (format "file%d" i) }