memory-leaks

Still reachable: lots of words in many pages.
git clone https://git.kevinlegouguec.net/memory-leaks
Log | Files | Refs | README | LICENSE

commit b9377e5b89c176716e18f2c51d0cca01312052af
parent dcc0c05dc1f6a22645bf9355b72aa44b49776620
Author: Kévin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Fri, 13 Jul 2018 08:34:49 +0200

Take notes on attempts to solve the " Narrow" itch

Diffstat:
MREADME.md | 2+-
Mpersonal/itches.md | 64+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md @@ -1,5 +1,5 @@ # Peniblec's Memory Leaks -## still reachable: 4901 words in 11 pages +## still reachable: 5159 words in 11 pages Hi! I am a software engineer interested in [a bunch of things]. diff --git a/personal/itches.md b/personal/itches.md @@ -14,7 +14,6 @@ - [.dir-locals changed priorities][bug#30008] between subfolder and major mode from 25 to 26 - eshell: `ls --group-directories-first` does not color folders -- make " Narrow" lighter customizable (src/xdisp.c) - Emoji(One) support - eww, gnus-article: adapt filling to window width changes - scroll-lock-mode @@ -43,6 +42,69 @@ [bug#30008]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30008 +## Make " Narrow" lighter customizable + +The " Narrow" string comes from `src/xdisp.c:decode_mode_spec`. + +TODO: + +1. get the string value of a variable in C +2. define a customizable string variable + +### Get the string value of a variable in C + +`decode_mode_spec` has some relevant snippets: + +- Given a `Lisp_Object obj`, `SSDATA(obj)` gives the string value as a + `char*`. + +- How to get a variable's `Lisp_Object`? + - `BVAR` works for buffer-local variables + - `V${lispname//-/_}` + +### Define a customizable string variable + +#### Defining variables visible to C code + +The C macro `DEFVAR_LISP(string-name, field-name)` does the following: + + define a static `Lisp_Objfwd` variable v + get the address of globals._f##field-name &f + + defvar_lisp(v, string-name, &f) + +As explained in the comments above `DEFVAR_LISP`, `globals` is a +global variable defined in `globals.h`, which is "auto-generated by +make-docfile" and exposes fields, `#define`s and `Lisp_Object`s for +every global variable. + +make-docfile (`lib-src/make-docfile.c`) takes C files as input and +searches all occurences of `^ +DEFSYM[ \t(]`, `^ +DEFVAR_[ILB]` or +`^DEFU`, analyses what comes after and generates appropriate +definitions for `globals.h`. + +`defvar_lisp` allocates a symbol using `Fmake_symbol`. + +#### Making it customizable + +`lisp/cus-start.el` defines customizable properties of symbols defined +by C code. + +AFAICT, there is no need to assign the default value right after +defining the variable with `DEFVAR_LISP`: e.g. `shell-file-name` is +`DEFVAR_LISP`ed in `src/callproc.c` and its default value is set in… +Mmm. Not in `cus-start.el`. There is this snippet in +`callproc.c:init_callproc`: + + ``` C + sh = getenv ("SHELL"); + Vshell_file_name = build_string (sh ? sh : "/bin/sh"); + ``` + +But when starting with `SHELL=rofl emacs -Q`, Custom says that the +value "has been changed outside Customize". Changed from what to +what? + ## Better out-of-the-box display for FORM FEED By default, FORM FEED is displayed as a dumb `^L` glyph. This is