minad / marginalia

:scroll: marginalia.el - Marginalia in the minibuffer
GNU General Public License v3.0
780 stars 27 forks source link

Add "b" as symbol class character for built-in functions #161

Closed Delapouite closed 1 year ago

Delapouite commented 1 year ago

Hello

This additional symbol class character make it easier to quickly assert if a function is a built-in (written in C) or a regular one written in Elisp.

Thanks

oantolin commented 1 year ago

Huh, I've been using the term "built-in" incorrectly! I use it to mean "comes with Emacs" whether a function is written in C or in Emacs Lisp; I think most people use "built-in" that way. But the docstring of subrp clearly uses "built-in" to mean C functions that come with Emacs.

oantolin commented 1 year ago

I'm not sure I find this information all that useful, to be honest. I think I'd almost never look at it. Why do you want it displayed @Delapouite?

Delapouite commented 1 year ago

I proposed this addition because I found this information particularly useful for learning purposes.

Emacs has a reputation of being hard to grasp for as many reasons as their as people who attempted, and often succeeded, to tame this old venerable program.

But after trying to self introspect the way I approached my own journey into Emacs and my initial struggles, I identified something: after 40+ years of accretions, there is simply too much stuffs (functions, variables, keymaps…, sometimes inconsistent) to have a feeling of what represent the real "core value" of Emacs. Which components constitute the true primordial/primitive bricks of Elisp upon which the rest is built upon?

The fact that the definition of what "built-in" means can be confusing as you just expressed. For instance, org-mode is now bundled with Emacs, so we could absolutely consider it a built-in Elisp package, but it does not really match the definition of being an indispensable foundation for other part of Emacs to work.

So it's not a hard 100% true rule, but most of the time when a function is written in C, it usually means that it's old or for performant reasons, and is therefore a critical part of what "is" Emacs. By being able to quickly identify these functions, it is a nice help to focus the learning process and offer a valuable entry point, complementary to the guide, help etc…

hmelman commented 1 year ago

FWIW I use a pre-built emacs on macOS and don't have the C source installed (the elisp source is installed). I often look at the elisp source but of course some functions I lookup are in C and I can't see their source. Finding this out sooner, say while using describe-function before hitting return, would be useful.

minad commented 1 year ago

@Delapouite

I am happy to add this information, since it can occasionally be helpful when doing Elisp development. Note that I recently added mouse tooltips to the symbol class characters which help for exploration. We should use subr-primitive-p instead of subrp, since subrp returns non-nil even for natively compiled functions. See https://github.com/minad/marginalia/commit/fb6cb9dac03ba60a0a90bf762c0d1dfadbe0dafe.

minad commented 1 year ago

@oantolin

I hope you are okay with this being added. We already display special forms (special macros) as M. Going a bit further and showing primitives as P seems reasonable. I had considered this before but forgot about it. We already show a lot of condensed information there, which is mostly useful for experienced Elisp hackers. Thanks to the tooltips the information is still somewhat accessible, but only if you move the mouse which is not so popular among Emacs users. ;)

oantolin commented 1 year ago

Both @Delapouite and @hmelman gave pretty compelling reasons for having this unobtrusive bit of information displayed, so I'm happy with the addition, @minad.