From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.help Subject: Re: Scanning parenthesis in string/comment Date: Mon, 23 Jan 2023 11:24:39 -0800 Message-ID: <760EF52F-D336-4E38-8691-CEA0339C6AE4@gmail.com> References: <497B6D44-1C2D-4C45-9B6B-6719D49B4A69@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.101.1.3\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23976"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Ruijie Yu Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 23 20:26:02 2023 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 1pK2SA-00061R-MI for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 23 Jan 2023 20:26:02 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pK2R9-0001Up-Fk; Mon, 23 Jan 2023 14:24:59 -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 1pK2R6-0001UY-Ed for help-gnu-emacs@gnu.org; Mon, 23 Jan 2023 14:24:56 -0500 Original-Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pK2R4-00080D-Qf for help-gnu-emacs@gnu.org; Mon, 23 Jan 2023 14:24:56 -0500 Original-Received: by mail-pl1-x632.google.com with SMTP id k18so12454375pll.5 for ; Mon, 23 Jan 2023 11:24:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=996NusWphBiBbbqdBQPJ/Zkc1QcW2NsHYyaDK/3d2fg=; b=Out6IBbMzEJZq0xFtd1SM9JpE/dNe1qqtN7YdM+2AcLyLxfJUf0z6eQBhVwR1d2lpt SebDZKZOTnuG7gHXQUhhJIcu8y+YILcca+qDKp3ymAB8TL2zovEKC2tROrEC0Zd7alZh 8u4NyTktC+TUgz69FBXboeGoah14aHvj0ISZqycLIRIaCTczmw2Gt10inSgl59IxkI9B 1fzvAV5ZvCzbg9T0woPLz7k9uNMD5QsH5irAlqa9suJSLjdxJqjHgjxW8+s3ZcsUBCKf EdDirgzTpxqDseJLV8balIhjSoDGBk4SaPxxDkNGIC6gJIO1YNEq+ULzEjFFONyYoAQr bDlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=996NusWphBiBbbqdBQPJ/Zkc1QcW2NsHYyaDK/3d2fg=; b=AzPFAO+3LomZk/xGkDFYMXz36ZQ/mDvw5z7kilcXdNWm6VSo3BKE8qu65HCBaNPwzK SyVoa81cwRSQiXltWgld5uEfnL1SGj+5E56JSWrah94bk3Dru77c/YPRCGVZT9uXdyFp XGPtgjigDQM9x4CB1q35AY1jBWV703toRiFpBbuxKDA/5KNWpc7nPYkw84XrPemXUkoC k5OJUSUJswfeOMSOGoORY4VmwmjFIu2u1hzDZBrIDq1sEKrvz5G4Jichi+m1lmfRNPCT 8LN2aTUu/spnxOmVNbuXywYaWrExslhLTWF61oUzZL1X6N7nNVrJFOpz3YtgD4EXy2rC YH7A== X-Gm-Message-State: AFqh2kq37TmWXHsiwTaug/pwN3mbgZlnWmHc1BiRbwjuckq4de575VzL QkdMf806Cq0IRnNoS3L1O/l8K9C6EXw= X-Google-Smtp-Source: AMrXdXuHNh73rC+dQIcV3mKDVaRQiD/e4e/wJdlrJsf9ZoUaPBXG8FgowQEf/X2PMNSHsNQgIHysJw== X-Received: by 2002:a17:902:d582:b0:192:903c:3726 with SMTP id k2-20020a170902d58200b00192903c3726mr25726434plh.28.1674501892889; Mon, 23 Jan 2023 11:24:52 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id a14-20020a1709027d8e00b0018999a3dd7esm83176plm.28.2023.01.23.11.24.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jan 2023 11:24:52 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3731.300.101.1.3) Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=casouri@gmail.com; helo=mail-pl1-x632.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: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:142520 Archived-At: > On Jan 22, 2023, at 5:49 PM, Ruijie Yu wrote: >=20 >=20 > Yuan Fu writes: >=20 >> I=E2=80=99m writing an expand-region-like function, which expands = region by logical entities, like word-at-point, list-at-point, etc. Say = I have this string >>=20 >> "Filter out invalid regions in REGIONS regarding ORIG. >> ORIG is the current position. Each region is (BEG . END).=E2=80=9D >>=20 >> And point is at the opening parenthesis, how do I detect this = balanced >> parenthesis pair and expand the region over it? syntax-pass and = forward-list >> only works with lists outside of strings and comments, IIUC. >>=20 >> Yuan >=20 > Based on what I remember reading from the relevant info pages and > docstrings, is it possible that you start a new syntax scan that = starts > *at point* and ends *before the ending quotes*? IIUC the function > `parse-partial-sexp' might be what you should look into next. Thanks, that seems to be the way to go. > What I understand is that you use thing-at-point similar functions, so > why not then define your own think at point in the sense as here = below: >=20 > ;;; Thing at point 'thing-within-quotes >=20 > (defun rcd-tap-thing-within-quotes-start () > "Move point to the beginning of thing within quotes." > (re-search-backward (rx (or "\"" "'"))) > (forward-char 1)) >=20 > (defun rcd-tap-thing-within-quotes-end () > "Move point to the end of thing within quotes." > (re-search-forward (rx (or "\"" "'"))) > (backward-char 1)) >=20 > (put 'thing-within-quotes 'beginning-op = 'rcd-tap-thing-within-quotes-start) > (put 'thing-within-quotes 'end-op 'rcd-tap-thing-within-quotes-end) >=20 > Then the above will give you whatever is inside of quotes you define > when you apply function: >=20 > (thing-at-point 'thing-within-quotes) >=20 > on it, and it will not work well outside of quotes. Yeah I can find the range of the string and do a parse inside. Thanks! Yuan=