aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/align.el68
1 files changed, 44 insertions, 24 deletions
diff --git a/lisp/align.el b/lisp/align.el
index 14287ce5342..d3195b44365 100644
--- a/lisp/align.el
+++ b/lisp/align.el
@@ -205,22 +205,22 @@ If nil,then no messages will ever be printed to the minibuffer."
205 :type '(repeat symbol) 205 :type '(repeat symbol)
206 :group 'align) 206 :group 'align)
207 207
208(defcustom align-dq-string-modes (append align-lisp-modes 208(defcustom align-dq-string-modes
209 align-c++-modes 209 (append align-lisp-modes align-c++-modes align-perl-modes
210 align-perl-modes) 210 '(python-mode))
211 "*A list of modes where double quoted strings should be excluded." 211 "*A list of modes where double quoted strings should be excluded."
212 :type '(repeat symbol) 212 :type '(repeat symbol)
213 :group 'align) 213 :group 'align)
214 214
215(defcustom align-sq-string-modes align-perl-modes 215(defcustom align-sq-string-modes
216 (append align-perl-modes '(python-mode))
216 "*A list of modes where single quoted strings should be excluded." 217 "*A list of modes where single quoted strings should be excluded."
217 :type '(repeat symbol) 218 :type '(repeat symbol)
218 :group 'align) 219 :group 'align)
219 220
220(defcustom align-open-comment-modes (append align-lisp-modes 221(defcustom align-open-comment-modes
221 align-c++-modes 222 (append align-lisp-modes align-c++-modes align-perl-modes
222 align-perl-modes 223 '(python-mode makefile-mode))
223 '(makefile-mode))
224 "*A list of modes with a single-line comment syntax. 224 "*A list of modes with a single-line comment syntax.
225These are comments as in Lisp, which have a beginning but, end with 225These are comments as in Lisp, which have a beginning but, end with
226the line (i.e., `comment-end' is an empty string)." 226the line (i.e., `comment-end' is an empty string)."
@@ -429,7 +429,7 @@ The possible settings for `align-region-separate' are:
429 (looking-at 429 (looking-at
430 "\\(goto\\|return\\|new\\|delete\\|throw\\)")) 430 "\\(goto\\|return\\|new\\|delete\\|throw\\)"))
431 (if (and (boundp 'font-lock-mode) font-lock-mode) 431 (if (and (boundp 'font-lock-mode) font-lock-mode)
432 (eq (cadr (memq 'face (text-properties-at (point)))) 432 (eq (get-text-property (point) 'face)
433 'font-lock-comment-face) 433 'font-lock-comment-face)
434 (eq (caar (c-guess-basic-syntax)) 'c)))))))) 434 (eq (caar (c-guess-basic-syntax)) 'c))))))))
435 435
@@ -448,6 +448,13 @@ The possible settings for `align-region-separate' are:
448 (modes . align-perl-modes) 448 (modes . align-perl-modes)
449 (tab-stop . nil)) 449 (tab-stop . nil))
450 450
451 (python-assignment
452 (regexp . ,(concat "[^=!<> \t\n]\\(\\s-*\\)="
453 "\\(\\s-*\\)\\([^>= \t\n]\\|$\\)"))
454 (group . (1 2))
455 (modes . '(python-mode))
456 (tab-stop . nil))
457
451 (make-assignment 458 (make-assignment
452 (regexp . "^\\s-*\\w+\\(\\s-*\\):?=\\(\\s-*\\)\\([^\t\n \\\\]\\|$\\)") 459 (regexp . "^\\s-*\\w+\\(\\s-*\\):?=\\(\\s-*\\)\\([^\t\n \\\\]\\|$\\)")
453 (group . (1 2)) 460 (group . (1 2))
@@ -471,10 +478,10 @@ The possible settings for `align-region-separate' are:
471 ;; perl-mode doesn't give us enough syntactic information (and we 478 ;; perl-mode doesn't give us enough syntactic information (and we
472 ;; don't do our own parsing yet), this rule is too destructive to 479 ;; don't do our own parsing yet), this rule is too destructive to
473 ;; run normally. 480 ;; run normally.
474 (perl-comma-delimiter 481 (basic-comma-delimiter
475 (regexp . ",\\(\\s-*\\)[^# \t\n]") 482 (regexp . ",\\(\\s-*\\)[^# \t\n]")
476 (repeat . t) 483 (repeat . t)
477 (modes . align-perl-modes) 484 (modes . (append align-perl-modes '(python-mode)))
478 (run-if . ,(function (lambda () current-prefix-arg)))) 485 (run-if . ,(function (lambda () current-prefix-arg))))
479 486
480 (c++-comment 487 (c++-comment
@@ -487,16 +494,6 @@ The possible settings for `align-region-separate' are:
487 (goto-char (match-beginning 1)) 494 (goto-char (match-beginning 1))
488 (not (bolp))))))) 495 (not (bolp)))))))
489 496
490 (c-macro-line-continuation
491 (regexp . "\\(\\s-*\\)\\\\$")
492 (modes . (append align-c++-modes '(makefile-mode)))
493 (column . c-backslash-column))
494; (valid
495; . ,(function
496; (lambda ()
497; (memq (caar (c-guess-basic-syntax))
498; '(cpp-macro cpp-macro-cont))))))
499
500 (c-chain-logic 497 (c-chain-logic
501 (regexp . "\\(\\s-*\\)\\(&&\\|||\\|\\<and\\>\\|\\<or\\>\\)") 498 (regexp . "\\(\\s-*\\)\\(&&\\|||\\|\\<and\\>\\|\\<or\\>\\)")
502 (modes . align-c++-modes) 499 (modes . align-c++-modes)
@@ -515,6 +512,29 @@ The possible settings for `align-region-separate' are:
515 (goto-char (match-end 2)) 512 (goto-char (match-end 2))
516 (looking-at "\\s-*\\(#\\|$\\)")))))) 513 (looking-at "\\s-*\\(#\\|$\\)"))))))
517 514
515 (python-chain-logic
516 (regexp . "\\(\\s-*\\)\\(\\<and\\>\\|\\<or\\>\\)")
517 (modes . '(python-mode))
518 (valid . ,(function
519 (lambda ()
520 (save-excursion
521 (goto-char (match-end 2))
522 (looking-at "\\s-*\\(#\\|$\\|\\\\\\)"))))))
523
524 (c-macro-line-continuation
525 (regexp . "\\(\\s-*\\)\\\\$")
526 (modes . align-c++-modes)
527 (column . c-backslash-column))
528; (valid
529; . ,(function
530; (lambda ()
531; (memq (caar (c-guess-basic-syntax))
532; '(cpp-macro cpp-macro-cont))))))
533
534 (basic-line-continuation
535 (regexp . "\\(\\s-*\\)\\\\$")
536 (modes . '(python-mode makefile-mode)))
537
518 (tex-record-separator 538 (tex-record-separator
519 (regexp . ,(function 539 (regexp . ,(function
520 (lambda (end reverse) 540 (lambda (end reverse)
@@ -1131,13 +1151,13 @@ have been aligned. No changes will be made to the buffer."
1131 (unless change 1151 (unless change
1132 (goto-char (cdar a)) 1152 (goto-char (cdar a))
1133 (if ecol 1153 (if ecol
1134 (if (not (= ecol (current-column))) 1154 (if (/= ecol (current-column))
1135 (setq change t)) 1155 (setq change t))
1136 (setq ecol (current-column)))) 1156 (setq ecol (current-column))))
1137 (when justify 1157 (when justify
1138 (goto-char (caar a)) 1158 (goto-char (caar a))
1139 (if (and (re-search-forward "\\s-*" (cdar a) t) 1159 (if (and (re-search-forward "\\s-*" (cdar a) t)
1140 (not (= (point) (cdar a)))) 1160 (/= (point) (cdar a)))
1141 (let ((bcol (current-column))) 1161 (let ((bcol (current-column)))
1142 (setcdr (car a) (cons (point-marker) (cdar a))) 1162 (setcdr (car a) (cons (point-marker) (cdar a)))
1143 (goto-char (cdr (cdar a))) 1163 (goto-char (cdr (cdar a)))
@@ -1153,7 +1173,7 @@ have been aligned. No changes will be made to the buffer."
1153 ;; `align-region', all we have to do here is indent. 1173 ;; `align-region', all we have to do here is indent.
1154 1174
1155 (unless change 1175 (unless change
1156 (setq change (and ecol (not (= col ecol))))) 1176 (setq change (and ecol (/= col ecol))))
1157 1177
1158 (when (or func change) 1178 (when (or func change)
1159 (while areas 1179 (while areas