1

I am using emacs (GNU Emacs 25.3.2) on Ubuntu. I was wondering if its possible to display short breadcrumbs or selected compound statement in a headerline (even another window is fine). Probably I am not able to describe it properly using words, let me try example, assuming I have some code like following:

 Line:1   while (condition 1) {
 Line:10    .......
 Line:60    some code...
 Line:61    if (condition 2) {
 Line:62       cursor is here now
          

When I am on line 62 header line should display

while(condition 1)->if(condition 2)

Or I can select to display this summary from say line 61 onward only. Basically summary of compound statements at a glance.

I am have tried using [1] but somehow it just displays tag (function) name in the headerline.

[1] https://www.emacswiki.org/emacs/SemanticIdleBreadcrumbsMode

Drew
  • 75,699
  • 9
  • 109
  • 225
Aval Sarri
  • 11
  • 2
  • You may find this annoying, and if so please just delete it, but may I give you a bit of unsought advice? Avoid cyclomatic complexity (that is, exactly the kind of hierarchical nesting you're talking about). No more than two levels maximum per function, ideally no more than one. Anything more should be broken out into its own separate function. Of course, you just have to break the rule sometimes, but mostly you'll benefit from it. If you're skeptical, all I can say is: try it for a while. You'll find your code is easier to understand, change, test, debug, refactor and re-use. Good luck! – Phil Hudson Sep 01 '21 at 21:42
  • @PhilHudson: All advice are welcome, thank you for the time. Issue is not of code size but rather screen real estate and working from home. I like to keep fonts very large (eyesight issue) and each disturbance causes re-reading of code. – Aval Sarri Sep 02 '21 at 05:15

1 Answers1

0

Yes, I think it's possible, and I think your question is clear.

As for how: You'll need to parse the C code to some extent around/before point, to get the breadcrumb pieces you want to show. Then, as you say, put them in a header line.

I added breadcrumbs to Info this way. You might check the code for that (in standard library info.el). Just search for Info-breadcrumbs.

(Obviously, the code to get the breadcrumbs pieces is different for Info than for your use case, but the idea is the same, and using the header can be the same.


You can also check my library `info+.el. There I have a user option for whether to show breadcrumbs in the header line, and a toggle command for that, and an option for whether to show breadcrumbs in the mode-line.

Drew
  • 75,699
  • 9
  • 109
  • 225