unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 66303@debbugs.gnu.org
Subject: bug#66303: [PATCH] Document 'M-x align' in the Emacs manual
Date: Mon, 02 Oct 2023 10:21:58 +0200	[thread overview]
Message-ID: <m1fs2tigd5.fsf@eshelyaron.com> (raw)

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

Tags: patch

Hi,

This is a request for documenting `M-x align` in the Emacs manual, along
with a suggested draft for such documentation.


Best,

Eshel


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Document-M-x-align-in-the-Emacs-manual.patch --]
[-- Type: text/patch, Size: 3987 bytes --]

From 20fa3ea348617350fa8a437fad75aa9e9a9a620f Mon Sep 17 00:00:00 2001
From: Eshel Yaron <me@eshelyaron.com>
Date: Mon, 2 Oct 2023 10:02:46 +0200
Subject: [PATCH] Document 'M-x align' in the Emacs manual

* doc/emacs/align.texi: New file.
* doc/emacs/emacs.texi: Include it and update menu.
---
 doc/emacs/align.texi | 70 ++++++++++++++++++++++++++++++++++++++++++++
 doc/emacs/emacs.texi |  2 ++
 2 files changed, 72 insertions(+)
 create mode 100644 doc/emacs/align.texi

diff --git a/doc/emacs/align.texi b/doc/emacs/align.texi
new file mode 100644
index 00000000000..c7e48890695
--- /dev/null
+++ b/doc/emacs/align.texi
@@ -0,0 +1,70 @@
+@c This is part of the Emacs manual.
+@c Copyright (C) 2023 Free Software Foundation, Inc.
+@c See file emacs.texi for copying conditions.
+@node Alignment
+@chapter Alignment
+@cindex alignment
+
+  @dfn{Alignment} is the process of adjusting whitespace in a sequence
+of lines such that in all lines certain parts begin at the same
+column.  This is usually done to enhance readability of a piece of
+text or code.  The classic example is aligning a series of assignments
+in C-like programming languages:
+
+@example
+int a = 1;
+short foo = 2;
+double blah = 4;
+@end example
+
+Is commonly aligned to:
+
+@example
+int    a    = 1;
+short  foo  = 2;
+double blah = 4;
+@end example
+
+@findex align
+  You can use the command @kbd{M-x align} to align lines in the
+current region.  This command knows about common alignment patterns
+across many markup and programming languages.  It encodes these
+patterns as a set of @dfn{alignment rules}, that say how to align
+different kinds of text in different contexts.
+
+@kbd{M-x align} splits the region into a series of @dfn{sections},
+usually sequences of non-blank lines, and aligns each section
+according to a matching alignment rule by expanding or contracting
+stretches of whitespace.  If you call this command with a prefix
+argument (@kbd{C-u M-x align}), it enables more alignment rules that
+are often useful but may sometimes be too intrusive.  For example, in
+a Lisp buffer with the following form:
+
+@lisp
+(set-face-attribute 'mode-line-inactive nil
+                    :box nil
+                    :background nil
+                    :underline "black")
+@end lisp
+
+Typing (@kbd{C-u M-x align}) yields:
+
+@lisp
+(set-face-attribute 'mode-line-inactive nil
+                    :box                nil
+                    :background         nil
+                    :underline          "black")
+@end lisp
+
+@vindex align-indent-before-aligning
+  If the user option @code{align-indent-before-aligning} is
+non-@code{nil}, Emacs indents the region before aligning it with
+@kbd{M-x align}.  @xref{Indentation}.
+
+@vindex align-to-tab-stop
+  The user option @code{align-to-tab-stop} says whether aligned parts
+should start at a tab stop (@pxref{Tab Stops}).  If this option is
+@code{nil}, @kbd{M-x align} uses just enough whitespace for alignment,
+disregarding tab stops.  If this is a non-@code{nil} symbol, @kbd{M-x
+align} checks the value of that symbol, and if this value is
+non-@code{nil}, @kbd{M-x align} aligns to tab stops.
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index 7a21eb49e24..c4ed9a6ae93 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -178,6 +178,7 @@ Top
 Advanced Features
 * Modes::               Major and minor modes alter Emacs's basic behavior.
 * Indentation::         Editing the white space at the beginnings of lines.
+* Alignment::           Making common parts of lines start at the same column.
 * Text::                Commands and modes for editing human languages.
 * Programs::            Commands and modes for editing programs.
 * Building::            Compiling, running and debugging programs.
@@ -1616,6 +1617,7 @@ Intro
 @include mule.texi
 @include modes.texi
 @include indent.texi
+@include align.texi
 @include text.texi
 @c Includes fortran-xtra.
 @include programs.texi
-- 
2.42.0


             reply	other threads:[~2023-10-02  8:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02  8:21 Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-10-02 16:05 ` bug#66303: [PATCH] Document 'M-x align' in the Emacs manual Eli Zaretskii
2023-10-02 19:30   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-05  7:52     ` Eli Zaretskii
2023-10-05 10:46       ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-07  7:26         ` Eli Zaretskii
2023-10-07 19:02           ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-14  8:00             ` Eli Zaretskii
2023-10-14 10:02               ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-14 10:26                 ` Eli Zaretskii
2023-10-14 10:47                   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-14 11:17                     ` Eli Zaretskii

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=m1fs2tigd5.fsf@eshelyaron.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=66303@debbugs.gnu.org \
    --cc=me@eshelyaron.com \
    /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).