[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Cycling first N heading levels in outline
From: |
Tassilo Horn |
Subject: |
Re: Cycling first N heading levels in outline |
Date: |
Sun, 23 May 2021 21:06:53 +0200 |
User-agent: |
mu4e 1.5.13; emacs 28.0.50 |
Christopher Dimech <dimech@gmx.com> writes:
> Hi Jean, do you know how to have subheadings for elisp using
> outline-minor-mode?
FWIW, I use these outline settings which gives me 8 levels of outlines
in any programming mode where the outline headings start with the
comment started of the mode followed by one or more asterisks.
--8<---------------cut here---------------start------------->8---
(defun th/outline-minor-mode-prefix-init ()
"Set `outline-minor-mode-prefix' for the current mode."
(let ((comment-starter (if comment-start
(replace-regexp-in-string
"[[:space:]]+" "" comment-start)
"")))
(setq comment-starter (replace-regexp-in-string "*" "[*]" comment-starter))
;; Just because ;;* looks better than ;* and won't be indented.
(when (string= comment-starter ";")
(setq comment-starter ";;"))
(when (eq major-mode 'bibtex-mode)
(setq comment-starter (if (eq bibtex-dialect 'biblatex)
"%"
"")))
(setq-local outline-minor-mode-prefix
(concat "^\\(?:" (regexp-quote comment-starter) "\\)"))))
(defun th/outline-minor-mode-init ()
(th/outline-minor-mode-prefix-init)
(setq-local outline-regexp (concat outline-minor-mode-prefix "[*]+"))
(font-lock-add-keywords
nil
`((,(concat outline-minor-mode-prefix "[*] .*$") 0
'org-level-1 t)
(,(concat outline-minor-mode-prefix "[*][*] .*$") 0
'org-level-2 t)
(,(concat outline-minor-mode-prefix "[*][*][*] .*$") 0
'org-level-3 t)
(,(concat outline-minor-mode-prefix "[*][*][*][*] .*$") 0
'org-level-4 t)
(,(concat outline-minor-mode-prefix "[*][*][*][*][*] .*$") 0
'org-level-5 t)
(,(concat outline-minor-mode-prefix "[*][*][*][*][*][*] .*$") 0
'org-level-6 t)
(,(concat outline-minor-mode-prefix "[*][*][*][*][*][*][*] .*$") 0
'org-level-7 t)
(,(concat outline-minor-mode-prefix "[*][*][*][*][*][*][*][*] .*$") 0
'org-level-8 t))))
(add-hook 'outline-minor-mode-hook #'th/outline-minor-mode-init)
(defvar th/outline-minor-mode-modes
'(c-mode c++-mode java-mode emacs-lisp-mode lisp-mode ruby-mode haskell-mode
lua-mode clojure-mode python-mode sh-mode bibtex-mode restclient-mode
TeX-mode LaTeX-mode))
(dolist (mode th/outline-minor-mode-modes)
(add-hook (intern (concat (symbol-name mode) "-hook")) #'outline-minor-mode))
--8<---------------cut here---------------end--------------->8---
So in elisp I write:
;;* Top Level Heading
;;** 2nd Level Heading
;;*** 3rd Level Heading
Bye,
Tassilo
- Re: Cycling first N heading levels in outline, (continued)
- Re: Cycling first N heading levels in outline, Ihor Radchenko, 2021/05/23
- Cycling first N heading levels in outline, Christopher Dimech, 2021/05/23
- Re: Cycling first N heading levels in outline, Ihor Radchenko, 2021/05/23
- Re: Cycling first N heading levels in outline, Jean Louis, 2021/05/23
- Cycling first N heading levels in outline, Christopher Dimech, 2021/05/23
- Re: Cycling first N heading levels in outline, Jean Louis, 2021/05/23
- Re: Cycling first N heading levels in outline, Jean Louis, 2021/05/23
- Re: Cycling first N heading levels in outline, Ihor Radchenko, 2021/05/23
- Re: Cycling first N heading levels in outline, Jean Louis, 2021/05/23
- Cycling first N heading levels in outline, Christopher Dimech, 2021/05/23
- Re: Cycling first N heading levels in outline,
Tassilo Horn <=
- Re: Cycling first N heading levels in outline, Stefan Monnier, 2021/05/23
- Cycling first N heading levels in outline, Christopher Dimech, 2021/05/24
- Re: Cycling first N heading levels in outline, Kévin Le Gouguec, 2021/05/24
- Cycling first N heading levels in outline, Christopher Dimech, 2021/05/24
- Cycling first N heading levels in outline, Christopher Dimech, 2021/05/25
- Cycling first N heading levels in outline, Christopher Dimech, 2021/05/24
- Re: Cycling first N heading levels in outline, Stefan Monnier, 2021/05/24
- Cycling first N heading levels in outline, Christopher Dimech, 2021/05/24
- Re: Cycling first N heading levels in outline, Ihor Radchenko, 2021/05/26