From 9ce43429943d1f4ef2ad743bdc9798abafc31826 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 15 May 2023 17:30:04 -0500 Subject: Rip off use-package's `autoload-keymap' thing --- emacs.el | 178 +++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 104 insertions(+), 74 deletions(-) diff --git a/emacs.el b/emacs.el index f466b83..e9e658c 100644 --- a/emacs.el +++ b/emacs.el @@ -22,6 +22,25 @@ ;;; Definitions: +(defmacro autoload-keymap (keymap library &optional parent-keymap) + "Require LIBRARY to load KEYMAP-SYMBOL, then press the buttons again. +This rips off `use-package-autoload-keymap' basically." + `(defun ,(intern (format "autoload-keymap-" keymap)) () + (interactive) + (unless (featurep ',library) + (require ',(cond + ((symbolp library) + library) + ((stringp library) + (intern library)) + (t (user-error "LIBRARY should be a symbol or string: %s" + library)))) + (let ((kv (this-command-keys-vector))) + (define-key ,(or parent-keymap (current-global-map)) kv ,keymap) + (setq unread-command-events + (mapcar (lambda (ev) (cons t ev)) + (listify-key-sequence kv))))))) + (defun renz/sort-by-alpha-length (elems) "Sort ELEMS first alphabetically, then by length." (sort elems (lambda (c1 c2) @@ -361,84 +380,95 @@ If REQUIRE is a non-nil value, require the package after adding it." ;;; Jabber -(use-package jabber - :load-path "~/src/jabber.el" - :defer t - :bind-keymap (("C-c j" . jabber-global-keymap)) - :preface nil - (setq-default jabber-chat-buffer-format "*%n*" - jabber-browse-buffer-format "*%n*" - jabber-groupchat-buffer-format "*%n*" - jabber-muc-private-buffer-format "*%n*") - :custom-face - (jabber-activity-face ((t :inherit jabber-chat-prompt-foreign - :foreground unspecified - :weight normal))) - (jabber-activity-personal-face ((t :inherit jabber-chat-prompt-local - :foreground unspecified - :weight bold))) - (jabber-chat-prompt-local ((t :inherit minibuffer-prompt - :foreground unspecified - :weight normal - :slant italic))) - (jabber-chat-prompt-foreign ((t :inherit warning - :foreground unspecified - :weight normal))) - (jabber-chat-prompt-system ((t :inherit font-lock-doc-face - :foreground unspecified))) - (jabber-rare-time-face ((t :inherit font-lock-comment-face - :foreground unspecified - :underline nil))) - :config +(ensure-package 'jabber t) +(add-to-list 'load-path + (expand-file-name "jabber-fallback-lib" + "~/src/jabber.el/")) + +(setopt jabber-chat-buffer-format "*%n*") +(setopt jabber-browse-buffer-format "*%n*") +(setopt jabber-groupchat-buffer-format "*%n*") +(setopt jabber-muc-private-buffer-format "*%n*") + +(face-spec-set 'jabber-activity-face + '((t :inherit jabber-chat-prompt-foreign + :foreground unspecified + :weight normal))) +(face-spec-set 'jabber-activity-personal-face + '((t :inherit jabber-chat-prompt-local + :foreground unspecified + :weight bold))) +(face-spec-set 'jabber-chat-prompt-local + '((t :inherit minibuffer-prompt + :foreground unspecified + :weight normal + :slant italic))) +(face-spec-set 'jabber-chat-prompt-foreign + '((t :inherit warning + :foreground unspecified + :weight normal))) +(face-spec-set 'jabber-chat-prompt-system + '((t :inherit font-lock-doc-face + :foreground unspecified))) +(face-spec-set 'jabber-rare-time-face + '((t :inherit font-lock-comment-face + :foreground unspecified + :underline nil))) + +(setopt jabber-auto-reconnect t) +(setopt jabber-last-read-marker "~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~") +(setopt jabber-muc-decorate-presence-patterns + '(("\\( enters the room ([^)]+)\\| has left the chatroom\\)$" . nil) + ("Mode #.*" . jabber-muc-presence-dim) + ("." . jabber-muc-presence-dim))) +(setopt jabber-activity-make-strings #'jabber-activity-make-strings-shorten) +(setopt jabber-rare-time-format + (format " - - - - - %%H:%d %%F" + (let ((min (string-to-number (format-time-string "%M")))) + (* 5 (floor min 5))))) +(setopt jabber-muc-header-line-format '(" " jabber-muc-topic)) + +(setopt jabber-groupchat-prompt-format "%n. ") +(setopt jabber-chat-local-prompt-format "%n. ") +(setopt jabber-chat-foreign-prompt-format "%n. ") +(setopt jabber-muc-private-foreign-prompt-format "%g/%n. ") + +(keymap-global-set "C-c C-SPC" #'jabber-activity-switch-to) +(with-eval-after-load 'jabber (require 'jabber-httpupload nil t) - (setopt jabber-auto-reconnect t - jabber-last-read-marker "~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~" - jabber-muc-decorate-presence-patterns - '(("\\( enters the room ([^)]+)\\| has left the chatroom\\)$" . nil) - ("Mode #.*" . jabber-muc-presence-dim) - ("." . jabber-muc-presence-dim)) - jabber-activity-make-strings #'jabber-activity-make-strings-shorten - jabber-rare-time-format - (format " - - - - - %%H:%d %%F" - (let ((min (string-to-number (format-time-string "%M")))) - (* 5 (floor min 5)))) - jabber-muc-header-line-format '(" " jabber-muc-topic)) - - (setopt jabber-groupchat-prompt-format "%n. " - jabber-chat-local-prompt-format "%n. " - jabber-chat-foreign-prompt-format "%n. " - jabber-muc-private-foreign-prompt-format "%g/%n. ") - - (keymap-global-set "C-c C-SPC" #'jabber-activity-switch-to) (map-keymap (lambda (key command) (define-key jabber-global-keymap (vector (+ key #x60)) command)) jabber-global-keymap) - (keymap-global-set "C-x C-j" #'dired-jump) - - (add-hook 'jabber-post-connect-hooks #'jabber-enable-carbons) - (remove-hook 'jabber-alert-muc-hooks 'jabber-muc-echo) - (remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo) - (add-hook 'jabber-chat-mode-hook 'visual-line-mode) - (add-hook 'jabber-chat-mode-hook (defun jabber-no-position () - (setq-local mode-line-position nil))) - (add-hook 'jabber-activity-mode-hook - (defun jabber-activity-no-global-mode () - (setq global-mode-string - (delete '(t jabber-activity-mode-string) - global-mode-string)))) - - (add-hook 'jabber-alert-muc-hooks - (defun jabber@highlight-acdw (&optional _ _ buf _ _) - (when buf - (with-current-buffer buf - (let ((regexp (rx word-boundary - "acdw" ; maybe get from the config? - word-boundary))) - (hi-lock-unface-buffer regexp) - (highlight-regexp regexp 'jabber-chat-prompt-local)))))) - - (when (fboundp 'jabber-chat-update-focus) - (add-hook 'window-configuration-change-hook #'jabber-chat-update-focus))) + (keymap-global-set "C-x C-j" #'dired-jump)) + +(keymap-global-set "C-c j" (autoload-keymap jabber-global-keymap jabber)) +(keymap-global-set "C-x C-j" #'dired-jump) + +(add-hook 'jabber-post-connect-hooks #'jabber-enable-carbons) +(remove-hook 'jabber-alert-muc-hooks 'jabber-muc-echo) +(remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo) +(add-hook 'jabber-chat-mode-hook 'visual-line-mode) + +(add-hook 'jabber-chat-mode-hook + (defun jabber-no-position () + (setq-local mode-line-position nil))) +(add-hook 'jabber-activity-mode-hook + (defun jabber-activity-no-global-mode () + (setq global-mode-string + (delete '(t jabber-activity-mode-string) + global-mode-string)))) +(add-hook 'jabber-alert-muc-hooks + (defun jabber@highlight-acdw (&optional _ _ buf _ _) + (when buf + (with-current-buffer buf + (let ((regexp (rx word-boundary + "acdw" ; maybe get from the config? + word-boundary))) + (hi-lock-unface-buffer regexp) + (highlight-regexp regexp 'jabber-chat-prompt-local)))))) + +(when (fboundp 'jabber-chat-update-focus) + (add-hook 'window-configuration-change-hook #'jabber-chat-update-focus)) ;;; Configuration: -- cgit 1.4.1-21-gabe81