Compare commits

..

124 Commits
1.1.1 ... 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
c3ff35a807 Bump major version number
Big changes!
2023-11-21 16:46:57 -05:00
84a172a0ea Add basic benchmark results to back up claims 2023-11-21 16:46:14 -05:00
b5551105d4 Rework mood-line-defformat macro to use plist 2023-11-21 16:45:34 -05:00
78925bdb72 Add processing step to escape mode line constructs 2023-11-20 17:40:40 -05:00
8414402234 Add defformat macro 2023-11-20 17:40:27 -05:00
1f0bf3377e Add tests 2023-11-18 20:29:21 -05:00
b41f6ba1dd Restructure project
mood-line has been restructured to improve modularity and configurability
with careful attention paid to performance and overall project complexity.
2023-11-18 20:20:29 -05:00
d948ba7a94 Move preview screenshot to LFS 2023-11-18 20:19:33 -05:00
110ac6dfc4 Add .gitattributes 2023-11-18 20:19:13 -05:00
ce70dc61ab Update README for impending 3.0.0 changes 2023-11-18 16:40:32 -05:00
67f73ede9a Bump version number 2023-11-18 15:35:35 -05:00
d695e20e0e Simplify formatting logic 2023-11-15 21:02:11 -05:00
50b224b342 Switch to correct buffer position indicator 2023-11-15 20:58:08 -05:00
bcd8725b21 Improve general compatibility of flymake segment 2023-10-16 13:35:08 -04:00
060959f5e2 Update required Emacs version to 26.1 2023-10-13 17:08:11 -04:00
8e2eb970a0 Update flymake segment 2023-10-13 17:06:41 -04:00
74546fa7bb Properly remove flymake hooks during deactivation 2023-10-13 17:06:03 -04: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
58e85c8150 Move modal editing segment to its own file 2023-01-26 04:17:55 -05:00
60faca6943 Update checker segments 2023-01-26 02:03:32 -05:00
a43bb1c96d Clean up face definitions 2023-01-26 02:02:34 -05:00
d6369af822 Update default ASCII checker status glyphs 2023-01-21 21:08:37 -05: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
2f9f5f37f5 Add option to disable major mode segment 2022-12-30 12:03:10 -05:00
ade4f40518 Use built-in string trimming functions 2022-12-30 12:01:46 -05:00
b5df8bfd5f Update :buffer-narrowed for fira code glyph set 2022-12-30 12:00:56 -05:00
e42ee24e23 Move optional segments section 2022-12-30 01:00:31 -05:00
318ceaf07a Merge branch 'mood-line-indent-segment' 2022-12-29 19:29:50 -05:00
acb57343a0 Add encoding face for indentation segment
This face will also be used to decorate other encoding-related segments
in the future.
2022-12-29 14:25:49 -05:00
9233fdce74 Tweak formatting of indentation segment 2022-12-29 09:00:52 -05:00
cff8cc6032 Add commentary to mood-line-segment-indentation 2022-12-29 08:07:01 -05:00
5c573fea9f Move indentation segment to its own file 2022-12-29 08:05:12 -05:00
c30d6e79c5 Replace deprecated face with obsolete face alias 2022-12-29 03:07:16 -05:00
6fe134fe4c Display appropriate status for indirect buffers 2022-12-29 01:10:40 -05:00
7b1371bd4b Tweak README.md 2022-12-29 00:51:30 -05:00
3aa9a9a83b Refine behavior and faces of buffer status segment
New faces have been added for the buffer status segment to allow
for more granular user customizations. Buffer narrowing should also
now be properly indicated when narrowing a non-file-backed buffer.
2022-12-29 00:40:30 -05:00
229eb4a04f Refine docstring for cursor position segment 2022-12-29 00:39:21 -05:00
410e54f9ba Fix potential bugs in coding system segments 2022-12-29 00:39:02 -05:00
Alynx Zhou
466a0292c9 Add indentation information segment 2022-12-28 20:40:59 +08:00
1943158fc9 Document :buffer-narrowed glyph 2022-12-22 06:22:36 -05:00
a651e5fc41 Add LICENSE 2022-12-22 11:16:23 +00:00
1aa7d52d16 Refactor project code for 2.0.0 2022-12-22 06:12:01 -05:00
62bd73f320 Update README.md 2022-12-20 22:17:55 +00:00
f1c88de4ed Update README.md 2022-12-20 22:16:32 +00:00
1a3128d098 Merge branch 'modal-editing' into 'master'
Adding modal editor support

See merge request jessieh/mood-line!7
2022-12-20 21:35:59 +00:00
trevDev()
46193c6029 Adding modal editor support 2022-12-20 21:35:59 +00:00
181e4b027d Merge branch 'patch-comments' into 'master'
* mood-line.el: Fixed multiple comments

