aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman1997-06-01 23:09:03 +0000
committerRichard M. Stallman1997-06-01 23:09:03 +0000
commitd06970e54c9842ce9a04d77d7cfabdd7c03a5888 (patch)
treef0b30e93a9c6d00bf6d70e5fe7e8ee2400e8da6c /lisp
parentc50d5ce0d1c6ef8a064e16834da8b903fd73c98d (diff)
downloademacs-d06970e54c9842ce9a04d77d7cfabdd7c03a5888.tar.gz
emacs-d06970e54c9842ce9a04d77d7cfabdd7c03a5888.zip
(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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/hideshow.el55
1 files changed, 30 insertions, 25 deletions
diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el
index 37cb707dcd4..92de8914fed 100644
--- a/lisp/progmodes/hideshow.el
+++ b/lisp/progmodes/hideshow.el
@@ -112,12 +112,10 @@ main(void)
112hidden and hs-show-hidden-short-form is t 112hidden and hs-show-hidden-short-form is t
113/* My function main... 113/* My function main...
114int 114int
115main(void) 115main(void)...
116{ ...
117 116
118 117For latest you have to be on the line containing the ellipsis when
119The latest has the disadvantage of not being symetrical, but it saves 118you do `hs-show-block'."
120screen lines ..."
121 :type 'boolean 119 :type 'boolean
122 :group 'hideshow) 120 :group 'hideshow)
123 121
@@ -144,9 +142,9 @@ Values other than these four will be interpreted as `signal'.")
144 142
145;;;#autoload 143;;;#autoload
146(defvar hs-special-modes-alist 144(defvar hs-special-modes-alist
147 '((c-mode "{" "}") 145 '((c-mode "{" "}" nil nil hs-c-like-adjust-block-beginning)
148 (c++-mode "{" "}" "/[*/]") 146 (c++-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning)
149 (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)) 147 (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))
150; I tested the java regexp using the following: 148; I tested the java regexp using the following:
151;(defvar hsj-public) 149;(defvar hsj-public)
152;(defvar hsj-syncronised) 150;(defvar hsj-syncronised)
@@ -271,7 +269,7 @@ It should return the position from where we should start hiding.
271 269
272It should not move the point. 270It should not move the point.
273 271
274See `java-hs-adjust-block-beginning' for an example of using this.") 272See `hs-c-like-adjust-block-beginning' for an example of using this.")
275 273
276;(defvar hs-emacs-type 'fsf 274;(defvar hs-emacs-type 'fsf
277; "Used to support both Emacs and Xemacs.") 275; "Used to support both Emacs and Xemacs.")
@@ -490,20 +488,27 @@ Return point, or nil if top-level."
490 ;; backwards for the block beginning, or a block end. 488 ;; backwards for the block beginning, or a block end.
491 (while try-again 489 (while try-again
492 (setq try-again nil) 490 (setq try-again nil)
493 (when (re-search-backward both-regexps (point-min) t) 491 (if (and (re-search-backward both-regexps (point-min) t)
494 (if (match-beginning 1) ; found a block beginning 492 (match-beginning 1)) ; found a block beginning
495 (if (save-match-data (hs-inside-comment-p)) 493 (if (save-match-data (hs-inside-comment-p))
496 ;;but it was inside a comment, so we have to look for 494 ;;but it was inside a comment, so we have to look for
497 ;;it again 495 ;;it again
498 (setq try-again t) 496 (setq try-again t)
499 ;; that's what we were looking for 497 ;; that's what we were looking for
500 (setq done (match-beginning 0))) 498 (setq done (match-beginning 0)))
501 ;; we found a block end, look to see if we were on a block 499 ;; we found a block end, or we reached the beginning of the
502 ;; beginning when we started 500 ;; buffer look to see if we were on a block beginning when we
503 (if (and 501 ;; started
504 (re-search-forward hs-block-start-regexp (point-max) t) 502 (if (and
505 (>= here (match-beginning 0)) (< here (match-end 0))) 503 (re-search-forward hs-block-start-regexp (point-max) t)
506 (setq done (match-beginning 0)))))) 504 (or
505 (and (>= here (match-beginning 0)) (< here (match-end 0)))
506 (and hs-show-hidden-short-form hs-adjust-block-beginning
507 (save-match-data
508 (= 1 (count-lines
509 (funcall hs-adjust-block-beginning
510 (match-end 0)) here))))))
511 (setq done (match-beginning 0)))))
507 (goto-char here) 512 (goto-char here)
508 (while (and (not done) 513 (while (and (not done)
509 ;; This had problems because the regexp can match something 514 ;; This had problems because the regexp can match something
@@ -554,8 +559,8 @@ Return point, or nil if top-level."
554 (forward-sexp 1)) 559 (forward-sexp 1))
555 (forward-sexp 1)))) 560 (forward-sexp 1))))
556 561
557(defun java-hs-adjust-block-beginning (arg) 562(defun hs-c-like-adjust-block-beginning (arg)
558 "Function to be assigned to `hs-adjust-block-beginning'. 563 "Function to be assigned to `hs-adjust-block-beginning' for C like modes.
559Arg is a position in buffer just after {. This goes back to the end of 564Arg is a position in buffer just after {. This goes back to the end of
560the function header. The purpose is to save some space on the screen 565the function header. The purpose is to save some space on the screen
561when displaying hidden blocks." 566when displaying hidden blocks."