Compare commits

...

41 Commits
3.0.0 ... main

Author SHA1 Message Date
a15d166249 Test new mood-line-segment-vc--rev behavior 2023-12-10 08:25:27 -05:00
7084fafaa4 Fix comment header 2023-12-10 08:25:20 -05:00
d1c024fdf9 Adjust mood-line-frame-status-client face 2023-12-10 08:09:54 -05:00
e0f6ba27a8 Add project segment 2023-12-10 08:08:46 -05:00
fdaeb1fddb Tweak header comments 2023-12-10 08:08:09 -05:00
d5b6b5b355 Fix typo 2023-12-10 07:57:02 -05:00
4ecd41b934 Improve icon contrast (again) 2023-12-09 06:29:07 -05:00
c0331b4879 Improve icon contrast 2023-12-09 06:28:04 -05:00
2a595780b3 Update repo icon 2023-12-09 06:25:44 -05:00
10b5195f1b Merge branch 'master' 2023-12-09 06:10:01 -05:00
99083c7c3a Bump minor version number 2023-12-09 05:52:27 -05:00
9b004b3d94 Tidy docs 2023-12-09 05:51:54 -05:00
020cbc918f Update preview image 2023-12-09 05:19:42 -05:00
a0c84a3c1e Remove obselete face alias definition
3.0.0 broke compatibility with just about everything that may have hooked into
the package, so it should be appropriate to shed this bit of cruft.
2023-12-09 05:13:28 -05:00
a9b55d8308 Refactor client segment
The client status indicator will be propertized with its own face.

The buffer status indicator and default mood-line-format configurations have
also been adjusted to make room for the new client status indicator.
2023-12-09 05:11:04 -05:00
eb3993601d Merge branch 'client-indicator' 2023-12-09 03:51:06 -05:00
5dfc7572dd Merge: handle vc-display-status being nil 2023-12-09 03:13:27 -05:00
731c786af4 Clarify benchmark results 2023-12-06 20:15:14 -05:00
8a580f30bb Remove unnecessary section header 2023-12-06 20:15:07 -05:00
1c22801c96 Add repository icon 2023-12-04 19:48:45 -05:00
fa79a8c302 Move preview.png from LFS 2023-12-04 19:18:29 -05:00
cc7b931a0b Disable LFS 2023-12-04 19:18:04 -05:00
ff0a35672e Remove fboundp check from mood-line--deflazy
Users are reporting errors caused by deflazy'd functions having void function
definitions. fboundp check may be causing this, and may be unnecessary anyhow.
2023-12-04 18:57:08 -05:00
a19fecd385 Bump patch version number 2023-12-04 18:42:20 -05:00
2050f81860 Fix compatibility with Emacs 27
inhibit-buffer-hooks parameter for get-buffer-create was introduced in Emacs 28.
2023-12-04 18:40:10 -05:00
b568f0faa9 Merge branch 'fix-readme' into 'master'
Fix use-package example in README

See merge request jessieh/mood-line!14
2023-11-28 15:27:29 +00:00
abaa476416 Point README at new issue tracker 2023-11-27 21:53:49 -05:00
19dc4775e5 Update Commentary section to reflect README 2023-11-24 19:23:55 -05:00
d8561e8446 Fix typo in README.md 2023-11-24 19:23:55 -05:00
51318ef090 Properly encapsulate byte-compiler declarations 2023-11-24 19:23:55 -05:00
b2172c52c8 Fix tests for revised mood-line-defformat macro 2023-11-24 19:23:52 -05:00
b7bc361b93 Fix typo in benchmark.md 2023-11-21 16:54:50 -05:00
e66e181ac2 Update .gitattributes 2023-11-21 16:54:43 -05:00
6e0af4bd7e Free benchmark.md from LFS 2023-11-21 16:51:09 -05:00
7ef73ff4e3 Fix typo in README.md 2023-11-21 16:48:59 -05:00
kngwyu
89d088c5ec Fix use-package example in README 2023-09-23 18:17:26 +09:00
Seth Ladygo
b1028ce61a Handle vc-display-status being nil. 2023-04-28 15:31:08 -07:00
Gregg Sangster
8331e01908 Add xah-fly-keys to modal segment 2023-03-16 15:54:27 -04:00
Trevor Richards
6e3f62f57c
Moved the emacsclient segment to before anzu 2022-12-31 16:19:32 -08:00
Trevor Richards
21e4addc9b
Added emacsclient indicator
Closes feature request from #25
2022-12-31 16:11:30 -08:00
Trevor Richards
25c7846b8f
Align mode-line-evil-state-alist 2022-12-30 21:03:29 -08:00
14 changed files with 193 additions and 107 deletions

