Hi Eric,
Thank you so much for the reply and the helpful suggestions! Actually I am
pretty satisfied at semantic-default-which-function's result, the only
problem is that I do not have much space to display all of it when I
splitting Emacs into multiple windows.
So I finally followed semantic's code to write an advice, which gets the
result of semantic-which-function and then truncate it to keep only the
last part of it. For my previous example,
namespaceA.namespaceB.classnameC.functionnameD(),
I'll keep as many levels as possible (backwards) as long as the length does
not exceed 15 chars. So for this specific case, only functionnameD() is
displayed. My code is below, which is almost the same as the one in
semantic. :)
(defadvice which-function (around zhiqiu-which-func-advice activate)
"Choose the function to display via semantic if it is currently active."
(if (and (featurep 'semantic) semantic--buffer-cache)
(let ((ol (semantic-find-tag-by-overlay)))
(setq ad-return-value (zhiqiu-short-function-name (funcall
semantic-which-function ol)) )
)
ad-do-it)
)
Thanks,
Zhiqiu
On Wed, Feb 22, 2012 at 4:57 AM, Eric M. Ludlam <ericludlam@...:
> On 02/18/2012 04:07 AM, Zhiqiu Kong wrote:
>
>> Hi,
>>
>> which-func-mode is very helpful and semantic's support makes it even
>> more helpful to me. But when I split my frame into multiple one, the
>> modeline does not have enough space for a long function name. Moreover,
>> most of the time I actually only need the last part of the function
>> name, such as for
>>
>> namespaceA.namespaceB.**classnameC.functionnameD()
>>
>> is there any way to make it to display only "functionnameD()" for me?
>>
>> Or even better, is there any function I can call to display the
>> prototype of the nearest function at point in the minibuffer?
>>
>> I tried the semantic-stickyfunc-mode but it seems not what I want: it
>> sticks not the function at point but the one above the first line.
>>
>> semantic-idle-breadcrumbs-mode is also good for me, but somehow I cannot
>> put it in the modeline. I customized it but it just did not show up. Is
>> this because I have customized my modeline format? I don't want it on
>> the header because I use tabbar and only one of them can reside in the
>> header. AFAI, I can specify which function this mode use to format the
>> function. I tried each of them but it is still too long for me.
>>
>> Thanks in advance for any suggestion. :D
>>
>
> Hi,
>
> Start with the variable semantic-which-function. If you set it to your
> own function, and have it first call semantic-default-which-**function,
> you can then munge the output to whatever you desire.
>
> Alternately, you could just take the last element of the input argument (a
> list of tags), and just call you favorite semantic-tag-format-* function on
> it.
>
> Good Luck
> Eric
>
|