Skip to content

Anoncheg1/emacs-outline-it

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

build

emacs-outline-it

Features

  • fontification like in Org for any mode.
  • fixes for Outline mode for jumping such as xref and goto (advices activates at loading)
  • configure TAB key It by default bound to indent-for-tab-command' we use indent-line-function`.

Configuration

(add-to-list 'load-path "/path/to/this/package/emacs-outline-it")
(require 'outline-it)
(outline-it-advices-activation)
;; configure TAB key and isearch C-M-s key if outline-it or outline-minor-mode activated
(add-hook 'outline-minor-mode-hook 'outline-it-outline-minor-mode-hook-function) ; optional, for .emacs
;; Or without outline-it and outline-minor-mode for any major mode.
;; Variable `outline-regexp' should be set.
(add-hook 'emacs-lisp-mode-hook 'outline-it-any-mode-hook-function)

Usage - by function

To use, defune your outline-it-your function same way like outline-it-python and outline-it-githubactionlog at

Then use M-x outline-it-your

;; from: [[file:outline-it.el::426::(defun outline-it-python ()]]
(defun outline-it-githubactionlog ()
  "For Github Action Melpazoid log of run.
Where is goups with substring ##[group].
To check use: (search-forward-regexp (regexp-quote \"##[group]\"))"
  (interactive)
  (setq-local outline-it-heading-alist '(("##\\[group]" . 1) ("" . 2)))
  (outline-it ".*##\\[group]\\|.*⸺ "))

Usage - by ~/.dir-locals.el file

Create file in the same directory.

For Elisp files:

((emacs-lisp-mode
  . (
     (outline-regexp . "^;;; ")
     (eval . (progn (keymap-local-set "C-c k" #'outline-previous-heading)
                    (keymap-local-set "C-c n" #'outline-next-heading)
                    (keymap-local-set "C-c C-e" #'outline-it-hide-others)
                    (keymap-local-set "<backtab>" #'outline-cycle-buffer)
                    (keymap-local-set "C-<tab>" #'outline-toggle-children)
                    (outline-hide-body)
                    )) ; noqa
     )))

For Bash files:

((sh-mode
  . (
     (outline-regexp . "^# -- ")
     (eval . (progn (keymap-local-set "C-c k" #'outline-previous-heading)
                    (keymap-local-set "C-c n" #'outline-next-heading)
                    (keymap-local-set "C-c C-e" #'outline-it-hide-others)
                    (keymap-local-set "<backtab>" #'outline-cycle-buffer)
                    (keymap-local-set "C-<tab>" #'outline-toggle-children)
                    (outline-hide-body) ;; or (outline-cycle-buffer 5) ;; narrow by building levels by 5 first characters
                    ))
     )))

Activation of outline-minor-mode is not required for simple working.

How

By calling outline-it we configure outline.el by setting its variables and bind keys.

To toggle header by TAB key we wrap indent-line-function function.

We replace outline-level function because it match outline-heading-alist incorrectly by full string match instead of searching substring.

For searching in headers we add hook to isearch-mode-hook' that add template to C-M-s isearch-forward-regexpcommand byoutline-regexp' variable. We do this globally without calling `outline-it' function.

Screenshot - conf-mode with with forced fontification of 3 headers ("^# -- " . 1) ("##\\[group]" . 2) ("⸺ " . 3)

outline-it

How Outline works

It uses two variables:

  1. outline-regexp - to search for header
  2. outline-heading-alist - is optional, to determinate level.

alist used in by outline-level function used by many others.

Function outline-back-to-heading -> outline-level ( used by outline-hide-sublevels and outline-hide-entry) uses functions:

  • outline-back-to-heading use var outline-regexp
  • outline-level uses var alist

Known bugs

(revert-buffer nil t t) not working.

Other packages for same purpose from other authors:

Other packages

Donate, sponsor author

You can sponsor author crypto money directly with crypto currencies:

  • BTC (Bitcoin) address: 1CcDWSQ2vgqv5LxZuWaHGW52B9fkT5io25
  • USDT (Tether) address: TVoXfYMkVYLnQZV3mGZ6GvmumuBfGsZzsN
  • TON (Telegram) address: UQC8rjJFCHQkfdp7KmCkTZCb5dGzLFYe2TzsiZpfsnyTFt9D

About

My way to use Emacs built-in Outline-minor-mode to structure new types of documents.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published