Function: align-highlight-rule

align-highlight-rule is an autoloaded, interactive and byte-compiled function defined in align.el.gz.

Signature

(align-highlight-rule BEG END TITLE &optional RULES EXCLUDE-RULES)

Documentation

Highlight the whitespace which a given rule would have modified.

BEG and END mark the extent of the region. TITLE identifies the rule that should be highlighted. If RULES or EXCLUDE-RULES is set to a list of rules (see align-rules-list), it can be used to override the default alignment rules that would have been used to identify the text to be colored.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/align.el.gz
;;;###autoload
(defun align-highlight-rule (beg end title &optional rules exclude-rules)
  "Highlight the whitespace which a given rule would have modified.
BEG and END mark the extent of the region.  TITLE identifies the rule
that should be highlighted.  If RULES or EXCLUDE-RULES is set to a
list of rules (see `align-rules-list'), it can be used to override the
default alignment rules that would have been used to identify the text
to be colored."
  (interactive
   (list (region-beginning) (region-end)
	 (completing-read
	  "Title of rule to highlight: "
	  (mapcar
           (lambda (rule)
             (list (symbol-name (car rule))))
	   (append (or align-mode-rules-list align-rules-list)
		   (or align-mode-exclude-rules-list
		       align-exclude-rules-list))) nil t)))
  (let ((ex-rule (assq (intern title)
		       (or align-mode-exclude-rules-list
			   align-exclude-rules-list)))
	face)
    (align-unhighlight-rule)
    (align-region
     beg end 'entire
     (or rules (if ex-rule
		   (or exclude-rules align-mode-exclude-rules-list
		       align-exclude-rules-list)
		 (or align-mode-rules-list align-rules-list)))
     (unless ex-rule (or exclude-rules align-mode-exclude-rules-list
			 align-exclude-rules-list))
     (lambda (b e mode)
       (if (and mode (listp mode))
           (if (equal (symbol-name (car mode)) title)
               (setq face (cons align-highlight-change-face
                                align-highlight-nochange-face))
             (setq face nil))
         (when face
           (let ((overlay (make-overlay b e)))
             (setq align-highlight-overlays
                   (cons overlay align-highlight-overlays))
             (overlay-put overlay 'face
                          (if mode
                              (car face)
                            (cdr face))))))))))