From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.devel Subject: Re: A read-based grep-like for symbols (el-search?) (was Do shorthands break basic tooling (tags, grep, etc)? (was Re: Shorthands have landed on master)) Date: Fri, 01 Oct 2021 22:58:09 +0000 Message-ID: <1dd5e2c1f42bce50dc26@heytings.org> References: <25d8d72022b571db5291@heytings.org> <87h7e2xsl5.fsf@gmail.com> <25d8d72022e1ea7ed022@heytings.org> <87fstl7lzw.fsf@web.de> <87a6jt7ilx.fsf@web.de> <87fstlzlaq.fsf@gmail.com> <20211001070242.GC16352@tuxteam.de> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37387"; mail-complaints-to="usenet@ciao.gmane.io" Cc: tomas@tuxteam.de, emacs-devel@gnu.org, Dmitry Gutov To: =?UTF-8?Q?Jo=C3=A3o_T=C3=A1vora?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Oct 02 00:59:22 2021 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 1mWRUw-0009Ww-40 for ged-emacs-devel@m.gmane-mx.org; Sat, 02 Oct 2021 00:59:22 +0200 Original-Received: from localhost ([::1]:56158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWRUv-0002KS-29 for ged-emacs-devel@m.gmane-mx.org; Fri, 01 Oct 2021 18:59:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWRTq-0000zg-HD for emacs-devel@gnu.org; Fri, 01 Oct 2021 18:58:15 -0400 Original-Received: from heytings.org ([95.142.160.155]:60640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWRTn-0005mQ-Rb for emacs-devel@gnu.org; Fri, 01 Oct 2021 18:58:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20210101; t=1633129090; bh=+MBtCjB6WUHVXCeZPz4WOQnosO00/5bucnEWVsSzJE4=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=AhR0L7K9qaVForZ3FKnvNJiCaFMRp97YG3HWQlYyGlrYSu9yW8KAe6qymUydaOL/I S22dYdeQitre2CNyxflGfmo8ejmNLjAqvvlCEvXJLO/cyPwDCBGbtlxgBlF+TQwldU xIriRIbIfMg0VoIwrJ40hEq7rq1yXD51OCl5/XKyha3IpMsdpTad2e9i27ZysAUl3E QHV/SVlsMbJMEU8O7xMbDP+P/PVI29Etf6tQccy5vg2sqdTC9pxwsLEm+BANo4jCV3 W6PXodno4ndMg8YrUeBDKnrtiufLoZkqNPt+UCYBXiTopBSFovE4/jz3Yz+AqCY4EF JlGMpWsBBRiyQ== In-Reply-To: Received-SPF: pass client-ip=95.142.160.155; envelope-from=gregory@heytings.org; helo=heytings.org 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_PASS=-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.23 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" Xref: news.gmane.io gmane.emacs.devel:276021 Archived-At: >> Speaking of shorthands, if only the "local" part of every symbol's name >> was something reliable (as is often the case in module/package systems >> out there), we could still implement the search for references using >> Grep fairly efficiently: you Grep across the files for the local name, >> and then post-filter the references by looking at the end of the file. > > Yes, yes, that's basically what happens with Common Lisp, because things > are separated by `:`. And in many other languages as you say. > Unfortunately, it's not 100% clean in Elisp because it relies on > convention, not syntax. > It seems very easy to enforce a syntax for this: diff --git a/src/lread.c b/src/lread.c index af0a799459..b66585df7d 100644 --- a/src/lread.c +++ b/src/lread.c @@ -4657,6 +4657,7 @@ oblookup_considering_shorthand (Lisp_Object obarray, const char *in, Lisp_Object lh_prefix = XCDR (pair); if (!STRINGP (sh_prefix) || !STRINGP (lh_prefix)) continue; + sh_prefix = concat2 (sh_prefix, build_string ("::")); ptrdiff_t sh_prefix_size = SBYTES (sh_prefix); /* Compare the prefix of the transformation pair to the symbol The "::" separator has a similar purpose in other languages (C++, Perl), it is not used anywhere in Emacs core, and it is used in a single place in ELPA (var::append-list in hyperbole). The ":" separator is already used in quite a few places, in Emacs core and in ELPA.