Mercurial > emacs
comparison lisp/cedet/semantic/util-modes.el @ 110534:826d60163924
Merge changes from emacs-23 branch.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Thu, 23 Sep 2010 22:10:54 -0400 |
parents | b799d38f522a |
children | 417b1e4d63cd |
comparison
equal
deleted
inserted
replaced
110517:64945cefe6a6 | 110534:826d60163924 |
---|---|
741 (defvar semantic-stickyfunc-sticky-classes | 741 (defvar semantic-stickyfunc-sticky-classes |
742 '(function type) | 742 '(function type) |
743 "List of tag classes which stickyfunc will display in the header line.") | 743 "List of tag classes which stickyfunc will display in the header line.") |
744 (make-variable-buffer-local 'semantic-stickyfunc-sticky-classes) | 744 (make-variable-buffer-local 'semantic-stickyfunc-sticky-classes) |
745 | 745 |
746 (defcustom semantic-stickyfunc-show-only-functions-p nil | |
747 "Non-nil means don't show lines that aren't part of a tag. | |
748 If this is nil, then comments or other text between tags that is | |
749 1 line above the top of the current window will be shown." | |
750 :group 'semantic | |
751 :type 'boolean) | |
752 | |
746 (defun semantic-stickyfunc-tag-to-stick () | 753 (defun semantic-stickyfunc-tag-to-stick () |
747 "Return the tag to stick at the current point." | 754 "Return the tag to stick at the current point." |
748 (let ((tags (nreverse (semantic-find-tag-by-overlay (point))))) | 755 (let ((tags (nreverse (semantic-find-tag-by-overlay (point))))) |
749 ;; Get rid of non-matching tags. | 756 ;; Get rid of non-matching tags. |
750 (while (and tags | 757 (while (and tags |
757 | 764 |
758 (defun semantic-stickyfunc-fetch-stickyline () | 765 (defun semantic-stickyfunc-fetch-stickyline () |
759 "Make the function at the top of the current window sticky. | 766 "Make the function at the top of the current window sticky. |
760 Capture its function declaration, and place it in the header line. | 767 Capture its function declaration, and place it in the header line. |
761 If there is no function, disable the header line." | 768 If there is no function, disable the header line." |
762 (let ((str | 769 (save-excursion |
763 (save-excursion | 770 (goto-char (window-start (selected-window))) |
764 (goto-char (window-start (selected-window))) | 771 (let* ((noshow (bobp)) |
765 (forward-line -1) | 772 (str |
766 (end-of-line) | 773 (progn |
767 ;; Capture this function | 774 (forward-line -1) |
768 (let* ((tag (semantic-stickyfunc-tag-to-stick))) | 775 (end-of-line) |
769 ;; TAG is nil if there was nothing of the appropriate type there. | 776 ;; Capture this function |
770 (if (not tag) | 777 (let* ((tag (semantic-stickyfunc-tag-to-stick))) |
771 ;; Set it to be the text under the header line | 778 ;; TAG is nil if there was nothing of the appropriate type there. |
772 (buffer-substring (point-at-bol) (point-at-eol)) | 779 (if (not tag) |
773 ;; Get it | 780 ;; Set it to be the text under the header line |
774 (goto-char (semantic-tag-start tag)) | 781 (if noshow |
775 ;; Klaus Berndl <klaus.berndl@sdm.de>: | 782 "" |
776 ;; goto the tag name; this is especially needed for languages | 783 (if semantic-stickyfunc-show-only-functions-p "" |
777 ;; like c++ where a often used style is like: | 784 (buffer-substring (point-at-bol) (point-at-eol)) |
778 ;; void | 785 )) |
779 ;; ClassX::methodM(arg1...) | 786 ;; Go get the first line of this tag. |
780 ;; { | 787 (goto-char (semantic-tag-start tag)) |
781 ;; ... | 788 ;; Klaus Berndl <klaus.berndl@sdm.de>: |
782 ;; } | 789 ;; goto the tag name; this is especially needed for languages |
783 ;; Without going to the tag-name we would get"void" in the | 790 ;; like c++ where a often used style is like: |
784 ;; header line which is IMHO not really useful | 791 ;; void |
785 (search-forward (semantic-tag-name tag) nil t) | 792 ;; ClassX::methodM(arg1...) |
786 (buffer-substring (point-at-bol) (point-at-eol)) | 793 ;; { |
787 )))) | 794 ;; ... |
788 (start 0)) | 795 ;; } |
789 (while (string-match "%" str start) | 796 ;; Without going to the tag-name we would get"void" in the |
790 (setq str (replace-match "%%" t t str 0) | 797 ;; header line which is IMHO not really useful |
791 start (1+ (match-end 0))) | 798 (search-forward (semantic-tag-name tag) nil t) |
792 ) | 799 (buffer-substring (point-at-bol) (point-at-eol)) |
793 ;; In 21.4 (or 22.1) the heder doesn't expand tabs. Hmmmm. | 800 )))) |
794 ;; We should replace them here. | 801 (start 0)) |
795 ;; | 802 (while (string-match "%" str start) |
796 ;; This hack assumes that tabs are kept smartly at tab boundaries | 803 (setq str (replace-match "%%" t t str 0) |
797 ;; instead of in a tab boundary where it might only represent 4 spaces. | 804 start (1+ (match-end 0))) |
798 (while (string-match "\t" str start) | 805 ) |
799 (setq str (replace-match " " t t str 0))) | 806 ;; In 21.4 (or 22.1) the header doesn't expand tabs. Hmmmm. |
800 str)) | 807 ;; We should replace them here. |
808 ;; | |
809 ;; This hack assumes that tabs are kept smartly at tab boundaries | |
810 ;; instead of in a tab boundary where it might only represent 4 spaces. | |
811 (while (string-match "\t" str start) | |
812 (setq str (replace-match " " t t str 0))) | |
813 str))) | |
801 | 814 |
802 (defun semantic-stickyfunc-menu (event) | 815 (defun semantic-stickyfunc-menu (event) |
803 "Popup a menu that can help a user understand stickyfunc-mode. | 816 "Popup a menu that can help a user understand stickyfunc-mode. |
804 Argument EVENT describes the event that caused this function to be called." | 817 Argument EVENT describes the event that caused this function to be called." |
805 (interactive "e") | 818 (interactive "e") |