From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Format code snippets of the wolfram language to improve readability. Date: Wed, 27 Apr 2022 08:32:13 +0800 Message-ID: References: <87ilqw6x9i.fsf@gmail.com> <377659b8-dc92-b916-f406-831e1bb24ffb@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="830"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Thibaut Verron Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 27 02:33:10 2022 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 1njVcD-000AeO-QK for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 27 Apr 2022 02:33:09 +0200 Original-Received: from localhost ([::1]:49556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njVcC-0006Jv-AS for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Apr 2022 20:33:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njVbY-0006Jk-7p for help-gnu-emacs@gnu.org; Tue, 26 Apr 2022 20:32:28 -0400 Original-Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:40744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njVbW-00050S-KY for help-gnu-emacs@gnu.org; Tue, 26 Apr 2022 20:32:27 -0400 Original-Received: by mail-ed1-x536.google.com with SMTP id p18so178305edr.7 for ; Tue, 26 Apr 2022 17:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ojdTj8Rg443SaPr5XH8oJBN5DrdNBeMFpapxp8hl+hE=; b=O3nNtFfYXlsVBLIiqfGx72VChNfeiP/pAaJEhTkZgesdpAMQPlOr1J2uZU8BydnxzP cBNEn64AN78+geh7jnlaHMiyuSzag6BldZqryx/uOMysOdzs5of9lSCgL5p2OX6AziQd pOyC1GPefejAkQaesFPznkhsOzWElhECJQe/kwGZHZlIu5a2RLhPgWcsVw7l1GtqRHAv wS4BnMMmaCESsjxjjQOm59GrtHlH9v6Ea7aKQFmB72jSQLVcrHR5jt0BzMaAi/J4TDnx fyRsBCRROVjw4sih7wCpcBN3KL5Hi8Dumu2EBjhJJArCUHiJBqL0qp2WtQiOEPGoaOxb j9/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ojdTj8Rg443SaPr5XH8oJBN5DrdNBeMFpapxp8hl+hE=; b=7vu6c/gdwdfQD2EDCsEtGGru0vkkQsalXxFH5zvZd2ONiemrN3HYtXHzzv3yoyOrRJ noLlw9mBFxT4KRhPxgFpW4f0HV5zr3bhFJGISq/qWluTcpOI421OZhciCSTBJffxmxaP rG3IJUg6jyxOEoURcUsiU7rKnNyaoPEryVuPrKSTjGE9beDnWZ5xUFIOlECgnStcWUox 0cuVzjiPxUlWb4KaE4vcdfBVZIfl4MSGHuphTzjP2hgWGOTCIlOWPMUDcPzCxKxnimp2 +msL5y55U9HMFPRmLXDYW9CeCSNqJGtA5UkEqnBQCnMR7nFnrSuNOFF72nbtrPTNbqF7 idEg== X-Gm-Message-State: AOAM5333FJIdLU2welnQbFyig3S8C51v/89gwk3O4x/uAmsqZKAUHb/t 0vG5etbDqM3DM2qzhpnkq+neTibf5F3ttoy5kFZUt2+iuCkX8qBoXcw= X-Google-Smtp-Source: ABdhPJyhV7UK7r3LRSDtDeHPCIrIrPvpYRPzEaWA2GwKISIdDmrfColcj6DWO/qFqWZPOfyoWBMuR3UeSfDxcJE9tZQ= X-Received: by 2002:a05:6402:d05:b0:425:b5c8:faeb with SMTP id eb5-20020a0564020d0500b00425b5c8faebmr27511759edb.273.1651019544771; Tue, 26 Apr 2022 17:32:24 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=hongyi.zhao@gmail.com; helo=mail-ed1-x536.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, T_SCC_BODY_TEXT_LINE=-0.01 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" Xref: news.gmane.io gmane.emacs.help:137040 Archived-At: On Tue, Apr 26, 2022 at 10:31 PM Thibaut Verron wrote: > > On 26/04/2022 16:00, Hongyi Zhao wrote: > > On Tue, Apr 26, 2022 at 9:17 PM Thibaut Verron wrote: > >> Hi, > >> > >> Once the mode is activated, introducing newlines at key places should > >> make the formula readable. > > Yes. It works. But this method needs to hit many times on to > > achieve the goal. > >> You can also use sexp-navigation commands to > >> quickly navigate the parentheses and find those key points. > > I don't have this command, as shown in the attachment. > > It's not one command, but a set of commands for navigating paired > expressions: for example forward-sexp C-M-f (jumping over a symbol or a > paired expression), backward-sexp C-M-b, and down-list C-M-d (jumping > inside the next paired expression). Those commands are designed for lisp > languages, but they work remarkably well for most programming languages > (and are even occasionally useful with natural languages). > > For example for your expression, you can get the formatted version I > sent with: (indented to follow the depth in the expression) > > C-M-d > C-M-d > C-j > C-M-f C-M-f C-f C-j > C-M-d > C-j > C-M-d > C-M-d > C-M-f C-M-f C-f C-j > C-M-f C-M-f C-f C-j > C-M-f C-M-f C-f C-j > C-M-f > C-f > C-f C-j > C-M-f C-M-f > C-f > C-f C-j > > I know that it looks somewhat complicated and long, but it's easier done > interactively than read. :) It would be much more useful to generalize the working logic like the one above and use a function implementation to handle the work here. Regards, HZ