Mercurial > hg > xemacs-beta
diff lisp/modes/hideshow.el @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | 54cc21c15cbb |
line wrap: on
line diff
--- a/lisp/modes/hideshow.el Mon Aug 13 08:45:53 2007 +0200 +++ b/lisp/modes/hideshow.el Mon Aug 13 08:46:35 2007 +0200 @@ -1,73 +1,76 @@ ;;; hideshow.el --- minor mode cmds to selectively display blocks of code -;;; Copyright (C) 1994,1995 Free Software Foundation +;; Copyright (C) 1994,1995,1996 Free Software Foundation + +;; Author: Thien-Thi Nguyen <ttn@netcom.com> +;; Version: 3.4 +;; Keywords: C C++ lisp tools editing +;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning -;;; Author: Thien-Thi Nguyen <ttn@netcom.com> -;;; Version: 3.4 -;;; Keywords: C C++ lisp tools editing -;;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning +;; This file is part of XEmacs. -;;; This file is part of GNU Emacs. +;; XEmacs is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2 of the License, or +;; (at your option) any later version. -;;; GNU Emacs is free software; you can redistribute it and/or modify it -;;; under the terms of the GNU General Public License as published by the -;;; Free Software Foundation; either version 2 of the License, or (at your -;;; option) any later version. -;;; -;;; GNU Emacs is distributed in the hope that it will be useful, but WITHOUT -;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -;;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -;;; for more details. -;;; -;;; You should have received a copy of the GNU General Public License along -;;; with this program; if not, write to the Free Software Foundation, Inc., -;;; 675 Mass Ave, Cambridge, MA 02139, USA. +;; XEmacs is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. -;;; LCD Archive Entry: -;;; hideshow|Thien-Thi Nguyen|ttn@netcom.com| -;;; minor mode commands to selectively display blocks of code| -;;; 18-Oct-1994|3.4|~/modes/hideshow.el.Z| +;; You should have received a copy of the GNU General Public License +;; along with XEmacs; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +;; 02111-1307, USA. + +;;; Synched up with: FSF 19.34. + +;; LCD Archive Entry: +;; hideshow|Thien-Thi Nguyen|ttn@netcom.com| +;; minor mode commands to selectively display blocks of code| +;; 18-Oct-1994|3.4|~/modes/hideshow.el.Z| ;;; Commentary: -;;; This file provides `hs-minor-mode'. When active, six commands: -;;; hs-{hide,show}-{all,block}, hs-show-region and hs-minor-mode -;;; are available. They implement block hiding and showing. Blocks are -;;; defined in mode-specific way. In c-mode or c++-mode, they are simply -;;; curly braces, while in lisp-ish modes they are parens. Multi-line -;;; comments (c-mode) can also be hidden. The command M-x hs-minor-mode -;;; toggles the minor mode or sets it (similar to outline minor mode). -;;; See documentation for each command for more info. -;;; -;;; The variable `hs-unbalance-handler-method' controls hideshow's behavior -;;; in the case of "unbalanced parentheses". See doc for more info. +;; This file provides `hs-minor-mode'. When active, six commands: +;; hs-{hide,show}-{all,block}, hs-show-region and hs-minor-mode +;; are available. They implement block hiding and showing. Blocks are +;; defined in mode-specific way. In c-mode or c++-mode, they are simply +;; curly braces, while in lisp-ish modes they are parens. Multi-line +;; comments (c-mode) can also be hidden. The command M-x hs-minor-mode +;; toggles the minor mode or sets it (similar to outline minor mode). +;; See documentation for each command for more info. +;; +;; The variable `hs-unbalance-handler-method' controls hideshow's behavior +;; in the case of "unbalanced parentheses". See doc for more info. -;;; Suggested usage: +;; Suggested usage: -;;; (load-library "hideshow") -;;; (defun my-hs-setup () "enables hideshow and binds some commands" -;;; (hs-minor-mode 1) -;;; (define-key hs-minor-mode-map "\C-ch" 'hs-hide-block) -;;; (define-key hs-minor-mode-map "\C-cs" 'hs-show-block) -;;; (define-key hs-minro-mode-map "\C-cH" 'hs-hide-all) -;;; (define-key hs-minro-mode-map "\C-cS" 'hs-show-all) -;;; (define-key hs-minor-mode-map "\C-cR" 'hs-show-region)) -;;; (add-hook 'X-mode-hook 'my-hs-setup t) ; other modes similarly -;;; -;;; where X = {emacs-lisp,c,c++,perl,...}. See the doc for the variable -;;; `hs-special-modes-alist' if you'd like to use hideshow w/ other modes. +;; (load-library "hideshow") +;; (defun my-hs-setup () "enables hideshow and binds some commands" +;; (hs-minor-mode 1) +;; (define-key hs-minor-mode-map "\C-ch" 'hs-hide-block) +;; (define-key hs-minor-mode-map "\C-cs" 'hs-show-block) +;; (define-key hs-minro-mode-map "\C-cH" 'hs-hide-all) +;; (define-key hs-minro-mode-map "\C-cS" 'hs-show-all) +;; (define-key hs-minor-mode-map "\C-cR" 'hs-show-region)) +;; (add-hook 'X-mode-hook 'my-hs-setup t) ; other modes similarly +;; +;; where X = {emacs-lisp,c,c++,perl,...}. See the doc for the variable +;; `hs-special-modes-alist' if you'd like to use hideshow w/ other modes. -;;; Etc: +;; Etc: -;;; Bug reports and fixes welcome (comments, too). Thanks go to -;;; Dean Andrews <adahome@ix.netcom.com> -;;; Preston F. Crow <preston.f.crow@dartmouth.edu> -;;; Gael Marziou <gael@gnlab030.grenoble.hp.com> -;;; Keith Sheffield <sheff@edcsgw2.cr.usgs.gov> -;;; Jan Djarv <jan.djarv@sa.erisoft.se> -;;; Lars Lindberg <qhslali@aom.ericsson.se> -;;; Alf-Ivar Holm <alfh@ifi.uio.no> -;;; for valuable feedback, code and bug reports. +;; Bug reports and fixes welcome (comments, too). Thanks go to +;; Dean Andrews <adahome@ix.netcom.com> +;; Preston F. Crow <preston.f.crow@dartmouth.edu> +;; Gael Marziou <gael@gnlab030.grenoble.hp.com> +;; Keith Sheffield <sheff@edcsgw2.cr.usgs.gov> +;; Jan Djarv <jan.djarv@sa.erisoft.se> +;; Lars Lindberg <qhslali@aom.ericsson.se> +;; Alf-Ivar Holm <alfh@ifi.uio.no> +;; for valuable feedback, code and bug reports. ;;; Code: @@ -77,13 +80,13 @@ (defvar hs-unbalance-handler-method 'top-level "*Symbol representing how \"unbalanced parentheses\" should be handled. -This error is usually signalled by hs-show-block. One of four values: +This error is usually signaled by `hs-show-block'. One of four values: `top-level', `next-line', `signal' or `ignore'. Default is `top-level'. - `top-level' -- Show top-level block containing the currently troublesome -block. + block. - `next-line' -- Use the fact that, for an already hidden block, its end -will be on the next line. Attempt to show this block. + will be on the next line. Attempt to show this block. - `signal' -- Pass the error through, stopping execution. - `ignore' -- Ignore the error, continuing execution. @@ -109,11 +112,12 @@ Note that the regexps should not contain leading or trailing whitespace.") -(defvar hs-hide-hooks nil - "*Hooks called at the end of hs-hide-all and hs-hide-block.") +(defvar hs-hide-hook nil + "*Hooks called at the end of `hs-hide-all' and `hs-hide-block'.") -(defvar hs-show-hooks nil - "*Hooks called at the end of hs-show-all, hs-show-block and hs-show-region.") +(defvar hs-show-hook nil + "*Hooks called at the end of commands to show text. +These commands include `hs-show-all', `hs-show-block' and `hs-show-region'.") (defvar hs-minor-mode-prefix "\C-c" "*Prefix key to use for hideshow commands in hideshow minor mode.") @@ -172,8 +176,8 @@ ;; snarfed from outline.el, but added buffer-read-only (defun hs-flag-region (from to flag) "Hides or shows lines from FROM to TO, according to FLAG. -If FLAG is \\n (newline character) then text is shown, while if FLAG -is \\^M \(control-M) the text is hidden." +If FLAG is `?\\n' (the newline character) then show the text; +if FLAG is `?\\^M' \(control-M) then hide the text." (let ((modp (buffer-modified-p)) buffer-read-only) ; nothing is immune (unwind-protect (progn @@ -225,7 +229,7 @@ (goto-char (if end (1+ (point)) p))))) (defun hs-safety-is-job-n () - "Warns if selective-display or selective-display-ellipses is nil." + "Warn if `selective-display' or `selective-display-ellipses' is nil." (let ((str "")) (or selective-display (setq str "selective-display nil ")) @@ -301,8 +305,8 @@ ;;;###autoload (defun hs-hide-all () "Hides all top-level blocks, displaying only first and last lines. -When done, point is repositioned at the beginning of the line, and -hs-hide-hooks is called. See documentation for `run-hooks'." +It moves point to the beginning of the line, and it runs the normal hook +`hs-hide-hook'. See documentation for `run-hooks'." (interactive) (hs-life-goes-on (message "hiding all blocks ...") @@ -320,25 +324,25 @@ (hs-safety-is-job-n)) (beginning-of-line) (message "hiding all blocks ... done") - (run-hooks 'hs-hide-hooks))) + (run-hooks 'hs-hide-hook))) (defun hs-show-all () "Shows all top-level blocks. -When done, point is unchanged, and hs-show-hooks is called. See -documentation for `run-hooks'." +This does not change point; it runs the normal hook `hs-show-hook'. +See documentation for `run-hooks'." (interactive) (hs-life-goes-on (message "showing all blocks ...") (hs-flag-region (point-min) (point-max) ?\n) (message "showing all blocks ... done") - (run-hooks 'hs-show-hooks))) + (run-hooks 'hs-show-hook))) ;;;###autoload (defun hs-hide-block (&optional end) "Selects a block and hides it. With prefix arg, reposition at end. Block is defined as a sexp for lispish modes, mode-specific otherwise. Comments are blocks, too. Upon completion, point is at repositioned and -hs-hide-hooks is called. See documentation for `run-hooks'." +the normal hook `hs-hide-hook' is run. See documentation for `run-hooks'." (interactive "P") (hs-life-goes-on (let ((c-reg (hs-inside-comment-p))) @@ -346,25 +350,25 @@ (cond ((string= comment-end "") (message "can't hide a single-line comment")) ((< (count-lines (car c-reg) (nth 1 c-reg)) 2) - (message "not enougn comment lines to hide")) + (message "not enough comment lines to hide")) (t (goto-char (nth 1 c-reg)) (forward-line -1) (hs-flag-region (car c-reg) (point) ?\C-m) (goto-char (if end (nth 1 c-reg) (car c-reg))) (hs-safety-is-job-n) - (run-hooks 'hs-hide-hooks))) + (run-hooks 'hs-hide-hook))) (if (or (looking-at hs-block-start-regexp) (hs-find-block-beginning)) (progn (hs-hide-block-at-point end) (hs-safety-is-job-n) - (run-hooks 'hs-hide-hooks))))))) + (run-hooks 'hs-hide-hook))))))) (defun hs-show-block (&optional end) "Selects a block and shows it. With prefix arg, reposition at end. -Upon completion, point is repositioned hs-show-hooks are called. See -documetation for `hs-hide-block' and `run-hooks'." +Upon completion, point is repositioned and the normal hook +`hs-show-hook' is run. See documentation for `hs-hide-block' and `run-hooks'." (interactive "P") (hs-life-goes-on (let ((c-reg (hs-inside-comment-p))) @@ -379,28 +383,28 @@ (progn (hs-show-block-at-point end) (hs-safety-is-job-n) - (run-hooks 'hs-show-hooks))))))) + (run-hooks 'hs-show-hook))))))) (defun hs-show-region (beg end) "Shows all lines from BEG to END, without doing any block analysis. -Note: hs-show-region is intended for use when when hs-show-block signals +Note:` hs-show-region' is intended for use when when `hs-show-block' signals `unbalanced parentheses' and so is an emergency measure only. You may become very confused if you use this command indiscriminately." (interactive "r") (hs-life-goes-on (hs-flag-region beg end ?\n) (hs-safety-is-job-n) - (run-hooks 'hs-show-hooks))) + (run-hooks 'hs-show-hook))) ;;;###autoload (defun hs-minor-mode (&optional arg) "Toggle hideshow minor mode. With ARG, turn hideshow minor mode on if ARG is positive, off otherwise. When hideshow minor mode is on, the menu bar is augmented with hideshow -commands and the hideshow commands are enabled. The variables\n -\tselective-display\n\tselective-display-ellipses\n -are set to t. Lastly, the hooks set in hs-minor-mode-hook are called. -See documentation for `run-hooks'.\n +commands and the hideshow commands are enabled. The variables +`selective-display' and `selective-display-ellipses' are set to t. +Last, the normal hook `hs-minor-mode-hook' is run; see the doc for `run-hooks'. + Turning hideshow minor mode off reverts the menu bar and the variables to default values and disables the hideshow commands." (interactive "P")