From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Daniel_Mart=C3=ADn?= Newsgroups: gmane.emacs.help Subject: Re: Exploring a code base? Date: Tue, 27 Oct 2020 23:53:12 +0100 Message-ID: References: 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="18481"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) Cc: help-gnu-emacs To: Yuri Khan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 27 23:54:05 2020 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 1kXXqu-0004iI-QT for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 27 Oct 2020 23:54:04 +0100 Original-Received: from localhost ([::1]:43284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXXqt-00040I-Rw for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 27 Oct 2020 18:54:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXXqO-0003zs-0g for help-gnu-emacs@gnu.org; Tue, 27 Oct 2020 18:53:32 -0400 Original-Received: from sonic309-25.consmr.mail.ir2.yahoo.com ([77.238.179.83]:46317) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXXqK-0008CD-8W for help-gnu-emacs@gnu.org; Tue, 27 Oct 2020 18:53:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1603839203; bh=zHEavHtNZgYVQKED0FbC2u88nDAXl2bFS6wUyjtKznI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject; b=hyGyMr+xCi49r58Rpt16N1Yfee/YyaydLxh96Hyji+ow9wdyhBeHRINbHCC+4sAUiOkJtZrZUfSkLWX7ceRfh/lRIgRF/kZeoFbRiByigAtnIpVqy8sxB1Ulr7bh8xPEwCzdYICweAfFEShS76kn1KVjKfWe/YOdd3L/ocw0SodTLbn/PZScz+t8mYNKgM+x5838tpp35OL2tHBvWb+l3FPgaqga7YjnONRYXjyiLSJ0RU0oN/MFaW0Exz8kM622OT/kMb6SwYet1BISYmGVN6qRjrhH5U8LRFdwWghp134VIHUfgpNtMe6vH8nj9KwswQmWa74euPsAkJ4V3Hbo3w== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1603839203; bh=RhvakqtXn257yZ4XNhu9BhhmNGynXh+gPAvmcoalNAn=; h=From:To:Subject:Date; b=Y2FLA5X0aicNXYfU9JoLbDi9wmd9KF8FclI49G4KqPbD0pXcV97OhOHQOKn8hK2e3MMlRVa2gS4ywPBjmeugmwoC1D8Peqmc9ysaC8ScTAWOB2HtJj50AzpShx1aZf4MHyBVzBx+R3bD+6xg1wwEyk6OYl/DNAyoC1ffpmFhv001RbdTGM9xqLkZBZk4kyGImGGK615vXVgCmpDAcSCp/qFeifzuXiAjgucC6BgRemvUy4jZI3sfrRvBmQeMu5TnJpB2oRNl2ksnlT3BF4fOuIdsDrlmM5yzR/vzkECIW8M4znbDJ2zcLJCRZBgdHyK0P8RuGNdnveGL06P5FesE4g== X-YMail-OSG: 9l_q_bUVM1m1GcsHDtjaExNXdluco9M.jtqFy3oxm8JWMY__8NYdHm2OyJSQch7 DM.7iJOlYU.zmWP4SF8Og7XYtPaQ850oPUIJ8UwHcKokYNMSHrTSiksdawwAK4Rvc4A4DnUvX3Z2 M4hHyeWqAOp5EdGvELnyMzseoND0ru3JZxM6s5LeaSuqW.Nn6dmXtVHAVs4sj7VZR_rBwjfz1j_j q3yj20YDds5GlvQQ7aceEmAHn8tXxo2a_2HuvORTYzzRbLm3y6.CnmAP3kpi.ZgXY9GfWnmRjD4b FipMCWGat2pjxgScGvyGNqjtd1gzAGxZ_Q3JmnisUXiRDLX.9FkU3RRyiMvePpsCPMNkSMQzUHcf 0yhw583kL7hrB0LVVbo6POFaRpWdBju_5tSdcJ4l66e1OQZvwCbMU4TFCNxyRHAaAiGEQVT0h3gU UDhxoWKJbg_yhPHRbcPtGLZzwWNG1NoRtk1WiCqGyzVhL_7VaLPeUaTRBeNRtmX.XOr0vuND7yeE 1jFUA0UMXggnzBug6neXvm9tXpBjDwHZ8zB46uHVAKnkyyR8wGfWCdW2NyQRcGfSiGzX7rIBf5jx jhIlhdPt.vNzSokJNjAl7TcUnInujiuZg1QSl6S.XWpAZyxNcnxnAIjyVcDLvjJ0OL8kleiMiu.Y MLHKVsVrCfv8aXR0wvl7vclCKCtTYfTdFcwl2Bz9rs8ex0.4mkfMyGM7lra3D8Cd5hMA97DGJAbL kvjGG7tz2JNcDfz9W4HGpTOG2ie1W_KrkoxHOn.LO6i8kRpEiRJWJl._GyRPCjrnsPf_ikZB1N5y XeEw750j7fh2u1r5wk.XB76_5wopvxxeJ2izsQ2HUn Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ir2.yahoo.com with HTTP; Tue, 27 Oct 2020 22:53:23 +0000 Original-Received: by smtp402.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID b4793d1e0b5d643b1134b5d6e81da5fb; Tue, 27 Oct 2020 22:53:15 +0000 (UTC) In-Reply-To: (Yuri Khan's message of "Tue, 27 Oct 2020 18:38:49 +0700") X-Mailer: WebService/1.1.16868 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Apache-HttpAsyncClient/4.1.4 (Java/11.0.7) Received-SPF: pass client-ip=77.238.179.83; envelope-from=mardani29@yahoo.es; helo=sonic309-25.consmr.mail.ir2.yahoo.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/27 18:53:24 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 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" Xref: news.gmane.io gmane.emacs.help:124757 Archived-At: Yuri Khan writes: > > When the change I=E2=80=99m doing is not very invasive, the affected subg= raph > fits completely in my head. However, when it doesn=E2=80=99t, I find myse= lf > having to record my traversal state. I create an Org buffer and > manually maintain a queue of nodes, marking those I haven=E2=80=99t yet > visited with TODO and those I have with DONE. Then I pick the first > TODO, grep or xref-find-references on it, add any relevant nodes to > the queue, make the necessary changes in the code, and mark the node > DONE. Repeat until no TODO. > > This is rather tedious. It feels like there should exist a better way, > maybe with a visualization of the graph structure. > > What do you use to explore and map a code base and perform extensive > changes on it? It depends on the programming language, but I usually rely on a compiler to generate an index for my project in the background. An index is similar to a TAGS file, except that it was generated by an actual compiler and therefore all code relationships (child of, parent of, referenced by, aggregate of, etc.) are stored in the index and are usually very accurate. There are many tools that can "visualize" code indexes. For C/C++ languages, there is Sourcetrail (https://github.com/CoatiSoftware/Sourcetrail), for example. Clangd (https://clangd.llvm.org), a language server for the C family of languages, can also generate an index that you can use to perform simple refactorings, like a rename, or to ask for the call graph of some function. Clangd is usable from Emacs via Eglot or lsp-mode. This code index approach still has limitations, though, like how to make sure that the index is completely up to date before a query, or how to scale it to codebases of millions of lines of code, where creating an index in a single machine is usually not possible. But I think a compiler-generated index may be a good trade-off over using grep + keeping track of things manually.