See merge request jessieh/mood-line!6
2022-12-20 21:28:35 +00:00
846db57dd9 Merge branch 'master' into 'patch-comments'
# Conflicts:
#   mood-line.el
2022-12-20 21:25:35 +00:00
65ae1099e2 Enforce normal font weight for status faces 2022-12-19 23:39:02 -05:00
df40e0e29d Make checkdoc happy 2022-12-19 23:38:36 -05:00
a4076c7eaa Tidy up appearance of anzu and MC segments 2022-12-19 23:38:01 -05:00
Trevor Richards
935043455c
* mood-line.el: Fixed multiple comments
In adherence with elisp convention, comments have been shortened
to fit within 80 columns. Some nitpicky grammar/spelling mistakes
were fixed. Some small inaccuracies were also corrected.
2022-07-28 21:07:37 -07:00
ef1c752679 Increment patch version number 2021-10-03 17:13:42 -04:00
34a1304ede Accommodate new flymake variable name in Emacs 28+ 2021-09-03 07:42:56 -04:00
f96bca2323 Fix formatting issue with visual-fill-column-mode 2021-09-03 05:19:50 -04:00
3697ae74c8 Fix presence of duplicate anzu indicator 2021-09-03 05:12:35 -04:00
58ea97f6ea Improve mode-line format restoration behavior 2021-09-03 05:12:06 -04:00
64cbd61c3d Increment patch version number 2020-07-22 19:27:49 -04:00
9d733093e5 Fix major mode name not appearing for some modes 2020-07-22 19:26:35 -04:00
929f257935 Increment patch version number 2020-07-21 04:34:44 +00:00
9358d9c81f Fix spacing issue with misc-info and process segs. 2020-07-20 23:47:18 -04:00
5ff7cb514d Increment patch version number 2020-04-28 23:09:18 -04:00
9cd761bdf6 Fix missing face in mood-line-segment-position fn 2020-04-28 23:06:34 -04:00
85b4fdecf1 Merge branch 'fixes' into 'master'
Implement various small fixes

See merge request jessieh/mood-line!4
2020-04-29 02:59:32 +00:00
Farlado
b39de8a325 Add a forgotten docstring 2020-03-17 06:53:11 -04:00
Farlado
1e0bd0425f Conform to function naming conventions 2020-03-15 20:16:46 -04:00
Farlado
70295f52a5 Provide faces for buffer name and major mode 2020-03-15 20:10:53 -04:00
Farlado
d4f4c50cbb Fix file header and emacs version dependency 2020-03-15 20:09:11 -04:00
0b07bdc7e7 Replace bold delta with regular delta symbol 2019-11-01 19:55:42 +00:00
9d116403a8 Remove unnecessary comments 2019-09-30 06:13:23 -04:00
43682f713e Increment patch version number 2019-09-30 05:59:29 -04:00
5fdab58c28 Fix read-only indicator showing up for non-files 2019-09-30 05:58:07 -04:00
2b643fdae3 Update README 2019-09-30 05:39:12 -04:00
82856d9186 Increment minor version number 2019-09-30 05:37:26 -04:00
543c82bb08 Fix #1, #5, #7, and #8 2019-09-30 05:34:56 -04:00
29ba637959 Merge branch 'fix/global-mode-string' into 'master'
Fix global-mode-string handling

See merge request jessieh/mood-line!3
2019-09-11 20:23:46 +00:00
a69fdd73ea Merge branch 'add-encoding-segment' into 'master'
Add encoding segment

See merge request jessieh/mood-line!2
2019-09-11 20:22:37 +00:00
TatriX
749279bc17 Fix global-mode-string handling
Current implementation doesn't always work. For example if one uses
mu4e:

```
(add-hook 'after-init-hook #'mu4e-alert-enable-mode-line-display)
```

`global-mode-string` will have `((:eval mu4e-alert-mode-line))` as
it's value. And it will result in error:

```
Error during redisplay: (eval (mood-line-segment-global-mode-string)) signaled (void-function :eval) [11 times]
```

This commit uses `format-mode-line` function to manually evaluate
`global-mode-string` and append it's result to the mode line if any.
2019-06-27 16:54:49 +02:00
Mahito TANNO
4e6a58cb98 Improve README 2019-06-13 14:12:34 +09:00
Mahito TANNO
4a4986e605 Show encoding and EOL style
There is no way to display encoding nor EOL style, although the
function "mood-line-segment-encoding" exists.  Therefore, I add
the function in order to display them in the right side of mode-
line.
2019-06-13 13:24:04 +09:00
3560d8aafd Increment patch version number 2019-06-06 06:46:16 -04:00
6c875529a2 Add segment to display 'mode-line-process' value 2019-06-06 06:44:59 -04:00
07355d6cf8 Add option to display point value 2019-06-06 06:44:27 -04:00
670f2c0c39 Merge branch 'fixed-unbound-variable-access' into 'master'
Fix unbound variable access

