From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tpeplt Newsgroups: gmane.emacs.help Subject: Re: Matching labels with buttons Date: Mon, 15 Jul 2024 14:29:33 -0400 Message-ID: <877cdm1pbm.fsf@gmail.com> References: <66950ec4.df0a0220.b86df.5c24@mx.google.com> Mime-Version: 1.0 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="35990"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Heime , Heime via Users list for the GNU Emacs text editor To: Bruno Barbier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 15 20:30:37 2024 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 1sTQT5-00099i-LR for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 15 Jul 2024 20:30:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTQSF-00067K-O6; Mon, 15 Jul 2024 14:29:43 -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 1sTQSB-00066Z-IZ for help-gnu-emacs@gnu.org; Mon, 15 Jul 2024 14:29:40 -0400 Original-Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTQS9-0006E7-8t for help-gnu-emacs@gnu.org; Mon, 15 Jul 2024 14:29:38 -0400 Original-Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-79f16c85da0so307384485a.2 for ; Mon, 15 Jul 2024 11:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721068176; x=1721672976; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dIRURbE/zwim+i+gkOpVwwAUJ0Tw9pSdUj7iYcyIUaE=; b=USe8JeWUuASdhvYlZYQeI1guLfUVju4/KL1ovpYpli+CZ/UHeAfG9dVfCP66P/YVIJ 023Xq0TV+zn7zH5F9ZhFwFo5xLCEH0uOvTDUWdFFHO+E7pYE+nAhqJgzLmT+PLkPWKvr 7kD5qNsbRgWHIZdDGiAOMLdLV7YiByr4QTqxfPqDidxgfC7GN7K5Sl1p4dDWuoGkjrv3 5a2WqxnzkiFOnJbhZ0o3HO063cbqLwO2svQBSKheF77TbtrmAcyFPQB7sO1y15dfIDXD rFZ7HmkLKiurxTGz3KD/dAugDuHcTbusARfD9j7fbpgTLTG8RQjrysJy9FMqdgyGI/4D t1dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721068176; x=1721672976; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=dIRURbE/zwim+i+gkOpVwwAUJ0Tw9pSdUj7iYcyIUaE=; b=QPVtekQeczM8FSFNWNcGsCFZyXSfEynqj0knNoxL8spfa/o+N+maQno+Y19j2m0oVU 0XLrYhFZ4Pb1DxQHOHWJyGQpW6sHrv5Q6mU+bRhAPeyu/mIVcM5d9PtHfpNJul1CWbmH CFsHaEamX6bJ/gyfS7P4XMpRTR4mY19lGlg/2fpX1tFc5SYBgZVLdn4DeYSSaYa2JdrK x+hnzi04zIVD+x2mPxqTp0y1BObwGbw3n9QYx/Lu3ZUG7zEUcA+OhuMZE1SZLMJzRqC8 o8j0ULxW0V7yPEtp/jb+Pw7f2k5H+OmBURGfATsDTwpD1sots0jHMiEk052jCuafxtWR q+mA== X-Forwarded-Encrypted: i=1; AJvYcCX+nj9iIewzdOBzA9matQGel0wBOsD+Rfu3EAcXfzLq4dcusd96CR1lujmOfcxGo/JW7fZC99jBVsMKatnTFl3kRnXFgzuK X-Gm-Message-State: AOJu0YxHLwwhbSDgJ1rBhoPmV23fEOgcNXssm+W7jGgKgzzWreBi4ZoJ W/XPANVtnEKrTQeqeshvT3rqQSYMQaLBjJbMGuCXcsGSp7+UPbMJ9PvmSuSP X-Google-Smtp-Source: AGHT+IFjM6MgMGvkbykdNNwQrAhAgcpuvmZ/R+zl4eQ5mBv5ZtURYsWEWenVQo02AKiGSo9brou5yQ== X-Received: by 2002:a05:620a:45a3:b0:79e:f80a:2ab8 with SMTP id af79cd13be357-7a179f3fbbdmr72980785a.25.1721068175774; Mon, 15 Jul 2024 11:29:35 -0700 (PDT) Original-Received: from t530.local ([2600:8806:a801:3150:6232:a925:a650:ba8c]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bbe6c6sm223366285a.39.2024.07.15.11.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 11:29:34 -0700 (PDT) In-Reply-To: <66950ec4.df0a0220.b86df.5c24@mx.google.com> (Bruno Barbier's message of "Mon, 15 Jul 2024 13:57:55 +0200") Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=tpeplt@gmail.com; helo=mail-qk1-x72c.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:147230 Archived-At: Bruno Barbier writes: > Heime writes: > > ... > > Because it does match: > > (string-match "\\(\\s-*\\[\\-\\]\\s-*\\)\\(.*\\)" "OFF [-]") > =3D> 3 > > When building regular expressions, I'm often using the amazing M-x > re-builder: it allows to construct regexps interactively with visual > feedbacks, it even understands the "rx" syntax, for more readable > regexps. > Seconded. Build your regular expression using the regular-expression builder, =E2=80=98re-builder=E2=80=99. See (info "(elisp) Regular Expressi= ons"). Note that =E2=80=98re-builder=E2=80=99 comes with a menu that you can use either= to carry out re-builder commands or to learn the re-builder key sequences for commands. An approach you can try: 1. Create a text file (or a only a buffer) that contains examples of strings that you want your regular expression to match. Start with the simplest example and build up line-by-line with additional examples to the most complex example that you can think of. 2. Start re-builder with M-x re-builder. Enter the simplest regular expression that should match your simplest example. Read the Elisp manual entry above, if necessary, to resolve any misunderstanding if your regular expression does not match. Once the simplest regular expression matches your simplest example, add to your regular expression in order to match the second example. The new expression should match your first and second example before you move to matching your third example. And so on. --=20 The lyf so short, the craft so long to lerne. - Geoffrey Chaucer, The Parliament of Birds.