From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov 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, 1 Oct 2021 18:48:27 +0300 Message-ID: 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; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13379"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 Cc: tomas@tuxteam.de, emacs-devel To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Oct 01 17:55:02 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 1mWKsH-0003JO-FS for ged-emacs-devel@m.gmane-mx.org; Fri, 01 Oct 2021 17:55:01 +0200 Original-Received: from localhost ([::1]:51250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWKsF-0003gY-Nf for ged-emacs-devel@m.gmane-mx.org; Fri, 01 Oct 2021 11:54:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWKm3-0004TC-Fe for emacs-devel@gnu.org; Fri, 01 Oct 2021 11:48:35 -0400 Original-Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]:41784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWKly-0002Zd-RJ for emacs-devel@gnu.org; Fri, 01 Oct 2021 11:48:35 -0400 Original-Received: by mail-lf1-x12b.google.com with SMTP id j5so35610664lfg.8 for ; Fri, 01 Oct 2021 08:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=v7gGKHgm5RnGgMM3xL0pJj4O/5Qe9t6xg4/ImE/n/4s=; b=qanrF6P6aDIlROcTOqF6NYjM6LBZf83czkQuEYVTNaD7ma80GMy6tn8rfdiRifIIVj z4CKgQHxvSEkA1kEfhlapsN484ugwh2u8Z7EYla8lhRNXMpqlO4SoJ8vgLXJ/XjfoCGb ePv17Hl1QO18MOvRQzvWRao6mKNQwGsC8MI87j5+GH9fsN2eGBf5TTJfGzup7GKjlptg ZjFaMIg2yHQ1q01ATwmCD+fqq+46ycd1SMKXPAYUAOtBGPuoRmSF7Rg141yPezhS0lVq uLZuJ8sK7/8NQK9Oy2nS94fijCCh1rjU7fqB9hEg6dnt1YZ/nNkxoYdNwyVc4zDeaTAM P2Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=v7gGKHgm5RnGgMM3xL0pJj4O/5Qe9t6xg4/ImE/n/4s=; b=XhfuemLzYNBLT1qX6lAvrUFS26SS3z4XnbwBaWwweO5U4Qwg7TBBT+9O7aw7V3pdnR 4EJCt/pBtVj317ifHkgsuKlrJLFOmFopthiQAFZ8V1uJtEqQ59pZD+d+1m/9wBVQEOGr ytFCQwMW7osiclKBqBnabDNF2nNlkCG4qLCgnWdpNt9hI+MDC/+oQYS6X1rwGQTFVrHF eKptVmVC0fPBQWQv1QantTIB3NxI1oRuYNKmhY+SbErIIzl0DZY1NnRdXF32V2T1JstR KirJiFdekx8M6XNzhFwO6s7+T6D9xHnSNXwYN4VrJBT317rP56RPpMaMk18kvFeD/WFA jtWA== X-Gm-Message-State: AOAM531DJ6h8Q0Zsaf0I4FEv4sK0q/LSNzx5diWz693yD8iGupX3/QjC OJQ+Bj70j7na+7OtsQw0Da/0Qrmxdok= X-Google-Smtp-Source: ABdhPJw8eK2+brANhWkNkKASj5QwDLo/bjJ0+ifr+PiBEcj56dlm6psugc7r7x9ktC6BKWXaHtPTjA== X-Received: by 2002:ac2:43ca:: with SMTP id u10mr6536973lfl.612.1633103309042; Fri, 01 Oct 2021 08:48:29 -0700 (PDT) Original-Received: from [192.168.1.113] ([178.252.127.239]) by smtp.googlemail.com with ESMTPSA id m4sm407247ljq.4.2021.10.01.08.48.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Oct 2021 08:48:28 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=raaahh@gmail.com; helo=mail-lf1-x12b.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-1.127, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:275990 Archived-At: On 01.10.2021 17:40, João Távora wrote: >> Certain language designers intentionally limit the language's power due >> to usability considerations, keeping in mind their audience. > > What languages, what evidence for this? Anyway, many more limit the power > due to performance considerations. Counts as "usability"? I guess. IME > language audiences that are interested in performance usually don't > care so much > about ergonomics and vice versa. Go would be one example. The reasoning lies largely in the field of usability. Their understanding of it, at least. But being able to use certain common tools belongs to the same area. >> 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. If we moved the declaration of the package prefix from the referring file (at the bottom) to the defining file, or just always said that the prefix must match the package name, this would make this possible. At the cost of some flexibility, of course, but I'm not sure who really needs that. Taking the example from the manual, the clients would be able to write ;; elisp-shorthands: (("snu" . "some-nice-string-utils")) but not ;; elisp-shorthands: (("sn" . "some-nice")) and that doesn't sound like a terrible limitation. > But > possible, yes. Would you like to work on that `thing-at-pt.el` front? thing-at-pt? I'm not sure which particular task you are referring to. >> If that approach is not feasible, we're limited to searching for the >> instances of 'require' forms (when the symbol/function can be mapped to >> a package name) and then searching inside every such file on the second >> pass. > > That's not the approach I was thinking of, but I hope to present a working > prototype soon, which is a better way to present ideas. Looking forward to it. >> read-ing the contents of every Lisp file is pretty expensive, in comparison. > > Have you benchmarked? What exactly have you benchmarked? Just `read` or > `read` + `parse-partial-sexp` (i.e. building the syntax-ppss cache)? > Versus what? I'm currently having a discussion where taking 2 seconds to search for a (very common) Lisp reference across Emacs code base is considered too slow, with all the Lisp overhead of parsing the results and constructing the list and rendering. Simply doing (benchmark 1 '(dolist (dir load-path) (when (file-exists-p dir) (let ((files (directory-files dir t "\\.el\\'"))) (dolist (file files) (unless (file-directory-p file) (with-temp-buffer (insert-file file) (read-from-string (buffer-string))))))))) Reports 2.5 seconds here.