unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Anand Tamariya <atamariya@gmail.com>
To: emacs-devel@gnu.org
Subject: Semantic lexer based indent region function
Date: Mon, 17 May 2021 10:49:32 +0530	[thread overview]
Message-ID: <CADm7Y4nWfBUGs+o9mjEB8A6YnqzyTpnsEKmZ6rHpGsX=B6BXXA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 795 bytes --]

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
<https://gitlab.com/atamariya/emacs/-/blob/js-format/lisp/cedet/semantic/java.el#L1502>
 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

[-- Attachment #2: Type: text/html, Size: 1305 bytes --]

                 reply	other threads:[~2021-05-17  5:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADm7Y4nWfBUGs+o9mjEB8A6YnqzyTpnsEKmZ6rHpGsX=B6BXXA@mail.gmail.com' \
    --to=atamariya@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).