2
.gitattributes vendored
View File

@ -1,2 +0,0 @@
# Repository assets (screenshots, etc.)
.repo-assets/** filter=lfs diff=lfs merge=lfs -text

View File

@ -1,3 +1,20 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7bb22f786b2a5e3f01d1c784b320f6451bf093ceb049d9b45f7c283344635495
size 670
```lisp
;; Emacs 29 with native compilation, default GC threshold
;; Run in a lisp-interaction-mode buffer with Flymake
(defun time-mode-line (num &optional and-mem)
(let ((gc-cons-threshold (if and-mem gc-cons-threshold most-positive-fixnum))
(start-time (current-time)))
(cl-loop for i to num
do (format-mode-line mode-line-format))
(format-time-string "%s.%3N seconds" (time-since start-time))))
;; Default mode line:
(time-mode-line 10000) ;; "0.440 seconds"
(time-mode-line 10000 :and-mem) ;; "2.402 seconds"
;; mood-line (default settings):
(mood-line-mode t)
(time-mode-line 10000) ;; "0.309 seconds"
(time-mode-line 10000 :and-mem) ;; "1.286 seconds"
```

BIN
.repo-assets/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
.repo-assets/icon.xcf Normal file

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3ac214b9c012211913dc903ced696036e85ca1d9c2af1d28b117e537da9ea108
size 231459

BIN
.repo-assets/preview.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

View File

@ -1,12 +1,10 @@
# mood-line
# <img src=".repo-assets/icon.png" width=50> mood-line
A lightweight, drop-in replacement for the default Emacs mode line configuration.
[![MELPA](https://melpa.org/packages/mood-line-badge.svg)](https://melpa.org/#/mood-line)
[![MELPA Stable](https://stable.melpa.org/packages/mood-line-badge.svg)](https://stable.melpa.org/#/mood-line)
## About
mood-line is a lightweight, drop-in replacement for the default Emacs mode line configuration.
## Features
* Clean, informative design
@ -17,11 +15,11 @@ mood-line is a lightweight, drop-in replacement for the default Emacs mode line
* Lazy-loaded extensions
* [Lightweight](./repo-assets/benchmark.md), no dependencies
* [Lightweight](.repo-assets/benchmark.md), no dependencies
## Preview
![Preview Image](.repo-assets/preview.png "Preview Image")
![Preview Image](.repo-assets/preview.webp "Preview Image")
## Configuration
@ -40,7 +38,7 @@ If you are a user of `use-package`, it is easy to configure mood-line directly i
;; Use pretty Fira Code-compatible glyphs
:custom
(mood-line-glyph-alist . mood-line-glyphs-fira-code))
(mood-line-glyph-alist mood-line-glyphs-fira-code))
```
### Format
@ -71,8 +69,8 @@ mood-line uses a modular segment format, and it is easy to reconfigure:
((mood-line-segment-checker) . " "))))
```
More information on the format specification is available in the documentation: \
`M-x describe-variable mood-line-format` \
More information on the format specification is available in the documentation:\
`M-x describe-variable mood-line-format`\
`M-x describe-function mood-line-defformat`
### Glyphs
@ -82,7 +80,7 @@ If you'd like to see prettier Unicode glyphs, you can change the value of `mood-
```elisp
;; The default set of glyphs:
;; * myModifiedFile.js Replace*3 + main Javascript ! Issues: 2
;; * myModifiedFile.js Replace*3 + main JavaScript ! Issues: 2
(setq mood-line-glyph-alist mood-line-glyphs-ascii)
;; A set of Fira Code-compatible Unicode glyphs:
@ -112,7 +110,7 @@ To run the included tests:
## Feedback
If you experience any issues with this package, please
[open an issue](https://gitlab.com/jessieh/mood-line/issues/new)
[open an issue](https://git.tty.dog/jessieh/mood-line/issues/new)
on the issue tracker.
Suggestions for improvements and feature requests are always appreciated, as well!

View File

@ -2,7 +2,7 @@
;;
;; Author: Jessie Hildebrandt <jessieh.net>
;; Homepage: https://gitlab.com/jessieh/mood-line
;;
;; This file is not part of GNU Emacs.
;;; Commentary:
@ -35,7 +35,7 @@
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; Compile time requirements
;; Required features
;; ---------------------------------- ;;
(eval-when-compile
@ -45,19 +45,19 @@
;; External variable defs
;; ---------------------------------- ;;
(defvar flycheck-current-errors)
(eval-when-compile
(defvar flycheck-current-errors))
;; ---------------------------------- ;;
;; External function decls
;; ---------------------------------- ;;
(declare-function mood-line--get-glyph "mood-line")
(declare-function flycheck-count-errors "flycheck")
(declare-function flymake-running-backends "flymake")
(declare-function flymake-reporting-backends "flymake")
(declare-function flymake--lookup-type-property "flymake")
(eval-when-compile
(declare-function mood-line--get-glyph "mood-line")
(declare-function flycheck-count-errors "flycheck")
(declare-function flymake-running-backends "flymake")
(declare-function flymake-reporting-backends "flymake")
(declare-function flymake--lookup-type-property "flymake"))
;; -------------------------------------------------------------------------- ;;
;;

View File

@ -3,7 +3,7 @@
;; Author: Alynx Zhou <alynx.zhou@gmail.com>
;; Jessie Hildebrandt <jessieh.net>
;; Homepage: https://gitlab.com/jessieh/mood-line
;;
;; This file is not part of GNU Emacs.
;;; Commentary:
@ -39,7 +39,8 @@
;; External function decls
;; ---------------------------------- ;;
(declare-function mood-line--get-glyph "mood-line")
(eval-when-compile
(declare-function mood-line--get-glyph "mood-line"))
;; -------------------------------------------------------------------------- ;;
;;

View File

@ -3,7 +3,7 @@
;; Author: trevDev() <trev@trevdev.ca>
;; Jessie Hildebrandt <jessieh.net>
;; Homepage: https://gitlab.com/jessieh/mood-line
;;
;; This file is not part of GNU Emacs.
;;; Commentary:
@ -107,6 +107,16 @@ e.g., (:foreground \"red\")."
(concat (propertize (car mode-cons)
'face (cdr mode-cons))))))
;; ---------------------------------- ;;
;; Xah segment
;; ---------------------------------- ;;
(defun mood-line-segment-modal--xah-fn ()
"Display the current xah-fly-keys state."
(if (bound-and-true-p xah-fly-insert-state-p)
"<I>"
"<C>"))
;; ---------------------------------- ;;
;; God segment
;; ---------------------------------- ;;

View File

@ -2,7 +2,7 @@
;;
;; Author: Jessie Hildebrandt <jessieh.net>
;; Homepage: https://gitlab.com/jessieh/mood-line
;;
;; This file is not part of GNU Emacs.
;;; Commentary:
@ -38,7 +38,8 @@
;; External function decls
;; ---------------------------------- ;;
(declare-function mood-line--get-glyph "mood-line")
(eval-when-compile
(declare-function mood-line--get-glyph "mood-line"))
;; -------------------------------------------------------------------------- ;;
;;
@ -48,8 +49,11 @@
(defun mood-line-segment-vc--rev (vc-mode-str backend)
"Return name of current file's revision for BACKEND according to `vc-mode'.
VC-MODE-STR is expected to be the value of `vc-mode' in the current buffer."
(or (pcase backend
VC-MODE-STR is expected to be the value of `vc-mode' in the current buffer.
If `vc-display-status' is nil, return the name of BACKEND."
(or (unless vc-display-status
(symbol-name backend))
(pcase backend
('Git (substring-no-properties vc-mode-str 5))
('Hg (substring-no-properties vc-mode-str 4)))
(ignore-errors

View File

@ -1,17 +1,16 @@
;;; mood-line.el --- A minimal mode line inspired by doom-modeline -*- lexical-binding: t; -*-
;;
;; Author: Jessie Hildebrandt <jessieh.net>
;; Homepage: https://gitlab.com/jessieh/mood-line
;; Keywords: mode-line faces
;; Version: 3.0.0
;; Version: 3.1.0
;; Package-Requires: ((emacs "26.1"))
;;
;; This file is not part of GNU Emacs.
;;; Commentary:
;;
;; mood-line is a minimal mode line configuration that aims to replicate
;; some of the features of the more advanced doom-modeline package.
;; mood-line is a lightweight, drop-in replacement for the default mode line.
;;
;; Features offered:
;; * Clean, informative design
@ -52,7 +51,7 @@
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; Compile time requirements
;; Required features
;; ---------------------------------- ;;
(eval-when-compile
@ -62,18 +61,19 @@
;; External variable defs
;; ---------------------------------- ;;
(defvar anzu--cached-count)
(defvar anzu--current-position)
(defvar anzu--overflow-p)
(defvar anzu--total-matched)
(eval-when-compile
(defvar anzu--cached-count)
(defvar anzu--current-position)
(defvar anzu--overflow-p)
(defvar anzu--total-matched))
;; ---------------------------------- ;;
;; External function decls
;; ---------------------------------- ;;
(declare-function mc/num-cursors "multiple-cursors")
(declare-function string-blank-p "subr-x")
(eval-when-compile
(declare-function mc/num-cursors "multiple-cursors")
(declare-function string-blank-p "subr-x"))
;; -------------------------------------------------------------------------- ;;
;;
@ -82,10 +82,8 @@
;; -------------------------------------------------------------------------- ;;
(defmacro mood-line--deflazy (name)
"Define dummy function NAME to `require' its module and call actual function.
If NAME is already bound, this does nothing."
(when-let ((not-bound (not (fboundp name)))
(module (intern (car (split-string (symbol-name name) "--")))))
"Define dummy function NAME to `require' its module and call actual function."
(let ((module (intern (car (split-string (symbol-name name) "--")))))
`(defun ,name (&rest args)
"Not yet loaded."
(fmakunbound (quote ,name))
@ -146,6 +144,8 @@ An optional key :padding may be provided, the value of which will be used as
(:buffer-modified . ?*)
(:buffer-read-only . ?#)
(:frame-client . ?@)
(:count-separator . ?*))
"Set of ASCII glyphs for use with mood-line.")
@ -167,6 +167,8 @@ An optional key :padding may be provided, the value of which will be used as
(:buffer-modified . ?●)
(:buffer-read-only . ?■)
(:frame-client . ?)
(:count-separator . ?×))
"Set of Fira Code-compatible glyphs for use with mood-line.")
@ -188,6 +190,8 @@ An optional key :padding may be provided, the value of which will be used as
(:buffer-modified . ?●)
(:buffer-read-only . ?■)
(:frame-client . ?⇅)
(:count-separator . ?✕))
"Set of Unicode glyphs for use with mood-line.")
@ -195,7 +199,7 @@ An optional key :padding may be provided, the value of which will be used as
(mood-line-defformat
:left
(((mood-line-segment-modal) . " ")
((mood-line-segment-buffer-status) . " ")
((or (mood-line-segment-buffer-status) " ") . " ")
((mood-line-segment-buffer-name) . " ")
((mood-line-segment-anzu) . " ")
((mood-line-segment-multiple-cursors) . " ")
@ -213,7 +217,10 @@ An optional key :padding may be provided, the value of which will be used as
(mood-line-defformat
:left
(((mood-line-segment-modal) . " ")
((mood-line-segment-buffer-status) . " ")
((or (mood-line-segment-buffer-status)
(mood-line-segment-client)
" ") . " ")
((mood-line-segment-project) . "/")
((mood-line-segment-buffer-name) . " ")
((mood-line-segment-anzu) . " ")
((mood-line-segment-multiple-cursors) . " ")
@ -290,6 +297,8 @@ Keys are names for different mode line glyphs, values are characters for that
:buffer-modified | File-backed buffer is modified
:buffer-read-only | File-backed buffer is read-only
:frame-client | Frame is a client for an Emacs daemon
:count-separator | Separates some indicator names from numerical counts
`mood-line-glyphs-ascii' will be used as a fallback whenever a glyph is found
@ -346,6 +355,10 @@ See `mood-line-defformat' for a helpful formatting macro."
"Face used for the ':buffer-narrowed' buffer status indicator."
:group 'mood-line-faces)
(defface mood-line-frame-status-client
'((t (:inherit mood-line-unimportant)))
"Face used for the :frame-client frame status indicator.")
(defface mood-line-major-mode
'((t (:inherit bold)))
"Face used for the major mode indicator."
@ -386,22 +399,13 @@ See `mood-line-defformat' for a helpful formatting macro."
"Face used for less important mode line elements."
:group 'mood-line-faces)
;; ---------------------------------- ;;
;; Obsolete faces
;; ---------------------------------- ;;
(define-obsolete-face-alias
'mood-line-modified
'mood-line-buffer-status-modified
"2.1.0")
;; -------------------------------------------------------------------------- ;;
;;
;; Helper functions
;;
;; -------------------------------------------------------------------------- ;;
(defvar mood-line--escape-buffer (get-buffer-create " *mood-line*" t)
(defvar mood-line--escape-buffer (get-buffer-create " *mood-line*")
"Buffer used by `mood-line--escape'.")
(defun mood-line--escape (&rest strings)
@ -457,17 +461,22 @@ described in the documentation for `mood-line-format', which see."
(mood-line--deflazy mood-line-segment-modal--evil-fn)
(mood-line--deflazy mood-line-segment-modal--meow-fn)
(mood-line--deflazy mood-line-segment-modal--xah-fn)
(mood-line--deflazy mood-line-segment-modal--god-fn)
(defun mood-line-segment-modal ()
"Return the correct mode line segment for the first active modal mode found.
Modal modes checked, in order: `evil-mode', `meow-mode', `god-mode'."
Modal editing modes checked, in order:
`evil-mode', `meow-mode', `xah-fly-keys', `god-mode'"
(cond
((bound-and-true-p evil-mode)
(mood-line-segment-modal--evil-fn))
((bound-and-true-p meow-mode)
(mood-line-segment-modal--meow-fn))
((featurep 'god-mode)
((bound-and-true-p xah-fly-keys)
(mood-line-segment-modal--xah-fn))
((or (bound-and-true-p god-local-mode)
(bound-and-true-p god-global-mode))
(mood-line-segment-modal--god-fn))))
;; ---------------------------------- ;;
@ -506,6 +515,33 @@ Modal modes checked, in order: `evil-mode', `meow-mode', `god-mode'."
((bound-and-true-p flymake-mode)
mood-line-segment-checker--flymake-text)))
;; -------------------------------------------------------------------------- ;;
;;
;; Client segment
;;
;; -------------------------------------------------------------------------- ;;
(defun mood-line-segment-client ()
"Return an indicator representing the client status of the current frame."
(when (frame-parameter nil 'client)
(propertize (mood-line--get-glyph :frame-client)
'face 'mood-line-frame-status-client)))
;; -------------------------------------------------------------------------- ;;
;;
;; Project segment
;;
;; -------------------------------------------------------------------------- ;;
(defun mood-line-segment-project ()
"Return project name from project.el or Projectile, if any."
(or
(and (fboundp 'project-name)
(project-current)
(project-name (project-current)))
(and (fboundp 'projectile-project-name)
(projectile-project-name))))
;; -------------------------------------------------------------------------- ;;
;;
;; anzu segment
@ -575,12 +611,10 @@ Modal modes checked, in order: `evil-mode', `meow-mode', `god-mode'."
'face 'mood-line-buffer-status-modified))
(buffer-read-only
(propertize (mood-line--get-glyph :buffer-read-only)
'face 'mood-line-buffer-status-read-only))
(t " "))
(if (buffer-narrowed-p)
'face 'mood-line-buffer-status-read-only)))
(when (buffer-narrowed-p)
(propertize (mood-line--get-glyph :buffer-narrowed)
'face 'mood-line-buffer-status-narrowed)
" ")))
'face 'mood-line-buffer-status-narrowed))))
;; ---------------------------------- ;;
;; Buffer name segment
@ -692,10 +726,6 @@ Modal modes checked, in order: `evil-mode', `meow-mode', `god-mode'."
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; Configuration
;; ---------------------------------- ;;
(defconst mood-line--hooks-alist
'((mood-line-segment-checker--flycheck-update
. (flycheck-mode-hook

View File

@ -34,4 +34,12 @@
(should (string= (mood-line-segment-vc--rev "" 'SVN)
"???"))))
(ert-deftest --rev/vc-display-status-nil ()
"Name of the VCS backend should be reported when `vc-display-status' is nil."
(let ((vc-display-status nil))
(should (string= (mood-line-segment-vc--rev " Git:main" 'Git)
"Git"))
(should (string= (mood-line-segment-vc--rev " Hg:main" 'Hg)
"Hg"))))
;;; mood-line-segment-vc-test.el ends here

View File

@ -17,57 +17,80 @@
;; mood-line-defformat
;; ---------------------------------- ;;
(ert-deftest -defformat/right-nil ()
"The format sequence should expand if the right segment list is not provided."
(should (equal (mood-line-defformat
;; Left
("XYZ")
;; Right
)
(ert-deftest -defformat/padding ()
"The expanded sequence should include the provided (or default) padding."
(should (equal (mood-line-defformat)
(list
;; Left
'("XYZ")
'(" ")
;; Right
nil))))
(ert-deftest -defformat/left-right ()
"The expanded sequence should should include left and right segments lists."
'(" "))))
(should (equal (mood-line-defformat
:padding
"---")
(list
;; Left
("ABC")
'("---")
;; Right
'("---")))))
(ert-deftest -defformat/left-right-nil ()
"The format sequence should expand if the left or right segment list is nil."
(should (equal (mood-line-defformat
:left
("XYZ"))
(list
;; Left
'("ABC")
'(" " "XYZ")
;; Right
'("XYZ")))))
'(" "))))
(should (equal (mood-line-defformat
:right
("XYZ"))
(list
;; Left
'(" ")
;; Right
'("XYZ" " ")))))
(ert-deftest -defformat/left-right ()
"The expanded sequence should include left and right segments lists."
(should (equal (mood-line-defformat
:left
("ABC")
:right
("XYZ"))
(list
;; Left
'(" " "ABC")
;; Right
'("XYZ" " ")))))
(ert-deftest -defformat/cons-cells ()
"Cons cell segments should expand into their `car' and `cdr' values."
(should (equal (mood-line-defformat
;; Left
:left
("ABC" ("ABC" . "XYZ") "XYZ")
;; Right
:right
("..." ((some-fn) . " ") "..."))
(list
;; Left
'("ABC" "ABC" "XYZ" "XYZ")
'(" " "ABC" "ABC" "XYZ" "XYZ")
;; Right
'("..." (some-fn) " " "...")))))
'("..." (some-fn) " " "..." " ")))))
(ert-deftest -defformat/exp-separators ()
"Non-string, non-cons expressions should expand followed by a blank string."
(should (equal (mood-line-defformat
;; Left
:left
("ABC" ("ABC" . "XYZ") some-exp "XYZ" (some-fn))
;; Right
:right
("..." ((some-fn) . " ") (another-fn) "..."))
(list
;; Left
'("ABC" "ABC" "XYZ" some-exp "" "XYZ" (some-fn) "")
'(" " "ABC" "ABC" "XYZ" some-exp "" "XYZ" (some-fn) "")
;; Right
'("..." (some-fn) " " (another-fn) "" "...")))))
'("..." (some-fn) " " (another-fn) "" "..." " ")))))
;; -------------------------------------------------------------------------- ;;
;;
@ -125,7 +148,7 @@
(should (string= segments-str "ABC123XYZ"))))
;; ---------------------------------- ;;
;; mood-line---process-format
;; mood-line--process-format
;; ---------------------------------- ;;
(ert-deftest --process-format/default ()