• Stars
    star
    108
  • Rank 321,259 (Top 7 %)
  • Language
    Emacs Lisp
  • License
    GNU General Publi...
  • Created over 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

modern block styling with org-indent

org-modern-indent

Modern block styling with org-indent.

org-modern provides a clean and efficient org style. The blocks (e.g. source, example) are particularly nicely decorated. But when org-indent is enabled, the block "bracket", which uses the fringe area, is disabled.

This small package approximately reproduces the block styling of org-modern when using org-indent. It can be used with or without org-modern. Recent versions support "bulk-indented" blocks nested within lists:

Updates

  • v0.1 features a complete re-write to use font-lock directly. This has a few benefits:
    1. No longer relies on org-mode face names for recognizing blocks, so org-src-block-faces can have arbitrary faces applied, e.g. for different src languages, as in the screenshot.
    2. Eliminates the "race" between font-locking and applying the prefix text properties.
    3. Enables in-text bracket decorations for "bulk-indented" blocks, for example blocks situated in an arbitrarily-nested plain list item.

Configure

(use-package org-modern-indent
  :load-path "~/code/emacs/org-modern-indent/"
  ; or
  ; :straight (org-modern-indent :type git :host github :repo "jdtsmith/org-modern-indent"))
  :config ; add late to hook
  (add-hook 'org-mode-hook #'org-modern-indent-mode 90))

Also, be sure to enable org-indent (see the variable org-startup-indented).

Hints

Bulk-indented blocks (e.g. within lists):

Bulk-indented blocks have "real" (space/tab) indent applied and managed by org. This extra indentation is applied by org on top of the (fake, prefix-based) indentation used by org-indent. To nest blocks properly within such indented content, e.g. in plain list items, you only have to begin the #+begin at the same level as the list element's text.

As an important principle, org-modern-indent does not alter the contents of the text in your org documents, not even indentation. It just styles what is there. To help achieve proper block bulk-indented alignment, here are a few ways to alter blocks indentation using org and other commands:

  • Start things right: Hit return after your last line of text (e.g in a list item), then immediately hit C-c C, to create the desired block. It will be indented at the right level:
    - This list item contains a:
        - sublist, which holds a block:
          [C-c C-,] here
    
  • Move flush left: Note: M-{ will get you to the start of a block quickly. M-\ at block start will move the block's first header line to column 0. Then M-S-left (or right) will indent the full block.
  • Indent rigidly: M-h selects the entire block. Then C-x TAB enters "rigid indent" mode, after which left/right moves the entire block.
  • Re-indent a block: If you have a block that is partially aligned, perhaps with a "hanging end", like so:
    - List 1
        - List 2
          #+begin_src lang
     	   foo_lang(x)
        #+end_src
    
    you can simply use M-S-left/right at block start (or in fact anywhere on the block header/footer) to org-indent-block. Note that org-src-preserve-indentation=nil is an important setting, to allow org to (re-)indent blocks to respect the local indentation inside list and other elements. Also note that (from org-indent-region):

The function will not indent contents of example blocks, verse blocks and export blocks as leading white spaces are assumed to be significant there.

Font spacing

The default fixed-pitch font (from which org-meta-line inherits) has line spacing >1.0 on some systems. This will introduce gaps even if your default font is changed, and line-space is nil. To correct it, add:

(set-face-attribute 'fixed-pitch nil :family "Hack" :height 1.0) ; or whatever font family

The bracket style

If you'd like a different face than org-meta-line for the "bracket", configure the org-modern-bracket-line face.

Related config

Optionally, if you want to use org-modern too (I do), a suggested config:

(use-package org-modern
  :ensure t
  :custom
  (org-modern-hide-stars nil)		; adds extra indentation
  (org-modern-table nil)
  (org-modern-list 
   '(;; (?- . "-")
     (?* . "β€’")
     (?+ . "β€£")))
  :hook
  (org-mode . org-modern-mode)
  (org-agenda-finalize . org-modern-agenda))

Also optional; use org-bullets instead for nicely aligned bullet stars.

(use-package org-bullets-mode
  :ensure org-bullets
  :config
  :hook org-mode)

Related packages

  • org-modern: A modern org styling. Works best without org-indent.
  • org-bullets: Unicode heading bullet replacement.
  • org-superstar: Prettify headings and plain lists.
  • nano-emacs: Beautiful and simple SVG-based theme for much of emacs, including org.

More Repositories

1

kind-icon

Completion kind text/icon prefix labelling for emacs in-region completion
Emacs Lisp
131
star
2

mlscroll

Lightweight scrollbar for the Emacs mode line
Emacs Lisp
65
star
3

outli

Simple comment-based outlines for Emacs
Emacs Lisp
48
star
4

mode-minder

Show all modes available in Emacs
Emacs Lisp
35
star
5

python-mls

Multi-line Shell Commands for Python REPLs in Emacs
34
star
6

shakespeare.org

An emacs org-mode of the collected works of shakespeare
Python
31
star
7

abridge-diff

Emacs package for refining diff hunks with very long lines (as in LaTeX files)
Emacs Lisp
18
star
8

org-mac-image-paste

Paste images and PDFs directly into org files on emacs-mac.
Emacs Lisp
15
star
9

idlwave

IDL Emacs editing and shell mode
Emacs Lisp
13
star
10

speedrect

Quick key bindings and other tools for rectangle-mark-mode
Emacs Lisp
13
star
11

consult-jump-project

Quickly jump between projects, their files and buffers with consult
Emacs Lisp
13
star
12

SplitView

Hammerspoon Spoon to automate putting two windows in fullscreen split-view
Lua
9
star
13

vertico-truncate

Judicious truncation for long vertico lines
Emacs Lisp
6
star
14

homebridge-denonmarantzavr

A Homebridge plugin for controlling Denon and Marantz AVRs
JavaScript
4
star
15

mqttthing-ikeaBlindZ2M

A Codec for homebridge-mqttthing supporting Ikea blinds via Zigbee2MQTT
JavaScript
3
star
16

TwistCube

An example Sketchup Ruby -> Dynamic Component interaction
Ruby
2
star
17

autoftp

Python
2
star
18

mac-tab-desktop

Save and restore native Mac tabs with desktop.el
Emacs Lisp
1
star
19

SoundTower

An Airplay to WLED Sound Server
JavaScript
1
star
20

comint-fold

Fold input + output blocks in Emacs comint shells
Emacs Lisp
1
star
21

homebridge-epson-vpnet

Epson Projector Power/Lens/Image Memory Control with HDR Autoswitch
JavaScript
1
star
22

cubism

Cube Builder for IRS Spectral Mapping
IDL
1
star
23

hidemoreless

A Sketchup Ruby plugin to manage selective hiding in nested entity heirarchies
Ruby
1
star