From 47df2733de3f5e5ba8384cc4e11a31235a9cfc5b Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 28 Aug 2021 00:23:56 -0500 Subject: Buttonize major mode in modeline --- lisp/acdw-modeline.el | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index 5784148..00eb056 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el @@ -40,7 +40,35 @@ (defun acdw-modeline/god-mode-indicator () "Display an indicator if `god-local-mode' is active." (when (bound-and-true-p god-local-mode) - " God")) + " Ω")) + +(defun acdw-modeline/major-mode () + "Displays the current major mode in the mode-line." + (propertize + (concat " " + (or (and (boundp 'delighted-modes) + (cadr (assq major-mode delighted-modes))) + (format-mode-line mode-name))) + 'face 'bold + 'keymap mode-line-major-mode-keymap + 'mouse-face 'mode-line-highlight)) + +(defun acdw-modeline/minions () ; by me + "Display a button for `minions-minor-modes-menu'." + (concat + " " + (propertize + "&" + 'help-echo (format + "Minor modes menu\nmouse-1: show menu.") + 'local-map (purecopy (simple-modeline-make-mouse-map + 'mouse-1 + (lambda (event) + (interactive "e") + (with-selected-window (posn-window + (event-start event)) + (minions-minor-modes-menu))))) + 'mouse-face 'mode-line-highlight))) (defun acdw-modeline/modified () ; modified from `simple-modeline' "Displays a color-coded buffer modification/read-only -- cgit 1.4.1-21-gabe81 From 543186282747d1019c7f32a6a7c1c8cb627b5152 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 28 Aug 2021 00:25:26 -0500 Subject: Sort acdw-modeline.el --- lisp/acdw-modeline.el | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'lisp') diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index 00eb056..df2811f 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el @@ -22,6 +22,15 @@ (require 'simple-modeline) (require 'minions) +(defcustom acdw-modeline/word-count-modes + (mapcar (lambda (m) (cons m nil)) simple-modeline-word-count-modes) + "Alist of modes to functions that `acdw-modeline/word-count' should dispatch. +If the cdr of the cons cell is nil, use the default function (`count-words'). +Otherwise, cdr should be a function that takes two points (see `count-words')." + :type '(alist :key-type (symbol :tag "Major-Mode") + :value-type function) + :group 'simple-modeline) + (defun acdw-modeline/buffer-name () ; gonsie "Display the buffer name in a face reflecting its modified status." (propertize " %b " @@ -92,23 +101,6 @@ indicator in the mode-line." (read-only-mode 'toggle))))) 'mouse-face 'mode-line-highlight)))) -(defun acdw-modeline/minions () ; by me - "Display a button for `minions-minor-modes-menu'." - (concat - " " - (propertize - "&" - 'help-echo (format - "Minor modes menu\nmouse-1: show menu.") - 'local-map (purecopy (simple-modeline-make-mouse-map - 'mouse-1 - (lambda (event) - (interactive "e") - (with-selected-window (posn-window - (event-start event)) - (minions-minor-modes-menu))))) - 'mouse-face 'mode-line-highlight))) - (defun acdw-modeline/narrowed () "Display an indication if the buffer is narrowed." (when (buffer-narrowed-p) @@ -176,15 +168,6 @@ Only shows if there is more than one window." (> winum--window-count 1)) (format winum-format (winum-get-number-string)))) -(defcustom acdw-modeline/word-count-modes - (mapcar (lambda (m) (cons m nil)) simple-modeline-word-count-modes) - "Alist of modes to functions that `acdw-modeline/word-count' should dispatch. -If the cdr of the cons cell is nil, use the default function (`count-words'). -Otherwise, cdr should be a function that takes two points (see `count-words')." - :type '(alist :key-type (symbol :tag "Major-Mode") - :value-type function) - :group 'simple-modeline) - (defun acdw-modeline/word-count () "Display a buffer word count, depending on the major mode. Uses `acdw-modeline/word-count-modes' to determine which function to use." -- cgit 1.4.1-21-gabe81 From 497fe962a0a369cb3638b3aa2f3d50f566def46d Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 28 Aug 2021 00:25:59 -0500 Subject: Add ZNC stuff... *NOTE*: private.el has also been updated!!! --- lisp/acdw-erc.el | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'lisp') diff --git a/lisp/acdw-erc.el b/lisp/acdw-erc.el index e375c61..801e871 100644 --- a/lisp/acdw-erc.el +++ b/lisp/acdw-erc.el @@ -80,7 +80,7 @@ If USE-TLS is non-nil, use TLS." (dolist (buffer (filter-server-buffers)) (with-message (format "Reconnecting to server: %s" (buffer-name buffer)) (with-current-buffer buffer - (erc-server-reconnect))))) + (erc-cmd-RECONNECT))))) (defun erc/disconnect () "Disconnect from all IRC servers." @@ -183,11 +183,9 @@ erc-modified-channels-alist. Should be executed on window change." "Overlay used to set bar") (setq erc-bar-overlay (make-overlay 0 0)) - +(overlay-put erc-bar-overlay 'face '(:overline "gray")) (with-eval-after-load 'erc-track - (overlay-put erc-bar-overlay 'face '(:underline "gray")) - ;;put the hook before erc-modified-channels-update (defadvice erc-track-mode (after erc-bar-setup-hook (&rest args) activate) @@ -196,6 +194,35 @@ erc-modified-channels-alist. Should be executed on window change." (add-hook 'erc-send-completed-hook (lambda (str) (erc-bar-update-overlay)))) + +;;; ZNC babeee +;; needed variables are stored in private.el +(defun znc/connect (znc-server znc-port znc-nick irc-servers) + (interactive (let ((zserv (or znc/server + (read-string "ZNC Server: "))) + (zport (or znc/port + (read-number "ZNC Port: "))) + (znick (or znc/nick + (read-string "ZNC Nick: "))) + (servers (or znc/irc-servers + (list + (cons + (read-string "IRC Server to connect to: ") + (read-passwd "Password: ")))))) + (list zserv zport znick servers))) + (let ((si 0)) + (dolist (server irc-servers) + (run-at-time si nil + (lambda () + (erc-tls :server znc-server + :port znc-port + :nick znc-nick + :password (format "%s/%s:%s" + znc-nick + (car server) + (cdr server))))) + (setq si (1+ si))))) + (provide 'acdw-erc) ;;; acdw-erc.el ends here -- cgit 1.4.1-21-gabe81 From 782cc6e31b08d73dfe4b0770f0cf6a20fc9d9859 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 28 Aug 2021 23:08:17 -0500 Subject: Change to circe --- init.el | 76 ++++++++++++++++++++++++++++++++++++++++++++-- lisp/acdw-irc.el | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ lisp/acdw-modeline.el | 5 +++ 3 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 lisp/acdw-irc.el (limited to 'lisp') diff --git a/init.el b/init.el index e174823..5ab1559 100644 --- a/init.el +++ b/init.el @@ -323,6 +323,7 @@ (:option erc-auto-discard-away t + erc-auto-set-away t erc-autoaway-idle-seconds 600 erc-autoaway-message "BRB (autoaway: %i seconds)" erc-button-url-regexp browse-url-button-regexp @@ -333,7 +334,7 @@ erc-fill-static-center 14 erc-format-nick-function #'erc-format-truncate-@nick erc-header-line-face-method #'erc/update-header-line-show-disconnected - erc-hide-list '("NICK" "MODE" "JOIN" "PART" "QUIT") + erc-hide-list '("NICK" "MODE" "JOIN" "PART" "QUIT" "AWAY") erc-interpret-controls-p t erc-interpret-mirc-color t erc-join-buffer 'bury @@ -353,7 +354,9 @@ erc-server-coding-system '(utf-8 . utf-8) erc-timestamp-intangible t erc-track-exclude-types (append erc-hide-list - '("AWAY" + '("AWAY" ; for some reason this triggers + ; track anyway... so it's in + ; `erc-hide-list' "353" "324" "329" "332" "333" "477")) erc-track-exclude-server-buffer t erc-track-position-in-mode-line 'before-modes @@ -1109,6 +1112,74 @@ like a dumbass." (setup (:straight (beginend)) (beginend-global-mode +1)) +(setup (:straight circe) + (require 'circe) + (require 'acdw-irc) + + (setq acdw-irc/post-my-nick "-> ") + + (setq circe-default-part-message "See You, Space Cowpokes . . ." + circe-highlight-nick-type 'all + ;; circe-network-options in private.el + circe-reduce-lurker-spam t + circe-server-auto-join-default-type :after-auth) + + (add-hook 'circe-chat-mode-hook + (defun circe-chat@setup () + (lui-set-prompt + (concat (propertize (acdw-irc/margin-format (buffer-name) + "" + ">") + 'face 'circe-prompt-face + 'read-only t 'intangible t + 'cursor-intangible t) + " ")) + (enable-circe-color-nicks) + (enable-circe-display-images) + (enable-circe-new-day-notifier))) + + (setq circe-format-say (format "%s%s%d%s%s%s" + acdw-irc/pre-nick + "{nick:" + (- acdw-irc/left-margin 1 + (+ (length acdw-irc/pre-nick) + (length acdw-irc/post-nick))) + "s} " + acdw-irc/post-nick + "{body}") + circe-format-self-say (format "%s%s%d%s%s%s" + acdw-irc/pre-my-nick + "{nick:" + (- acdw-irc/left-margin 1 + (+ (length acdw-irc/pre-my-nick) + (length acdw-irc/post-my-nick))) + "s} " + acdw-irc/post-my-nick + "{body}") + circe-format-action (concat "*" + (repeat-string (- acdw-irc/left-margin 3) + " ") + "* {nick} {body}") + circe-format-self-action (concat "-*" + (repeat-string (- acdw-irc/left-margin 4) + " ") + "* {nick} {body}") + lui-fill-type (concat + (repeat-string (- acdw-irc/left-margin 2) + " ") + " ")) + + (setq lui-time-stamp-position 'right-margin + lui-time-stamp-format "%H:%M") + (add-hook 'lui-mode-hook + (defun lui-mode@setup () + (setq right-margin-width 5 + scroll-margin 0 + fringes-outside-margins t + word-wrap t + wrap-prefix (repeat-string + (1+ acdw-irc/left-margin) " "))))) + (setup (:straight (consult :host github :repo "minad/consult")) @@ -1696,6 +1767,7 @@ successive invocations." acdw-modeline/wc acdw-modeline/text-scale simple-modeline-segment-process + acdw-modeline/track acdw-modeline/god-mode-indicator acdw-modeline/winum acdw-modeline/minions diff --git a/lisp/acdw-irc.el b/lisp/acdw-irc.el new file mode 100644 index 0000000..193275c --- /dev/null +++ b/lisp/acdw-irc.el @@ -0,0 +1,84 @@ +;;; acdw-irc.el -*- lexical-binding: t; coding: utf-8-unix -*- + +(require 's nil :noerror) + +(defgroup acdw-irc nil + "Customizations for IRC." + :group 'applications) + +(defcustom acdw-irc/left-margin 16 + "The size of the margin for nicks, etc. on the left." + :type 'integer) + +(defcustom acdw-irc/pre-nick "" + "What to show before a nick." + :type 'string) + +(defcustom acdw-irc/post-nick " | " + "What to show after a nick." + :type 'string) + +(defcustom acdw-irc/pre-my-nick "-" + "What to show before the current user's nick." + :type 'string) + +(defcustom acdw-irc/post-my-nick "-> " + "What to show after the current user's nick." + :type 'string) + +(defcustom acdw-irc/ellipsis "~" + "The ellipsis for when a string is too long." + :type 'string) + + +;;; Convenience functions (I don't want to /depend/ on s.el) + +(if (fboundp 's-repeat) + (defalias 'repeat-string 's-repeat) + (defun repeat-string (num s) + "Make a string of STR repeated NUM times. +Stolen from s.el." + (declare (pure t) (side-effect-free t)) + (let (ss) + (while (> num 0) + (setq ss (cons str ss) + num (1- num))) + (apply #'concat ss)))) + +(if (fboundp 's-truncate) + (defalias 'truncate-string 's-truncate) + (defun truncate-string (len s &optional ellipsis) + "If STR is longer than LEN, cut it down and add ELLIPSIS to the end. +When not specified, ELLIPSIS defaults to '...'." + (declare (pure t) (side-effect-free t)) + (unless ellipsis + (setq ellipsis "...")) + (if (> (length s) len) + (format "%s%s" (substring s 0 (- len (length ellipsis))) ellipsis) + s))) + + +;;; IRC stuff + +(defun acdw-irc/margin-format (str &optional before after alignment) + "Print STR to fit in `acdw-irc/left-margin'. +Optional arguments BEFORE and AFTER specify strings to go +... before and after the string. ALIGNMENT aligns left on nil +and right on t." + (let* ((before (or before "")) + (after (or after "")) + (str-length (length str)) + (before-length (length before)) + (after-length (length after)) + (max-length (- acdw-irc/left-margin 1 (+ before-length after-length))) + (left-over (max 0 (- max-length str-length)))) + (format "%s%s%s%s%s" + before + (if alignment (repeat-string left-over " ") "") + (truncate-string max-length str acdw-irc/ellipsis) + (if alignment "" (repeat-string left-over " ")) + after))) + + +(provide 'acdw-irc) +;;; acdw-irc.el ends here diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index df2811f..6a11418 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el @@ -155,6 +155,11 @@ is, if point < mark." " (%-d)") text-scale-mode-amount))) +(defun acdw-modeline/track () + "Display `tracking-mode' information." + (when tracking-mode + tracking-mode-line-buffers)) + (defun acdw-modeline/vc-branch () "Display the version control branch of the current buffer in the modeline." ;; from https://www.gonsie.com/blorg/modeline.html, from Doom -- cgit 1.4.1-21-gabe81 From 58846be1749d7a915a11e977fab57c022451131f Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 28 Aug 2021 23:09:06 -0500 Subject: Ignore errors --- lisp/acdw-erc.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/acdw-erc.el b/lisp/acdw-erc.el index 801e871..dd8525d 100644 --- a/lisp/acdw-erc.el +++ b/lisp/acdw-erc.el @@ -78,8 +78,8 @@ If USE-TLS is non-nil, use TLS." "Reconnect to all IRC servers." (interactive) (dolist (buffer (filter-server-buffers)) - (with-message (format "Reconnecting to server: %s" (buffer-name buffer)) - (with-current-buffer buffer + (with-current-buffer buffer + (ignore-errors (erc-cmd-RECONNECT))))) (defun erc/disconnect () -- cgit 1.4.1-21-gabe81