annotate lisp/align.el @ 94264:6d96ac31f7cd

(buffers-menu-max-size): Move its definition down to the "Buffers Menu" section. Change group name `mouse' to `menu'. (yank-menu-length): Change group name `mouse' to `menu'. (buffers-menu-buffer-name-length): New user option. (menu-bar-update-buffers): Use buffers-menu-buffer-name-length instead of the hard-coded number 27.
author Juri Linkov <juri@jurta.org>
date Tue, 22 Apr 2008 20:35:46 +0000
parents 1e3a407766b9
children ee5932bf781d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 32451
diff changeset
1 ;;; align.el --- align text to a specific column, by regexp
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
74439
ddcbd2c1b70d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68651
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
79721
73661ddc7ac7 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
74616
d8af1b789e17 Previous change was a comment change.
Richard M. Stallman <rms@gnu.org>
parents: 74615
diff changeset
6 ;; Author: John Wiegley <johnw@gnu.org>
74615
ac990ee1126d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 74439
diff changeset
7 ;; Maintainer: FSF
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; Keywords: convenience languages lisp
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
78236
9355f9b7bbff Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75347
diff changeset
14 ;; the Free Software Foundation; either version 3, or (at your option)
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; any later version.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62402
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62402
diff changeset
25 ;; Boston, MA 02110-1301, USA.
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;; This mode allows you to align regions in a context-sensitive fashion.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; The classic use is to align assignments:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;; int a = 1;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; short foo = 2;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;; double blah = 4;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; becomes
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;; int a = 1;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; short foo = 2;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;; double blah = 4;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;;; Usage:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;; There are several variables which define how certain "categories"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;; of syntax are to be treated. These variables go by the name
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;; `align-CATEGORY-modes'. For example, "c++" is such a category.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 ;; There are several rules which apply to c++, but since several other
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;; languages have a syntax similar to c++ (e.g., c, java, etc), these
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;; modes are treated as belonging to the same category.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 ;; If you want to add a new mode under a certain category, just
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;; customize that list, or add the new mode manually. For example, to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;; make jde-mode a c++ category mode, use this code in your .emacs
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; file:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 ;; (setq align-c++-modes (cons 'jde-mode align-c++-modes))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 ;; In some programming modes, it's useful to have the aligner run only
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;; after indentation is performed. To achieve this, customize or set
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 ;; the variable `align-indent-before-aligning' to t.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 ;;; Module Authors:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 ;; In order to incorporate align's functionality into your own
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 ;; modules, there are only a few steps you have to follow.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 ;; 1. Require or load in the align.el library.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 ;; 2. Define your alignment and exclusion rules lists, either
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 ;; customizable or not.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 ;; 3. In your mode function, set the variables
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 ;; `align-mode-rules-list' and `align-mode-exclude-rules-list'
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 ;; to your own rules lists.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 ;; If there is any need to add your mode name to one of the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ;; align-?-modes variables (for example, `align-dq-string-modes'), use
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 ;; `add-to-list', or some similar function which checks first to see
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 ;; if the value is already there. Since the user may customize that
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 ;; mode list, and then write your mode name into their .emacs file,
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 ;; causing the symbol already to be present the next time they load
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 ;; your package.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 ;; Example:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 ;; (require 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 ;; (defcustom my-align-rules-list
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 ;; '((my-rule
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 ;; (regexp . "Sample")))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 ;; :type align-rules-list-type
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 ;; :group 'my-package)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 ;; (put 'my-align-rules-list 'risky-local-variable t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 ;; (add-to-list 'align-dq-string-modes 'my-package-mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 ;; (add-to-list 'align-open-comment-modes 'my-package-mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 ;; (defun my-mode ()
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 ;; ...
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 ;; (setq align-mode-rules-list my-align-rules-list))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 ;;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 ;; Note that if you need to install your own exclusion rules, then you
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 ;; will also need to reproduce any double-quoted string, or open
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 ;; comment exclusion rules that are defined in the standard
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 ;; `align-exclude-rules-list'. At the moment there is no convenient
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 ;; way to mix both mode-local and global rules lists.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 ;;; History:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 ;; Version 1.0 was created in the earlier part of 1996, using a very
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 ;; simple algorithm that understand only basic regular expressions.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 ;; Parts of the code were broken up and included in vhdl-mode.el
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 ;; around this time. After several comments from users, and a need to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 ;; find a more robust, performant algorithm, 2.0 was born in late
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 ;; 1998. Many different approaches were taken (mostly due to the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 ;; complexity of TeX tables), but finally a scheme was discovered
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 ;; which worked fairly well for most common usage cases. Development
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 ;; beyond version 2.8 is not planned, except for problems that users
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 ;; might encounter.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 ;;; Code:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (defgroup align nil
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 "Align text to a specific column, by regexp."
30890
7bd10623068c (align) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents: 30254
diff changeset
126 :version "21.1"
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 :group 'fill)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 ;;; User Variables:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 (defcustom align-load-hook nil
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 "*Hook that gets run after the aligner has been loaded."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 :type 'hook
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 (defcustom align-indent-before-aligning nil
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 "*If non-nil, indent the marked region before aligning it."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 :type 'boolean
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (defcustom align-default-spacing 1
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 "*An integer that represents the default amount of padding to use.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 If `align-to-tab-stop' is non-nil, this will represent the number of
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 tab stops to use for alignment, rather than the number of spaces.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 Each alignment rule can optionally override both this variable. See
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 `align-mode-alist'."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 :type 'integer
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 (defcustom align-to-tab-stop 'indent-tabs-mode
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 "*If non-nil, alignments will always fall on a tab boundary.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 It may also be a symbol, whose value will be taken."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 :type '(choice (const nil) symbol)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 (defcustom align-region-heuristic 500
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 "*If non-nil, used as a heuristic by `align-current'.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 Since each alignment rule can possibly have its own set of alignment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 sections (whenever `align-region-separate' is non-nil, and not a
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 string), this heuristic is used to determine how far before and after
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 point we should search in looking for a region separator. Larger
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 values can mean slower perform in large files, although smaller values
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 may cause unexpected behavior at times."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 :type 'integer
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 (defcustom align-highlight-change-face 'highlight
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 "*The face to highlight with if changes are necessary."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 :type 'face
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 (defcustom align-highlight-nochange-face 'secondary-selection
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 "*The face to highlight with if no changes are necessary."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 :type 'face
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 (defcustom align-large-region 10000
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 "*If an integer, defines what constitutes a \"large\" region.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 If nil,then no messages will ever be printed to the minibuffer."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 :type 'integer
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 (defcustom align-c++-modes '(c++-mode c-mode java-mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 "*A list of modes whose syntax resembles C/C++."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 :type '(repeat symbol)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 (defcustom align-perl-modes '(perl-mode cperl-mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 "*A list of modes where perl syntax is to be seen."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 :type '(repeat symbol)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 (defcustom align-lisp-modes
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 '(emacs-lisp-mode lisp-interaction-mode lisp-mode scheme-mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 "*A list of modes whose syntax resembles Lisp."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 :type '(repeat symbol)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 (defcustom align-tex-modes
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 '(tex-mode plain-tex-mode latex-mode slitex-mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 "*A list of modes whose syntax resembles TeX (and family)."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 :type '(repeat symbol)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 (defcustom align-text-modes '(text-mode outline-mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 "*A list of modes whose content is plain text."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 :type '(repeat symbol)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
210 (defcustom align-dq-string-modes
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
211 (append align-lisp-modes align-c++-modes align-perl-modes
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
212 '(python-mode))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 "*A list of modes where double quoted strings should be excluded."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 :type '(repeat symbol)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
217 (defcustom align-sq-string-modes
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
218 (append align-perl-modes '(python-mode))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 "*A list of modes where single quoted strings should be excluded."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 :type '(repeat symbol)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
223 (defcustom align-open-comment-modes
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
224 (append align-lisp-modes align-c++-modes align-perl-modes
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
225 '(python-mode makefile-mode))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 "*A list of modes with a single-line comment syntax.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 These are comments as in Lisp, which have a beginning but, end with
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 the line (i.e., `comment-end' is an empty string)."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 :type '(repeat symbol)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 (defcustom align-region-separate "^\\s-*[{}]?\\s-*$"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 "*Select the method by which alignment sections will be separated.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 If this is a symbol, that symbol's value will be used.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 For the sake of clarification, consider the following example, which
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 will be referred to in the descriptions below.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 int alpha = 1; /* one */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 double beta = 2.0;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 long gamma; /* ten */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 unsigned int delta = 1; /* one */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 long double epsilon = 3.0;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 long long omega; /* ten */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 The possible settings for `align-region-separate' are:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 `entire' The entire region being aligned will be considered as a
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 single alignment section. Assuming that comments were not
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 being aligned to a particular column, the example would
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 become:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 int alpha = 1; /* one */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 double beta = 2.0;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 long gamma; /* ten */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 unsigned int delta = 1; /* one */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 long double epsilon;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 long long chi = 10; /* ten */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 `group' Each contiguous set of lines where a specific alignment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 occurs is considered a section for that alignment rule.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 Note that each rule will may have any entirely different
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 set of section divisions than another.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 int alpha = 1; /* one */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 double beta = 2.0;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 long gamma; /* ten */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 unsigned int delta = 1; /* one */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 long double epsilon;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 long long chi = 10; /* ten */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 `largest' When contiguous rule sets overlap, the largest section
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 described will be taken as the alignment section for each
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 rule touched by that section.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 int alpha = 1; /* one */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 double beta = 2.0;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 long gamma; /* ten */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 unsigned int delta = 1; /* one */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 long double epsilon;
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 long long chi = 10; /* ten */
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 NOTE: This option is not supported yet, due to algorithmic
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 issues which haven't been satisfactorily resolved. There
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 are ways to do it, but they're both ugly and resource
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 consumptive.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 regexp A regular expression string which defines the section
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 divider. If the mode you're in has a consistent divider
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 between sections, the behavior will be very similar to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 `largest', and faster. But if the mode does not use clear
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 separators (for example, if you collapse your braces onto
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 the preceding statement in C or perl), `largest' is
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 probably the better alternative.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 function A function that will be passed the beginning and ending
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 locations of the region in which to look for the section
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 separator. At the very beginning of the attempt to align,
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 both of these parameters will be nil, in which case the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 function should return non-nil if it wants each rule to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 define its own section, or nil if it wants the largest
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 section found to be used as the common section for all rules
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 that occur there.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 list A list of markers within the buffer that represent where
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 the section dividers lie. Be certain to use markers! For
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 when the aligning begins, the ensuing contract/expanding of
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 whitespace will throw off any non-marker positions.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 This method is intended for use in Lisp programs, and not
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 by the user."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 :type '(choice
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (const :tag "Entire region is one section" entire)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 (const :tag "Align by contiguous groups" group)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 ; (const largest)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (regexp :tag "Regexp defines section boundaries")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 (function :tag "Function defines section boundaries"))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (put 'align-region-separate 'risky-local-variable t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (defvar align-rules-list-type
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 '(repeat
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 (cons
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 :tag "Alignment rule"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 (symbol :tag "Title")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 (cons :tag "Required attributes"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 (cons :tag "Regexp"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (const :tag "(Regular expression to match)" regexp)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 (choice :value "\\(\\s-+\\)" regexp function))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (repeat
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 :tag "Optional attributes"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 (choice
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 (cons :tag "Repeat"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 (const :tag "(Repeat this rule throughout line)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 repeat)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (boolean :value t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 (cons :tag "Paren group"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (const :tag "(Parenthesis group to use)" group)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 (choice :value 2
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 integer (repeat integer)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 (cons :tag "Modes"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 (const :tag "(Modes where this rule applies)" modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 (sexp :value (text-mode)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 (cons :tag "Case-fold"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 (const :tag "(Should case be ignored for this rule)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 case-fold)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 (boolean :value t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 (cons :tag "To Tab Stop"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (const :tag "(Should rule align to tab stops)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 tab-stop)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 (boolean :value nil))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 (cons :tag "Valid"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 (const :tag "(Return non-nil if rule is valid)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 valid)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 (function :value t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 (cons :tag "Run If"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 (const :tag "(Return non-nil if rule should run)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 run-if)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (function :value t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 (cons :tag "Column"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (const :tag "(Column to fix alignment at)" column)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 (choice :value comment-column
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 integer symbol))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 (cons :tag "Spacing"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 (const :tag "(Amount of spacing to use)" spacing)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (integer :value 1))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (cons :tag "Justify"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 (const :tag "(Should text be right justified)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 justify)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 (boolean :value t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 ;; make sure this stays up-to-date with any changes
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 ;; in `align-region-separate'
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (cons :tag "Separate"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 (const :tag "(Separation to use for this rule)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 separate)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (choice :value "^\\s-*$"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (const entire)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 (const group)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 ; (const largest)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 regexp function)))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 "The `type' form for any `align-rules-list' variable.")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (defcustom align-rules-list
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 `((lisp-second-arg
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (regexp . "\\(^\\s-+[^( \t\n]\\|(\\(\\S-+\\)\\s-+\\)\\S-+\\(\\s-+\\)")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (group . 3)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (modes . align-lisp-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (run-if . ,(function (lambda () current-prefix-arg))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (lisp-alist-dot
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (regexp . "\\(\\s-*\\)\\.\\(\\s-*\\)")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (group . (1 2))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (modes . align-lisp-modes))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 (open-comment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 (regexp . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (lambda (end reverse)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (funcall (if reverse 're-search-backward
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 're-search-forward)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 (concat "[^ \t\n\\\\]"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 (regexp-quote comment-start)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 "\\(.+\\)$") end t))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (modes . align-open-comment-modes))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (c-macro-definition
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 (regexp . "^\\s-*#\\s-*define\\s-+\\S-+\\(\\s-+\\)")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 (modes . align-c++-modes))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (c-variable-declaration
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 (regexp . ,(concat "[*&0-9A-Za-z_]>?[&*]*\\(\\s-+[*&]*\\)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 "[A-Za-z_][0-9A-Za-z:_]*\\s-*\\(\\()\\|"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 "=[^=\n].*\\|(.*)\\|\\(\\[.*\\]\\)*\\)?"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 "\\s-*[;,]\\|)\\s-*$\\)"))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 (group . 1)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 (modes . align-c++-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (justify . t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 (valid
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 (lambda ()
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (not (or (save-excursion
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (goto-char (match-beginning 1))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 (backward-word 1)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (looking-at
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 "\\(goto\\|return\\|new\\|delete\\|throw\\)"))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (if (and (boundp 'font-lock-mode) font-lock-mode)
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
431 (eq (get-text-property (point) 'face)
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 'font-lock-comment-face)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 (eq (caar (c-guess-basic-syntax)) 'c))))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 (c-assignment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (regexp . ,(concat "[^-=!^&*+<>/| \t\n]\\(\\s-*[-=!^&*+<>/|]*\\)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 "=\\(\\s-*\\)\\([^= \t\n]\\|$\\)"))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (group . (1 2))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (modes . align-c++-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (justify . t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (tab-stop . nil))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (perl-assignment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (regexp . ,(concat "[^=!^&*-+<>/| \t\n]\\(\\s-*\\)=[~>]?"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 "\\(\\s-*\\)\\([^>= \t\n]\\|$\\)"))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (group . (1 2))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (modes . align-perl-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (tab-stop . nil))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
450 (python-assignment
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
451 (regexp . ,(concat "[^=!<> \t\n]\\(\\s-*\\)="
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
452 "\\(\\s-*\\)\\([^>= \t\n]\\|$\\)"))
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
453 (group . (1 2))
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
454 (modes . '(python-mode))
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
455 (tab-stop . nil))
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
456
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (make-assignment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 (regexp . "^\\s-*\\w+\\(\\s-*\\):?=\\(\\s-*\\)\\([^\t\n \\\\]\\|$\\)")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 (group . (1 2))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 (modes . '(makefile-mode))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 (tab-stop . nil))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 (c-comma-delimiter
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (regexp . ",\\(\\s-*\\)[^/ \t\n]")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (repeat . t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (modes . align-c++-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 (run-if . ,(function (lambda () current-prefix-arg))))
60505
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
468 ; (valid
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
469 ; . ,(function
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
470 ; (lambda ()
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
471 ; (memq (caar (c-guess-basic-syntax))
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
472 ; '(brace-list-intro
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
473 ; brace-list-entry
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
474 ; brace-entry-open))))))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 ;; With a prefix argument, comma delimiter will be aligned. Since
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 ;; perl-mode doesn't give us enough syntactic information (and we
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 ;; don't do our own parsing yet), this rule is too destructive to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 ;; run normally.
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
480 (basic-comma-delimiter
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 (regexp . ",\\(\\s-*\\)[^# \t\n]")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (repeat . t)
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
483 (modes . (append align-perl-modes '(python-mode)))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (run-if . ,(function (lambda () current-prefix-arg))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (c++-comment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 (regexp . "\\(\\s-*\\)\\(//.*\\|/\\*.*\\*/\\s-*\\)$")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (modes . align-c++-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 (column . comment-column)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 (valid . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (lambda ()
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 (save-excursion
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 (goto-char (match-beginning 1))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 (not (bolp)))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 (c-chain-logic
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (regexp . "\\(\\s-*\\)\\(&&\\|||\\|\\<and\\>\\|\\<or\\>\\)")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 (modes . align-c++-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 (valid . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 (lambda ()
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (save-excursion
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 (goto-char (match-end 2))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (looking-at "\\s-*\\(/[*/]\\|$\\)"))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 (perl-chain-logic
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 (regexp . "\\(\\s-*\\)\\(&&\\|||\\|\\<and\\>\\|\\<or\\>\\)")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (modes . align-perl-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 (valid . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (lambda ()
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 (save-excursion
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 (goto-char (match-end 2))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 (looking-at "\\s-*\\(#\\|$\\)"))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
514 (python-chain-logic
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
515 (regexp . "\\(\\s-*\\)\\(\\<and\\>\\|\\<or\\>\\)")
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
516 (modes . '(python-mode))
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
517 (valid . ,(function
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
518 (lambda ()
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
519 (save-excursion
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
520 (goto-char (match-end 2))
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
521 (looking-at "\\s-*\\(#\\|$\\|\\\\\\)"))))))
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
522
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
523 (c-macro-line-continuation
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
524 (regexp . "\\(\\s-*\\)\\\\$")
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
525 (modes . align-c++-modes)
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
526 (column . c-backslash-column))
60505
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
527 ; (valid
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
528 ; . ,(function
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
529 ; (lambda ()
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
530 ; (memq (caar (c-guess-basic-syntax))
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
531 ; '(cpp-macro cpp-macro-cont))))))
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
532
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
533 (basic-line-continuation
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
534 (regexp . "\\(\\s-*\\)\\\\$")
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
535 (modes . '(python-mode makefile-mode)))
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
536
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 (tex-record-separator
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (regexp . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 (lambda (end reverse)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 (align-match-tex-pattern "&" end reverse))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 (group . (1 2))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 (modes . align-tex-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (repeat . t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 (tex-tabbing-separator
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (regexp . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (lambda (end reverse)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 (align-match-tex-pattern "\\\\[=>]" end reverse))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 (group . (1 2))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (modes . align-tex-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 (repeat . t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 (run-if . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 (lambda ()
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 (eq major-mode 'latex-mode)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 (tex-record-break
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (regexp . "\\(\\s-*\\)\\\\\\\\")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 (modes . align-tex-modes))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 ;; With a numeric prefix argument, or C-u, space delimited text
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 ;; tables will be aligned.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (text-column
67698
fe96c1f121e3 (align-rules-list): Use [ \t] instead of \s-
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 67480
diff changeset
563 (regexp . "\\(^\\|\\S-\\)\\([ \t]+\\)\\(\\S-\\|$\\)")
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 (group . 2)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 (modes . align-text-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566 (repeat . t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 (run-if . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 (lambda ()
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 (and current-prefix-arg
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 (not (eq '- current-prefix-arg)))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 ;; With a negative prefix argument, lists of dollar figures will
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 ;; be aligned.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 (text-dollar-figure
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 (regexp . "\\$?\\(\\s-+[0-9]+\\)\\.")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 (modes . align-text-modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 (justify . t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 (run-if . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (lambda ()
60505
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
580 (eq '- current-prefix-arg)))))
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
581
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
582 (css-declaration
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
583 (regexp . "^\\s-*\\w+:\\(\\s-*\\).*;")
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
584 (group . (1))
c919a3aa031f 2005-03-07 Karl Chen <quarl@cs.berkeley.edu>
John Wiegley <johnw@newartisans.com>
parents: 57972
diff changeset
585 (modes . '(css-mode html-mode))))
47920
839ee0b81fe0 (align-rules-list, align-exclude-rules-list): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 45052
diff changeset
586 "*A list describing all of the available alignment rules.
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587 The format is:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589 ((TITLE
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 (ATTRIBUTE . VALUE) ...)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591 ...)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 The following attributes are meaningful:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 `regexp' This required attribute must be either a string describing
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 a regular expression, or a function (described below).
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 For every line within the section that this regular
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 expression matches, the given rule will be applied to that
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 line. The exclusion rules denote which part(s) of the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 line should not be modified; the alignment rules cause the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
601 identified whitespace group to be contracted/expanded such
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 that the \"alignment character\" (the character
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603 immediately following the identified parenthesis group),
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604 occurs in the same column for every line within the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 alignment section (see `align-region-separate' for a
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
606 description of how the region is broken up into alignment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607 sections).
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
609 The `regexp' attribute describes how the text should be
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610 treated. Within this regexp, there must be at least one
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611 group of characters (typically whitespace) identified by
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612 the special opening and closing parens used in regexp
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
613 expressions (`\\\\(' and `\\\\)') (see the Emacs manual on
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614 the syntax of regular expressions for more info).
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
615
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
616 If `regexp' is a function, it will be called as a
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
617 replacement for `re-search-forward'. This means that it
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 should return nil if nothing is found to match the rule,
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
619 or it should set the match data appropriately, move point
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620 to the end of the match, and return the value of point.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
621
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622 `group' For exclusion rules, the group identifies the range of
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623 characters that should be ignored. For alignment rules,
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624 these are the characters that will be deleted/expanded for
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625 the purposes of alignment. The \"alignment character\" is
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
626 always the first character immediately following this
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 parenthesis group. This attribute may also be a list of
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628 integer, in which case multiple alignment characters will
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 be aligned, with the list of integer identifying the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 whitespace groups which precede them. The default for
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631 this attribute is 1.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 `modes' The `modes' attribute, if set, should name a list of
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 major modes -- or evaluate to such a value -- in which the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 rule is valid. If not set, the rule will apply to all
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 modes.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638 `case-fold' If `regexp' is an ordinary regular expression string
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639 containing alphabetic character, sometimes you may want
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
640 the search to proceed case-insensitively (for languages
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 that ignore case, such as pascal for example). In that
51264
ca3933891346 (align-rules-list): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 47920
diff changeset
642 case, set `case-fold' to a non-nil value, and the regular
ca3933891346 (align-rules-list): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 47920
diff changeset
643 expression search will ignore case. If `regexp' is set to
ca3933891346 (align-rules-list): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 47920
diff changeset
644 a function, that function must handle the job of ignoring
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645 case by itself.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
647 `tab-stop' If the `tab-stop' attribute is set, and non-nil, the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
648 alignment character will always fall on a tab stop
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
649 (whether it uses tabs to get there or not depends on the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
650 value of `indent-tabs-mode'). If the `tab-stop' attribute
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
651 is set to nil, tab stops will never be used. Otherwise,
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
652 the value of `align-to-tab-stop' determines whether or not
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
653 to align to a tab stop. The `tab-stop' attribute may also
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654 be a list of t or nil values, corresponding to the number
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
655 of parenthesis groups specified by the `group' attribute.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
656
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
657 `repeat' If the `repeat' attribute is present, and non-nil, the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
658 rule will be applied to the line continuously until no
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
659 further matches are found.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
661 `valid' If the `valid' attribute is set, it will be used to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
662 determine whether the rule should be invoked. This form
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
663 is evaluated after the regular expression match has been
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
664 performed, so that it is possible to use the results of
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
665 that match to determine whether the alignment should be
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666 performed. The buffer should not be modified during the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
667 evaluation of this form.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
668
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669 `run-if' Like `valid', the `run-if' attribute tests whether the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670 rule should be run at all -- even before any searches are
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
671 done to determine if the rule applies to the alignment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
672 region. This can save time, since `run-if' will only be
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
673 run once for each rule. If it returns nil, the rule will
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
674 not be attempted.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676 `column' For alignment rules, if the `column' attribute is set --
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 which must be an integer, or a symbol whose value is an
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
678 integer -- it will be used as the column in which to align
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679 the alignment character. If the text on a particular line
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680 happens to overrun that column, a single space character,
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
681 or tab stop (see `align-to-tab-stop') will be added
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
682 between the last text character and the alignment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 character.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
684
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 `spacing' Alignment rules may also override the amount of spacing
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
686 that would normally be used by providing a `spacing'
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
687 attribute. This must be an integer, or a list of integers
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
688 corresponding to the number of parenthesis groups matched
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
689 by the `group' attribute. If a list of value is used, and
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
690 any of those values is nil, `align-default-spacing' will
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
691 be used for that subgroup. See `align-default-spacing'
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
692 for more details on spacing, tab stops, and how to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
693 indicate how much spacing should be used. If TAB-STOP is
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
694 present, it will override the value of `align-to-tab-stop'
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
695 for that rule.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
697 `justify' It is possible with `regexp' and `group' to identify a
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
698 character group that contains more than just whitespace
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
699 characters. By default, any non-whitespace characters in
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
700 that group will also be deleted while aligning the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
701 alignment character. However, if the `justify' attribute
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
702 is set to a non-nil value, only the initial whitespace
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703 characters within that group will be deleted. This has
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
704 the effect of right-justifying the characters that remain,
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
705 and can be used for outdenting or just plain old right-
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
706 justification.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708 `separate' Each rule can define its own section separator, which
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709 describes how to identify the separation of \"sections\"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
710 within the region to be aligned. Setting the `separate'
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711 attribute overrides the value of `align-region-separate'
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
712 (see the documentation of that variable for possible
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713 values), and any separation argument passed to `align'."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714 :type align-rules-list-type
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
715 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
716
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
717 (put 'align-rules-list 'risky-local-variable t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
719 (defvar align-exclude-rules-list-type
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720 '(repeat
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721 (cons
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
722 :tag "Exclusion rule"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 (symbol :tag "Title")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
724 (cons :tag "Required attributes"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
725 (cons :tag "Regexp"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
726 (const :tag "(Regular expression to match)" regexp)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
727 (choice :value "\\(\\s-+\\)" regexp function))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
728 (repeat
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
729 :tag "Optional attributes"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
730 (choice
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
731 (cons :tag "Repeat"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
732 (const :tag "(Repeat this rule throughout line)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
733 repeat)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
734 (boolean :value t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 (cons :tag "Paren group"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736 (const :tag "(Parenthesis group to use)" group)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737 (choice :value 2
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738 integer (repeat integer)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739 (cons :tag "Modes"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
740 (const :tag "(Modes where this rule applies)" modes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741 (sexp :value (text-mode)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
742 (cons :tag "Case-fold"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
743 (const :tag "(Should case be ignored for this rule)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
744 case-fold)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
745 (boolean :value t)))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
746 "The `type' form for any `align-exclude-rules-list' variable.")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
747
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748 (defcustom align-exclude-rules-list
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749 `((exc-dq-string
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
750 (regexp . "\"\\([^\"\n]+\\)\"")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
751 (repeat . t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
752 (modes . align-dq-string-modes))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
753
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
754 (exc-sq-string
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755 (regexp . "'\\([^'\n]+\\)'")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
756 (repeat . t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
757 (modes . align-sq-string-modes))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
758
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
759 (exc-open-comment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
760 (regexp
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
761 . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762 (lambda (end reverse)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
763 (funcall (if reverse 're-search-backward
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
764 're-search-forward)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
765 (concat "[^ \t\n\\\\]"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
766 (regexp-quote comment-start)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
767 "\\(.+\\)$") end t))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
768 (modes . align-open-comment-modes))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
770 (exc-c-comment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
771 (regexp . "/\\*\\(.+\\)\\*/")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
772 (repeat . t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
773 (modes . align-c++-modes))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
774
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
775 (exc-c-func-params
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
776 (regexp . "(\\([^)\n]+\\))")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
777 (repeat . t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
778 (modes . align-c++-modes))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
779
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
780 (exc-c-macro
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
781 (regexp . "^\\s-*#\\s-*\\(if\\w*\\|endif\\)\\(.*\\)$")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
782 (group . 2)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
783 (modes . align-c++-modes)))
47920
839ee0b81fe0 (align-rules-list, align-exclude-rules-list): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 45052
diff changeset
784 "*A list describing text that should be excluded from alignment.
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
785 See the documentation for `align-rules-list' for more info."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786 :type align-exclude-rules-list-type
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
787 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
788
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
789 (put 'align-exclude-rules-list 'risky-local-variable t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
790
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
791 ;;; Internal Variables:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
792
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
793 (defvar align-mode-rules-list nil
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
794 "Alignment rules specific to the current major mode.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
795 See the variable `align-rules-list' for more details.")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
796
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
797 (make-variable-buffer-local 'align-mode-rules-list)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
798
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
799 (defvar align-mode-exclude-rules-list nil
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
800 "Alignment exclusion rules specific to the current major mode.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
801 See the variable `align-exclude-rules-list' for more details.")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
802
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
803 (make-variable-buffer-local 'align-mode-exclude-rules-list)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
804
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
805 (defvar align-highlight-overlays nil
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
806 "The current overlays highlighting the text matched by a rule.")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
807
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
808 ;; Sample extension rule set, for vhdl-mode. This should properly be
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
809 ;; in vhdl-mode.el itself.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
810
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
811 (defcustom align-vhdl-rules-list
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
812 `((vhdl-declaration
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
813 (regexp . "\\(signal\\|variable\\|constant\\)\\(\\s-+\\)\\S-")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
814 (group . 2))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
815
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
816 (vhdl-case
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
817 (regexp . "\\(others\\|[^ \t\n=<]\\)\\(\\s-*\\)=>\\(\\s-*\\)\\S-")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
818 (group . (2 3))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
819 (valid
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
820 . ,(function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
821 (lambda ()
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
822 (not (string= (downcase (match-string 1))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
823 "others"))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
824
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
825 (vhdl-colon
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
826 (regexp . "[^ \t\n:]\\(\\s-*\\):\\(\\s-*\\)[^=\n]")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
827 (group . (1 2)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
828
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
829 (direction
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
830 (regexp . ":\\s-*\\(in\\|out\\|inout\\|buffer\\)\\(\\s-*\\)")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
831 (group . 2))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
832
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
833 (sig-assign
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
834 (regexp . "[^ \t\n=<]\\(\\s-*\\)<=\\(\\s-*\\)\\S-")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
835 (group . (1 2)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
836
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
837 (var-assign
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
838 (regexp . "[^ \t\n:]\\(\\s-*\\):="))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
839
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
840 (use-entity
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
841 (regexp . "\\(\\s-+\\)use\\s-+entity")))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
842 "*Alignment rules for `vhdl-mode'. See `align-rules-list' for more info."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
843 :type align-rules-list-type
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
844 :group 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
845
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
846 (put 'align-vhdl-rules-list 'risky-local-variable t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
847
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
848 (defun align-set-vhdl-rules ()
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
849 "Setup the `align-mode-rules-list' variable for `vhdl-mode'."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
850 (setq align-mode-rules-list align-vhdl-rules-list))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
851
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
852 (add-hook 'vhdl-mode-hook 'align-set-vhdl-rules)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
853
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
854 (add-to-list 'align-dq-string-modes 'vhdl-mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
855 (add-to-list 'align-open-comment-modes 'vhdl-mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
856
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
857 ;;; User Functions:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
858
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
859 ;;;###autoload
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
860 (defun align (beg end &optional separate rules exclude-rules)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
861 "Attempt to align a region based on a set of alignment rules.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
862 BEG and END mark the region. If BEG and END are specifically set to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
863 nil (this can only be done programmatically), the beginning and end of
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
864 the current alignment section will be calculated based on the location
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
865 of point, and the value of `align-region-separate' (or possibly each
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
866 rule's `separate' attribute).
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
867
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
868 If SEPARATE is non-nil, it overrides the value of
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
869 `align-region-separate' for all rules, except those that have their
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
870 `separate' attribute set.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
871
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
872 RULES and EXCLUDE-RULES, if either is non-nil, will replace the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
873 default rule lists defined in `align-rules-list' and
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
874 `align-exclude-rules-list'. See `align-rules-list' for more details
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
875 on the format of these lists."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
876 (interactive "r")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
877 (let ((separator
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
878 (or separate
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30890
diff changeset
879 (if (and (symbolp align-region-separate)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30890
diff changeset
880 (boundp align-region-separate))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
881 (symbol-value align-region-separate)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
882 align-region-separate)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
883 'entire)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
884 (if (not (or ;(eq separator 'largest)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
885 (and (functionp separator)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
886 (not (funcall separator nil nil)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
887 (align-region beg end separator
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
888 (or rules align-mode-rules-list align-rules-list)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
889 (or exclude-rules align-mode-exclude-rules-list
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
890 align-exclude-rules-list))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
891 (let ((sec-first end)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
892 (sec-last beg))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
893 (align-region beg end
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
894 (or exclude-rules
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
895 align-mode-exclude-rules-list
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
896 align-exclude-rules-list) nil
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
897 separator
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
898 (function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
899 (lambda (b e mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
900 (when (and mode (listp mode))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
901 (setq sec-first (min sec-first b)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
902 sec-last (max sec-last e))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
903 (if (< sec-first sec-last)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
904 (align-region sec-first sec-last 'entire
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
905 (or rules align-mode-rules-list align-rules-list)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
906 (or exclude-rules align-mode-exclude-rules-list
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
907 align-exclude-rules-list)))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
908
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
909 ;;;###autoload
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
910 (defun align-regexp (beg end regexp &optional group spacing repeat)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
911 "Align the current region using an ad-hoc rule read from the minibuffer.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
912 BEG and END mark the limits of the region. This function will prompt
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
913 for the REGEXP to align with. If no prefix arg was specified, you
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
914 only need to supply the characters to be lined up and any preceding
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
915 whitespace is replaced. If a prefix arg was specified, the full
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
916 regexp with parenthesized whitespace should be supplied; it will also
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
917 prompt for which parenthesis GROUP within REGEXP to modify, the amount
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
918 of SPACING to use, and whether or not to REPEAT the rule throughout
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
919 the line. See `align-rules-list' for more information about these
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
920 options.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
921
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
922 For example, let's say you had a list of phone numbers, and wanted to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
923 align them so that the opening parentheses would line up:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
924
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
925 Fred (123) 456-7890
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
926 Alice (123) 456-7890
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
927 Mary-Anne (123) 456-7890
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
928 Joe (123) 456-7890
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
929
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
930 There is no predefined rule to handle this, but you could easily do it
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
931 using a REGEXP like \"(\". All you would have to do is to mark the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
932 region, call `align-regexp' and type in that regular expression."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
933 (interactive
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
934 (append
67480
b34c1d612bd4 (align-regexp, align-highlight-rule): Use region-beginning and region-end
Eli Zaretskii <eliz@gnu.org>
parents: 64818
diff changeset
935 (list (region-beginning) (region-end))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
936 (if current-prefix-arg
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
937 (list (read-string "Complex align using regexp: "
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
938 "\\(\\s-*\\)")
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 60505
diff changeset
939 (string-to-number
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
940 (read-string
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
941 "Parenthesis group to modify (justify if negative): " "1"))
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 60505
diff changeset
942 (string-to-number
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
943 (read-string "Amount of spacing (or column if negative): "
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
944 (number-to-string align-default-spacing)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
945 (y-or-n-p "Repeat throughout line? "))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
946 (list (concat "\\(\\s-*\\)"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
947 (read-string "Align regexp: "))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
948 1 align-default-spacing nil))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
949 (let ((rule
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
950 (list (list nil (cons 'regexp regexp)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
951 (cons 'group (abs group))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
952 (if (< group 0)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
953 (cons 'justify t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
954 (cons 'bogus nil))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
955 (if (>= spacing 0)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
956 (cons 'spacing spacing)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
957 (cons 'column (abs spacing)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
958 (cons 'repeat repeat)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
959 (align-region beg end 'entire rule nil nil)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
960
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
961 ;;;###autoload
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
962 (defun align-entire (beg end &optional rules exclude-rules)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
963 "Align the selected region as if it were one alignment section.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
964 BEG and END mark the extent of the region. If RULES or EXCLUDE-RULES
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
965 is set to a list of rules (see `align-rules-list'), it can be used to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
966 override the default alignment rules that would have been used to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
967 align that section."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
968 (interactive "r")
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
969 (align beg end 'entire rules exclude-rules))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
970
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
971 ;;;###autoload
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
972 (defun align-current (&optional rules exclude-rules)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
973 "Call `align' on the current alignment section.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
974 This function assumes you want to align only the current section, and
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
975 so saves you from having to specify the region. If RULES or
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
976 EXCLUDE-RULES is set to a list of rules (see `align-rules-list'), it
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
977 can be used to override the default alignment rules that would have
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
978 been used to align that section."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
979 (interactive)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
980 (align nil nil nil rules exclude-rules))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
981
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
982 ;;;###autoload
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
983 (defun align-highlight-rule (beg end title &optional rules exclude-rules)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
984 "Highlight the whitespace which a given rule would have modified.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
985 BEG and END mark the extent of the region. TITLE identifies the rule
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
986 that should be highlighted. If RULES or EXCLUDE-RULES is set to a
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
987 list of rules (see `align-rules-list'), it can be used to override the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
988 default alignment rules that would have been used to identify the text
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
989 to be colored."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
990 (interactive
67480
b34c1d612bd4 (align-regexp, align-highlight-rule): Use region-beginning and region-end
Eli Zaretskii <eliz@gnu.org>
parents: 64818
diff changeset
991 (list (region-beginning) (region-end)
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
992 (completing-read
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
993 "Title of rule to highlight: "
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
994 (mapcar
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
995 (function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
996 (lambda (rule)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
997 (list (symbol-name (car rule)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
998 (append (or align-mode-rules-list align-rules-list)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
999 (or align-mode-exclude-rules-list
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1000 align-exclude-rules-list))) nil t)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1001 (let ((ex-rule (assq (intern title)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1002 (or align-mode-exclude-rules-list
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1003 align-exclude-rules-list)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1004 face)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1005 (align-unhighlight-rule)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1006 (align-region
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1007 beg end 'entire
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1008 (or rules (if ex-rule
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1009 (or exclude-rules align-mode-exclude-rules-list
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1010 align-exclude-rules-list)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1011 (or align-mode-rules-list align-rules-list)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1012 (unless ex-rule (or exclude-rules align-mode-exclude-rules-list
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1013 align-exclude-rules-list))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1014 (function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1015 (lambda (b e mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1016 (if (and mode (listp mode))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1017 (if (equal (symbol-name (car mode)) title)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1018 (setq face (cons align-highlight-change-face
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1019 align-highlight-nochange-face))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1020 (setq face nil))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1021 (when face
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1022 (let ((overlay (make-overlay b e)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1023 (setq align-highlight-overlays
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1024 (cons overlay align-highlight-overlays))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1025 (overlay-put overlay 'face
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1026 (if mode
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1027 (car face)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1028 (cdr face)))))))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1029
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1030 ;;;###autoload
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1031 (defun align-unhighlight-rule ()
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1032 "Remove any highlighting that was added by `align-highlight-rule'."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1033 (interactive)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1034 (while align-highlight-overlays
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1035 (delete-overlay (car align-highlight-overlays))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1036 (setq align-highlight-overlays
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1037 (cdr align-highlight-overlays))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1038
30254
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1039 ;;;###autoload
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1040 (defun align-newline-and-indent ()
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1041 "A replacement function for `newline-and-indent', aligning as it goes."
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1042 (interactive)
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30890
diff changeset
1043 (let ((separate (or (if (and (symbolp align-region-separate)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30890
diff changeset
1044 (boundp align-region-separate))
30254
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1045 (symbol-value align-region-separate)
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1046 align-region-separate)
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1047 'entire))
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1048 (end (point)))
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1049 (call-interactively 'newline-and-indent)
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1050 (save-excursion
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1051 (forward-line -1)
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1052 (while (not (or (bobp)
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1053 (align-new-section-p (point) end separate)))
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1054 (forward-line -1))
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1055 (align (point) end))))
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1056
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1057 ;;; Internal Functions:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1058
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1059 (defun align-match-tex-pattern (regexp end &optional reverse)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1060 "Match REGEXP in TeX mode, counting backslashes appropriately.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1061 END denotes the end of the region to be searched, while REVERSE, if
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1062 non-nil, indicates that the search should proceed backward from the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1063 current position."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1064 (let (result)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1065 (while
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1066 (and (setq result
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1067 (funcall
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1068 (if reverse 're-search-backward
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1069 're-search-forward)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1070 (concat "\\(\\s-*\\)" regexp
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1071 "\\(\\s-*\\)") end t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1072 (let ((pos (match-end 1))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1073 (count 0))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1074 (while (and (> pos (point-min))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1075 (eq (char-before pos) ?\\))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1076 (setq count (1+ count) pos (1- pos)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1077 (eq (mod count 2) 1))
74617
92a7d7de57cb Fix rare bug in align.el
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents: 74616
diff changeset
1078 (goto-char (match-beginning (if reverse 1 2)))))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1079 result))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1080
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1081 (defun align-new-section-p (beg end separator)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1082 "Is there a section divider between BEG and END?
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1083 SEPARATOR specifies how to look for the section divider. See the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1084 documentation for `align-region-separate' for more details."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1085 (cond ((or (not separator)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1086 (eq separator 'entire))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1087 nil)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1088 ((eq separator 'group)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1089 (let ((amount 2))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1090 (save-excursion
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1091 (goto-char end)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1092 (if (bolp)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1093 (setq amount 1)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1094 (> (count-lines beg end) amount)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1095 ((stringp separator)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1096 (save-excursion
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1097 (goto-char beg)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1098 (re-search-forward separator end t)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1099 ((functionp separator)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1100 (funcall separator beg end))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1101 ((listp separator)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1102 (let ((seps separator) yes)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1103 (while seps
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1104 (if (and (>= (car seps) beg)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1105 (<= (car seps) end))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1106 (setq yes t seps nil)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1107 (setq seps (cdr seps))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1108 yes))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1109
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1110 (defun align-adjust-col-for-rule (column rule spacing tab-stop)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1111 "Adjust COLUMN according to the given RULE.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1112 SPACING specifies how much spacing to use.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1113 TAB-STOP specifies whether SPACING refers to tab-stop boundaries."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1114 (unless spacing
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1115 (setq spacing align-default-spacing))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1116 (if (<= spacing 0)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1117 column
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1118 (if (not tab-stop)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1119 (+ column spacing)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1120 (let ((stops tab-stop-list))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1121 (while stops
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1122 (if (and (> (car stops) column)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1123 (= (setq spacing (1- spacing)) 0))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1124 (setq column (car stops)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1125 stops nil)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1126 (setq stops (cdr stops)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1127 column)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1128
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1129 (defsubst align-column (pos)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1130 "Given a position in the buffer, state what column it's in.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1131 POS is the position whose column will be taken. Note that this
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1132 function will change the location of point."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1133 (goto-char pos)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1134 (current-column))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1135
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1136 (defsubst align-regions (regions props rule func)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1137 "Align the regions specified in REGIONS, a list of cons cells.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1138 PROPS describes formatting features specific to the given regions.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1139 RULE specifies exactly how to perform the alignments.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1140 If FUNC is specified, it will be called with each region that would
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1141 have been aligned, rather than modifying the text."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1142 (while regions
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1143 (save-excursion
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1144 (align-areas (car regions) (car props) rule func))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1145 (setq regions (cdr regions)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1146 props (cdr props))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1147
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1148 (defun align-areas (areas props rule func)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1149 "Given a list of AREAS and formatting PROPS, align according to RULE.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1150 AREAS should be a list of cons cells containing beginning and ending
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1151 markers. This function sweeps through all of the beginning markers,
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1152 finds out which one starts in the furthermost column, and then deletes
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1153 and inserts text such that all of the ending markers occur in the same
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1154 column.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1155
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1156 If FUNC is non-nil, it will be called for each text region that would
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1157 have been aligned. No changes will be made to the buffer."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1158 (let* ((column (cdr (assq 'column rule)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1159 (fixed (if (symbolp column)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1160 (symbol-value column)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1161 column))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1162 (justify (cdr (assq 'justify rule)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1163 (col (or fixed 0))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1164 (width 0)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1165 ecol change look)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1166
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1167 ;; Determine the alignment column.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1168 (let ((a areas))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1169 (while a
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1170 (unless fixed
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1171 (setq col (max col (align-column (caar a)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1172 (unless change
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1173 (goto-char (cdar a))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1174 (if ecol
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
1175 (if (/= ecol (current-column))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1176 (setq change t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1177 (setq ecol (current-column))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1178 (when justify
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1179 (goto-char (caar a))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1180 (if (and (re-search-forward "\\s-*" (cdar a) t)
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
1181 (/= (point) (cdar a)))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1182 (let ((bcol (current-column)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1183 (setcdr (car a) (cons (point-marker) (cdar a)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1184 (goto-char (cdr (cdar a)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1185 (setq width (max width (- (current-column) bcol))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1186 (setq a (cdr a))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1187
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1188 (unless fixed
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1189 (setq col (+ (align-adjust-col-for-rule
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1190 col rule (car props) (cdr props)) width)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1191
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1192 ;; Make all ending positions to occur in the goal column. Since
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1193 ;; the whitespace to be modified was already deleted by
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1194 ;; `align-region', all we have to do here is indent.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1195
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1196 (unless change
29493
0345c6ffb8b4 Update from author.
Gerd Moellmann <gerd@gnu.org>
parents: 27327
diff changeset
1197 (setq change (and ecol (/= col ecol))))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1198
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1199 (when (or func change)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1200 (while areas
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1201 (let ((area (car areas))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1202 (gocol col) cur)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1203 (when area
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1204 (if func
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1205 (funcall func (car area) (cdr area) change)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1206 (if (not (and justify
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1207 (consp (cdr area))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1208 (goto-char (cdr area))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1209 (goto-char (cddr area))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1210 (let ((ecol (current-column)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1211 (goto-char (cadr area))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1212 (setq gocol (- col (- ecol (current-column))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1213 (setq cur (current-column))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1214 (cond ((< gocol 0) t) ; don't do anything
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1215 ((= cur gocol) t) ; don't need to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1216 ((< cur gocol) ; just add space
57972
fc790bd5db8f (align-areas): Delete whitespace before reindenting, so
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
1217 ;; FIXME: It is stated above that "...the
fc790bd5db8f (align-areas): Delete whitespace before reindenting, so
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
1218 ;; whitespace to be modified was already
fc790bd5db8f (align-areas): Delete whitespace before reindenting, so
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
1219 ;; deleted by `align-region', all we have
fc790bd5db8f (align-areas): Delete whitespace before reindenting, so
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
1220 ;; to do here is indent." However, this
fc790bd5db8f (align-areas): Delete whitespace before reindenting, so
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
1221 ;; doesn't seem to be true, so we first
fc790bd5db8f (align-areas): Delete whitespace before reindenting, so
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
1222 ;; delete the whitespace to avoid tabs
fc790bd5db8f (align-areas): Delete whitespace before reindenting, so
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
1223 ;; after spaces.
fc790bd5db8f (align-areas): Delete whitespace before reindenting, so
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
1224 (delete-horizontal-space t)
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1225 (indent-to gocol))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1226 (t
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1227 ;; This code works around an oddity in the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1228 ;; FORCE argument of `move-to-column', which
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1229 ;; tends to screw up markers if there is any
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1230 ;; tabbing.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1231 (let ((endcol (align-column
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1232 (if (and justify
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1233 (consp (cdr area)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1234 (cadr area)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1235 (cdr area))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1236 (abuts (<= gocol
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1237 (align-column (car area)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1238 (if abuts
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1239 (goto-char (car area))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1240 (move-to-column gocol t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1241 (let ((here (point)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1242 (move-to-column endcol t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1243 (delete-region here (point))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1244 (if abuts
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1245 (indent-to (align-adjust-col-for-rule
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1246 (current-column) rule
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1247 (car props) (cdr props)))))))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1248 (setq areas (cdr areas))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1249
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1250 (defun align-region (beg end separate rules exclude-rules
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1251 &optional func)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1252 "Align a region based on a given set of alignment rules.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1253 BEG and END specify the region to be aligned. Either may be nil, in
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1254 which case the range will stop at the nearest section division (see
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1255 `align-region-separate', and `align-region-heuristic' for more
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1256 information').
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1257
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1258 The region will be divided into separate alignment sections based on
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1259 the value of SEPARATE.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1260
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1261 RULES and EXCLUDE-RULES are a pair of lists describing how to align
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1262 the region, and which text areas within it should be excluded from
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1263 alignment. See the `align-rules-list' for more information on the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1264 required format of these two lists.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1265
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1266 If FUNC is specified, no text will be modified. What `align-region'
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1267 will do with the rules is to search for the alignment areas, as it
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1268 regularly would, taking account for exclusions, and then call FUNC,
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1269 first with the beginning and ending of the region to be aligned
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1270 according to that rule (this can be different for each rule, if BEG
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1271 and END were nil), and then with the beginning and ending of each
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1272 text region that the rule would have applied to.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1273
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1274 The signature of FUNC should thus be:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1275
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1276 (defun my-align-function (beg end mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1277 \"If MODE is a rule (a list), return t if BEG to END are to be searched.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1278 Otherwise BEG to END will be a region of text that matches the rule's
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1279 definition, and MODE will be non-nil if any changes are necessary.\"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1280 (unless (and mode (listp mode))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1281 (message \"Would have aligned from %d to %d...\" beg end)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1282
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1283 This feature (of passing a FUNC) is used internally to locate the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1284 position of exclusion areas, but could also be used for any other
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1285 purpose where you might want to know where the regions that the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1286 aligner would have dealt with are."
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1287 (let ((end-mark (and end (copy-marker end t)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1288 (real-beg beg)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1289 (real-end end)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1290 (report (and (not func) align-large-region beg end
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1291 (>= (- end beg) align-large-region)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1292 (rule-index 1)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1293 (rule-count (length rules)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1294 (if (and align-indent-before-aligning real-beg end-mark)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1295 (indent-region real-beg end-mark nil))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1296 (while rules
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1297 (let* ((rule (car rules))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1298 (run-if (assq 'run-if rule))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1299 (modes (assq 'modes rule)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1300 ;; unless the `run-if' form tells us not to, look for the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1301 ;; rule..
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1302 (unless (or (and modes (not (memq major-mode
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1303 (eval (cdr modes)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1304 (and run-if (not (funcall (cdr run-if)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1305 (let* ((current-case-fold case-fold-search)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1306 (case-fold (assq 'case-fold rule))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1307 (regexp (cdr (assq 'regexp rule)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1308 (regfunc (and (functionp regexp) regexp))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1309 (rulesep (assq 'separate rule))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1310 (thissep (if rulesep (cdr rulesep) separate))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1311 same (eol 0)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1312 group group-c
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1313 spacing spacing-c
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1314 tab-stop tab-stop-c
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1315 repeat repeat-c
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1316 valid valid-c
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1317 pos-list first
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1318 regions index
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1319 last-point b e
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1320 save-match-data
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1321 exclude-p
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1322 align-props)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1323 (save-excursion
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1324 ;; if beg and end were not given, figure out what the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1325 ;; current alignment region should be. Depending on the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1326 ;; value of `align-region-separate' it's possible for
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1327 ;; each rule to have its own definition of what that
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1328 ;; current alignment section is.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1329 (if real-beg
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1330 (goto-char beg)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1331 (if (or (not thissep) (eq thissep 'entire))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1332 (error "Cannot determine alignment region for '%s'"
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1333 (symbol-name (cdr (assq 'title rule)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1334 (beginning-of-line)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1335 (while (and (not (eobp))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1336 (looking-at "^\\s-*$"))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1337 (forward-line))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1338 (let* ((here (point))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1339 (start here))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1340 (while (and here
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1341 (let ((terminus
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1342 (and align-region-heuristic
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1343 (- (point)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1344 align-region-heuristic))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1345 (if regfunc
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1346 (funcall regfunc terminus t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1347 (re-search-backward regexp
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1348 terminus t))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1349 (if (align-new-section-p (point) here thissep)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1350 (setq beg here
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1351 here nil)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1352 (setq here (point))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1353 (if (not here)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1354 (goto-char beg))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1355 (beginning-of-line)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1356 (setq beg (point))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1357 (goto-char start)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1358 (setq here (point))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1359 (while (and here
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1360 (let ((terminus
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1361 (and align-region-heuristic
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1362 (+ (point)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1363 align-region-heuristic))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1364 (if regfunc
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1365 (funcall regfunc terminus nil)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1366 (re-search-forward regexp terminus t))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1367 (if (align-new-section-p here (point) thissep)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1368 (setq end here
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1369 here nil)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1370 (setq here (point))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1371 (if (not here)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1372 (goto-char end))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1373 (forward-line)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1374 (setq end (point)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1375 end-mark (copy-marker end t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1376 (goto-char beg)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1377
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1378 ;; If we have a region to align, and `func' is set and
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1379 ;; reports back that the region is ok, then align it.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1380 (when (or (not func)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1381 (funcall func beg end rule))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1382 (unwind-protect
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1383 (let (exclude-areas)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1384 ;; determine first of all where the exclusions
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1385 ;; lie in this region
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1386 (when exclude-rules
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1387 ;; guard against a problem with recursion and
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1388 ;; dynamic binding vs. lexical binding, since
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1389 ;; the call to `align-region' below will
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1390 ;; re-enter this function, and rebind
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1391 ;; `exclude-areas'
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1392 (set (setq exclude-areas
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1393 (make-symbol "align-exclude-areas"))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1394 nil)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1395 (align-region
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1396 beg end 'entire
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1397 exclude-rules nil
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1398 `(lambda (b e mode)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1399 (or (and mode (listp mode))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1400 (set (quote ,exclude-areas)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1401 (cons (cons b e)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1402 ,exclude-areas)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1403 (setq exclude-areas
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1404 (sort (symbol-value exclude-areas)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1405 (function
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1406 (lambda (l r)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1407 (>= (car l) (car r)))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1408
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1409 ;; set `case-fold-search' according to the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1410 ;; (optional) `case-fold' property
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1411 (and case-fold
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1412 (setq case-fold-search (cdr case-fold)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1413
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1414 ;; while we can find the rule in the alignment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1415 ;; region..
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1416 (while (and (< (point) end-mark)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1417 (if regfunc
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1418 (funcall regfunc end-mark nil)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1419 (re-search-forward regexp
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1420 end-mark t)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1421
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1422 ;; give the user some indication of where we
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1423 ;; are, if it's a very large region being
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1424 ;; aligned
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1425 (if report
45029
18577b549577 (align-region): Fix call to `message'.
Richard M. Stallman <rms@gnu.org>
parents: 43115
diff changeset
1426 (let ((symbol (car rule)))
18577b549577 (align-region): Fix call to `message'.
Richard M. Stallman <rms@gnu.org>
parents: 43115
diff changeset
1427 (if (and symbol (symbolp symbol))
30254
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1428 (message
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1429 "Aligning `%s' (rule %d of %d) %d%%..."
45052
8357077d84d7 (align-region): Fixed the fix to align-region, because the "name"
John Wiegley <johnw@newartisans.com>
parents: 45029
diff changeset
1430 (symbol-name symbol) rule-index rule-count
30254
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1431 (/ (* (- (point) real-beg) 100)
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1432 (- end-mark real-beg)))
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1433 (message
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1434 "Aligning %d%%..."
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1435 (/ (* (- (point) real-beg) 100)
857a458d569d Added a new feature to align.el
John Wiegley <johnw@newartisans.com>
parents: 29493
diff changeset
1436 (- end-mark real-beg))))))
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1437
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1438 ;; if the search ended us on the beginning of
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1439 ;; the next line, move back to the end of the
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1440 ;; previous line.
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1441 (if (bolp)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1442 (forward-char -1))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1443
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1444 ;; lookup the `group' attribute the first time
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1445 ;; that we need it
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1446 (unless group-c
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1447 (setq group (or (cdr (assq 'group rule)) 1))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1448 (if (listp group)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1449 (setq first (car group))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1450 (setq first group group (list group)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1451 (setq group-c t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1452
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1453 (unless spacing-c
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1454 (setq spacing (cdr (assq 'spacing rule))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1455 spacing-c t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1456
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1457 (unless tab-stop-c
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1458 (setq tab-stop
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1459 (let ((rule-ts (assq 'tab-stop rule)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1460 (if rule-ts
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1461 (cdr rule-ts)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1462 (if (symbolp align-to-tab-stop)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1463 (symbol-value align-to-tab-stop)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1464 align-to-tab-stop)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1465 tab-stop-c t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1466
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1467 ;; test whether we have found a match on the same
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1468 ;; line as a previous match
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1469 (if (> (point) eol)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1470 (setq same nil
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1471 eol (save-excursion
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1472 (end-of-line)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1473 (point-marker))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1474
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1475 ;; lookup the `repeat' attribute the first time
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1476 (or repeat-c
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1477 (setq repeat (cdr (assq 'repeat rule))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1478 repeat-c t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1479
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1480 ;; lookup the `valid' attribute the first time
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1481 (or valid-c
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1482 (setq valid (assq 'valid rule)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1483 valid-c t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1484
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1485 ;; remember the beginning position of this rule
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1486 ;; match, and save the match-data, since either
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1487 ;; the `valid' form, or the code that searches for
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1488 ;; section separation, might alter it
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1489 (setq b (match-beginning first)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1490 save-match-data (match-data))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1491
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1492 ;; unless the `valid' attribute is set, and tells
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1493 ;; us that the rule is not valid at this point in
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1494 ;; the code..
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1495 (unless (and valid (not (funcall (cdr valid))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1496
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1497 ;; look to see if this match begins a new
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1498 ;; section. If so, we should align what we've
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1499 ;; collected so far, and then begin collecting
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1500 ;; anew for the next alignment section
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1501 (if (and last-point
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1502 (align-new-section-p last-point b
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1503 thissep))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1504 (progn
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1505 (align-regions regions align-props
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1506 rule func)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1507 (setq last-point (copy-marker b t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1508 regions nil
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1509 align-props nil))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1510 (setq last-point (copy-marker b t)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1511
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1512 ;; restore the match data
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1513 (set-match-data save-match-data)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1514
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1515 ;; check whether the region to be aligned
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1516 ;; straddles an exclusion area
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1517 (let ((excls exclude-areas))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1518 (setq exclude-p nil)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1519 (while excls
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1520 (if (and (< (match-beginning (car group))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1521 (cdar excls))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1522 (> (match-end (car (last group)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1523 (caar excls)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1524 (setq exclude-p t
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1525 excls nil)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1526 (setq excls (cdr excls)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1527
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1528 ;; go through the list of parenthesis groups
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1529 ;; matching whitespace text to be
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1530 ;; contracted/expanded (or possibly
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1531 ;; justified, if the `justify' attribute was
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1532 ;; set)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1533 (unless exclude-p
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1534 (let ((g group))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1535 (while g
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1536
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1537 ;; we have to use markers, since
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1538 ;; `align-areas' may modify the buffer
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1539 (setq b (copy-marker
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1540 (match-beginning (car g)) t)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1541 e (copy-marker (match-end (car g)) t))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1542
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1543 ;; record this text region for alignment
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1544 (setq index (if same (1+ index) 0))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1545 (let ((region (cons b e))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1546 (props (cons
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1547 (if (listp spacing)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1548 (car spacing)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1549 spacing)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1550 (if (listp tab-stop)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1551 (car tab-stop)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1552 tab-stop))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1553 (if (nth index regions)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1554 (setcar (nthcdr index regions)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1555 (cons region
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1556 (nth index regions)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1557 (if regions
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1558 (progn
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1559 (nconc regions
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1560 (list (list region)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1561 (nconc align-props (list props)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1562 (setq regions
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1563 (list (list region)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1564 (setq align-props (list props)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1565
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1566 ;; if any further rule matches are
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1567 ;; found before `eol', then they are
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1568 ;; on the same line as this one; this
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1569 ;; can only happen if the `repeat'
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1570 ;; attribute is non-nil
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1571 (if (listp spacing)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1572 (setq spacing (cdr spacing)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1573 (if (listp tab-stop)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1574 (setq tab-stop (cdr tab-stop)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1575 (setq same t g (cdr g))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1576
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1577 ;; if `repeat' has not been set, move to
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1578 ;; the next line; don't bother searching
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1579 ;; anymore on this one
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1580 (if (and (not repeat) (not (bolp)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1581 (forward-line)))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1582
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1583 ;; when they are no more matches for this rule,
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1584 ;; align whatever was left over
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1585 (if regions
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1586 (align-regions regions align-props rule func)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1587
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1588 (setq case-fold-search current-case-fold)))))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1589 (setq rules (cdr rules)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1590 rule-index (1+ rule-index)))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1591
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1592 (if report
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1593 (message "Aligning...done"))))
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1594
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1595 ;; Provide:
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1596
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1597 (provide 'align)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1598
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1599 (run-hooks 'align-load-hook)
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1600
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79721
diff changeset
1601 ;; arch-tag: ef79cccf-1db8-4888-a8a1-d7ce2d1532f7
27327
c7597f93c50d *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1602 ;;; align.el ends here