Mercurial > emacs
changeset 18093:1e53ce338e0d
(hs-show-hidden-short-form): Updated doc string.
(hs-adjust-block-beginning): Likewise.
(hs-special-modes-alist): C and C++ should also use
hs-c-like-adjust-block-beginning.
(hs-find-block-beginning): If hs-adjust-block-beginning is t and
we apply hs-adjust-block-beginning and we reach the point means
that we found the block beginning.
(hs-c-like-adjust-block-beginning):
Renamed from java-hs-adjust-block-beginning.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 01 Jun 1997 23:09:03 +0000 |
parents | 8428d56cd207 |
children | 54cf1b43247b |
files | lisp/progmodes/hideshow.el |
diffstat | 1 files changed, 30 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/progmodes/hideshow.el Sun Jun 01 22:24:22 1997 +0000 +++ b/lisp/progmodes/hideshow.el Sun Jun 01 23:09:03 1997 +0000 @@ -112,12 +112,10 @@ hidden and hs-show-hidden-short-form is t /* My function main... int -main(void) -{ ... +main(void)... - -The latest has the disadvantage of not being symetrical, but it saves -screen lines ..." +For latest you have to be on the line containing the ellipsis when +you do `hs-show-block'." :type 'boolean :group 'hideshow) @@ -144,9 +142,9 @@ ;;;#autoload (defvar hs-special-modes-alist - '((c-mode "{" "}") - (c++-mode "{" "}" "/[*/]") - (java-mode "\\(\\(\\([ \t]*\\(\\(public\\|private\\|protected\\|abstract\\|static\\|\\final\\)[ \t\n]+\\)+\\(synchronized[ \t\n]*\\)?[a-zA-Z0-9_:]+[ \t\n]*\\(\\[[ \t\n]*\\][ \t\n]*\\)?\\([a-zA-Z0-9_:]+[ \t\n]*\\)([^)]*)\\([ \n\t]+throws[ \t\n][^{]+\\)?\\)\\|\\([ \t]*static[^{]*\\)\\)[ \t\n]*{\\)" "}" "/[*/]" java-hs-forward-sexp java-hs-adjust-block-beginning)) + '((c-mode "{" "}" nil nil hs-c-like-adjust-block-beginning) + (c++-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning) + (java-mode "\\(\\(\\([ \t]*\\(\\(public\\|private\\|protected\\|abstract\\|static\\|\\final\\)[ \t\n]+\\)+\\(synchronized[ \t\n]*\\)?[a-zA-Z0-9_:]+[ \t\n]*\\(\\[[ \t\n]*\\][ \t\n]*\\)?\\([a-zA-Z0-9_:]+[ \t\n]*\\)([^)]*)\\([ \n\t]+throws[ \t\n][^{]+\\)?\\)\\|\\([ \t]*static[^{]*\\)\\)[ \t\n]*{\\)" "}" "/[*/]" java-hs-forward-sexp hs-c-like-adjust-block-beginning)) ; I tested the java regexp using the following: ;(defvar hsj-public) ;(defvar hsj-syncronised) @@ -271,7 +269,7 @@ It should not move the point. -See `java-hs-adjust-block-beginning' for an example of using this.") +See `hs-c-like-adjust-block-beginning' for an example of using this.") ;(defvar hs-emacs-type 'fsf ; "Used to support both Emacs and Xemacs.") @@ -490,20 +488,27 @@ ;; backwards for the block beginning, or a block end. (while try-again (setq try-again nil) - (when (re-search-backward both-regexps (point-min) t) - (if (match-beginning 1) ; found a block beginning - (if (save-match-data (hs-inside-comment-p)) - ;;but it was inside a comment, so we have to look for - ;;it again - (setq try-again t) - ;; that's what we were looking for - (setq done (match-beginning 0))) - ;; we found a block end, look to see if we were on a block - ;; beginning when we started - (if (and - (re-search-forward hs-block-start-regexp (point-max) t) - (>= here (match-beginning 0)) (< here (match-end 0))) - (setq done (match-beginning 0)))))) + (if (and (re-search-backward both-regexps (point-min) t) + (match-beginning 1)) ; found a block beginning + (if (save-match-data (hs-inside-comment-p)) + ;;but it was inside a comment, so we have to look for + ;;it again + (setq try-again t) + ;; that's what we were looking for + (setq done (match-beginning 0))) + ;; we found a block end, or we reached the beginning of the + ;; buffer look to see if we were on a block beginning when we + ;; started + (if (and + (re-search-forward hs-block-start-regexp (point-max) t) + (or + (and (>= here (match-beginning 0)) (< here (match-end 0))) + (and hs-show-hidden-short-form hs-adjust-block-beginning + (save-match-data + (= 1 (count-lines + (funcall hs-adjust-block-beginning + (match-end 0)) here)))))) + (setq done (match-beginning 0))))) (goto-char here) (while (and (not done) ;; This had problems because the regexp can match something @@ -554,8 +559,8 @@ (forward-sexp 1)) (forward-sexp 1)))) -(defun java-hs-adjust-block-beginning (arg) - "Function to be assigned to `hs-adjust-block-beginning'. +(defun hs-c-like-adjust-block-beginning (arg) + "Function to be assigned to `hs-adjust-block-beginning' for C like modes. Arg is a position in buffer just after {. This goes back to the end of the function header. The purpose is to save some space on the screen when displaying hidden blocks."