about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--config.org175
1 files changed, 171 insertions, 4 deletions
diff --git a/config.org b/config.org index ab7cef6..295e021 100644 --- a/config.org +++ b/config.org
@@ -580,15 +580,16 @@ landed on a good one: =simple-modeline=.
580#+begin_src emacs-lisp :noweb-ref settings 580#+begin_src emacs-lisp :noweb-ref settings
581 (setq-default simple-modeline-segments 581 (setq-default simple-modeline-segments
582 '(;; left side 582 '(;; left side
583 (simple-modeline-segment-modified 583 (acdw/modeline/modified
584 simple-modeline-segment-buffer-name 584 simple-modeline-segment-buffer-name
585 simple-modeline-segment-position) 585 acdw/modeline/vc-status
586 acdw/modeline/position)
586 ;; right side 587 ;; right side
587 (simple-modeline-segment-minor-modes 588 (simple-modeline-segment-minor-modes
588 simple-modeline-segment-input-method 589 simple-modeline-segment-input-method
589 simple-modeline-segment-vc
590 simple-modeline-segment-misc-info 590 simple-modeline-segment-misc-info
591 simple-modeline-segment-process 591 simple-modeline-segment-process
592 acdw/modeline/acdw-minions
592 simple-modeline-segment-major-mode))) 593 simple-modeline-segment-major-mode)))
593#+end_src 594#+end_src
594 595
@@ -596,6 +597,8 @@ landed on a good one: =simple-modeline=.
596 (simple-modeline-mode +1) 597 (simple-modeline-mode +1)
597#+end_src 598#+end_src
598 599
600**** Simple modeline custom segments
601
599***** COMMENT Functions to figure out what window is focused 602***** COMMENT Functions to figure out what window is focused
600 603
601How is this not built into Emacs? Oh well, I have [[https://github.com/jamesnvc/dotfiles/blob/master/emacs.d/modules/cogent-modeline.el][Cogent]] to thank. 604How is this not built into Emacs? Oh well, I have [[https://github.com/jamesnvc/dotfiles/blob/master/emacs.d/modules/cogent-modeline.el][Cogent]] to thank.
@@ -626,6 +629,158 @@ How is this not built into Emacs? Oh well, I have [[https://github.com/jamesnvc
626 (advice-add 'select-window :after #'cogent-line-set-selected-window) 629 (advice-add 'select-window :after #'cogent-line-set-selected-window)
627#+end_src 630#+end_src
628 631
632***** COMMENT Nyan mode
633
634#+begin_src emacs-lisp :noweb-ref packages
635 (straight-use-package 'nyan-mode)
636#+end_src
637
638#+begin_src emacs-lisp :noweb-ref settings
639 (setq-default nyan-bar-length 24)
640#+end_src
641
642#+begin_src emacs-lisp :noweb-ref modes
643 (nyan-mode +1)
644#+end_src
645
646#+begin_src emacs-lisp :noweb-ref functions
647 (defun acdw/modeline/nyan ()
648 "Show `nyan-mode' cat in the selected window, or position."
649 (if (and ;nyan-mode
650 (cogent-line-selected-window-active-p))
651 (nyan-create)
652 "%p%%"))
653#+end_src
654
655****** Rewrite =simple-modeline--format=
656
657#+begin_src emacs-lisp :noweb-ref functions
658 (defun simple-modeline--format (left-segments right-segments)
659 "Return a string of `window-width' length containing
660 LEFT-SEGMENTS and RIGHT-SEGMENTS, aligned respectively.
661
662 This version is fixed for `nyan-mode' ... maybe??"
663 (let* ((left (simple-modeline--format-segments left-segments))
664 (right (simple-modeline--format-segments right-segments))
665 (reserve (+ 1 (length right))))
666 (when (and window-system (eq 'right (get-scroll-bar-mode)))
667 (setq reserve (- reserve 3)))
668 (concat
669 left
670 (propertize " "
671 'display `((space
672 :align-to (- (+ right right-fringe right-margin)
673 ,reserve)))
674 'face '(:inherit simple-modeline-space))
675 right)))
676#+end_src
677
678***** Tweak =simple-modeline-segment-modified=
679
680#+begin_src emacs-lisp :noweb-ref functions
681 (defun acdw/modeline/modified ()
682 "Show the modified/readonly state in the modeline.
683 See `simple-modeline-status-modified'."
684 (if (not (string-match-p "\\*.*\\*" (buffer-name)))
685 (let* ((read-only (and buffer-read-only (buffer-file-name)))
686 (modified (buffer-modified-p)))
687 (propertize
688 (if read-only " ×" (if modified " ●" " ○"))
689 'face `(:inherit
690 ,(if modified 'simple-modeline-status-modified
691 (if read-only 'simple-modeline-status-error
692 'simple-modeline-unimportant)))
693 'help-echo (format
694 "Buffer is %s and %smodified\nmouse-1: Toggle read-only status."
695 (if read-only "read-only" "writable")
696 (if modified "" "not "))
697 'local-map (purecopy (simple-modeline-make-mouse-map
698 'mouse-1
699 (lambda (event)
700 (interactive "e")
701 (with-selected-window (posn-window (event-start event))
702 (read-only-mode 'toggle)))))
703 'mouse-face 'mode-line-highlight))
704 "_"))
705#+end_src
706
707***** Easier minor-modes
708
709#+begin_src emacs-lisp :noweb-ref functions
710 (defun acdw/modeline/acdw-minions ()
711 "Show `acdw/mode' icon as a button to enable `minions-minor-modes-menu'.
712
713 This enables me to `blackout' all global minor-mode
714 lighters (including `acdw/mode'), and hide them behind a button,
715 saving space in the mode line."
716 (propertize " ⱷ"
717 'help-echo "Minor modes"
718 'local-map (purecopy (simple-modeline-make-mouse-map
719 'mouse-1
720 (lambda (event)
721 (interactive "e")
722 (with-selected-window (posn-window
723 (event-start event))
724 (minions-minor-modes-menu)))))
725 'mouse-face 'mode-line-highlight))
726#+end_src
727
728***** Shorter VC-mode segment
729
730#+begin_src emacs-lisp :noweb-ref functions
731 (defun acdw/modeline/vc-status ()
732 "Displays the VC status in the modeline."
733 '(vc-mode (:eval
734 (let ((branch-name (replace-regexp-in-string
735 (format "^\s*%s:?-?"
736 (vc-backend buffer-file-name))
737 "" vc-mode))
738 (f (cond ((string= "up-to-date"
739 (vc-state buffer-file-name))
740 '((:slant normal)))
741 (t
742 '((:slant italic))))))
743 (propertize (concat " " branch-name)
744 'face f
745 'help-echo (format
746 "%s: %s\nmouse-1: Run magit-status"
747 vc-mode
748 (vc-state buffer-file-name))
749 'local-map (purecopy
750 (simple-modeline-make-mouse-map
751 'mouse-1
752 (lambda (ev)
753 (interactive "e")
754 (with-selected-window
755 (posn-window
756 (event-start ev))
757 (magit-status-setup-buffer
758 (file-name-directory
759 buffer-file-name))))))
760 'mouse-face 'mode-line-highlight)))))
761#+end_src
762
763***** Position in file
764
765#+begin_src emacs-lisp :noweb-ref functions
766 (defun acdw/modeline/position ()
767 "Displays the current cursor position in the mode-line."
768 `((line-number-mode (-6 " %l"))
769 ((column-number-mode
770 (column-number-indicator-zero-based
771 (4 ":%c")
772 (4 ":%C"))))
773 " " mode-line-percent-position "%% "
774 ,(if (region-active-p)
775 (propertize (format "+%s "
776 (apply #'+ (mapcar
777 (lambda (pos)
778 (- (cdr pos)
779 (car pos)))
780 (region-bounds))))
781 'font-lock-face 'font-lock-variable-name-face))))
782#+end_src
783
629**** Blackout some modes :package: 784**** Blackout some modes :package:
630 785
631Like =diminish= or =delight=, =blackout= allows me to remove some 786Like =diminish= or =delight=, =blackout= allows me to remove some
@@ -965,12 +1120,16 @@ on as I please.
965 (define-minor-mode acdw/mode 1120 (define-minor-mode acdw/mode
966 "A mode for `acdw/map'." 1121 "A mode for `acdw/map'."
967 :init-value t 1122 :init-value t
968 :lighter " " 1123 :lighter " acdw"
969 :keymap acdw/map) 1124 :keymap acdw/map)
970 1125
971 (define-globalized-minor-mode acdw/global-mode acdw/mode acdw/mode) 1126 (define-globalized-minor-mode acdw/global-mode acdw/mode acdw/mode)
972#+end_src 1127#+end_src
973 1128
1129#+begin_src emacs-lisp :noweb-ref modes
1130 (blackout 'acdw/mode)
1131#+end_src
1132
974**** Turn off acdw/mode in the minibuffer 1133**** Turn off acdw/mode in the minibuffer
975 1134
976#+begin_src emacs-lisp :noweb-ref acdw-mode 1135#+begin_src emacs-lisp :noweb-ref acdw-mode
@@ -1350,6 +1509,10 @@ I think that'll work -- I only care about line aesthetics with text.
1350Programming modes should be /allowed/ to have long lines, regardless 1509Programming modes should be /allowed/ to have long lines, regardless
1351of how /terrible/ it is to have them. 1510of how /terrible/ it is to have them.
1352 1511
1512#+begin_src emacs-lisp :noweb-ref modes
1513 (blackout 'auto-fill-mode)
1514#+end_src
1515
1353*** Visual fill column mode 1516*** Visual fill column mode
1354 1517
1355In reading-intensive views, this mode keeps the text from getting too 1518In reading-intensive views, this mode keeps the text from getting too
@@ -1654,6 +1817,10 @@ Let's use =hunspell=.
1654 (add-hook 'prog-mode-hook #'flyspell-prog-mode) 1817 (add-hook 'prog-mode-hook #'flyspell-prog-mode)
1655#+end_src 1818#+end_src
1656 1819
1820#+begin_src emacs-lisp :noweb-ref modes
1821 (blackout 'flyspell-mode)
1822#+end_src
1823
1657*** Flyspell-correct :package: 1824*** Flyspell-correct :package:
1658 1825
1659Display corrections with =completing-read=. 1826Display corrections with =completing-read=.