forked from Malabarba/smart-mode-line
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smart-mode-line.el
1753 lines (1548 loc) · 77.2 KB
/
smart-mode-line.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; smart-mode-line.el --- A color coded smart mode-line.
;; Copyright (C) 2012 Artur Malabarba <[email protected]>
;; Author: Artur Malabarba <[email protected]>
;; URL: http://github.com/Malabarba/smart-mode-line
;; Version: 2.10
;; Package-Requires: ((emacs "24.3") (rich-minority "0.1.1"))
;; Keywords: mode-line faces themes
;; Prefix: sml
;; Separator: /
;;; Commentary:
;;
;; Smart Mode Line is a sexy mode-line for Emacs. It aims to be easy to
;; read from small to large monitors by using *colors*, a *prefix feature*, and
;; *smart truncation*.
;;
;; New in v2.5
;; ===========
;; - Emacs 24.4 compatible.
;; - Integration with [Projectile](https://github.com/bbatsov/projectile)!
;; - Display `current-directory' in Shell and eshell.
;; - New value for `sml/theme': `automatic' (highly recommended).
;; - `sml/apply-theme' is interactive and has completion.
;; - Smart-mode-line themes are now regular themes.
;;
;; Installation
;; ===
;; **smart-mode-line** is available on Melpa, and that's the recommended
;; way of installing it. If you do that, you can simply activate it with:
;;
;; (sml/setup)
;;
;; To set the color theme, do one of the following BEFORE `sml/setup`:
;;
;; (setq sml/theme 'dark)
;; (setq sml/theme 'light)
;; (setq sml/theme 'respectful)
;;
;; Features
;; ===
;; Its main features include:
;;
;; 1. **Color coded**:
;; Highlights the most important information for you
;; (buffer name, modified state, line number). Don't
;; like the colors? See item *5.*!
;;
;; 2. **Fixed width** (if you want):
;; Lets you set a maxium width for the path name and mode names, and
;; truncates them intelligently (truncates the directory, not the
;; buffer name). Also let's you **right indent** strings in the
;; mode-line (see `sml/mode-width').
;;
;; 3. **Directory as Prefixes**:
;; Prefix feature saves a LOT of space. e.g. *"~/.emacs.d/"*
;; is translated to *":ED:"* in the path (open a file inside
;; this folder to see it in action). Long path names you
;; are commonly working on are displayed as short
;; abbreviations. Set your own prefixes to make best use
;; of it (by configuring `sml/replacer-regexp-list'). Mousing
;; over the abbreviated path will show you the full
;; path. See below for examples.
;;
;; 4. **Hide or Highlight minor-modes**:
;; The [rich-minority](https://github.com/Malabarba/rich-minority)
;; package saves even more space. Select which minor modes you don't
;; want to see listed by adding them to the variable
;; `rm-excluded-modes', or even highlight the modes that are more
;; important with the variable `rm-text-properties'. This will filter
;; out the modes you don't care about and unclutter the modes list
;; (mousing over the modes list still shows the full list).
;;
;; 4. **Hide minor-modes**:
;; Hidden-modes feature saves even more space. Select
;; which minor modes you don't want to see listed by
;; customizing the `rm-blacklist' variable. This will
;; filter out the modes you don't care about and unclutter
;; the modes list (mousing over the modes list still shows
;; the full list).
;;
;; 5. **Very easy to configure**:
;; All colors and variables are customizable. You can change the
;; whole theme with `sml/apply-theme', or just customize anything
;; manually with `sml/customize' and `sml/customize-faces'. There are
;; *DOZENS* of variables to customize your mode-line, just pop over
;; there and have a look!
;;
;; 6. **Compatible with absolutely anything**:
;; I'm serious. Versions 2.0 and above should be compatible with
;; **any** other packages that display information in the mode-line
;; (evil, nyan-mode, elscreen, display-battery-mode, etc). If you
;; find *ANYTHING* that does not appear as it should, file a bug report
;; and I'll get to it.
;;
;; Important Variables:
;; ===
;; All variables can be edited by running `sml/customize', and the
;; documentations are mostly self explanatory, I list here only the
;; most important ones.
;;
;; 1. `sml/theme'
;; Choose what theme you want to use for the mode-line colors. For now
;; there are 3 different themes: `dark', `light', and `respectful'.
;;
;; 1. `sml/shorten-directory' and `sml/shorten-modes'
;; Setting both of these to `t' guarantees a fixed width mode-line
;; (directory name and minor-modes list will be truncated to fit). To
;; actually define the width, see below.
;;
;; 2. `sml/name-width' and `sml/mode-width'
;; Customize these according to the width of your Emacs frame. I set
;; them to `40' and `full' respectively, and the mode-line fits
;; perfectly when the frame is split in two even on my laptop's small
;; 17" monitor. `full' means everything after the minor-modes will be
;; right-indented.
;;
;; 3. `sml/replacer-regexp-list'
;; This variable is a list of (REGEXP REPLACEMENT) that is used
;; to parse the path. The replacements are applied
;; sequentially. This allows you to greatly abbreviate the path
;; that's shown in the mode-line. If this abbreviation is of
;; the form *":SOMETHING:"*, it is considered a prefix and get's
;; a different color (you can change what's considered a prefix
;; by customizing `sml/prefix-regexp').
;; For example, if you do a lot of work on a folder called
;; *"~/Dropbox/Projects/In-Development/"* almost half the
;; mode-line would be occupied just by the folder name, which
;; is much less important than the buffer name. But, you can't
;; just hide the folder name, since editing a file in
;; *"~/Dropbox/Projects/In-Development/Source"* is VERY different
;; from editting a file in *"~/Dropbox/Projects/Source"*. By
;; setting up a prefix for your commonly used folders, you get
;; all that information without wasting all that space. In this
;; example you could set the replacement to *":ProjDev:"* or just
;; *":InDev:"*, so the path shown in the mode-line will be
;; *":ProjDev:Source/"* (saves a lot of space without hiding
;; information).
;;
;; Here go some more useful examples:
;;
;; (add-to-list 'sml/replacer-regexp-list '("^~/Dropbox/Projects/In-Development/" ":ProjDev:") t)
;; (add-to-list 'sml/replacer-regexp-list '("^~/Documents/Work/" ":Work:") t)
;;
;; ;; Added in the right order, they even work sequentially:
;; (add-to-list 'sml/replacer-regexp-list '("^~/Dropbox/" ":DB:") t)
;; (add-to-list 'sml/replacer-regexp-list '("^:DB:Documents" ":DDocs:") t)
;; (add-to-list 'sml/replacer-regexp-list '("^~/Git-Projects/" ":Git:") t)
;; (add-to-list 'sml/replacer-regexp-list '("^:Git:\\(.*\\)/src/main/java/" ":G/\\1/SMJ:") t)
;;; License:
;;
;; This file is NOT part of GNU Emacs.
;;
;; 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.
;;
;;; Change Log:
;; 2.6 - 2014/08/15 - Allow for sml/name-width to have different mininum and maximum values.
;; 2.6 - 2014/08/15 - Delegated minor-mode filtering to rich-minority package.
;; 2.5.3 - 2014/06/18 - Fix custom-theme-load-path for manual installations.
;; 2.5.2 - 2014/06/16 - sml/no-confirm-load-theme variable to skip theme confirmation.
;; 2.5.1 - 2014/06/16 - sml/apply-theme no-confirm in daemon mode.
;; 2.5 - 2014/05/15 - sml/theme: New possible values: 'automatic (highly recommended) or nil.
;; 2.5 - 2014/05/14 - sml/mode-width: New possible value: 'right.
;; 2.5 - 2014/05/14 - Themes engine completely redone.
;; 2.5 - 2014/05/14 - sml/apply-theme is interactive.
;; 2.4.5 - 2014/04/24 - Changed default value of sml/mode-width back to 'full.
;; 2.4.3 - 2014/03/25 - sml/mode-line-buffer-identification fix for ggtags.
;; 2.4.2 - 2014/03/13 - Perspective support simplified to sml/apply-theme.
;; 2.4.2 - 2014/03/13 - Projectile integration only applies after the user replacements (to change, see sml/use-projectile-p).
;; 2.4.1 - 2014/03/11 - Small fix to dired-mode with uniquify.
;; 2.4 - 2014/03/10 - Projectile integration! To disable it, set sml/use-projectile-p.
;; 2.4 - 2014/03/10 - Change the order of line/column numbers with sml/order-of-line-and-column.
;; 2.4 - 2014/03/10 - Take over dired's buffer-identification. We will undo this if dired ever does anything special with this variable.
;; 2.4 - 2014/03/10 - Show current-directory in Shell and eshell.
;; 2.4 - 2014/03/10 - Tested against 24.4.
;; 2.4 - 2014/03/10 - Ditch total number of lines count.
;; 2.3.13 - 2014/03/05 - sml/apply-theme forces our foreground/background colors.
;; 2.3.12 - 2014/03/05 - Use sml/show-remote to hide/show the "@" symbol. .
;; 2.3.12 - 2014/03/05 - Support showing tramp state (remote buffer).
;; 2.3.12 - 2014/02/27 - sml/apply-theme avoids nesting.
;; 2.3.11 - 2014/02/15 - Silent sml/apply-theme.
;; 2.3.10 - 2014/02/15 - Fix sml/setup ignoring sml/theme.
;; 2.3.9 - 2014/02/10 - sml/hidden-modes allows regexps.
;; 2.3.8 - 2014/02/07 - Buffer identification width auto-updates when sml/name-width changes.
;; 2.3.8 - 2014/02/07 - sml/apply-theme customizes helm-candidate-number.
;; 2.3.7 - 2014/01/21 - Adapt sml/generate-buffer-identification.
;; 2.3.6 - 2013/12/16 - sml/replacer follows symlinks.
;; 2.3.6 - 2013/12/16 - Fix filling and name on the very first update of non-file buffers.
;; 2.3.5 - 2013/12/14 - sml/generate-position-help runs less often now.
;; 2.3.4 - 2013/12/14 - Remove lag-inducing advice.
;; 2.3.3 - 2013/12/09 - Fix sml/get-directory for files attached to mails - Thanks tsdh.
;; 2.3.2 - 2013/12/07 - Fix for themes which set :inverse-video t in the mode-line.
;; 2.3.1 - 2013/12/04 - sml/show-frame-identification now always defaults to nil.
;; 2.3.1 - 2013/12/04 - Fix for sml/show-client not working.
;; 2.3 - 2013/12/04 - sml/show-frame-identification only t for terminals.
;; 2.3 - 2013/12/03 - Mark boolean's as safe-local-variables.
;; 2.2.3 - 2013/12/03 - Fix possible recursion in sml/apply-theme.
;; 2.2.2 - 2013/11/27 - Fix sml/apply-theme to consider saved faces.
;; 2.2.1 - 2013/11/27 - Fix doc for sml/show-frame-identification.
;; 2.2 - 2013/11/26 - Better minor list and some fixes.
;; 2.0.5 - 2013/11/24 - sml/revert no longer available.
;; 2.0.4 - 2013/11/24 - Improved faces a little.
;; 2.0.3.4 - 2013/11/15 - Workaround to prevent core dump.
;; 2.0.3.3 - 2013/11/13 - Small fix on sml/generate-buffer-identification for man pages.
;; 2.0.3.2 - 2013/11/12 - sml/filter-mode-line-list now uses remove nil.
;; 2.0.3.1 - 2013/11/08 - Quick fix sml/get-directory.
;; 2.0.3 - 2013/11/07 - sml/show-frame-identification.
;; 2.0.3 - 2013/11/07 - Improvements to sml/parse-mode-line-elements.
;; 2.0.3 - 2013/11/07 - sml/compile-position-construct.
;; 2.0.3 - 2013/11/07 - Line-number removed from sml/generate-position-help.
;; 2.0.3 - 2013/11/07 - Position optimization with sml/position-construct.
;; 2.0.3 - 2013/11/07 - Performance optimization thanks to sml/buffer-identification.
;; 2.0.2 - 2013/11/05 - better sml/replacer-regexp-list.
;; 2.0.2 - 2013/11/05 - sml/mule-info also hides input system.
;; 2.0.2 - 2013/11/05 - show-encoding is now alias for sml/mule-info.
;; 2.0.2 - 2013/11/05 - Removed anchors.
;; 2.0.1 - 2013/11/04 - Slight fix on sml/apply-theme
;; 2.0 - 2013/11/04 - Remove unnecessary functions.
;; 2.0 - 2013/11/04 - Many other internal improvements.
;; 2.0 - 2013/11/02 - Remove sml/mode-line-format
;; 2.0 - 2013/11/02 - Reduce huge spaces in mode-line-format
;; 2.0 - 2013/11/02 - Redesign the format to use mode-line-mule-info.
;; 2.0 - 2013/11/02 - Redesign the format to use mode-line-client.
;; 2.0 - 2013/11/02 - Redesign the format to use mode-line-modified.
;; 2.0 - 2013/11/02 - Redesign the format to use mode-line-remote.
;; 2.0 - 2013/11/02 - Manually edits mode-line-front-space.
;; 2.0 - 2013/11/02 - Manually edits mode-line-frame-identification.
;; 2.0 - 2013/11/02 - Manually edits mode-line-buffer-identification.
;; 2.0 - 2013/11/02 - Manually edits mode-line-end-spaces.
;; 2.0 - 2013/11/02 - Redesign the format to use mode-line-modes.
;; 2.0 - 2013/11/01 - Redesign the format to use mode-line-position.
;; 1.30.1 - 2013/10/21 - eval-when-compile cl
;; 1.30 - 2013/10/13 - Click mode list to toggle minor-mode hiding.
;; 1.29.2 - 2013/10/02 - Different default position-percentage face.
;; 1.29.1 - 2013/08/22 - Fix hang introduced with last update.
;; 1.29 - 2013/08/11 - Fixed lag with remote files.
;; 1.28.1 - 2013/08/11 - Fix for the erc fix.
;; 1.28 - 2013/08/11 - Fixing erc notifications.
;; 1.27 - 2013/08/10 - Changed default value of sml/mode-width to a number. 'full didn't work for everyone.
;; 1.27 - 2013/08/10 - Doc bug.
;; 1.26 - 2013/07/18 - Fix for % in the process string.
;; 1.25 - 2013/07/16 - sml/override-theme also tries to set good colors for the text (not just the background).
;; 1.24 - 2013/07/16 - sml/mule-info face changed to be less important.
;; 1.23.2 - 2013/07/15 - Changed doc of sml/replacer-regexp-list.
;; 1.23.1 - 2013/07/15 - moved perspective variable to eval-after-load.
;; 1.23 - 2013/07/15 - added an icon to mew-format.
;; 1.23 - 2013/07/15 - obsolete sml/show-time.
;; 1.23 - 2013/07/15 - fixed a bug which required emacs restart for changes to take effect.
;; 1.22 - 2013/07/15 - sml/vc-mode-show-backend implemented.
;; 1.22 - 2013/07/15 - move mew-support variable.
;; 1.22 - 2013/07/15 - Changed default value of sml/replacer-regexp-list.
;; 1.21 - 2013/07/14 - Encoding description.
;; 1.21 - 2013/07/14 - Reestructured some of the present functions.
;; 1.21 - 2013/07/14 - New position indicator.
;; 1.20 - 2013/07/14 - vc-mode support.
;; 1.19 - 2013/07/14 - Reorganized groups.
;; 1.18 - 2013/07/12 - mew variables only get created if mew is loaded.
;; 1.18 - 2013/07/12 - Reformulated the simplified mode-line.
;; 1.18 - 2013/07/12 - Added number of lines to mouse tooltip of position.
;; 1.17 - 2013/07/10 - Fallback 'modified' string.
;; 1.16 - 2013/07/08 - Changed implementation of battery display.
;; 1.16 - 2013/07/08 - Fixed battery-display.
;; 1.15 - 2013/07/06 - Implemented sml-modeline support.
;; 1.14 - 2013/06/25 - Slightly reduced the default value of extra-filler.
;; 1.13 - 2013/06/10 - removed 'cl requirement.
;; 1.13 - 2013/06/10 - Advice to mew-biff-clear.
;; 1.12 - 2013/06/06 - Gigantic typo fix. Sorry about that.
;; 1.11 - 2013/06/05 - Added biff support.
;; 1.10 - 2013/05/24 - Fix for buffer name with '%'.
;; 1.9 - 2013/05/13 - Now uses file name instead of buffer-name by default, controled by `sml/show-file-name'.
;; 1.9 - 2013/05/13 - When showing buffer name, can strip the <N> part by setting `sml/show-trailing-N'.
;; 1.8.3 - 2013/04/21 - Fixed first line of docs.
;; 1.8.2 - 2013/04/18 - added empty anchors throughout the mode-line.
;; 1.8.2 - 2013/04/18 - evil-mode support.
;; 1.8.1 - 2013/04/17 - sml/bug-report function.
;; 1.8.1 - 2013/04/17 - sml/override-theme variable.
;; 1.8.1 - 2013/04/17 - Changed install instruction to override theme settings.
;; 1.8 - 2013/04/14 - sml/mode-width can now be 'full.
;; 1.7.1 - 2012/11/17 - Perspective support.
;; 1.7 - 2012/11/14 - Fixed some modes not showing in the minor mode list - Thanks Constantin.
;; 1.7 - 2012/11/14 - Fixed infinite loop. - Thanks Constantin.
;; 1.7 - 2012/11/14 - Fixed for dired-mode.
;; 1.7 - 2012/11/14 - Added parent customize groups.
;; 1.6.2 - 2012/07/13 - Fixed mode shortenning.
;; 1.6.1 - 2012/07/12 - NEW FEATURE: Modes list now fully supports clicking.
;; 1.6.1 - 2012/07/12 - NEW FEATURE: `sml/version' constant.
;; 1.6.1 - 2012/07/12 - `sml/hidden-modes' is now a list of strings (not regexps).
;; 1.6 - 2012/07/09 - NEW FEATURE: Customizable faces for the prefix, see `sml/prefix-face-list'.
;; 1.5.4 - 2012/06/28 - Optimized regexp-replacer.
;; 1.5.3 - 2012/06/20 - Remove prefix and folder for non-files. Color the :Git prefix.
;; 1.5.2 - 2012/06/14 - Saner default widths and mode-name fix for Term.
;; 1.5.1 - 2012/06/12 - Fixed battery font for corner cases.
;; 1.5 - 2012/06/11 - Added support for display-battery-mode. See the description for more.
;;; Code:
(require 'cl-lib)
(require 'custom)
(require 'cus-face)
(require 'rich-minority)
(defconst sml/version "2.10" "Version of the smart-mode-line.el package.")
(defun sml/bug-report ()
"Opens github issues page in a web browser. Please send me any bugs you find, and please include your Emacs and sml versions."
(interactive)
(browse-url "https://github.com/Malabarba/smart-mode-line/issues/new")
(message "Your sml/version is: %s, and your emacs version is: %s.\nPlease include this in your report!" sml/version emacs-version))
(defun sml/customize ()
"Open the customization group for the `smart-mode-line' package."
(interactive)
(customize-group 'smart-mode-line t))
(defun sml/customize-faces ()
"Open the customization group for faces used by the `smart-mode-line' package."
(interactive)
(customize-group 'smart-mode-line-faces t))
(defgroup smart-mode-line '()
"Customization group for the `smart-mode-line' package."
:group 'convenience
:prefix 'sml)
(defgroup smart-mode-line-position '()
"Showing the point position in the smart mode line."
:group 'smart-mode-line
:prefix 'sml)
(defgroup smart-mode-line-path-and-prefix '()
"Showing the path, buffer-name, and prefix in the smart mode line."
:group 'smart-mode-line
:prefix 'sml)
(defgroup smart-mode-line-mode-list '()
"Showing major/minor modes in the smart mode line."
:group 'smart-mode-line
:prefix 'sml)
(defgroup smart-mode-line-others '()
"Showing other data in the smart mode line."
:group 'smart-mode-line
:prefix 'sml)
(defgroup smart-mode-line-faces '()
"Font (face) colors for the `smart-mode-line.el' package.
You can fully customize any of the fonts to match the color you
want. You can also set properties like bold with ':weight bold'.
Note that, by default, smart-mode-line overrides your theme's
settings for the background and foreground color of the modeline
face. We need to override, otherwise some elements become
unreadable on lighter themes. If you'd rather configure these
unreadable colors yourself and keep your theme's settings, just
set `sml/override-theme' to nil."
:prefix 'sml
:group 'smart-mode-line
:group 'faces)
;;; Actual Code
(defvar erc-track-position-in-mode-line)
(defvar sml/simplified nil
"Temporary dynamic variable. Used for filling.")
(defvar sml/active-background-color)
(defvar sml/-debug nil
"Whether debugging information should be printed.")
(defmacro sml/-debug (fmt &rest r)
"If variable `sml/-debug' is non-nil, describe FMT.
If FMT is a string, this is essentially the same as `message'.
If FMT is anything else, this is essentially:
(message \"%s is: %s\" 'FMT FMT)"
(when (and (boundp 'sml/-debug) sml/-debug)
(if (stringp fmt)
`(apply #'message (concat "[sml/debug] " ,fmt) ,r)
`(message "[sml/debug] %s is: %s" ',fmt ,fmt))))
(defvar sml/shortener-func 'sml/do-shorten-directory
"Function used to shorten the directory name.
Value is a funcallable symbol that takes two arguments: the
string to be shortened and the maximum size. This is set
automatically when `sml/shorten-directory' is changed via the
customization menu or via the `sml/toggle-shorten-directory'
function (which are the only ways you should change it).")
(defun sml/set-shortener-func (sym val)
"Configure `sml/shortener-func' according to `sml/shorten-directory'.
Set SYM to VAL."
(set-default sym val)
(if val (setq sml/shortener-func 'sml/do-shorten-directory)
(setq sml/shortener-func 'sml/not-shorten-directory)))
(define-obsolete-variable-alias 'sml/time-format 'display-time-format)
(define-obsolete-variable-alias 'sml/show-time 'display-time-mode)
(define-obsolete-variable-alias 'sml/override-theme 'sml/theme)
(defcustom sml/theme 'automatic
"Defines which theme `smart-mode-line' should use.
This is usually one of the symbols:
'automatic, 'respectful, 'dark, 'light or nil;
but it can be something else if there are other smart-mode-line
themes defined.
Setting this to 'light and 'dark will apply some predefined
colors to the mode-line, which are designed to be easy to read.
Setting this to nil will apply almost no colors. Use this if your
global color theme already customizes sml faces (flatui-theme is
an example).
Setting this to 'automatic will let sml decide between 'light or
'dark or nil, to best match the global theme that is active when
`sml/setup' is called.
Setting it to 'respectful will try to use the colors defined by
your current Emacs theme (emphasis on the \"try\"). Use this if
you color theme does NOT customize sml faces, AND if you're not
happy with 'light or 'dark.
This option will make the mode-line colors more consistent with
buffer colors (when compared to 'light or 'dark, which have fixed
colors) , but it's a bit of a shot in the dark. The result will
vary for each color theme, and you may get colors that don't read
well.
But don't forget, ALL COLORS ARE CUSTOMIZABLE!
`sml/customize-faces'
Any color you change manually won't get affected by this
variable.
Setting this variable via `setq' only has effect BEFORE calling
`sml/setup'. If smart-mode-line is already loaded, use
`sml/apply-theme' instead (or the customization interface)."
:type '(choice (const :tag "Automatically choose between 'light, 'dark, or nil during setup. (Default and Recommended)" automatic)
(const :tag "Don't use a theme." nil)
(const :tag "Use a dark color-theme." dark)
(const :tag "Use a light color-theme." light)
(const :tag "Respect the color-theme's colors." respectful)
(symbol :tag "Other smart-mode-line theme you installed."))
:set 'sml/apply-theme
:initialize 'custom-initialize-default
:group 'smart-mode-line-faces :group 'smart-mode-line)
(defcustom sml/position-percentage-format "%p"
"Format used to display position in the buffer.
Set it to nil to hide the number."
:type 'string
:group 'smart-mode-line-position
:package-version '(smart-mode-line . "2.0"))
(put 'sml/position-percentage-format 'risky-local-variable t)
(defcustom sml/line-number-format "%3l"
"Format used to display line number.
Empty it or disable `line-number-mode' to hide the number."
:type 'string
:group 'smart-mode-line-position
:set 'sml/compile-position-construct
:initialize 'custom-initialize-default)
(put 'sml/line-number-format 'risky-local-variable t)
(defcustom sml/size-indication-format "%I "
"Format to display buffer size when `size-indication-mode' is on."
:type 'string
:group 'smart-mode-line-position
:package-version '(smart-mode-line . "2.0")
:set 'sml/compile-position-construct
:initialize 'custom-initialize-default)
(put 'sml/size-indication-format 'risky-local-variable t)
(defcustom sml/col-number-format "%2c"
"Format used to display column number.
Empty it or disable `column-number-mode' to hide the number."
:type 'string
:group 'smart-mode-line-position
:set 'sml/compile-position-construct
:initialize 'custom-initialize-default)
(put 'sml/col-number-format 'risky-local-variable t)
(defcustom sml/numbers-separator ":"
"Separator between line and column number.
Since we use different faces for line and column number, you can
just set this to \"\" to save an extra char of space."
:type 'string
:group 'smart-mode-line-position)
(defcustom sml/show-remote t
"Whether to display an \"@\" for remote buffers.
If the buffer is local, an \"-\" is displayed instead.
If this variable is nil, nothing is displayed."
:type 'boolean
:group 'smart-mode-line-others)
(put 'sml/show-remote 'safe-local-variable 'booleanp)
(defcustom sml/show-client nil
"Whether to show an \"@\" for emacsclient frames."
:type 'boolean
:group 'smart-mode-line-others)
(put 'sml/show-client 'safe-local-variable 'booleanp)
(defcustom sml/modified-char (char-to-string (if (char-displayable-p ?×) ?× ?*))
"String that indicates if buffer is modified. Should be one SINGLE char."
:type 'string
:group 'smart-mode-line-others
:package-version '(smart-mode-line . "1.16"))
(defcustom sml/show-trailing-N t
"Whether the \"<N>\" suffix in buffer names should be displayed in the mode-line."
:type 'boolean
:group 'smart-mode-line-path-and-prefix)
(put 'sml/show-trailing-N 'safe-local-variable 'booleanp)
(defcustom sml/show-file-name t
"Unless nil: show file name instead of buffer name on the mode-line."
:type 'boolean
:group 'smart-mode-line-path-and-prefix)
(put 'sml/show-file-name 'safe-local-variable 'booleanp)
(defcustom sml/fill-char ?\s
"The char to be used for filling."
:type 'char
:group 'smart-mode-line-path-and-prefix)
(defcustom sml/replacer-regexp-list
`((,(concat "^" (if (boundp 'org-directory) (regexp-quote org-directory) "~/org/")) ":Org:")
("^~/\\.emacs\\.d/elpa/" ":ELPA:")
("^~/\\.emacs\\.d/" ":ED:")
("^/sudo:.*:" ":SU:")
("^~/Documents/" ":Doc:")
("^~/Dropbox/" ":DB:")
("^:\\([^:]*\\):Documento?s/" ":\\1/Doc:")
("^~/[Gg]it/" ":Git:")
("^~/[Gg]it[Hh]ub/" ":Git:")
("^~/[Gg]it\\([Hh]ub\\|\\)-?[Pp]rojects/" ":Git:"))
"List of pairs of strings used (by `sml/replacer') to create prefixes.
The first string of each pair is a regular expression, the second
is a replacement. These pairs are sequentially applied on the
file path to replace portions of it, turning them into prefixes.
For instance, \"~/.emacs.d/\" is replaced by \":ED:\", which is
shorter but easily identified.
The replacement strings can really be anything, but to be colored
as a prefix a string must start and end with \":\" (see the
default as an example, as an exception \"~/\" is also a prefix).
Replacement doesn't stop on first match, so you can have stacking replacements:
(add-to-list 'sml/replacer-regexp-list '(\"^:DB:Org/\" \":Org:\") t)
Remember that `add-to-list' adds items to the FRONT, and you'll
usually want to add them to the back (thus the t at the end).
You can also set custom colors (faces) for these prefixes, just
set `sml/prefix-face-list' accordingly."
:type '(repeat (list regexp string))
:group 'smart-mode-line-path-and-prefix
:package-version '(smart-mode-line . "1.22"))
(defcustom sml/prefix-regexp '(":\\(.*:\\)" "~/")
"List of Regexps used to identify prefixes.
A prefix is anything at the beginning of a line that matches any
of these regexps. Don't start these regexps with \"^\", the
parser applies that for you."
:type '(repeat regexp)
:group 'smart-mode-line-path-and-prefix)
(defcustom sml/prefix-face-list '((":SU:" sml/sudo)
(":G" sml/git)
("" sml/prefix))
"List of (STRING FACE) pairs used by `sml/propertize-prefix'.
After the file path is constructed, the prefix contained in it is
colored according to this list. The elements are checked one by
one and, if the prefix contains the STRING part of the pair, then
FACE is applied to it (and checking stops there)."
:type '(repeat (list string face))
:group 'smart-mode-line-path-and-prefix)
(defcustom sml/name-width 44
"Minimum and maximum size of the file name in the mode-line.
If `sml/shorten-directory' is nil, this is the minimum width.
Otherwise, this is both the minimum and maximum width.
Alternatively, you can set the minimum and maximum widths
separately, by setting this variable to a cons cell of integers:
(MIN-WIDTH . MAX-WIDTH)
"
:type '(choice integer (cons (integer :tag "Minimum width")
(integer :tag "Maximum width")))
:group 'smart-mode-line-path-and-prefix)
(defcustom sml/shorten-directory t
"Should directory name be shortened to fit width?
When the buffer+directory name is longer than
`sml/name-width':
if nil the rest of the mode-line is pushed right;
otherwise the directory name is shortened to fit."
:type 'boolean
:group 'smart-mode-line-path-and-prefix
:set 'sml/set-shortener-func)
(put 'sml/shorten-directory 'safe-local-variable 'booleanp)
(defcustom sml/full-mode-string " +"
"String that's appended to the minor-mode list when it's full."
:type 'string
:group 'smart-mode-line-mode-list)
(defcustom sml/shorten-mode-string " -"
"String that's appended to the minor-mode list when all modes are displayed."
:type 'string
:group 'smart-mode-line-mode-list)
(defcustom sml/shorten-modes t
"Should modes list be shortened to fit width?
When the modes list is longer than `sml/mode-width':
if nil the rest of the mode-line is pushed right;
otherwise the list is shortened to fit."
:type 'boolean
:group 'smart-mode-line-mode-list)
(put 'sml/shorten-modes 'safe-local-variable 'booleanp)
(defun sml/toggle-shorten-directory (&rest val)
"Toggle the variable `sml/shorten-directory'.
If given an argument VAL, the variable is set to the argument,
otherwise it is toggled. This can be used as an alternative to
customizing the variable with `customize-group'. Setting the
variable with `setq' will NOT work and should be avoided."
(interactive)
(sml/set-shortener-func 'sml/shorten-directory
(if val (car-safe val)
(not sml/shorten-directory))))
(defun sml/toggle-shorten-modes (&rest val)
"Toggle the variable `sml/shorten-modes'.
If given an argument VAL, the variable is set to the argument,
otherwise it is toggled. This can be used as an alternative to
customizing the variable with `customize-group'. Equivalent to
setting the variable with `setq'."
(interactive)
(setq sml/shorten-modes (if val (car val)
(not sml/shorten-modes)))
(force-mode-line-update))
(defcustom sml/mode-width 'full
"Maximum and/or minimum size of the modes list in the mode-line.
If it is an integer, then the modes list width is that many
characters.
If it is the symbol `full', then the mode-list fills all the
empty space is available in the mode-line (this has the effect of
indenting right anything after the mode-list).
If it is the symbol `right', then it behaves like `full', but the
minor-modes list is moved all the way to the right.
If `sml/shorten-modes' is nil, this is the minimum width.
Otherwise, this is both the minimum and maximum width."
:type '(choice integer symbol)
:group 'smart-mode-line-mode-list
:package-version '(smart-mode-line . "2.4.5"))
(defcustom sml/battery-format " %p"
"Format used to display the battery in the mode-line.
Only relevant if using `display-battery-mode'. See that function
for the syntax."
:type 'string
:group 'smart-mode-line-others)
(defcustom sml/modified-time-string "Modified on %T %Y-%m-%d."
"String format used for displaying the modified time.
This is shown in the tooltip when hovering over the \"modified
file\" character (which is usually a * right before the file
name."
:type 'string
:group 'smart-mode-line-others)
(defcustom sml/extra-filler 0
"The number of extra filling chars to use.
It comes into play when `sml/mode-width' is set to 'full.
This is necessary because the mode-line width (which we need but
don't have access to) is larger than `window-total-width' (which
we have access to).
Decrease this if right indentation seems to be going too far (or
if you just want to fine-tune it)."
:type 'integer
:group 'smart-mode-line-mode-list)
;; Face definitions
(defface sml/global '((t :inverse-video nil)) "" :group 'smart-mode-line-faces)
(defface sml/modes '((t :inherit sml/global)) "" :group 'smart-mode-line-faces)
(defface sml/minor-modes '((t :inherit sml/global)) "" :group 'smart-mode-line-faces)
(defface sml/filename '((t :inherit sml/global :weight bold)) "" :group 'smart-mode-line-faces)
(defface sml/prefix '((t :inherit sml/global)) "" :group 'smart-mode-line-faces)
(defface sml/read-only '((t :inherit sml/not-modified)) "" :group 'smart-mode-line-faces)
(defface sml/modified '((t :inherit sml/not-modified :foreground "Red" :weight bold))
"" :group 'smart-mode-line-faces)
(defface sml/outside-modified '((t :inherit sml/not-modified :foreground "#ffffff" :background "#c82829"))
"" :group 'smart-mode-line-faces)
(defface sml/line-number '((t :inherit sml/modes :weight bold)) "" :group 'smart-mode-line-faces)
(defface sml/remote '((t :inherit sml/global)) "" :group 'smart-mode-line-faces)
(defface sml/name-filling '((t :inherit sml/position-percentage)) "" :group 'smart-mode-line-faces)
(defface sml/position-percentage '((t :inherit sml/prefix :weight normal)) "" :group 'smart-mode-line-faces)
(defface sml/col-number '((t :inherit sml/global)) "" :group 'smart-mode-line-faces)
(defface sml/numbers-separator '((t :inherit sml/col-number)) "" :group 'smart-mode-line-faces)
(defface sml/client '((t :inherit sml/prefix)) "" :group 'smart-mode-line-faces)
(defface sml/not-modified '((t :inherit sml/global)) "" :group 'smart-mode-line-faces)
(defface sml/mule-info '((t :inherit sml/global)) "" :group 'smart-mode-line-faces)
(defface sml/sudo '((t :inherit sml/outside-modified)) "" :group 'smart-mode-line-faces)
(defface sml/git '((t :inherit (sml/read-only sml/prefix))) "" :group 'smart-mode-line-faces)
(defface sml/folder '((t :inherit sml/global :weight normal)) "" :group 'smart-mode-line-faces)
(defface sml/process '((t :inherit sml/prefix)) "" :group 'smart-mode-line-faces)
(defface sml/vc '((t :inherit sml/git)) "" :group 'smart-mode-line-faces)
(defface sml/vc-edited '((t :inherit sml/prefix)) "" :group 'smart-mode-line-faces)
(defface sml/charging '((t :inherit sml/global :foreground "ForestGreen")) "" :group 'smart-mode-line-faces)
(defface sml/discharging '((t :inherit sml/global :foreground "Red")) "" :group 'smart-mode-line-faces)
(defface sml/time '((t :inherit sml/modes)) "" :group 'smart-mode-line-faces)
(defvar sml/-apply-theme-is-running nil "Avoid nesting in `sml/apply-theme'.")
(defcustom sml/no-confirm-load-theme nil
"If non-nil, `sml/apply-theme' will pass the NO-CONFIRM flag to `load-theme'.
If you're having problems with Emacs always asking for permission
to load a theme (and not remembering your choice), you can set
this to t to workaround the problem. But it's recommended that
you try the problem instead."
:type 'boolean
:group 'smart-mode-line-faces
:package-version '(smart-mode-line . "2.5.2"))
;;;###autoload
(when load-file-name
(let ((dir (file-name-as-directory (file-name-directory load-file-name))))
(add-to-list 'custom-theme-load-path dir)
(when (file-directory-p (file-name-as-directory (concat dir "themes")))
(add-to-list 'custom-theme-load-path
(file-name-as-directory (concat dir "themes"))))))
(defun sml/apply-theme (theme &optional value silent)
"Apply the theme called smart-mode-line-THEME.
THEME is usually one of the symbols: respectful, dark, or light;
but it can be something else if there are other smart-mode-line
themes defined.
See the `sml/theme' variable for the meaning of each symbol.
This function will call `disable-theme' on any enabled themes
whose name starts with \"smart-mode-line-\", then it will call
`load-theme' on the theme called \"smart-mode-line-THEME\".
This also sets the `sml/theme' variable, see its documentation
for more information on each value.
The second argument (VALUE) is for internal use only, DON'T USE IT.
Third argument SILENT prevents messages."
(interactive
(list
(intern
(completing-read
"Load smart-mode-line theme: "
(cons
'automatic
(mapcar
(lambda (x) (replace-regexp-in-string "\\`smart-mode-line-" "" (symbol-name x)))
(cl-remove-if-not #'sml/theme-p (custom-available-themes))))))
nil nil))
(sml/-debug "Entering apply-theme")
(when (eq theme (intern "")) (setq theme nil))
(sml/-debug theme)
(sml/-debug sml/theme)
(unless silent (message "[sml] %s set to %s" 'sml/theme (or value theme)))
(sml/-debug sml/-apply-theme-is-running)
(unless sml/-apply-theme-is-running
(let ((sml/-apply-theme-is-running t)) ;Avoid nesting.
;; Set the variable
(setq-default sml/theme (or value theme))
(sml/-debug sml/theme)
;; Disable any previous smart-mode-line themes.
(sml/-debug custom-enabled-themes)
(mapc (lambda (x) (when (sml/theme-p x) (disable-theme x)))
custom-enabled-themes)
(sml/-debug custom-enabled-themes)
;; Load the theme requested.
(sml/-debug sml/theme)
(when (eq sml/theme 'automatic)
(setq sml/theme (sml/-automatically-decide-theme)))
(sml/-debug sml/theme)
(when sml/theme
(let ((theme-name
(if (sml/theme-p sml/theme) sml/theme
(intern (format "smart-mode-line-%s" sml/theme)))))
(sml/-debug theme-name)
(load-theme theme-name sml/no-confirm-load-theme))))))
(defadvice enable-theme (after sml/after-enable-theme-advice (theme) activate)
"Make sure smart-mode-line themes take priority over global themes that don't customize sml faces."
(unless (or (eq theme 'user) (sml/faces-from-theme theme))
(mapc #'enable-theme
(reverse (cl-remove-if-not #'sml/theme-p custom-enabled-themes)))))
(defun sml/theme-p (theme)
"Return non-nil if theme named THEME is a smart-mode-line theme.
Takes symbols and strings."
(string-match "\\`smart-mode-line-" (if (symbolp theme) (symbol-name theme) theme)))
(defvaralias 'sml/show-encoding 'sml/mule-info)
(defcustom sml/show-eol nil
"Whether to display the buffer EOL in the mode-line."
:type 'boolean
:group 'smart-mode-line-others)
(put 'sml/show-eol 'safe-local-variable 'booleanp)
(defcustom sml/outside-modified-char "M"
"Char to display if buffer needs to be reverted."
:type 'string
:group 'smart-mode-line-others
:package-version '(smart-mode-line . "1.20"))
(defvaralias 'sml/encoding-format 'sml/mule-info)
(defcustom sml/mule-info "%z"
"Format for multilingual information. Set this to nil to hide buffer encoding."
:type '(choice string (const :tag "Don't display." nil))
:group 'smart-mode-line-others
:package-version '(smart-mode-line . "2.0"))
(defcustom sml/read-only-char "R"
"Displayed when buffer is readonly."
:type 'string
:group 'smart-mode-line-others
:package-version '(smart-mode-line . "1.20"))
(defcustom sml/show-frame-identification nil
"Whether to show frame identification or not.
In some systems this doesn't even display anything. It's most useful
on terminals, but you might want to disable it anyway.
Just set this to nil, and frame identification won't be displayed."
:type 'boolean
:group 'smart-mode-line-others
:package-version '(smart-mode-line . "2.0.3"))
(put 'sml/show-frame-identification 'safe-local-variable 'booleanp)
(defcustom sml/vc-mode-show-backend nil
"Whether to show or not the backend in vc-mode's mode-line description.
I think most people only use one backend, so this defaults to nil.
If you want it to show the backend, just set it to t."
:type 'boolean
:group 'smart-mode-line-others
:package-version '(smart-mode-line . "1.22"))
(put 'sml/vc-mode-show-backend 'safe-local-variable 'booleanp)
(defvar sml/position-construct nil "Used for recycling position information.")
(put 'sml/position-construct 'risky-local-variable t)
(defvar sml/position-help-text nil "Help-text for position information.")
(make-variable-buffer-local 'sml/position-help-text)
;;; Buffer Identification
(defvar sml/buffer-identification-filling nil
"Filling generated by `sml/fill-for-buffer-identification'.")
(make-variable-buffer-local 'sml/buffer-identification-filling)
(put 'sml/buffer-identification-filling 'risky-local-variable t)
(defvar sml/buffer-identification nil
"Used for recycling buffer identification without having to recompute it.")
(make-variable-buffer-local 'sml/buffer-identification)
(put 'sml/buffer-identification 'risky-local-variable t)
(defadvice rename-buffer (after sml/after-rename-buffer-advice ())
"Regenerate buffer-identification after `rename-buffer'."
(sml/generate-buffer-identification))
(defadvice set-visited-file-name (after sml/after-set-visited-file-name-advice ())
"Regenerate buffer-identification after `set-visited-file-name'."
(sml/generate-buffer-identification))
(defvar sml/name-width-old nil "Used for recalculating buffer identification filling only when necessary.")
(make-variable-buffer-local 'sml/name-width-old)
(defvar sml/shorten-directory-old nil "Used for recalculating buffer identification filling only when necessary.")
(make-variable-buffer-local 'sml/shorten-directory-old)
(defun sml/generate-buffer-identification-if-necessary ()
"Call `sml/generate-buffer-identification' only if `sml/name-width' has changed."
(unless (and (equal sml/name-width-old sml/name-width)
(equal sml/shorten-directory-old sml/shorten-directory))
(setq sml/name-width-old sml/name-width)
(setq sml/shorten-directory-old sml/shorten-directory)
(sml/generate-buffer-identification))
nil)
(defvar sml/mode-line-client
`(sml/show-client
(:eval (if (frame-parameter nil 'client)
,(propertize "@" 'face 'sml/client 'help-echo (purecopy "emacsclient frame"))
" ")))
"Construct that replaces `mode-line-client'.")
(defvar sml/mode-line-buffer-identification
'("" (sml/buffer-identification
sml/buffer-identification
(:eval (sml/generate-buffer-identification))))
"Replace the default `mode-line-buffer-identification' with our own.")
(defvar sml/projectile-replacement-format)
(defvar sml/use-projectile-p)
(defvar sml/projectile-loaded-p nil "Non-nil if projectile has been loaded.")
(defcustom sml/pos-id-separator " "
"Miscellaneous mode-line construct."
:type 'string)
(put 'sml/pos-id-separator 'risky-local-variable t)
(defcustom sml/pre-modes-separator " "
"Miscellaneous mode-line construct."
:type 'string)
(put 'sml/pre-modes-separator 'risky-local-variable t)
(defcustom sml/pre-id-separator ""
"Miscellaneous mode-line construct."
:type 'string)
(put 'sml/pre-id-separator 'risky-local-variable t)
(defcustom sml/pre-minor-modes-separator ""
"Miscellaneous mode-line construct."
:type 'string)
(put 'sml/pre-minor-modes-separator 'risky-local-variable t)
(defcustom sml/pos-minor-modes-separator ""
"Miscellaneous mode-line construct."
:type 'string)
(put 'sml/pos-minor-modes-separator 'risky-local-variable t)
(defun sml/-automatically-decide-theme ()
"Return the most appropriate sml theme, based on global theme."
(sml/-debug "Entering -automatically-decide-theme")
(sml/-debug (sml/global-theme-support-sml-p))
(unless (sml/global-theme-support-sml-p)
(sml/-debug (face-background 'mode-line nil t))
(sml/-debug (face-background 'default nil t))
(let ((bg (ignore-errors
(or (face-background 'mode-line nil t)
(face-background 'default nil t)))))
(if (ignore-errors
(and (stringp bg)
(> (color-distance "white" bg)
(color-distance "black" bg))))
'dark 'light))))
(defun sml/-setup-theme ()
"Decide what theme to use and apply it.
Used during initialization."
(sml/-debug "Entering -setup-theme")
(sml/-debug sml/theme)
(when sml/theme
(when (eq sml/theme 'automatic)
(setq sml/theme (sml/-automatically-decide-theme)))
(sml/-debug "chosen theme:")
(sml/-debug sml/theme)
(sml/apply-theme sml/theme nil :silent)))
(defvar battery-mode-line-format)
;;;###autoload
(defun sml/setup (&optional arg)
"Setup the mode-line to be smart and sexy.
ARG is ignored. Just call this function in your init file, and
the mode-line will be setup."
(interactive)
(sml/-debug "Entering setup")
(sml/-debug custom-enabled-themes)
;; Just a couple of useful variables
(setq sml/simplified nil)
(setq battery-mode-line-format sml/battery-format)