Merge from emacs-24; up to 2012-05-07T21:26:08Z!rgm@gnu.org
[bpt/emacs.git] / lisp / cedet / semantic / util-modes.el
index 9f53dff..c9a0fae 100644 (file)
@@ -1,7 +1,6 @@
 ;;; semantic/util-modes.el --- Semantic minor modes
 
-;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 2000-2005, 2007-2012  Free Software Foundation, Inc.
 
 ;; Authors: Eric M. Ludlam <zappo@gnu.org>
 ;;          David Ponce <david@dponce.com>
@@ -110,7 +109,7 @@ Only minor modes that are locally enabled are shown in the mode line."
                  (tail (or (memq elem minor-mode-alist)
                            (setq minor-mode-alist
                                  (cons elem minor-mode-alist)))))
-            (setcdr tail (nconc locals (cdr tail)))))))))      
+            (setcdr tail (nconc locals (cdr tail)))))))))
 
 (defun semantic-desktop-ignore-this-minor-mode (buffer)
   "Installed as a minor-mode initializer for Desktop mode.
@@ -439,7 +438,7 @@ The state is indicated in the modeline with the following characters:
  `-'  ->  The cache is up to date.
  `!'  ->  The cache requires a full update.
  `~'  ->  The cache needs to be incrementally parsed.
- `%'  ->  The cache is not currently parseable.
+ `%'  ->  The cache is not currently parsable.
  `@'  ->  Auto-parse in progress (not set here.)
 With prefix argument ARG, turn on if positive, otherwise off.  The
 minor mode can be turned on only if semantic feature is available and
@@ -525,7 +524,7 @@ This marker is one of the following:
  `-'  ->  The cache is up to date.
  `!'  ->  The cache requires a full update.
  `~'  ->  The cache needs to be incrementally parsed.
- `%'  ->  The cache is not currently parseable.
+ `%'  ->  The cache is not currently parsable.
  `@'  ->  Auto-parse in progress (not set here.)
 Arguments IGNORE are ignored, and accepted so this can be used as a hook
 in many situations."
@@ -743,6 +742,13 @@ minor mode is enabled."
   "List of tag classes which stickyfunc will display in the header line.")
 (make-variable-buffer-local 'semantic-stickyfunc-sticky-classes)
 
+(defcustom semantic-stickyfunc-show-only-functions-p nil
+  "Non-nil means don't show lines that aren't part of a tag.
+If this is nil, then comments or other text between tags that is
+1 line above the top of the current window will be shown."
+  :group 'semantic
+  :type 'boolean)
+
 (defun semantic-stickyfunc-tag-to-stick ()
   "Return the tag to stick at the current point."
   (let ((tags (nreverse (semantic-find-tag-by-overlay (point)))))
@@ -759,45 +765,51 @@ minor mode is enabled."
   "Make the function at the top of the current window sticky.
 Capture its function declaration, and place it in the header line.
 If there is no function, disable the header line."
-  (let ((str
-        (save-excursion
-          (goto-char (window-start (selected-window)))
-          (forward-line -1)
-          (end-of-line)
-          ;; Capture this function
-          (let* ((tag (semantic-stickyfunc-tag-to-stick)))
-            ;; TAG is nil if there was nothing of the appropriate type there.
-            (if (not tag)
-                ;; Set it to be the text under the header line
-                (buffer-substring (point-at-bol) (point-at-eol))
-              ;; Get it
-              (goto-char (semantic-tag-start tag))
-               ;; Klaus Berndl <klaus.berndl@sdm.de>:
-               ;; goto the tag name; this is especially needed for languages
-               ;; like c++ where a often used style is like:
-               ;;     void
-               ;;     ClassX::methodM(arg1...)
-               ;;     {
-               ;;       ...
-               ;;     }
-               ;; Without going to the tag-name we would get"void" in the
-               ;; header line which is IMHO not really useful
-               (search-forward (semantic-tag-name tag) nil t)
-              (buffer-substring (point-at-bol) (point-at-eol))
-              ))))
-       (start 0))
-    (while (string-match "%" str start)
-      (setq str (replace-match "%%" t t str 0)
-           start (1+ (match-end 0)))
-      )
-    ;; In 21.4 (or 22.1) the heder doesn't expand tabs.  Hmmmm.
-    ;; We should replace them here.
-    ;;
-    ;; This hack assumes that tabs are kept smartly at tab boundaries
-    ;; instead of in a tab boundary where it might only represent 4 spaces.
-    (while (string-match "\t" str start)
-      (setq str (replace-match "        " t t str 0)))
-    str))
+  (save-excursion
+    (goto-char (window-start (selected-window)))
+    (let* ((noshow (bobp))
+          (str
+           (progn
+             (forward-line -1)
+             (end-of-line)
+             ;; Capture this function
+             (let* ((tag (semantic-stickyfunc-tag-to-stick)))
+               ;; TAG is nil if there was nothing of the appropriate type there.
+               (if (not tag)
+                   ;; Set it to be the text under the header line
+                   (if noshow
+                       ""
+                     (if semantic-stickyfunc-show-only-functions-p ""
+                       (buffer-substring (point-at-bol) (point-at-eol))
+                       ))
+                 ;; Go get the first line of this tag.
+                 (goto-char (semantic-tag-start tag))
+                 ;; Klaus Berndl <klaus.berndl@sdm.de>:
+                 ;; goto the tag name; this is especially needed for languages
+                 ;; like c++ where a often used style is like:
+                 ;;     void
+                 ;;     ClassX::methodM(arg1...)
+                 ;;     {
+                 ;;       ...
+                 ;;     }
+                 ;; Without going to the tag-name we would get"void" in the
+                 ;; header line which is IMHO not really useful
+                 (search-forward (semantic-tag-name tag) nil t)
+                 (buffer-substring (point-at-bol) (point-at-eol))
+                 ))))
+          (start 0))
+      (while (string-match "%" str start)
+       (setq str (replace-match "%%" t t str 0)
+             start (1+ (match-end 0)))
+       )
+      ;; In 21.4 (or 22.1) the header doesn't expand tabs.  Hmmmm.
+      ;; We should replace them here.
+      ;;
+      ;; This hack assumes that tabs are kept smartly at tab boundaries
+      ;; instead of in a tab boundary where it might only represent 4 spaces.
+      (while (string-match "\t" str start)
+       (setq str (replace-match "        " t t str 0)))
+      str)))
 
 (defun semantic-stickyfunc-menu (event)
   "Popup a menu that can help a user understand stickyfunc-mode.
@@ -998,5 +1010,4 @@ function was called, move the overlay."
 ;; generated-autoload-load-name: "semantic/util-modes"
 ;; End:
 
-;; arch-tag: 18f5a3d8-1fd7-4c17-b149-a313c126987d
 ;;; semantic/util-modes.el ends here