1

I'm finding that defining outline-regexp does not do for me in python-mode what it does for me in other language modes. Someone else on Stack Exchange ran into the same problem, and a suggested answer to their question makes it clear that python-mode preconfigures some definitions for outline-minor-mode. But what those preconfigurations are, and more importantly how to use them, is not documented anywhere I can find.

you are viewing a single comment's thread
view the rest of the comments
[-] JDRiverRun@alien.top 1 points 11 months ago

M-x find-library python, followed by C-s outline- shows what's happening: python-base-mode sets the local outline variables locally, in its mode body. Since mode hooks always run after the body of their mode definitions, you could add a bit of code to the python-base-mode-hook (or a parent of it, like prog-mode-hook) setting your desired outline config there (i.e. overwriting what python mode did).

I do that using outli simply (in a use-package stanza):

 :hook ((prog-mode text-mode) . outli-mode))

BTW, here's a handy guide (from this epic answer) to what runs in which order upon invoking a derived major mode like python-ts-mode:

So when we call (child-mode), the full sequence is:

(run-hooks 'change-major-mode-hook) ;; actually the first thing done by
(kill-all-local-variables)          ;; <-- this function
,@grandparent-body
,@parent-body
,@child-body
(run-hooks 'change-major-mode-after-body-hook)
(run-hooks 'grandparent-mode-hook)
(run-hooks 'parent-mode-hook)
(run-hooks 'child-mode-hook)
(run-hooks 'after-change-major-mode-hook)
this post was submitted on 23 Oct 2023
1 points (100.0% liked)

Emacs

305 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS