From e4f7ed9609d85f80f3f54dae7485f06a49fc4d3c Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 11 Jan 2022 16:01:03 -0600 Subject: Lots o changes at work I need to fix +circe-define-filter or something --- lisp/+circe.el | 13 ++++++++-- lisp/+modeline.el | 72 ++++++++++++++++++++++++++++++++++++------------------- lisp/+org.el | 3 ++- lisp/+tab-bar.el | 20 ++++++++++++++++ lisp/acdw.el | 5 +++- 5 files changed, 84 insertions(+), 29 deletions(-) (limited to 'lisp') 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 -- cgit 1.4.1-21-gabe81