From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Nikita Domnitskii Newsgroups: gmane.emacs.devel Subject: Re: Instead of pcase Date: Tue, 28 Nov 2023 12:35:26 +0600 Message-ID: <87y1eiz8pd.fsf@yggdrasil.mail-host-address-is-not-set> References: <87fs169mjj.fsf@posteo.net> <093f11a1-57c2-5e56-d39b-26fef1c67cbb@gutov.dev> <25942.25061.217864.329049@retriever.mtv.corp.google.com> <87zfzdcz6z.fsf@posteo.net> <87zfza2aq2.fsf@web.de> <7nmsv9zq6u.fsf@ecube.ecubist.org> <7nv89x5tsi.fsf@ecube.ecubist.org> <87o7focuf5.fsf@web.de> <875y1r10jr.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39343"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: rms@gnu.org, michael_heerdegen@web.de Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 28 14:54:42 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 1r7yXx-0009y5-I9 for ged-emacs-devel@m.gmane-mx.org; Tue, 28 Nov 2023 14:54:41 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7yWo-0000PN-Ag; Tue, 28 Nov 2023 08:53:30 -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 1r7rh7-0005Cy-Oi for emacs-devel@gnu.org; Tue, 28 Nov 2023 01:35:42 -0500 Original-Received: from out-182.mta1.migadu.com ([95.215.58.182]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7rh4-0006No-GQ for emacs-devel@gnu.org; Tue, 28 Nov 2023 01:35:41 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=domnitskii.me; s=key1; t=1701153331; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aPno2DwynZgTvbFqLey5DsIr6ce3+V6FDwepxiwVv7M=; b=ILw9xoYxkA5fUwC7tzGYyOLxB0FE9O3XWK6kt5Y4DflQ9D63mpJcZ8mEwP/7VCvbk4bY4w 1TJt6Sy9EE0jxH9kan0DlyvZlo8MBnhhcxWBHdooWtJWEsGX/eCexsEuzHGhDCTg9MiCiZ Pcj23D8/REX3XasnXbYd0AFVFu0nYF0= In-Reply-To: X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=95.215.58.182; envelope-from=nikita@domnitskii.me; helo=out-182.mta1.migadu.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 28 Nov 2023 08:53:27 -0500 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:313315 Archived-At: Richard Stallman writes: > (cond* (:bind b1 (b (save-window-excursion (find-file-at-point filename)))) > ((bufferp b) (setq b1 b)) > ((bufferp (car-safe b)) (setq b1 (car-safe b)))) > (if b1 (switch-to-buffer-other-window b))) > > (cond* (:bind b1 (b (save-window-excursion (find-file-at-point filename)))) > ((bufferp b) (switch-to-buffer-other-window b)) > ((bufferp (car-safe b)) (switch-to-buffer-other-window (car-safe b))))) > > (let ((b (save-window-excursion (find-file-at-point filename))) b1) > (if (or (match-set b1 b (bufferp b1)) > (match-set b1 (car-safe b) (bufferp b1))) > (switch-to-buffer-other-window b1))) To be honest all variants look less expressive than original pcase. Maybe instead of trying to implement cond* we should look into impoving pcase patterns? As a starting point I suggest Racket pattern matching implementation (which in my opinion is fairly readable): https://docs.racket-lang.org/reference/match.html -- Best Regards, Nikita Domnitskii