[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 90266b8: Tweak how 'align' and 'align-regexp' align text
From: |
Lars Ingebrigtsen |
Subject: |
master 90266b8: Tweak how 'align' and 'align-regexp' align text |
Date: |
Tue, 19 Oct 2021 16:39:10 -0400 (EDT) |
branch: master
commit 90266b8356dc5e7e6e437fb37b49970205b01408
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Tweak how 'align' and 'align-regexp' align text
* lisp/align.el (align-rules-list): Change to work without `C-u'.
(align): Doc clarification.
(align-regexp): Ditto, and change default `C-u' regexp from
"\\(\\s-*\\)" to "\\(\\s-*\\)" so that it'll make things columnar
if the user just hits RET through all the defaults.
---
etc/NEWS | 9 +++++++++
lisp/align.el | 46 +++++++++++++++++++++++++++++-----------------
2 files changed, 38 insertions(+), 17 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 98c710a..20696af 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -103,6 +103,15 @@ delimiter in the echo area.
* Changes in Specialized Modes and Packages in Emacs 29.1
+** align
+
+---
+*** Alignment in 'text-mode' has changed.
+Previously, 'M-x align' didn't do anything, and you have to say 'C-u
+M-x align' for it to work. This has now been changed. The default
+for regexp for 'C-u M-x align-regexp' has also been changed to be
+easier for inexperienced users to use.
+
** eww
+++
diff --git a/lisp/align.el b/lisp/align.el
index 7ced7b7..2fd6dcd 100644
--- a/lisp/align.el
+++ b/lisp/align.el
@@ -553,8 +553,7 @@ The possible settings for `align-region-separate' are:
(modes . align-text-modes)
(repeat . t)
(run-if . ,(lambda ()
- (and current-prefix-arg
- (not (eq '- current-prefix-arg))))))
+ (not (eq '- current-prefix-arg)))))
;; With a negative prefix argument, lists of dollar figures will
;; be aligned.
@@ -836,11 +835,22 @@ See the variable `align-exclude-rules-list' for more
details.")
;;;###autoload
(defun align (beg end &optional separate rules exclude-rules)
"Attempt to align a region based on a set of alignment rules.
-BEG and END mark the region. If BEG and END are specifically set to
-nil (this can only be done programmatically), the beginning and end of
-the current alignment section will be calculated based on the location
-of point, and the value of `align-region-separate' (or possibly each
-rule's `separate' attribute).
+Interactively, BEG and END are the mark/point of the current region.
+
+Many modes define specific alignment rules, and some of these
+rules in some modes react to the current prefix argument. For
+instance, in `text-mode', `M-x align' will align into columns
+based on space delimiters, while `C-u - M-x align' will align
+into columns based on the \"$\" character. See the
+`align-rules-list' variable definition for the specific rules.
+
+Also see `align-regexp', which will guide you through various
+parameters for aligning text.
+
+Non-interactively, if BEG and END are nil, the beginning and end
+of the current alignment section will be calculated based on the
+location of point, and the value of `align-region-separate' (or
+possibly each rule's `separate' attribute).
If SEPARATE is non-nil, it overrides the value of
`align-region-separate' for all rules, except those that have their
@@ -889,6 +899,15 @@ on the format of these lists."
BEG and END mark the limits of the region. Interactively, this function
prompts for the regular expression REGEXP to align with.
+Interactively, if you specify a prefix argument, the function
+will guide you through entering the full regular expression, and
+then prompts for which subexpression parenthesis GROUP (default
+1) within REGEXP to modify, the amount of SPACING (default
+`align-default-spacing') to use, and whether or not to REPEAT the
+rule throughout the line.
+
+See `align-rules-list' for more information about these options.
+
For example, let's say you had a list of phone numbers, and wanted to
align them so that the opening parentheses would line up:
@@ -908,15 +927,8 @@ regular expression after you enter it. Interactively, you
only
need to supply the characters to be lined up, and any preceding
whitespace is replaced.
-Non-interactively (or if you specify a prefix argument), you must
-enter the full regular expression, including the subexpression.
-Interactively, the function also then prompts for which
-subexpression parenthesis GROUP (default 1) within REGEXP to
-modify, the amount of SPACING (default `align-default-spacing')
-to use, and whether or not to REPEAT the rule throughout the
-line.
-
-See `align-rules-list' for more information about these options.
+Non-interactively, you must enter the full regular expression,
+including the subexpression.
The non-interactive form of the previous example would look something like:
(align-regexp (point-min) (point-max) \"\\\\(\\\\s-*\\\\)(\")
@@ -928,7 +940,7 @@ construct a rule to pass to `align-region', which does the
real work."
(list (region-beginning) (region-end))
(if current-prefix-arg
(list (read-string "Complex align using regexp: "
- "\\(\\s-*\\)" 'align-regexp-history)
+ "\\(\\s-*\\) " 'align-regexp-history)
(string-to-number
(read-string
"Parenthesis group to modify (justify if negative): " "1"))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 90266b8: Tweak how 'align' and 'align-regexp' align text,
Lars Ingebrigtsen <=