Closes #2

See merge request jessieh/mood-line!1
2019-06-06 09:47:26 +00:00
Serghei Iakovlev
9654a5bf2e Fix unbound variable access 2019-06-06 09:47:25 +00:00
14 changed files with 2075 additions and 264 deletions

20
.repo-assets/benchmark.md Normal file
View File

@ -0,0 +1,20 @@
```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.

BIN
.repo-assets/preview.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

339
LICENSE Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
mood-line
Copyright (C) 2022 Jessie Hildebrandt
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

113
README.md
View File

@ -1,45 +1,116 @@
# mood-line
### Version 1.1.1
# <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 minimal mode-line configuration that aims to replicate some of the features of the
[doom-modeline](https://github.com/seagle0128/doom-modeline)
package.
## Features
* Clean, minimal design
* Clean, informative design
* Anzu and multiple-cursors counters
* Customizable, modular segment format
* Version control status indicator
* Customizable glyph sets
* Flycheck status indicator
* Lazy-loaded extensions
* Lightweight with no dependencies
* [Lightweight](.repo-assets/benchmark.md), no dependencies
## Preview
![Preview Image](https://gitlab.com/jessieh/mood-line/raw/assets/mood-line.png "Preview Image")
![Preview Image](.repo-assets/preview.webp "Preview Image")
## Installation
## Configuration
To enable `mood-line`, place this in your configuration file after loading the package:
You can install mood-line directly via `package-install` from [MELPA](https://melpa.org/).
After installation, you can activate the global minor mode with `M-x mood-line-mode`.
Deactivating `mode-line-mode` will restore the default `mode-line-format`.
`(mood-line-mode)`
If you are a user of `use-package`, it is easy to configure mood-line directly in your init.el:
Disabling `mood-line` can be accomplished by toggling `mood-line-mode` off.
```elisp
(use-package mood-line
## Known Issues
;; Enable mood-line
:config
(mood-line-mode)
* No known issues.
;; Use pretty Fira Code-compatible glyphs
:custom
(mood-line-glyph-alist mood-line-glyphs-fira-code))
```
### Format
mood-line uses a modular segment format, and it is easy to reconfigure:
```elisp
;; Default format:
;; * init.el 4:32 Top ELisp ! Issues: 2
(setq mood-line-format mood-line-format-default)
;; Extended format:
;; * init.el 4:32:52 Top SPCx2 LF UTF-8 ELisp ! Issues: 2
(setq mood-line-format mood-line-format-default-extended)
;; Custom format:
;; * init.el : ELisp Top 4:32 | ! Issues: 2
(setq mood-line-format
(mood-line-defformat
:left
(((mood-line-segment-buffer-status) . " ")
((mood-line-segment-buffer-name) . " : ")
(mood-line-segment-major-mode))
:right
(((mood-line-segment-scroll) . " ")
((mood-line-segment-cursor-position) . " ")
((when (mood-line-segment-checker) "|") . " ")
((mood-line-segment-checker) . " "))))
```
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
By default, mood-line will use basic ASCII character glyphs to decorate mode line segments.
If you'd like to see prettier Unicode glyphs, you can change the value of `mood-line-glyph-alist`:
```elisp
;; The default set of glyphs:
;; * 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:
;; ● myModifiedFile.js Replace×3 + main JavaScript → Issues: 2
(setq mood-line-glyph-alist mood-line-glyphs-fira-code)
;; A set of Unicode glyphs:
;; ● myModifiedFile.js Replace✕3 🞤 main JavaScript ⚑ Issues: 2
(setq mood-line-glyph-alist mood-line-glyphs-unicode)
```
If you'd like to supply your own glyphs, you can use the customization interface
(`M-x customize-variable mood-line-glyph-alist`) or view the documentation
(`M-x describe-variable mood-line-glyph-alist`) for more information.
You can further tweak the behavior and appearance of mood-line by viewing the customizable variables
and faces in the `mood-line` and `mood-line-faces` customization groups. (`M-x customize-group mood-line`)
## Testing
To run the included tests:
```bash
./ert-test.sh
```
## 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!

5
ert-test.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
emacs --quick --batch --load=ert \
--load=test/mood-line-test.el \
--load=test/mood-line-segment-vc-test.el \
--funcall=ert-run-tests-batch-and-exit

View File

@ -0,0 +1,168 @@
;;; mood-line-segment-checker.el --- A checker status segment for mood-line -*- lexical-binding: t; -*-
;;
;; Author: Jessie Hildebrandt <jessieh.net>
;; Homepage: https://gitlab.com/jessieh/mood-line
;;
;; This file is not part of GNU Emacs.
;;; Commentary:
;;
;; This segment displays the current status of any active checker.
;;; License:
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;; Code:
;; -------------------------------------------------------------------------- ;;
;;
;; Byte-compiler declarations
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; Required features
;; ---------------------------------- ;;
(eval-when-compile
(require 'flymake))
;; ---------------------------------- ;;
;; External variable defs
;; ---------------------------------- ;;
(eval-when-compile
(defvar flycheck-current-errors))
;; ---------------------------------- ;;
;; External function decls
;; ---------------------------------- ;;
(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"))
;; -------------------------------------------------------------------------- ;;
;;
;; Helper functions
;;
;; -------------------------------------------------------------------------- ;;
(defun mood-line-segment-checker--format-status (status error warning note)
"Format STATUS into a segment string with ERROR, WARNING, and NOTE counts."
(pcase status
('running
(format #("%s Checking"
0 11 (face mood-line-status-neutral))
(mood-line--get-glyph :checker-checking)))
('errored
(format #("%s Error"
0 2 (face mood-line-status-error))
(mood-line--get-glyph :checker-errored)))
('interrupted
(format #("%s Paused"
0 9 (face mood-line-status-neutral))
(mood-line--get-glyph :checker-interrupted)))
('finished
(cond
((> error 0)
(let ((issues (+ error warning)))
(format #("%s %s Issue%s"
0 2 (face mood-line-status-error))
(mood-line--get-glyph :checker-issues)
issues
(if (> issues 1) "s" ""))))
((> warning 0)
(format #("%s %s Issue%s"
0 2 (face mood-line-status-warning))
(mood-line--get-glyph :checker-issues)
warning
(if (> warning 1) "s" "")))
((> note 0)
(format #("%s %s Note%s"
0 2 (face mood-line-status-info))
(mood-line--get-glyph :checker-info)
note
(if (> note 1) "s" "")))
(t
(format #("%s No Issues"
0 12 (face mood-line-status-neutral))
(mood-line--get-glyph :checker-good)))))))
;; -------------------------------------------------------------------------- ;;
;;
;; Flycheck update handler
;;
;; -------------------------------------------------------------------------- ;;
(defvar-local mood-line-segment-checker--flycheck-text nil
"Mode line segment string indicating the current state of `flycheck-mode'.")
(defun mood-line-segment-checker--flycheck-update (&optional status)
"Update `mood-line-segment-checker--flycheck-text' with flycheck's STATUS."
(setq mood-line-segment-checker--flycheck-text
(let-alist (flycheck-count-errors flycheck-current-errors)
(when-let* ((valid-statuses '(finished running errored interrupted))
(status-valid (member status valid-statuses))
(error (or .error 0))
(warning (or .warning 0))
(note (or .info 0)))
(mood-line-segment-checker--format-status
status error warning note)))))
;; -------------------------------------------------------------------------- ;;
;;
;; Flymake update handler
;;
;; -------------------------------------------------------------------------- ;;
(defvar-local mood-line-segment-checker--flymake-text nil
"Mode line segment string indicating the current state of `flymake-mode'.")
(defun mood-line-segment-checker--flymake-count (type)
"Return count of current flymake reports of TYPE."
(cl-loop for diag in (flymake-diagnostics)
as diag-type = (flymake-diagnostic-type diag)
count (eq (flymake--lookup-type-property diag-type 'severity)
(flymake--lookup-type-property type 'severity))))
(defun mood-line-segment-checker--flymake-update (&rest _args)
"Update `mood-line-segment-checker--flymake-state' with flymake's status."
(setq mood-line-segment-checker--flymake-text
(when-let ((flymake-active (and (fboundp 'flymake-is-running)
(flymake-is-running)))
(status (if (seq-difference (flymake-running-backends)
(flymake-reporting-backends))
'running 'finished))
(error (mood-line-segment-checker--flymake-count :error))
(warning (mood-line-segment-checker--flymake-count :warning))
(note (mood-line-segment-checker--flymake-count :note)))
(mood-line-segment-checker--format-status
status error warning note))))
;; -------------------------------------------------------------------------- ;;
;;
;; Provide package
;;
;; -------------------------------------------------------------------------- ;;
(provide 'mood-line-segment-checker)
;;; mood-line-segment-checker.el ends here

View File

@ -0,0 +1,225 @@
;;; mood-line-segment-indentation.el --- An indentation info segment for mood-line -*- lexical-binding: t; -*-
;;
;; 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:
;;
;; This segment displays indentation style information for the current buffer.
;;; License:
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;; Code:
;; -------------------------------------------------------------------------- ;;
;;
;; Byte-compiler declarations
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; External function decls
;; ---------------------------------- ;;
(eval-when-compile
(declare-function mood-line--get-glyph "mood-line"))
;; -------------------------------------------------------------------------- ;;
;;
;; Custom definitions
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; Group definitions
;; ---------------------------------- ;;
(defgroup mood-line-segment-indentation nil
"An indentation info segment for mood-line."
:group 'mood-line)
;; ---------------------------------- ;;
;; Variable definitions
;; ---------------------------------- ;;
(defcustom mood-line-segment-indentation-always-show-offset nil
"When non-nil, always show the indentation offset of the current mode.
Default behavior of the indentation segment is to display the indentation offset
of the current mode when `indent-tabs-mode' is non-nil and an offset value can
be found for the current mode. Otherwise, `tab-wdith' will be shown.
When `mood-line-segment-indentation-always-show-offset' is set to non-nil, the
indentation offset will always be shown alongside `tab-width'. If an offset
value cannot be found for the current mode, a \"?\" character will be displayed
alongside `tab-width'."
:group 'mood-line-segment-indentation
:type 'boolean)
;; Assembled from `editorconfig-indentation-alist' and `doom-modeline-indent-alist':
;; https://github.com/editorconfig/editorconfig-emacs/blob/b8043702f3d977db0e030c6c64ee4a810cad5f45/editorconfig.el#L175
;; https://github.com/seagle0128/doom-modeline/blob/fe9ee5a2a950f9ded10261a05a12adc577ae9e36/doom-modeline-core.el#L284
(defcustom mood-line-segment-indentation-mode-offset-alist
'((apache-mode apache-indent-level)
(awk-mode c-basic-offset)
(bpftrace-mode c-basic-offset)
(c++-mode c-basic-offset)
(c-mode c-basic-offset)
(cmake-mode cmake-tab-width)
(coffee-mode coffee-tab-width)
(cperl-mode cperl-indent-level)
(crystal-mode crystal-indent-level)
(csharp-mode c-basic-offset)
(css-mode css-indent-offset)
(d-mode c-basic-offset)
(emacs-lisp-mode lisp-indent-offset)
(enh-ruby-mode enh-ruby-indent-level)
(erlang-mode erlang-indent-level)
(ess-mode ess-indent-offset)
(f90-mode f90-associate-indent
f90-continuation-indent
f90-critical-indent
f90-do-indent
f90-if-indent
f90-program-indent
f90-type-indent)
(feature-mode feature-indent-offset
feature-indent-level)
(fsharp-mode fsharp-continuation-offset
fsharp-indent-level
fsharp-indent-offset)
(groovy-mode groovy-indent-offset)
(haskell-mode haskell-indent-spaces
haskell-indent-offset
haskell-indentation-layout-offset
haskell-indentation-left-offset
haskell-indentation-starter-offset
haskell-indentation-where-post-offset
haskell-indentation-where-pre-offset
shm-indent-spaces)
(haxor-mode haxor-tab-width)
(idl-mode c-basic-offset)
(jade-mode jade-tab-width)
(java-mode c-basic-offset)
(js-mode js-indent-level)
(js-jsx-mode js-indent-level sgml-basic-offset)
(js2-mode js2-basic-offset)
(js2-jsx-mode js2-basic-offset sgml-basic-offset)
(js3-mode js3-indent-level)
(json-mode js-indent-level)
(json-ts-mode json-ts-mode-indent-offset)
(julia-mode julia-indent-offset)
(kotlin-mode kotlin-tab-width)
(latex-mode tex-indent-basic)
(lisp-mode lisp-indent-offset)
(livescript-mode livescript-tab-width)
(lua-mode lua-indent-level)
(matlab-mode matlab-indent-level)
(meson-mode meson-indent-basic)
(mips-mode mips-tab-width)
(mustache-mode mustache-basic-offset)
(nasm-mode nasm-basic-offset)
(nginx-mode nginx-indent-level)
(nxml-mode nxml-child-indent)
(objc-mode c-basic-offset)
(octave-mode octave-block-offset)
(perl-mode perl-indent-level)
(php-mode c-basic-offset)
(pike-mode c-basic-offset)
(ps-mode ps-mode-tab)
(pug-mode pug-tab-width)
(puppet-mode puppet-indent-level)
(python-mode python-indent-offset)
(rjsx-mode js-indent-level sgml-basic-offset)
(ruby-mode ruby-indent-level)
(rust-mode rust-indent-offset)
(rustic-mode rustic-indent-offset)
(scala-mode scala-indent:step)
(scss-mode css-indent-offset)
(sgml-mode sgml-basic-offset)
(sh-mode sh-basic-offset sh-indentation)
(slim-mode slim-indent-offset)
(sml-mode sml-indent-level)
(tcl-mode tcl-indent-level
tcl-continued-indent-level)
(terra-mode terra-indent-level)
(typescript-mode typescript-indent-level)
(typescript-ts-base-mode typescript-ts-mode-indent-offset)
(verilog-mode verilog-indent-level
verilog-indent-level-behavioral
verilog-indent-level-declaration
verilog-indent-level-module
verilog-cexp-indent
verilog-case-indent)
(web-mode web-mode-attr-indent-offset
web-mode-attr-value-indent-offset
web-mode-code-indent-offset
web-mode-css-indent-offset
web-mode-markup-indent-offset
web-mode-sql-indent-offset
web-mode-block-padding
web-mode-script-padding
web-mode-style-padding)
(yaml-mode yaml-indent-offset))
"Alist mapping major mode names to their respective indent offset variables.
When multiple variables are specified for a given mode, the offset value will
be retrieved from the first variable that resolves to a value, evaluated in the
order provided."
:group 'mood-line-segment-indentation
:type '(alist :key-type symbol :value-type sexp))
;; -------------------------------------------------------------------------- ;;
;;
;; Indentation style info segment
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; Segment function
;; ---------------------------------- ;;
(defun mood-line-segment-indentation ()
"Return the indentation style of the current buffer."
(let* ((mode-offset (symbol-value
(seq-some #'identity
(cdr (assoc major-mode
mood-line-segment-indentation-mode-offset-alist))))))
(propertize (concat (if indent-tabs-mode "TAB" "SPC")
(mood-line--get-glyph :count-separator)
(if mood-line-segment-indentation-always-show-offset
(format "%s:%d"
(or mode-offset "?")
tab-width)
(number-to-string (if indent-tabs-mode
tab-width
(or mode-offset tab-width)))))
'face 'mood-line-encoding)))
;; -------------------------------------------------------------------------- ;;
;;
;; Provide package
;;
;; -------------------------------------------------------------------------- ;;
(provide 'mood-line-segment-indentation)
;;; mood-line-segment-indentation.el ends here

138
mood-line-segment-modal.el Normal file
View File

@ -0,0 +1,138 @@
;;; mood-line-segment-modal.el --- A modal editing status segment for mood-line -*- lexical-binding: t; -*-
;;
;; 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:
;;
;; This segment displays modal editing information for the current buffer.
;;; License:
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;; Code:
;; -------------------------------------------------------------------------- ;;
;;
;; Custom definitions
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; Group definitions
;; ---------------------------------- ;;
(defgroup mood-line-segment-modal nil
"A modal editing status segment for mood-line."
:group 'mood-line)
;; ---------------------------------- ;;
;; Variable definitions
;; ---------------------------------- ;;
(defcustom mood-line-segment-modal-evil-state-alist
'((normal . ("<N>" . font-lock-variable-name-face))
(insert . ("<I>" . font-lock-string-face))
(visual . ("<V>" . font-lock-keyword-face))
(replace . ("<R>" . font-lock-type-face))
(motion . ("<M>" . font-lock-constant-face))
(operator . ("<O>" . font-lock-function-name-face))
(emacs . ("<E>" . font-lock-builtin-face)))
"Alist specifying indicators and faces for corresponding `evil-mode' states.
The face may be either a face symbol or a property list of key-value pairs;
e.g., (:foreground \"red\")."
:group 'mood-line-segment-modal
:type '(alist :key-type symbol
:value-type (cons (string :tag "Display text")
(choice :tag "Face" face plist))))
(defcustom mood-line-segment-modal-meow-state-alist
'((normal . ("<N>" . font-lock-variable-name-face))
(insert . ("<I>" . font-lock-string-face))
(keypad . ("<K>" . font-lock-keyword-face))
(beacon . ("<B>" . font-lock-type-face))
(motion . ("<M>" . font-lock-constant-face)))
"Alist specifying indicators and faces corresponding `meow-mode' states.
The face may be either a face symbol or a property list of key-value pairs;
e.g., (:foreground \"red\")."
:group 'mood-line-segment-modal
:type '(alist :key-type symbol
:value-type (cons (string :tag "Display text")
(choice :tag "Face" face plist))))
;; -------------------------------------------------------------------------- ;;
;;
;; Modal editing segments
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; Evil segment
;; ---------------------------------- ;;
(defun mood-line-segment-modal--evil-fn ()
"Return the current `evil-mode' state."
(when (boundp 'evil-state)
(let ((mode-cons (alist-get evil-state
mood-line-segment-modal-evil-state-alist)))
(concat (propertize (car mode-cons)
'face (cdr mode-cons))))))
;; ---------------------------------- ;;
;; Meow segment
;; ---------------------------------- ;;
(defun mood-line-segment-modal--meow-fn ()
"Return the current `meow-mode' state."
(when (boundp 'meow--current-state)
(let ((mode-cons (alist-get meow--current-state
mood-line-segment-modal-meow-state-alist)))
(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
;; ---------------------------------- ;;
(defun mood-line-segment-modal--god-fn ()
"Return an indicator of whether or not `god-mode' is active."
(if (bound-and-true-p god-local-mode)
(propertize "<G>" 'face 'mood-line-status-warning)
"---"))
;; -------------------------------------------------------------------------- ;;
;;
;; Provide package
;;
;; -------------------------------------------------------------------------- ;;
(provide 'mood-line-segment-modal)
;;; mood-line-segment-modal.el ends here

114
mood-line-segment-vc.el Normal file
View File

@ -0,0 +1,114 @@
;;; mood-line-segment-vc.el --- A vc-mode info segment for mood-line -*- lexical-binding: t; -*-
;;
;; Author: Jessie Hildebrandt <jessieh.net>
;; Homepage: https://gitlab.com/jessieh/mood-line
;;
;; This file is not part of GNU Emacs.
;;; Commentary:
;;
;; This segment displays the current status of vc-mode.
;;; License:
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;; Code:
;; -------------------------------------------------------------------------- ;;
;;
;; Byte-compiler declarations
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; External function decls
;; ---------------------------------- ;;
(eval-when-compile
(declare-function mood-line--get-glyph "mood-line"))
;; -------------------------------------------------------------------------- ;;
;;
;; Helper functions
;;
;; -------------------------------------------------------------------------- ;;
(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.
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
(substring (vc-working-revision buffer-file-name backend) 0 7))
"???"))
;; -------------------------------------------------------------------------- ;;
;;
;; VC segment
;;
;; -------------------------------------------------------------------------- ;;
(defvar-local mood-line-segment-vc--text nil
"Mode line segment string indicating the current state of `vc-mode'.")
(defun mood-line-segment-vc--update (&rest _args)
"Update `mood-line-segment-vc--text' against the current VCS state."
(setq mood-line-segment-vc--text
(when-let* ((vc-active (and vc-mode buffer-file-name))
(backend (vc-backend buffer-file-name))
(state (vc-state buffer-file-name))
(rev (mood-line-segment-vc--rev vc-mode backend)))
(cond
((memq state '(edited added))
(format #("%s %s"
0 2 (face mood-line-status-info))
(mood-line--get-glyph :vc-added)
rev))
((eq state 'needs-merge)
(format #("%s %s"
0 2 (face mood-line-status-warning))
(mood-line--get-glyph :vc-needs-merge)
rev))
((eq state 'needs-update)
(format #("%s %s"
0 2 (face mood-line-status-warning))
(mood-line--get-glyph :vc-needs-update)
rev))
((memq state '(removed conflict unregistered))
(format #("%s %s"
0 2 (face mood-line-status-error))
(mood-line--get-glyph :vc-conflict)
rev))
(t
(format #("%s %s"
0 5 (face mood-line-status-neutral))
(mood-line--get-glyph :vc-good)
rev))))))
;; -------------------------------------------------------------------------- ;;
;;
;; Provide package
;;
;; -------------------------------------------------------------------------- ;;
(provide 'mood-line-segment-vc)
;;; mood-line-segment-vc.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,45 @@
;;; mood-line-segment-vc-test.el --- Test specifications for mood-line-segment-vc.el -*- lexical-binding: t; -*-
(add-to-list 'load-path ".")
(require 'ert)
(require 'mood-line)
(require 'mood-line-segment-vc)
;;; Code:
;; -------------------------------------------------------------------------- ;;
;;
;; Helper functions
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; mood-line-segment-vc--rev
;; ---------------------------------- ;;
(ert-deftest --rev/git ()
"Current rev should be cleanly extracted from git `vc-mode' status string."
(should (string= (mood-line-segment-vc--rev " Git:main" 'Git)
"main")))
(ert-deftest --rev/hg ()
"Current rev should be cleanly extracted from hg `vc-mode' status string."
(should (string= (mood-line-segment-vc--rev " Hg:main" 'Hg)
"main")))
(ert-deftest --rev/unknown ()
"Current rev should be reported as \"???\" when backend is unsupported."
(let ((buffer-file-name ""))
(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

206
test/mood-line-test.el Normal file
View File

@ -0,0 +1,206 @@
;;; mood-line-test.el --- Test specifications for mood-line.el -*- lexical-binding: t; -*-
(add-to-list 'load-path ".")
(require 'ert)
(require 'mood-line)
;;; Code:
;; -------------------------------------------------------------------------- ;;
;;
;; Macros
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; mood-line-defformat
;; ---------------------------------- ;;
(ert-deftest -defformat/padding ()
"The expanded sequence should include the provided (or default) padding."
(should (equal (mood-line-defformat)
(list
;; Left
'(" ")
;; Right
'(" "))))
(should (equal (mood-line-defformat
:padding
"---")
(list
;; Left
'("---")
;; 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
'(" " "XYZ")
;; Right
'(" "))))
(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
("ABC" ("ABC" . "XYZ") "XYZ")
:right
("..." ((some-fn) . " ") "..."))
(list
;; Left
'(" " "ABC" "ABC" "XYZ" "XYZ")
;; Right
'("..." (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
("ABC" ("ABC" . "XYZ") some-exp "XYZ" (some-fn))
:right
("..." ((some-fn) . " ") (another-fn) "..."))
(list
;; Left
'(" " "ABC" "ABC" "XYZ" some-exp "" "XYZ" (some-fn) "")
;; Right
'("..." (some-fn) " " (another-fn) "" "..." " ")))))
;; -------------------------------------------------------------------------- ;;
;;
;; Helper functions
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; mood-line--get-glyph
;; ---------------------------------- ;;
(ert-deftest --get-glyph/unicode ()
"Glyphs should be fethed from `mood-line-glyph-alist'."
(let ((mood-line-glyph-alist '((:checker-info . ?🛈))))
(should (string= (mood-line--get-glyph :checker-info) "🛈"))))
(ert-deftest --get-glyph/fallback-ascii ()
"Glyphs should be fetched from `mood-line-glyphs-ascii' as a fallback."
(let ((mood-line-glyph-alist nil))
(should (string= (mood-line--get-glyph :checker-info) "i"))))
;; ---------------------------------- ;;
;; mood-line--process-segments
;; ---------------------------------- ;;
(ert-deftest --process-segments/default ()
"`mood-line-format-default' should be processed without error."
(let* ((left (car mood-line-format-default))
(right (cadr mood-line-format-default))
(left-str (mood-line--process-segments left))
(right-str (mood-line--process-segments right)))
(should (> (length left-str) 0))
(should (> (length right-str) 0))))
(ert-deftest --process-segments/strings ()
"Literal strings should be concatenated."
(let* ((segments '("ABC" " " "123" " " "XYZ"))
(segments-str (mood-line--process-segments segments)))
(should (string= segments-str "ABC 123 XYZ"))))
(ert-deftest --process-segments/nil-neighbor-exclusion ()
"A nil value should mean skipping evaluation of the following segment."
(let* ((segments '("ABC" nil " " "123" nil " " "XYZ" nil))
(segments-str (mood-line--process-segments segments)))
(should (string= segments-str "ABC123XYZ"))))
(ert-deftest --process-segments/functions ()
"Functions should be evaluated, and their return values concatenated."
(let* ((segments '((string ?A ?B ?C)
(numberp nil) " "
(number-to-string (+ 100 20 3))
(identity nil) " "
(concat "X" "Y" "Z")))
(segments-str (mood-line--process-segments segments)))
(should (string= segments-str "ABC123XYZ"))))
;; ---------------------------------- ;;
;; mood-line--process-format
;; ---------------------------------- ;;
(ert-deftest --process-format/default ()
"`mood-line-format-default' should be processed without error."
(let* ((format-str (mood-line--process-format mood-line-format-default)))
(should (> (length format-str) 0))))
(ert-deftest --process-format/nil-okay ()
"Either segment list should process without error if the other list is nil."
(let* ((format-l-nil '(nil ("ABC" nil " " "123" nil " " "XYZ")))
(format-r-nil '(("ABC" nil " " "123" nil " " "XYZ") nil))
(format-l-nil-str (mood-line--process-format format-l-nil))
(format-r-nil-str (mood-line--process-format format-r-nil)))
(should (string-suffix-p "ABC123XYZ" format-l-nil-str))
(should (string-prefix-p "ABC123XYZ" format-r-nil-str))))
;; -------------------------------------------------------------------------- ;;
;;
;; mood-line-mode
;;
;; -------------------------------------------------------------------------- ;;
;; ---------------------------------- ;;
;; mood-line--activate
;; ---------------------------------- ;;
(ert-deftest --activate/mode-line-format ()
"`mode-line-format' should be set by `mood-line--activate'."
(let* ((setting-val (alist-get 'mode-line-format
mood-line--settings-alist))
(mood-line--settings-alist `((mode-line-format . ,setting-val)))
(mood-line-format mood-line-format-default)
(mode-line-format '("ABC 123 XYZ"))
(format-str (mood-line--process-format mood-line-format)))
(mood-line--activate)
(should (string= (format-mode-line mode-line-format)
(format-mode-line format-str)))))
;; ---------------------------------- ;;
;; mood-line--deactivate
;; ---------------------------------- ;;
(ert-deftest --deactivate/mode-line-format ()
"`mode-line-format' should be restored by `mood-line--deactivate'."
(let* ((setting-val (alist-get 'mode-line-format
mood-line--settings-alist))
(mood-line--settings-alist `((mode-line-format . ,setting-val)))
(mood-line--settings-backup-alist nil)
(mood-line-format mood-line-format-default)
(mode-line-format "ABC 123 XYZ"))
(mood-line--activate)
(mood-line--deactivate)
(should (string= mode-line-format "ABC 123 XYZ"))))
;;; mood-line-test.el ends here