diff --git a/early-init.el b/early-init.el index 2cfcb84..508336e 100644 --- a/early-init.el +++ b/early-init.el @@ -75,34 +75,32 @@ See `no-littering' for examples.") (bottom . right))) ;;; Fonts +(progn + ;; Set default faces + (let ((font-name system-default-font) + (font-size system-default-height) + (variable-font-name system-variable-pitch-font) + (variable-font-size system-variable-pitch-height)) + (set-face-attribute 'default nil :family system-default-font + :height font-size :weight 'book) + (set-face-attribute 'italic nil :family font-name + :height font-size :slant 'italic) + (set-face-attribute 'variable-pitch nil :family variable-font-name + :height variable-font-size)) -;; Set default faces - -(let ((font-name system-default-font) - (font-size system-default-height) - (variable-font-name system-variable-pitch-font) - (variable-font-size system-variable-pitch-height)) - (set-face-attribute 'default nil :family system-default-font - :height font-size :weight 'book) - (set-face-attribute 'italic nil :family font-name - :height font-size :slant 'italic) - (set-face-attribute 'variable-pitch nil :family variable-font-name - :height variable-font-size)) - -;; Emoji fonts - -(let ((ffl (font-family-list))) - (dolist (font '("Noto Color Emoji" - "Noto Emoji" - "Segoe UI Emoji" - "Apple Color Emoji" - "FreeSans" - "FreeMono" - "FreeSerif" - "Unifont" - "Symbola")) - (when (member font ffl) - (set-fontset-font t 'symbol (font-spec :family font) nil :append)))) + ;; Emoji fonts + (let ((ffl (font-family-list))) + (dolist (font '("Noto Color Emoji" + "Noto Emoji" + "Segoe UI Emoji" + "Apple Color Emoji" + "FreeSans" + "FreeMono" + "FreeSerif" + "Unifont" + "Symbola")) + (when (member font ffl) + (set-fontset-font t 'symbol (font-spec :family font) nil :append))))) ;;; Packages diff --git a/init.el b/init.el index 74d08a6..ca888da 100644 --- a/init.el +++ b/init.el @@ -163,7 +163,6 @@ "imgur.com" "pixelfed" "instagram.com" "bibliogram.art" "reddit.com" "teddit.net" - "tildes.net" "taskiq" "twitter.com" "nitter.net" "streamable.com" @@ -402,7 +401,12 @@ ;; context-menu-region ;; context-menu-undo ;; context-menu-dictionary)) - (context-menu-mode +1))) + (context-menu-mode +1)) + (dolist (click '( ; Fix scrolling in the margin + wheel-down double-wheel-down triple-wheel-down + wheel-up double-wheel-up triple-wheel-up)) + (global-set-key (vector 'right-margin click) 'mwheel-scroll) + (global-set-key (vector 'left-margin click) 'mwheel-scroll))) (setup org ;; Plain org with the `setup' form for sorting, but I install with straight. @@ -566,9 +570,21 @@ (:option shr-width (- fill-column 5) ; pad out for wide letters shr-use-fonts t)) +(setup tab-bar + (:require +tab-bar) + (:option tab-bar-tab-name-function '+tab-bar-tab-name-truncated-left + tab-bar-tab-name-truncated-max 20 + tab-bar-tab-name-ellipsis truncate-string-ellipsis) + (tab-bar-mode +1) + (+tab-bar-misc-info-mode +1)) + (setup text (:hook #'turn-on-auto-fill)) +(setup time + (:option display-time-format "%H:%M") + (display-time-mode +1)) + (setup (:straight 0x0) (:option 0x0-default-server 'ttm) (with-eval-after-load 'embark @@ -746,7 +762,7 @@ #'+circe-F/C-mode ;; For some reason `+circe-shorten-url-mode' won't work right out of ;; the gate. - (lambda () (run-with-idle-timer 0.25 nil #'+circe-shorten-url-mode))) + (lambda () (run-at-time 0.25 nil #'+circe-shorten-url-mode))) (:bind "C-c C-s" #'circe-command-SLAP)) (:with-mode lui-mode @@ -774,13 +790,23 @@ (:local-set fringes-outside-margins t right-margin-width (length lui-time-stamp-format) scroll-margin 0 + scroll-step 1 word-wrap t wrap-prefix (+string-repeat +circe-left-margin " ") line-number-mode nil column-number-mode nil file-percentage-mode nil visual-fill-column-extra-text-width - (cons +circe-left-margin 0))) + (cons +circe-left-margin 0)) + (with-eval-after-load 'vertico-multiform + (setf (alist-get 'lui-next-button-or-complete vertico-multiform-commands) + '(flat)))) + + (:with-mode tracking-mode + (:option tracking-position 'before-modes) + (add-to-list 'mode-line-misc-info + '(tracking-mode + tracking-mode-line-buffers))) (with-eval-after-load 'topsy (:option (append topsy-mode-functions) @@ -942,6 +968,7 @@ See also `crux-reopen-as-root-mode'." elfeed-search-trailing-width 24 elfeed-search-title-min-width 24 elfeed-search-title-max-width 78 + elfeed-search-remain-on-entry t elfeed-show-unique-buffers t elfeed-db-directory (elfeed/ "db/" t) elfeed-log 'debug ; until I can figure out syncing... @@ -1047,7 +1074,9 @@ See also `crux-reopen-as-root-mode'." (:option flyspell-correct--cr-key ";") (:bind-into flyspell "C-;" #'flyspell-correct-wrapper - "" #'+flyspell-correct-buffer)) + "" #'+flyspell-correct-buffer) + (with-eval-after-load 'vertico-multiform + (setf (alist-get 'flyspell-correct-wrapper vertico-multiform-commands) nil))) (setup (:straight-when (forge :host github :repo "magit/forge") @@ -1200,8 +1229,6 @@ See also `crux-reopen-as-root-mode'." (setf (alist-get 'gfm-mode apheleia-mode-alist) 'markdownfmt)))) (setup (:straight minions) - (:option minions-prominent-modes - '(tracking-mode)) (minions-mode +1)) (setup (:straight (mode-line-bell @@ -1428,12 +1455,17 @@ See also `crux-reopen-as-root-mode'." (helpful-function) (helpful-macro) (helpful-callable) - (helpful-variable)) + (helpful-variable) + (completion-at-point flat) + (indent-for-tab-command flat) + (consult-buffer flat) + (insert-char)) ;; This is applied /after/ the above, so default is at the end of ;; this alist. vertico-multiform-categories '((file buffer grid) - (t unobtrusive))) + (t flat))) (dolist (buf-cmd '(consult-find + consult-yank-pop consult-locate consult-grep consult-git-grep @@ -1442,7 +1474,9 @@ See also `crux-reopen-as-root-mode'." consult-line-multi consult-multi-occur consult-keep-lines - consult-focus-lines)) + consult-focus-lines + consult-imenu + consult-outline)) (setf (alist-get buf-cmd vertico-multiform-commands) '(buffer))) (:with-map vertico-map (:bind "RET" #'vertico-directory-enter @@ -1491,8 +1525,3 @@ 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/+circe.el b/lisp/+circe.el index 3d6ea60..a8db1ec 100644 --- a/lisp/+circe.el +++ b/lisp/+circe.el @@ -245,6 +245,14 @@ can easily remove elements.") match)) text))) +(defun +circe-shorten-urls-all () + "Turn on `+circe-shorten-url-mode' in all chat buffers." + (interactive) + (+mapc-some-buffers + (lambda () (+circe-shorten-url-mode +1)) + (lambda (buf) + (derived-mode-p 'circe-chat-mode)))) + ;; Temperature conversion (+circe-define-filter +circe-F/C-mode @@ -261,12 +269,13 @@ can easily remove elements.") (round (+ 32 (* (/ 9.0 5.0) degc)))) (defun str-F/C (text) - (replace-regexp-in-string "[0-9.]+[Ff]" + (replace-regexp-in-string "[^.]\\([[:digit:]]+\\(?:\\.[[:digit:]]+\\)?[fF]\\)" (lambda (match) (format "%s/%dC" match (fahrenheit-to-celsius (string-to-number match)))) - text)) + text + nil 1)) (provide '+circe) ;;; +circe.el ends here diff --git a/lisp/+modeline.el b/lisp/+modeline.el index 3f25a40..10bf6d2 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el @@ -183,32 +183,54 @@ The order of elements matters: whichever one matches first is applied." "Toggle the percentage display in the mode line (File Percentage Mode)." :init-value t :global t :group 'mode-line) -(defun +modeline-position (&optional _) ; adapted from `simple-modeline' - "Display the current cursor position." +(defun +modeline-file-percentage (&optional spacer) + "Display the position in the current file." + `(,(or spacer +modeline-default-spacer) + (:propertize (file-percentage-mode + (" " (-3 "%p") "%%")) + font-lock-face font-lock-comment-face))) + +(define-minor-mode region-indicator-mode + "Toggle the region indicator in the mode line." + :init-value t :global t :group 'mode-line) + +(defun +modeline-region (&optional spacer) + "Display an indicator if the region is active." + (when (and region-indicator-mode + (region-active-p)) + (list + (format "%s%6s" + (or spacer +modeline-default-spacer) + (propertize (format "%s%d" + (if (and (< (point) (mark))) "-" "+") + (apply '+ (mapcar (lambda (pos) + (- (cdr pos) + (car pos))) + (region-bounds)))) + 'font-lock-face 'font-lock-variable-name-face))))) + +(defun +modeline-line-column (&optional spacer) ; adapted from `simple-modeline' + "Display the current cursor line and column depending on modes." (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)))) + `(,(or spacer +modeline-default-spacer) + (: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)))) + +(defun +modeline-position (&optional _) + "Display the current cursor position. +See `line-number-mode', `column-number-mode', `file-percentage-mode'" + (append (+modeline-line-column) + (+modeline-region) + (+modeline-file-percentage))) (defun +modeline-vc (&optional spacer) "Display the version control branch of the current buffer in the modeline." diff --git a/lisp/+org.el b/lisp/+org.el index 348ba6e..95a3da2 100644 --- a/lisp/+org.el +++ b/lisp/+org.el @@ -420,7 +420,8 @@ the deletion might narrow the column." "Open thing at point, or if there isn't something, list things." (interactive "P") (save-excursion - (let* ((this-char-type (org-element-type (org-element-context))) + (let* ((browse-url-browser-function #'browse-url-default-browser) + (this-char-type (org-element-type (org-element-context))) (prev-char-type (ignore-errors (save-excursion (backward-char) diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el index 2a03121..1dc1f68 100644 --- a/lisp/+tab-bar.el +++ b/lisp/+tab-bar.el @@ -21,6 +21,26 @@ (defvar +tab-bar-show-original nil "Original value of `tab-bar-show'.") +(defun +tab-bar-tab-name-truncated-left () + "Generate the tab name from the buffer of the selected window. +This is just like `tab-bar-tab-name-truncated', but truncates the +name to the left." + (let* ((tab-name (buffer-name (window-buffer (minibuffer-selected-window)))) + (ellipsis (cond + (tab-bar-tab-name-ellipsis) + ((char-displayable-p ?…) "…") + ("..."))) + (l-ell (length ellipsis)) + (l-name (length tab-name))) + (if (< (length tab-name) tab-bar-tab-name-truncated-max) + tab-name + (propertize (concat + (when (> (+ l-name l-ell) tab-bar-tab-name-truncated-max) + ellipsis) + (truncate-string-to-width tab-name l-name + (max 0 (- l-name tab-bar-tab-name-truncated-max l-ell)))) + 'help-echo tab-name)))) + ;; Emacs 27 diff --git a/lisp/acdw.el b/lisp/acdw.el index 603f46f..7cad67c 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -145,7 +145,10 @@ within a `with-current-buffer' form." (let ((pred (or predicate t))) (dolist (buf (buffer-list)) (with-current-buffer buf - (when (if (fboundp pred) (funcall pred buf) pred) + (when (if (or (eq (car-safe pred) 'closure) + (fboundp pred)) + (funcall pred buf) + pred) (funcall func)))))) ;; https://github.com/cstby/emacs.d/blob/main/init.el#L67