Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescherti committed Oct 16, 2024
1 parent 5d4b518 commit 68f80d3
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ The `outline-indent.el` Emacs package offers a similar functionality to Vim's `s
- [Maintaining blank lines between folded sections](#maintaining-blank-lines-between-folded-sections)
- [Why not use origami.el or yafolding?](#why-not-use-origamiel-or-yafolding)
- [Why not use folding.el?](#why-not-use-foldingel)
- [How to make Emacs indent new lines based on previous non-blank line?](#how-to-make-emacs-indent-new-lines-based-on-previous-non-blank-line)
- [What other packages can be used to maintain proper indentation in indentation-sensitive programming languages](#what-other-packages-can-be-used-to-maintain-proper-indentation-in-indentation-sensitive-programming-languages)
- [dtrt-indent](#dtrt-indent)
- [License](#license)
- [Links](#links)

Expand Down Expand Up @@ -251,6 +254,43 @@ The `folding.el` package is no longer maintained (abandoned) and uses markers in

In contrast, `outline-indent.el` uses indentation levels to determine foldable sections.

### How to make Emacs indent new lines based on previous non-blank line?

The following code snippet configures Emacs to indent based on the indentation of the previous non-blank line:
```emacs-lisp
;; This ensures that pressing Enter will insert a new line and indent it.
(global-set-key (kbd "RET") #'newline-and-indent)
;; Indentation based on the indentation of the previous non-blank line.
(setq-default indent-line-function #'indent-relative-first-indent-point)
;; In modes such as `text-mode', pressing Enter multiple times removes
;; the indentation. The following fixes the issue and ensures that text
;; is properly indented using `indent-relative' or
;; `indent-relative-first-indent-point'.
(setq-default indent-line-ignored-functions '())
```

### What other packages can be used to maintain proper indentation in indentation-sensitive programming languages

#### dtrt-indent

The *dtrt-indent* provides an Emacs minor mode that detects the original indentation offset used in source code files and automatically adjusts Emacs settings accordingly, making it easier to edit files created with different indentation styles.

You can install it by adding the following to your Emacs init files:
```emacs-lisp
(use-package dtrt-indent
:ensure t
:commands (dtrt-indent-global-mode
dtrt-indent-mode
dtrt-indent-adapt
dtrt-indent-undo
dtrt-indent-diagnosis
dtrt-indent-highlight)
:config
(dtrt-indent-global-mode))
```

## License

The `outline-indent` Emacs package has been written by [James Cherti](https://www.jamescherti.com/) and is distributed under terms of the GNU General Public License version 3, or, at your choice, any later version.
Expand Down

0 comments on commit 68f80d3

Please sign in to comment.