From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: finalpatch Newsgroups: gmane.emacs.devel Subject: Patch to make which-function-mode work better with CEDET/Semantic Date: Mon, 07 Jan 2013 13:58:28 +1100 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1357527532 5818 80.91.229.3 (7 Jan 2013 02:58:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Jan 2013 02:58:52 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 07 03:59:08 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ts2vZ-0002gD-TN for ged-emacs-devel@m.gmane.org; Mon, 07 Jan 2013 03:59:06 +0100 Original-Received: from localhost ([::1]:51587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ts2vK-0002qw-J5 for ged-emacs-devel@m.gmane.org; Sun, 06 Jan 2013 21:58:50 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:56196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ts2vH-0002qo-2m for emacs-devel@gnu.org; Sun, 06 Jan 2013 21:58:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ts2vE-0000Hj-Kj for emacs-devel@gnu.org; Sun, 06 Jan 2013 21:58:47 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:53692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ts2vE-0000Hd-EG for emacs-devel@gnu.org; Sun, 06 Jan 2013 21:58:44 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ts2vR-0002VL-7w for emacs-devel@gnu.org; Mon, 07 Jan 2013 03:58:58 +0100 Original-Received: from 203.111.191.138 ([203.111.191.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Jan 2013 03:58:57 +0100 Original-Received: from fengli by 203.111.191.138 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Jan 2013 03:58:57 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 24 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 203.111.191.138 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (darwin) Cancel-Lock: sha1:ibh6h+UsfKnpRNKrw8c4NliQWZo= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:156102 Archived-At: The Imenu structure generated by Semantic has a slightly different layout which causes which-function-mode to fall back to the less accurate add-log-current-defun. This is particularly noticeable when editing c++ code because add-log-current-defun is often incapable of parsing c++ methods correctly. diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 721c610..5e11a56 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el @@ -314,7 +314,9 @@ If no function name is found, return nil." namestack (cons (car pair) namestack) alist (cdr pair))) - ((number-or-marker-p (setq mark (cdr pair))) + ((or (number-or-marker-p (setq mark (cdr pair))) + (and (overlayp (cdr pair)) + (setq mark (overlay-start (cdr pair))))) (when (and (>= (setq offset (- (point) mark)) 0) (< offset minoffset)) ; Find the closest item. (setq minoffset offset -- Feng Li