From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Anand Tamariya Newsgroups: gmane.emacs.devel Subject: Semantic lexer based indent region function Date: Mon, 17 May 2021 10:49:32 +0530 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000be45d005c27fbd25" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1825"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon May 17 07:20:23 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 1liVfy-0000Ex-Sd for ged-emacs-devel@m.gmane-mx.org; Mon, 17 May 2021 07:20:22 +0200 Original-Received: from localhost ([::1]:42198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1liVfx-0002bg-3L for ged-emacs-devel@m.gmane-mx.org; Mon, 17 May 2021 01:20:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1liVfP-0001xg-MG for emacs-devel@gnu.org; Mon, 17 May 2021 01:19:47 -0400 Original-Received: from mail-il1-x134.google.com ([2607:f8b0:4864:20::134]:33559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1liVfN-0005j5-UM for emacs-devel@gnu.org; Mon, 17 May 2021 01:19:47 -0400 Original-Received: by mail-il1-x134.google.com with SMTP id z1so5053953ils.0 for ; Sun, 16 May 2021 22:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=8d5zZNdxNzXDzWPtH0dCX5i2NyJDpnEEHMoeIAt9/pI=; b=j4D2NzWyv8WP8iE0ANYSmSPxJ4nU5GJsyL9vm54Vv7tzTDvuk8TYCRD3mFgIbqlrSG ITZdCWMBd3e27NRxVt4ukNMVH9MKBvBqzoGSC4KeJoT5cqUcRtOU6exSZVBMV3Yum7RY wPpV/l6ooNVrJs2wA6z25NKXNi+n3dzW6hNS+Pr3/S/rEYs70aCmMab89Df0teXzsEu+ SUaT+Phh+TtY5XIoNp7dvpwZgiGsTftVqBnRi1xNKgvZkBpXPSJ4WV+vknpx9BK93qca fijiaPX2wI4JeyL/0d+gNNDibzrqezJKspGkAqYUyhYTvRIynNGBO7PMoRCpYE9eJRaZ y8nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8d5zZNdxNzXDzWPtH0dCX5i2NyJDpnEEHMoeIAt9/pI=; b=d0Uin8v2Wbs4PxNVNPOtUQVSp9M6FtOlRI+mzR2H00+2U5ZmnPXkMSLkx18GDNcGac EDh8e42PLGbmz8LO00bcxyM2bQwbZ9AEV9YKC6xWz5kK+HC3C38u7OKWDlI+u8qI2WF8 CBeJIQiuK4Gk/bURZt+tIE3JowEb9No0+5wqPo10a2ehqgTiL9Mq1xrKM/c77dKZWfxS eYQh2VzialtcquiTAP4X89OoZfXXRdkWm2vAA1AnnRDdl6xJ2XXvAvLYsrvG5EDoeO8E QjlDtg1uPJg0mitFQhBCc3WZNchLtMs1BAbPyzxHPaBEMx2QT1zxeYxOo+HBAFcDGiSp 3Zxg== X-Gm-Message-State: AOAM531tH6o4dwmHyv84FZTcA+SVdK1LU6MBOvQS7suRc4ovnq22XRyt KrJgHAB/y56KLUDHSmheEfpNOVbGIh+D+iW02/dc2QaER10= X-Google-Smtp-Source: ABdhPJwiL4fabW5OxD1D0ecEbqEYcEaxXNt181RJMITRMxu0IrMnCBDzQCrKO8cp/X1qFTIm0ni5eeBTkr8sG80T+/A= X-Received: by 2002:a05:6e02:1649:: with SMTP id v9mr10000941ilu.62.1621228783550; Sun, 16 May 2021 22:19:43 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::134; envelope-from=atamariya@gmail.com; helo=mail-il1-x134.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, HTML_MESSAGE=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: 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:269386 Archived-At: --000000000000be45d005c27fbd25 Content-Type: text/plain; charset="UTF-8" Here is a Semantic lexer based indent region function for formatting code in Emacs. It should work for Java and javascript. Feel free to use it if you like the output or customize it to suit your needs. *Screenshots:* https://lifeofpenguin.blogspot.com/2021/05/semantic-lexer-based-indent-region.html *Code:* semantic-indent-region Features - Removes redundant whitespace. Multiple new lines are replaced by two new lines to mark paragraph separation. - Uses tab for indent and fill-column width to wrap lines (hard wrap). Set values for *tab-width* and *fill-column* as per your preference. - Adds one indent for each level of nested code. - Splits line on semi-colon. Regards, Anand --000000000000be45d005c27fbd25 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Here is a = Semantic lexer based indent=20 region function for formatting code in Emacs. It should work for Java and= =20 javascript. Feel free to use it if you like the output or customize it=20 to suit your needs.

Code: semantic-indent-region

=C2=A0Features

  • Removes redundant whitespace. Multiple new l= ines are replaced by two new lines to mark paragraph separation.
  • Us= es tab for indent and fill-column width to wrap lines (hard wrap). Set valu= es for tab-width and fill-column as per your preference.
  • =
  • Adds one indent for each level of nested code.
  • Splits line on s= emi-colon.
  • Regards,
    Anand

    <= /div>

    --000000000000be45d005c27fbd25--