Function: pascal-hide-other-defuns

pascal-hide-other-defuns is an interactive and byte-compiled function defined in pascal.el.gz.

Signature

(pascal-hide-other-defuns)

Documentation

Show only the current defun.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/pascal.el.gz
(defun pascal-hide-other-defuns ()
  "Show only the current defun."
  (interactive)
  (save-excursion
    (let ((beg (progn (if (not (looking-at "\\(function\\|procedure\\)\\>"))
			  (pascal-beg-of-defun))
		      (line-beginning-position)))
	  (end (progn (pascal-end-of-defun)
		      (backward-sexp 1)
                      (line-beginning-position 2)))
	  (opoint (point-min)))
      ;; BEG at BOL.
      ;; OPOINT at EOL.
      ;; END at BOL.
      (goto-char (point-min))

      ;; Hide all functions before current function
      (while (re-search-forward "^[ \t]*\\(function\\|procedure\\)\\>"
                                beg 'move)
	(pascal-outline-change opoint (line-end-position 0) t)
	(setq opoint (line-end-position))
	;; Functions may be nested
	(if (> (progn (pascal-end-of-defun) (point)) beg)
	    (goto-char opoint)))
      (if (> beg opoint)
	  (pascal-outline-change opoint (1- beg) t))

      ;; Show current function
      (pascal-outline-change (1- beg) end nil)
      ;; Hide nested functions
      (forward-char 1)
      (while (re-search-forward "^\\(function\\|procedure\\)\\>" end 'move)
	(setq opoint (line-end-position))
	(pascal-end-of-defun)
	(pascal-outline-change opoint (line-end-position) t))

      (goto-char end)
      (setq opoint end)

      ;; Hide all function after current function
      (while (re-search-forward "^\\(function\\|procedure\\)\\>" nil 'move)
	(pascal-outline-change opoint (line-end-position 0) t)
	(setq opoint (line-end-position))
	(pascal-end-of-defun))
      (pascal-outline-change opoint (point-max) t)

      ;; Hide main program
      (if (< (progn (forward-line -1) (point)) end)
	  (progn
	    (goto-char beg)
	    (pascal-end-of-defun)
	    (backward-sexp 1)
	    (pascal-outline-change (line-end-position) (point-max) t))))))