]> git.eshelyaron.com Git - emacs.git/commitdiff
(hs-show-hidden-short-form): Updated doc string.
authorRichard M. Stallman <rms@gnu.org>
Sun, 1 Jun 1997 23:09:03 +0000 (23:09 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sun, 1 Jun 1997 23:09:03 +0000 (23:09 +0000)
(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.

lisp/progmodes/hideshow.el

index 37cb707dcd437e443d54605fc100c2c0fdb59379..92de8914fed516d41cb00f2f29847ea57d91c538 100644 (file)
@@ -112,12 +112,10 @@ main(void)
 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 @@ Values other than these four will be interpreted as `signal'.")
 
 ;;;#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 return the position from where we should start hiding.
 
 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 @@ Return point, or nil if top-level."
     ;; 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 @@ Return point, or nil if top-level."
          (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."