From 3379638199bf15bb1439209c1d5ace8daa560cfd Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 10 Jan 2022 23:44:45 -0600 Subject: Change mode-line and tab-bar --- init.el | 52 +++++++++++++++++++++--------------- lisp/+modeline.el | 47 +++++++++++++++++--------------- lisp/+tab-bar.el | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 43 deletions(-) create mode 100644 lisp/+tab-bar.el diff --git a/init.el b/init.el index f4d6533..f0a93a6 100644 --- a/init.el +++ b/init.el @@ -1278,27 +1278,32 @@ See also `crux-reopen-as-root-mode'." (setup (:straight (simple-modeline :fork (:host github :repo "duckwork/simple-modeline"))) (:require +modeline) - (:option simple-modeline-segments `((;; left - +modeline-ace-window-display - +modeline-modified - ,(+modeline-concat - '(+modeline-god-mode - +modeline-reading-mode - +modeline-narrowed) - ",") - +modeline-buffer-name - +modeline-position - +modeline-anzu - ) - (;; right - +modeline-track - +modeline-vc - simple-modeline-segment-misc-info - simple-modeline-segment-process - +modeline-text-scale - +modeline-minions - +modeline-major-mode - ))) + (:option simple-modeline-segments + `(( ; left + +modeline-ace-window-display + +modeline-modified + +modeline-buffer-name + (lambda () (+modeline-vc ": ")) + ,(+modeline-concat + '(+modeline-minions + +modeline-major-mode)) + +modeline-anzu + ) + ( ; right + (lambda () + (unless +tab-bar-misc-info-mode + (+modeline-concat + '(+modeline-track + simple-modeline-segment-misc-info)))) + + simple-modeline-segment-process + +modeline-text-scale + ,(+modeline-concat + '(+modeline-god-mode + +modeline-reading-mode + +modeline-narrowed) + ",") + +modeline-position))) (simple-modeline-mode +1)) (setup (:straight smartscan) @@ -1469,3 +1474,8 @@ See also `crux-reopen-as-root-mode'." (:require +zzz-to-char) (:option zzz-to-char-reach 1024) (:global "M-z" #'+zzz-to-char)) + +(setup tab-bar + (:require +tab-bar) + (tab-bar-mode +1) + (+tab-bar-misc-info-mode +1)) diff --git a/lisp/+modeline.el b/lisp/+modeline.el index a0195f1..3f25a40 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el @@ -88,7 +88,7 @@ This function makes a lambda, so you can throw it straight into (defun +modeline-major-mode (&optional spacer) "Display the current `major-mode'." (concat (or spacer +modeline-default-spacer) - (propertize (+string-truncate (format-mode-line mode-name) 12) + (propertize (+string-truncate (format-mode-line mode-name) 16) 'face 'bold 'keymap mode-line-major-mode-keymap 'help-echo (concat (format-mode-line mode-name) @@ -185,27 +185,30 @@ The order of elements matters: whichever one matches first is applied." (defun +modeline-position (&optional _) ; adapted from `simple-modeline' "Display the current cursor position." - (list '((line-number-mode - ((column-number-mode - (column-number-indicator-zero-based - (9 " %l:%c") - (9 " %l:%C")) - (6 " %l:"))) - ((column-number-mode - (column-number-indicator-zero-based - (5 " :%c") - (5 " :%C")))))) - '(file-percentage-mode - ((-3 "%p") "%% ")) - (if (region-active-p) - (propertize (format "%s%-5d" - (if (and (mark) (< (point) (mark))) "-" "+") - (apply '+ (mapcar - (lambda (pos) - (- (cdr pos) - (car pos))) - (region-bounds)))) - 'font-lock-face 'font-lock-variable-name-face)))) + (let ((sep "|") (before " [") (after "]")) + (list `(:propertize (line-number-mode + ((column-number-mode + (column-number-indicator-zero-based + ,(concat before "%l" sep "%c" after) + ,(concat before "%l" sep "%C" after)) + ,(concat before "%l" sep "" after))) + ((column-number-mode + (column-number-indicator-zero-based + ,(concat before sep "%c" after) + ,(concat before sep "%C" after))))) + font-lock-face font-lock-comment-face) + (if (region-active-p) + (propertize (format "%s%-5d" + (if (and (mark) (< (point) (mark))) "-" "+") + (apply '+ (mapcar + (lambda (pos) + (- (cdr pos) + (car pos))) + (region-bounds)))) + 'font-lock-face 'font-lock-variable-name-face)) + '(:propertize (file-percentage-mode + (" " (-3 "%p") "%%")) + font-lock-face font-lock-comment-face)))) (defun +modeline-vc (&optional spacer) "Display the version control branch of the current buffer in the modeline." diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el new file mode 100644 index 0000000..2a03121 --- /dev/null +++ b/lisp/+tab-bar.el @@ -0,0 +1,80 @@ +;;; +tab-bar.el -*- lexical-binding: t; -*- + +;;; Commentary: + +;; Emacs 28 comes with an easy-to-use `tab-bar-format' option, but I still use +;; Emacs 27 on my Windows machine. Thus, the code in this file. + +;;; Code: + +(require 'tab-bar) + + +;; Common + +(defun +tab-bar-misc-info () + "Display `mode-line-misc-info', formatted for the tab-bar." + `((global menu-item ,(string-trim-right + (format-mode-line mode-line-misc-info)) + ignore))) + +(defvar +tab-bar-show-original nil + "Original value of `tab-bar-show'.") + + +;; Emacs 27 + +(defun +tab-bar-misc-info-27 (output &rest _) + "Display `mode-line-misc-info' in the `tab-bar' on Emacs 27. +This is :filter-return advice for `tab-bar-make-keymap-1'." + (let* ((reserve (length (format-mode-line mode-line-misc-info))) + (str (propertize " " + 'display `(space :align-to (- right (- 0 right-margin) + ,reserve))))) + (prog1 (append output + `((align-right menu-item ,str nil)) + (+tab-bar-misc-info))))) + + +;; Emacs 28 + +(defvar +tab-bar-format-original nil + "Original value of `tab-bar-format'.") + +(defun +tab-bar-misc-info-28 () + "Display `mode-line-misc-info', right-aligned, on Emacs 28." + (append (unless (memq 'tab-bar-format-align-right tab-bar-format) + '(tab-bar-format-align-right)) + '(+tab-bar-misc-info))) + + + +(define-minor-mode +tab-bar-misc-info-mode + "Show the `mode-line-misc-info' in the `tab-bar'." + :lighter "" + :global t + (if +tab-bar-misc-info-mode + (progn ; Enable + (setq +tab-bar-show-original tab-bar-show) + (cond + ((boundp 'tab-bar-format) ; Emacs 28 + (setq +tab-bar-format-original tab-bar-format) + (unless (memq '+tab-bar-misc-info tab-bar-format) + (setq tab-bar-format + (append tab-bar-format (+tab-bar-misc-info-28))))) + ((fboundp 'tab-bar-make-keymap-1) ; Emacs 27 + (advice-add 'tab-bar-make-keymap-1 :filter-return + '+tab-bar-misc-info-27))) + (setq tab-bar-show t)) + (progn ; Disable + (setq tab-bar-show +tab-bar-show-original) + (cond + ((boundp 'tab-bar-format) ; Emacs 28 + (setq tab-bar-format +tab-bar-format-original)) + ((fboundp 'tab-bar-make-keymap-1) ; Emacs 27 + (advice-remove 'tab-bar-make-keymap-1 '+tab-bar-misc-info-27)))))) + + + +(provide '+tab-bar) +;;; +tab-bar.el ends here -- cgit 1.4.1-21-gabe81 From dcf3a3aa023309d0a8d6a8df7c5e3ca42eaf9c8a Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 10 Jan 2022 23:52:02 -0600 Subject: Fix bug --- lisp/+org.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/+org.el b/lisp/+org.el index 090af5a..348ba6e 100644 --- a/lisp/+org.el +++ b/lisp/+org.el @@ -421,9 +421,10 @@ the deletion might narrow the column." (interactive "P") (save-excursion (let* ((this-char-type (org-element-type (org-element-context))) - (prev-char-type (save-excursion - (backward-char) - (org-element-type (org-element-context)))) + (prev-char-type (ignore-errors + (save-excursion + (backward-char) + (org-element-type (org-element-context))))) (types '(citation citation-reference clock comment comment-block footnote-definition footnote-reference headline inline-src-block inlinetask keyword link -- cgit 1.4.1-21-gabe81 From 4d1605ce45ef684176672830bec34173862b2cd1 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 10 Jan 2022 23:52:11 -0600 Subject: Hook reading-mode into view-mode I need to fix reading-mode, however. --- init.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index f0a93a6..9722a64 100644 --- a/init.el +++ b/init.el @@ -113,7 +113,8 @@ (+ensure-after-init #'+pulse-location-mode)) (setup (:require reading) - (:global "C-c C-r" #'reading-mode)) + (:hook-into view-mode) ; XXX doesn't go back + ) (setup (:require user-save) (add-hook 'user-save-hook #'+clean-empty-lines) -- cgit 1.4.1-21-gabe81 From e91bb5a1bef2770169987c88c730c735c10e0eb4 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 10 Jan 2022 23:52:31 -0600 Subject: Add music to browse-url-with-mpv --- init.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/init.el b/init.el index 9722a64..c4f71b0 100644 --- a/init.el +++ b/init.el @@ -179,9 +179,12 @@ (cond ((executable-find "mpv") #'+browse-image-with-mpv) (t #'eww-browse-url)) args))) - (cons (rx ; videos + (cons (rx (or "youtube.com" "youtu.be" "yewtu.be" - (seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos))) + ;; videos + (seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos) + ;; music + (seq "." (or "ogg" "mp3") eos))) (lambda (&rest args) (apply (if (executable-find "mpv") #'+browse-url-with-mpv -- cgit 1.4.1-21-gabe81 From 0e43d013ea22fe622d13370a50a44d548c94ccd0 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 10 Jan 2022 23:52:43 -0600 Subject: Bleh --- init.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index c4f71b0..be470ab 100644 --- a/init.el +++ b/init.el @@ -1042,6 +1042,7 @@ See also `crux-reopen-as-root-mode'." (:+key "M-q" #'filldent-dwim)) (setup (:straight flyspell-correct) + (:load-after flyspell) (:also-load +flyspell-correct) (:option flyspell-correct--cr-key ";") (:bind-into flyspell @@ -1223,7 +1224,8 @@ See also `crux-reopen-as-root-mode'." (:hook-into org-mode)) (setup (:straight org-sticky-header) - (:hook-into org-mode)) + ;; (:hook-into org-mode) + ) (setup (:straight org-visibility) (:option org-visibility-state-file (.etc "org-visibility") -- cgit 1.4.1-21-gabe81