Function: antlr-hide-actions
antlr-hide-actions is an interactive and byte-compiled function
defined in antlr-mode.el.gz.
Signature
(antlr-hide-actions ARG &optional SILENT)
Documentation
Hide or unhide all actions in buffer.
Hide all actions including arguments in brackets if ARG is 1 or if
called interactively without prefix argument. Hide all actions
excluding arguments in brackets if ARG is 2 or higher. Unhide all
actions if ARG is 0 or negative. See antlr-action-visibility.
Display a message unless optional argument SILENT is non-nil.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/antlr-mode.el.gz
;; TODO: `antlr-hide-actions' should probably be a minor mode like
;; `hide-ifdef-mode'. Whether to exclude arguments (of limited use) should be
;; controlled by `antlr-action-visibility' (negative value)
(defun antlr-hide-actions (arg &optional silent)
"Hide or unhide all actions in buffer.
Hide all actions including arguments in brackets if ARG is 1 or if
called interactively without prefix argument. Hide all actions
excluding arguments in brackets if ARG is 2 or higher. Unhide all
actions if ARG is 0 or negative. See `antlr-action-visibility'.
Display a message unless optional argument SILENT is non-nil."
(interactive "p")
(with-silent-modifications
(if (> arg 0)
(let ((regexp (if (= arg 1) "[]}]" "}"))
(diff (and antlr-action-visibility
(+ (max antlr-action-visibility 0) 2))))
(antlr-hide-actions 0 t)
(save-excursion
(goto-char (point-min))
(while (antlr-re-search-forward regexp nil)
(let ((beg (ignore-errors (scan-sexps (point) -1))))
(when beg
(if diff ; braces are visible
(if (> (point) (+ beg diff))
(add-text-properties (1+ beg) (1- (point))
'(invisible t intangible t)))
;; if actions is on line(s) of its own, hide WS
(and (looking-at "[ \t]*$")
(save-excursion
(goto-char beg)
(skip-chars-backward " \t")
(and (bolp) (setq beg (point))))
(beginning-of-line 2)) ; beginning of next line
(add-text-properties beg (point)
'(invisible t intangible t)))))))
(or silent
(message "Hide all actions (%s arguments)...done"
(if (= arg 1) "including" "excluding"))))
(remove-text-properties (point-min) (point-max)
'(invisible nil intangible nil))
(or silent
(message "Unhide all actions (including arguments)...done")))))