/ruri

thin layer over mode-line

Primary LanguageEmacs LispISC LicenseISC

Ruri for Emacs

瑠璃の地と人も見つべしわが床は涙の玉と敷きに敷ければ

Ruri is a thin layer over mode-line. A thin layer that makes mode-line modular.

/screenshots/mini.png?raw=true

/screenshots/full.png?raw=true

Installation

Please use straight.el or something like that.

Then update the mode-line-format using the function ruri-install:

(ruri-install
 '(modified size summary major-mode flycheck lsp encoding))

By default, segments are joined using 2 spaces; The separator can be customized via ruri-separator.

Defining Your Own Segments

Example

Let’s see a toy example. The following code defines a new segment my-great-segment and uses it:

;; shows current time using the face "error"
(define-ruri-segment my-great-segment
  (propertize (current-time-string) 'face 'error))

(ruri-install
 '(modified size summary major-mode encoding my-great-segment))

The code results in something like this:

/screenshots/example.png?raw=true

You can easily see that the resulting string of my-great-segment is added to the mode-line.

Details

New segments can be defined using (define-ruri-segment NAME BODY). The NAME here is the name of the newly-defined segment, and the BODY is the body of a function that returns a (possibly propetrized) string. Using this BODY, Ruri defines a nullary function (lambda () ,@BODY) with some appropriate name (ruri--segment:my-great-segment, in the case of the example above).

Defined segments can be added to the mode-line using ruri-install. From the names of the segments passed to this function, Ruri finds corresponding renderer functions (e.g. ruri--segment:my-great-segment), and calls it every time when mode-line needs to be updated. Ruri joins all the return values of these renderer functions, resulting a colorfully decorated mode-line.

See Also