diff options
| author | Glenn Morris | 2013-07-25 22:45:15 -0400 |
|---|---|---|
| committer | Glenn Morris | 2013-07-25 22:45:15 -0400 |
| commit | 8358a09d4f1e7e26bec6f72c267fd2b931d00c19 (patch) | |
| tree | cedcc8b9e2c86cc201146cdfbfb662dd5665196b /lisp | |
| parent | 15ac32d5284476d27dd40bd238c3bab633081aee (diff) | |
| download | emacs-8358a09d4f1e7e26bec6f72c267fd2b931d00c19.tar.gz emacs-8358a09d4f1e7e26bec6f72c267fd2b931d00c19.zip | |
* lisp/align.el (align-regexp): Doc fix.
(align-region): Explicit error if subexpression missing/does not match.
Fixes: debbugs:14857
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/align.el | 39 |
2 files changed, 31 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 25ce0ff9cd3..79582ea560a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2013-07-26 Glenn Morris <rgm@gnu.org> | 1 | 2013-07-26 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * align.el (align-regexp): Doc fix. (Bug#14857) | ||
| 4 | (align-region): Explicit error if subexpression missing/does not match. | ||
| 5 | |||
| 3 | * simple.el (global-visual-line-mode): | 6 | * simple.el (global-visual-line-mode): |
| 4 | Do not duplicate the mode lighter. (Bug#14858) | 7 | Do not duplicate the mode lighter. (Bug#14858) |
| 5 | 8 | ||
diff --git a/lisp/align.el b/lisp/align.el index 1b62042be75..3d2ca192245 100644 --- a/lisp/align.el +++ b/lisp/align.el | |||
| @@ -906,15 +906,8 @@ on the format of these lists." | |||
| 906 | ;;;###autoload | 906 | ;;;###autoload |
| 907 | (defun align-regexp (beg end regexp &optional group spacing repeat) | 907 | (defun align-regexp (beg end regexp &optional group spacing repeat) |
| 908 | "Align the current region using an ad-hoc rule read from the minibuffer. | 908 | "Align the current region using an ad-hoc rule read from the minibuffer. |
| 909 | BEG and END mark the limits of the region. This function will prompt | 909 | BEG and END mark the limits of the region. Interactively, this function |
| 910 | for the REGEXP to align with. If no prefix arg was specified, you | 910 | prompts for the regular expression REGEXP to align with. |
| 911 | only need to supply the characters to be lined up and any preceding | ||
| 912 | whitespace is replaced. If a prefix arg was specified, the full | ||
| 913 | regexp with parenthesized whitespace should be supplied; it will also | ||
| 914 | prompt for which parenthesis GROUP within REGEXP to modify, the amount | ||
| 915 | of SPACING to use, and whether or not to REPEAT the rule throughout | ||
| 916 | the line. See `align-rules-list' for more information about these | ||
| 917 | options. | ||
| 918 | 911 | ||
| 919 | For example, let's say you had a list of phone numbers, and wanted to | 912 | For example, let's say you had a list of phone numbers, and wanted to |
| 920 | align them so that the opening parentheses would line up: | 913 | align them so that the opening parentheses would line up: |
| @@ -925,8 +918,29 @@ align them so that the opening parentheses would line up: | |||
| 925 | Joe (123) 456-7890 | 918 | Joe (123) 456-7890 |
| 926 | 919 | ||
| 927 | There is no predefined rule to handle this, but you could easily do it | 920 | There is no predefined rule to handle this, but you could easily do it |
| 928 | using a REGEXP like \"(\". All you would have to do is to mark the | 921 | using a REGEXP like \"(\". Interactively, all you would have to do is |
| 929 | region, call `align-regexp' and type in that regular expression." | 922 | to mark the region, call `align-regexp' and enter that regular expression. |
| 923 | |||
| 924 | REGEXP must contain at least one parenthesized subexpression, typically | ||
| 925 | whitespace of the form \"\\\\(\\\\s-*\\\\)\". In normal interactive use, | ||
| 926 | this is automatically added to the start of your regular expression after | ||
| 927 | you enter it. You only need to supply the characters to be lined up, and | ||
| 928 | any preceding whitespace is replaced. | ||
| 929 | |||
| 930 | If you specify a prefix argument (or use this function non-interactively), | ||
| 931 | you must enter the full regular expression, including the subexpression. | ||
| 932 | The function also then prompts for which subexpression parenthesis GROUP | ||
| 933 | \(default 1) within REGEXP to modify, the amount of SPACING (default | ||
| 934 | `align-default-spacing') to use, and whether or not to REPEAT the rule | ||
| 935 | throughout the line. | ||
| 936 | |||
| 937 | See `align-rules-list' for more information about these options. | ||
| 938 | |||
| 939 | The non-interactive form of the previous example would look something like: | ||
| 940 | \(align-regexp (point-min) (point-max) \"\\\\(\\\\s-*\\\\)(\") | ||
| 941 | |||
| 942 | This function is a nothing more than a small wrapper that helps you | ||
| 943 | construct a rule to pass to `align-region', which does the real work." | ||
| 930 | (interactive | 944 | (interactive |
| 931 | (append | 945 | (append |
| 932 | (list (region-beginning) (region-end)) | 946 | (list (region-beginning) (region-end)) |
| @@ -1498,6 +1512,9 @@ aligner would have dealt with are." | |||
| 1498 | (setq rule-beg (match-beginning first) | 1512 | (setq rule-beg (match-beginning first) |
| 1499 | save-match-data (match-data)) | 1513 | save-match-data (match-data)) |
| 1500 | 1514 | ||
| 1515 | (or rule-beg | ||
| 1516 | (error "No match for subexpression %s" first)) | ||
| 1517 | |||
| 1501 | ;; unless the `valid' attribute is set, and tells | 1518 | ;; unless the `valid' attribute is set, and tells |
| 1502 | ;; us that the rule is not valid at this point in | 1519 | ;; us that the rule is not valid at this point in |
| 1503 | ;; the code.. | 1520 | ;; the code.. |