From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: daanturo Newsgroups: gmane.emacs.devel Subject: Re: A function to take the regexp-matched subsring directly Date: Sun, 30 Oct 2022 23:46:10 +0700 Message-ID: <831245da-8f0f-85b7-0cb7-e088157012d2@gmail.com> References: <87wn8h9uy4.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22504"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Cc: emacs-devel@gnu.org To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Oct 30 18:01:36 2022 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 1opBgl-0005h0-Aq for ged-emacs-devel@m.gmane-mx.org; Sun, 30 Oct 2022 18:01:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opBfz-0001a6-KR; Sun, 30 Oct 2022 13:00:47 -0400 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 1opBS5-00052r-Jj for emacs-devel@gnu.org; Sun, 30 Oct 2022 12:46:25 -0400 Original-Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opBS4-00078f-3h for emacs-devel@gnu.org; Sun, 30 Oct 2022 12:46:25 -0400 Original-Received: by mail-pl1-x62e.google.com with SMTP id io19so8870482plb.8 for ; Sun, 30 Oct 2022 09:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=rxVowy05bvQwU/r5LVNa2Qd6dUR8mkPvTwU0UptxMq0=; b=osLPoL7vtCF9acTMSqbYyJbZ+YRUbzKBLDl2xRNiTg21efN+6MJQmC+Hubm711i42T 29KR/3nB3izpZ0RI/jwKSBiPieKmNUfpVNNtvdQmsYTlBOh4rzoQYI7LE9Iu/9uwMFNR u2T3BH8g0iUaPA8r4aw0J3OLAM9XmUp7KbTMq00kzRz6kzO7intiLZAIIkzstwZBjFsy RNxQmGDHXfELG93UPy+nMAfAKxQ1XyGbRKTCb4PGVyDgWqO3dCo/v/HW/tOWALy543fF S6BoSp3q74wdnN1mWY0gtdjoN89YoLvXUZXgYMgPs6Pk/LQ06dlGWX6SS5ATl2mnubml tQ9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rxVowy05bvQwU/r5LVNa2Qd6dUR8mkPvTwU0UptxMq0=; b=ACbVL0Th+cSMu1vlRjAbksmLiO01D5sk+BEq8HvksDmdU3+48v+yG7XB/HXVVp7dig qVtnMMSd9YAPl89xsMWEKKZzm1/aKxWcf4pxxlnd0Y+GxHHmo4Seiec6IY1wg58XOmJm 4o0NYeaOPzR37olbZAXe/yW4Y/+NFT4eglF6UrBjOsbM9lLGpIVyGwwlRHBpUPQdWscg /YWLzpVC87thrNvSx1K7tw7agw4cwsRBEt27r/eojZzIFcHSt2QDxRM5vCy8w7MR9bqh 6vtU7LFKIFL6KlTvRo4ZtHqHAlqCKfBrKIboi4L6Xrc+vWc1TfOnaje3nK6K6EaezNJ/ 8Qvw== X-Gm-Message-State: ACrzQf1f8Sita9Jb8FHu5tHaKQbKwvF1w+dH5FPQ43ujCMuF04SGD2EE J90E32ThRpKz6RTQPmTE928= X-Google-Smtp-Source: AMsMyM7GhfbNRbeoUnjEfHliPs2FMe1umyasOX2bDvmD8zRbTc0kIVYdXZEwq3l4EsnoubUtfdXafw== X-Received: by 2002:a17:903:41cf:b0:186:ac4b:21b7 with SMTP id u15-20020a17090341cf00b00186ac4b21b7mr10111865ple.123.1667148382494; Sun, 30 Oct 2022 09:46:22 -0700 (PDT) Original-Received: from ?IPV6:2001:ee0:4f8d:5d40:72b7:27ac:56c4:2f2a? ([2001:ee0:4f8d:5d40:72b7:27ac:56c4:2f2a]) by smtp.gmail.com with ESMTPSA id q24-20020a63e958000000b00458a0649474sm2568001pgj.11.2022.10.30.09.46.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 30 Oct 2022 09:46:21 -0700 (PDT) Content-Language: en-US In-Reply-To: <87wn8h9uy4.fsf@posteo.net> Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=daanturo@gmail.com; helo=mail-pl1-x62e.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, NICE_REPLY_A=-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-Mailman-Approved-At: Sun, 30 Oct 2022 13:00:46 -0400 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: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298825 Archived-At: On 30/10/2022 22:45, Philip Kaludercic wrote: > Is there a reason you find yourself working with strings as opposed to > buffers? I've seen people try to force functional paradigms on Emacs > when they do stuff like creating a list of lines in a buffer then > iterating over these instead of using the (faster) buffer searching > mechanisms. My worry is that functions like these, while useful per se, > might make more people inclined to write unideomatic and wasteful code. In my case, strings are usually file names and shell command outputs ```elisp ;; Get the commit hash returned by git blame (shell-command-to-string "git blame -L 1,1 -- README") "19dcb237b5b (Eli Zaretskii 2022-01-01 02:45:51 -0500 1) Copyright (C) 2001-2022 Free Software Foundation, Inc. " ;; parse: (regexp-match "^[^ ]+" "19dcb237b5b (Eli Zaretskii 2022-01-01 02:45:51 -0500 1) Copyright (C) 2001-2022 Free Software Foundation, Inc. ") => "19dcb237b5b" ;; From `vc-revision-other-window''s file name, find the original name and the revision (regexp-match*     "\\(.*?\\)\\(?:\\.~\\(.*?\\)~\\)?\\'"     "/foo/bar.el.~main~")      => ("/foo/bar.el.~main~" "/foo/bar.el" "main") ``` And many possible cases where the strings maybe buffer names or any not so long strings that are not the size of a buffer. -- Daanturo.