Compare commits
No commits in common. "615f0e4ca59278f78d01b8fe7a13dd0c435a3737" and "cbf4d0326fa411a75a79084e95af3aedd5bc1523" have entirely different histories.
615f0e4ca5
...
cbf4d0326f
6 changed files with 44 additions and 211 deletions
106
catchup.el
106
catchup.el
|
@ -1,106 +0,0 @@
|
||||||
;;; catchup.el --- catch up with system stats -*- lexical-binding:t -*-
|
|
||||||
|
|
||||||
;; Copyright (C) 2024 Jeremy Baxter
|
|
||||||
|
|
||||||
;; Author: Jeremy Baxter <jeremy@baxters.nz>
|
|
||||||
;; Maintainer: Jeremy Baxter <jeremy@baxters.nz>
|
|
||||||
;; Created: July 2024
|
|
||||||
|
|
||||||
;; This file is not part of GNU Emacs.
|
|
||||||
|
|
||||||
;; catchup.el is free software: you can redistribute it and/or modify
|
|
||||||
;; it under the terms of the GNU General Public License as published by
|
|
||||||
;; the Free Software Foundation, either version 3 of the License, or
|
|
||||||
;; (at your option) any later version.
|
|
||||||
;;
|
|
||||||
;; catchup.el is distributed in the hope that it will be useful,
|
|
||||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
;; GNU General Public License for more details.
|
|
||||||
;;
|
|
||||||
;; You should have received a copy of the GNU General Public License
|
|
||||||
;; along with catchup.el. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
;;; Commentary:
|
|
||||||
|
|
||||||
;; catchup.el provides `catchup', a command for fetching system
|
|
||||||
;; stats or other information. Custom shell commands can be run
|
|
||||||
;; or a file can be read, and that information is then formatted
|
|
||||||
;; and displayed in the minibuffer. The output style and look can
|
|
||||||
;; be customized with `catchup-spec' and `catchup-separator'.
|
|
||||||
|
|
||||||
;; TODO: add a memory statistic using `memory-info'
|
|
||||||
|
|
||||||
;;; Code:
|
|
||||||
|
|
||||||
(defvar catchup-buffer "*Catchup*"
|
|
||||||
"Temporary buffer used by `catchup' types.")
|
|
||||||
|
|
||||||
(defvar catchup-separator "\t"
|
|
||||||
"Separator between `catchup' data.")
|
|
||||||
|
|
||||||
(defvar catchup-spec '((format-time-string "%Y/%m/%d\n%T"))
|
|
||||||
"List representing data to show in `catchup'.
|
|
||||||
|
|
||||||
Each element is a list: the car of each sublist being a symbol representing
|
|
||||||
the function to call, and the cdr being the rest of the arguments to pass
|
|
||||||
to said function.
|
|
||||||
|
|
||||||
catchup.el provides some helper functions you can use; `catchup-file' and
|
|
||||||
`catchup-shell', which are primitives, and `catchup-battery', a helper
|
|
||||||
function built from the primitives.
|
|
||||||
|
|
||||||
The default value represents a call to `format-time-string', which shows
|
|
||||||
the current date and time.")
|
|
||||||
|
|
||||||
(defun catchup--strip (str)
|
|
||||||
(string-match "\\`\\s-*\\(.*?\\)\\s-*\n?\\'" str)
|
|
||||||
(match-string 1 str))
|
|
||||||
|
|
||||||
(defun catchup-file (file-name)
|
|
||||||
"Return the contents of the file FILE-NAME."
|
|
||||||
(let*
|
|
||||||
((result nil)
|
|
||||||
(exists (get-file-buffer file-name))
|
|
||||||
(buffer (if exists exists (find-file-noselect file-name))))
|
|
||||||
(with-current-buffer buffer
|
|
||||||
(setq result (buffer-string))
|
|
||||||
(unless exists
|
|
||||||
(kill-this-buffer)))
|
|
||||||
(catchup--strip result)))
|
|
||||||
|
|
||||||
(defun catchup-battery (&optional battery-format)
|
|
||||||
"Return the battery capacity formatted according to BATTERY-FORMAT."
|
|
||||||
(format (or battery-format "%s")
|
|
||||||
(catchup-file "/sys/class/power_supply/BAT0/capacity")))
|
|
||||||
|
|
||||||
(defun catchup-shell (command)
|
|
||||||
"Return the output of running COMMAND in the shell."
|
|
||||||
(let ((result nil))
|
|
||||||
(shell-command command catchup-buffer)
|
|
||||||
(with-current-buffer catchup-buffer
|
|
||||||
(setq result (buffer-string))
|
|
||||||
(kill-this-buffer))
|
|
||||||
result))
|
|
||||||
|
|
||||||
(defun catchup ()
|
|
||||||
"Display system statistics.
|
|
||||||
|
|
||||||
Only information in `catchup-spec' is displayed; see its documentation for
|
|
||||||
more information on configuring it.
|
|
||||||
|
|
||||||
A separator or divider to divide information can be provided with
|
|
||||||
`catchup-separator'. This string is placed between every result."
|
|
||||||
(interactive)
|
|
||||||
(let
|
|
||||||
((final ""))
|
|
||||||
(dolist (sublist catchup-spec)
|
|
||||||
(setq final
|
|
||||||
(concat final (catchup--strip
|
|
||||||
(apply (car sublist) (cdr sublist)))
|
|
||||||
catchup-separator)))
|
|
||||||
(message "%s" (catchup--strip final))))
|
|
||||||
|
|
||||||
(provide 'catchup)
|
|
||||||
|
|
||||||
;;; catchup.el ends here
|
|
11
enotify.el
11
enotify.el
|
@ -22,19 +22,14 @@
|
||||||
;; You should have received a copy of the GNU General Public License
|
;; You should have received a copy of the GNU General Public License
|
||||||
;; along with enotify.el. If not, see <https://www.gnu.org/licenses/>.
|
;; along with enotify.el. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
;;; Commentary:
|
|
||||||
|
|
||||||
;; enotify.el provides `enotify', a command for connecting to an IRC
|
|
||||||
;; server, joining a channel, sending a message, and then leaving.
|
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(defvar enotify-buffer "*enotify*"
|
(defvar enotify-buffer "*enotify*"
|
||||||
"Name of the `enotify' process buffer.")
|
"Name of the enotify process buffer")
|
||||||
(defvar enotify-proc "enotify-process"
|
(defvar enotify-proc "enotify-process"
|
||||||
"Name of the `enotify' socket process.")
|
"Name of the enotify socket process")
|
||||||
(defvar enotify-realname "enotify-client"
|
(defvar enotify-realname "enotify-client"
|
||||||
"IRC realname for `enotify' that shows up in /whois.")
|
"enotify's IRC realname that shows up in /whois")
|
||||||
|
|
||||||
(defun enotify-send-string (proc string)
|
(defun enotify-send-string (proc string)
|
||||||
(process-send-string proc (concat string "\r\n")))
|
(process-send-string proc (concat string "\r\n")))
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
;; This is a modified version of erc-highlight-nicknames.el from
|
;; This is a modified version of erc-highlight-nicknames.el from
|
||||||
;; <https://emacswiki.org/emacs/erc-highlight-nicknames.el>. It has been
|
;; <https://emacswiki.org/emacs/erc-highlight-nicknames.el>. It has been
|
||||||
;; extended to use the configured ERC colour palette, using the faces
|
;; extended to use the configured ERC colour palette, using the faces
|
||||||
;; with names beginning with `fg:erc-color-face'.
|
;; with names beginning with `fg:erc-color-face'.
|
||||||
;;
|
;;
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
;; for a list of these faces.
|
;; for a list of these faces.
|
||||||
|
|
||||||
;; Originally authored by André Riemann in 2007 and updated from 2008-2014
|
;; Originally authored by André Riemann in 2007 and updated from 2008-2014
|
||||||
;; by Andy Stewart. ERC face support was added by Jeremy Baxter in 2023.
|
;; by Andy Stewart. ERC face support was added by Jeremy Baxter in 2023.
|
||||||
|
|
||||||
;; To use erc-highlight-nicknames.el, put this in your init file:
|
;; To use erc-highlight-nicknames.el, put this in your init file:
|
||||||
;;
|
;;
|
||||||
|
@ -108,7 +108,8 @@
|
||||||
|
|
||||||
(defface erc-highlight-nick-base-face
|
(defface erc-highlight-nick-base-face
|
||||||
'((t nil))
|
'((t nil))
|
||||||
"Face used for highlighting nicknames before color is added."
|
"Base face used for highlighting nicknames in ERC before the
|
||||||
|
color is added."
|
||||||
:group 'erc-faces)
|
:group 'erc-faces)
|
||||||
|
|
||||||
(defvar erc-highlight-face-table
|
(defvar erc-highlight-face-table
|
||||||
|
@ -116,7 +117,7 @@
|
||||||
"Hash table containing unique ERC nickname faces.")
|
"Hash table containing unique ERC nickname faces.")
|
||||||
|
|
||||||
(defun hexcolor-luminance (color)
|
(defun hexcolor-luminance (color)
|
||||||
"Return the luminance of color COLOR. COLOR is a string \(e.g.
|
"Returns the luminance of color COLOR. COLOR is a string \(e.g.
|
||||||
\"#ffaa00\", \"blue\"\) `color-values' accepts. Luminance is a
|
\"#ffaa00\", \"blue\"\) `color-values' accepts. Luminance is a
|
||||||
value of 0.299 red + 0.587 green + 0.114 blue and is always
|
value of 0.299 red + 0.587 green + 0.114 blue and is always
|
||||||
between 0 and 255."
|
between 0 and 255."
|
||||||
|
@ -127,7 +128,7 @@ between 0 and 255."
|
||||||
(floor (+ (* 0.299 r) (* 0.587 g) (* 0.114 b)) 256)))
|
(floor (+ (* 0.299 r) (* 0.587 g) (* 0.114 b)) 256)))
|
||||||
|
|
||||||
(defun invert-color (color)
|
(defun invert-color (color)
|
||||||
"Return the inverted color of COLOR."
|
"Returns the inverted color of COLOR."
|
||||||
(let* ((values (x-color-values color))
|
(let* ((values (x-color-values color))
|
||||||
(r (car values))
|
(r (car values))
|
||||||
(g (car (cdr values)))
|
(g (car (cdr values)))
|
||||||
|
|
57
esv.el
57
esv.el
|
@ -1,4 +1,4 @@
|
||||||
;;; esv.el --- read the Bible -*- lexical-binding:t -*-
|
;;; esv.el --- read the Bible from Emacs -*- lexical-binding:t -*-
|
||||||
|
|
||||||
;; Copyright (C) 2024 Jeremy Baxter
|
;; Copyright (C) 2024 Jeremy Baxter
|
||||||
|
|
||||||
|
@ -41,23 +41,24 @@
|
||||||
|
|
||||||
(defcustom esv-close-existing-buffers nil
|
(defcustom esv-close-existing-buffers nil
|
||||||
"Whether to close an existing `esv' buffer if one already exists."
|
"Whether to close an existing `esv' buffer if one already exists."
|
||||||
:type 'boolean)
|
:type 'boolean
|
||||||
|
:group 'esv)
|
||||||
(defcustom esv-columns 72
|
(defcustom esv-columns 72
|
||||||
"Length of each line output by `esv'."
|
"Length of each line output by `esv'."
|
||||||
:type 'natnum)
|
:type 'natnum
|
||||||
|
:group 'esv)
|
||||||
(defcustom esv-mode-hook nil
|
(defcustom esv-mode-hook nil
|
||||||
"Hook run after entering `esv-mode'."
|
"Hook run after entering `esv-mode'."
|
||||||
:type 'hook)
|
:type 'hook
|
||||||
|
:group 'esv)
|
||||||
(defcustom esv-process "esv"
|
(defcustom esv-process "esv"
|
||||||
"Name of the process created by `esv'."
|
"Name of the process created by `esv'."
|
||||||
:type 'string)
|
:type 'string
|
||||||
|
:group 'esv)
|
||||||
(defcustom esv-program "esv"
|
(defcustom esv-program "esv"
|
||||||
"Path to or name of the program started by `esv'."
|
"Path to or name of the program started by `esv'."
|
||||||
:type 'string)
|
:type 'string
|
||||||
|
:group 'esv)
|
||||||
|
|
||||||
(defvar esv-arguments '()
|
(defvar esv-arguments '()
|
||||||
"List of additional arguments passed to `esv-program'.")
|
"List of additional arguments passed to `esv-program'.")
|
||||||
|
@ -68,35 +69,31 @@
|
||||||
|
|
||||||
(read-only-mode))
|
(read-only-mode))
|
||||||
|
|
||||||
(defun esv (passage)
|
(defun esv (book verses)
|
||||||
"Fetch the Bible passage identified by PASSAGE.
|
"Fetch the Bible passage identified by BOOK and VERSES.
|
||||||
The result will be redirected to a buffer named after PASSAGE.
|
The result will be redirected to a buffer named after the passage.
|
||||||
|
|
||||||
Requires the esv command line tool to be in the system's PATH.
|
Requires the esv command line tool to be in the system's PATH.
|
||||||
esv can be acquired at <https://sr.ht/~jeremy/esv>."
|
esv can be acquired at <https://sr.ht/~jeremy/esv>."
|
||||||
(interactive "MPassage: ")
|
(interactive "MBook: \nMVerses: ")
|
||||||
(let*
|
(let
|
||||||
((slices (split-string passage))
|
((buffer (concat book " " verses))
|
||||||
(verses (car (last slices)))
|
|
||||||
(book (mapconcat #'(lambda (e) e)
|
|
||||||
(take (1- (length slices)) slices) " "))
|
|
||||||
(buffer (concat book " " verses))
|
|
||||||
(arg-list (append esv-arguments
|
(arg-list (append esv-arguments
|
||||||
(list (format "-l%d" esv-columns))
|
(list (format "-l%d" esv-columns)))))
|
||||||
(list book) (list verses))))
|
|
||||||
(catch 'buffer-exists
|
(catch 'buffer-exists
|
||||||
(when (get-buffer buffer)
|
(when (get-buffer buffer)
|
||||||
(unless esv-close-existing-buffers
|
(unless esv-close-existing-buffers
|
||||||
(message "Buffer `%s' already exists" buffer)
|
(message "Buffer `%s' already exists" buffer)
|
||||||
(throw 'buffer-exists nil))
|
(throw 'buffer-exists nil))
|
||||||
(kill-buffer buffer)))
|
(kill-buffer buffer))
|
||||||
(apply #'call-process esv-program nil buffer t arg-list)
|
(apply #'call-process esv-program nil buffer t
|
||||||
(display-buffer buffer)
|
(append arg-list (list book) (list verses)))
|
||||||
(with-current-buffer buffer
|
(display-buffer buffer)
|
||||||
(esv-mode)
|
(with-current-buffer buffer
|
||||||
(goto-char (point-min)))
|
(esv-mode)
|
||||||
(set-window-start (get-buffer-window buffer) (point-min)))
|
(goto-char (point-min)))
|
||||||
t)
|
(set-window-start (get-buffer-window buffer) (point-min))
|
||||||
|
t)))
|
||||||
|
|
||||||
(provide 'esv)
|
(provide 'esv)
|
||||||
|
|
||||||
|
|
57
ini-mode.el
57
ini-mode.el
|
@ -1,57 +0,0 @@
|
||||||
;;; ini-mode.el --- major mode for INI -*- lexical-binding:t -*-
|
|
||||||
|
|
||||||
;; Copyright (C) 2024 Jeremy Baxter
|
|
||||||
|
|
||||||
;; Author: Jeremy Baxter <jeremy@baxters.nz>
|
|
||||||
;; Maintainer: Jeremy Baxter <jeremy@baxters.nz>
|
|
||||||
;; Created: July 2024
|
|
||||||
;; Keywords: ini
|
|
||||||
|
|
||||||
;; This file is not part of GNU Emacs.
|
|
||||||
|
|
||||||
;; ini-mode.el is free software: you can redistribute it and/or modify
|
|
||||||
;; it under the terms of the GNU General Public License as published by
|
|
||||||
;; the Free Software Foundation, either version 3 of the License, or
|
|
||||||
;; (at your option) any later version.
|
|
||||||
;;
|
|
||||||
;; ini-mode.el is distributed in the hope that it will be useful,
|
|
||||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
;; GNU General Public License for more details.
|
|
||||||
;;
|
|
||||||
;; You should have received a copy of the GNU General Public License
|
|
||||||
;; along with ini-mode.el. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
;;; Commentary:
|
|
||||||
|
|
||||||
;; ini-mode.el provides `ini-mode', an implementation of a simple
|
|
||||||
;; font-locking major mode for INI.
|
|
||||||
|
|
||||||
;;; Code:
|
|
||||||
|
|
||||||
(require 'font-lock)
|
|
||||||
|
|
||||||
(defvar ini-mode-font-lock-keywords
|
|
||||||
'(("\\([#;].*$\\)" . font-lock-comment-face)
|
|
||||||
("\\[\\(.+\\)\\]" 1 'font-lock-type-face)
|
|
||||||
("\\(^.+\\)=" 1 'font-lock-variable-name-face)
|
|
||||||
("=\\(.+$\\)" 1 'font-lock-string-face)
|
|
||||||
("\\(\\$?{\\)\\(.+\\)\\(}\\)"
|
|
||||||
(1 'font-lock-bracket-face t)
|
|
||||||
(2 'font-lock-variable-use-face t)
|
|
||||||
(3 'font-lock-bracket-face t))
|
|
||||||
("\\(%\\)\\(.+\\)\\(%\\)"
|
|
||||||
(1 'font-lock-bracket-face t)
|
|
||||||
(2 'font-lock-variable-use-face t)
|
|
||||||
(3 'font-lock-bracket-face t)))
|
|
||||||
"Keywords for font locking in `ini-mode'.")
|
|
||||||
|
|
||||||
(define-derived-mode ini-mode nil "INI"
|
|
||||||
"Major mode for editing INI."
|
|
||||||
|
|
||||||
(font-lock-mode)
|
|
||||||
(font-lock-add-keywords nil ini-mode-font-lock-keywords))
|
|
||||||
|
|
||||||
(provide 'ini-mode)
|
|
||||||
|
|
||||||
;;; ini-mode.el ends here
|
|
13
phobos.el
13
phobos.el
|
@ -1,4 +1,4 @@
|
||||||
;;; phobos.el --- view Phobos documentation -*- lexical-binding:t -*-
|
;;; phobos.el --- view Phobos documentation from within Emacs -*- lexical-binding:t -*-
|
||||||
|
|
||||||
;; Copyright (C) 2024 Jeremy Baxter
|
;; Copyright (C) 2024 Jeremy Baxter
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
;; phobos.el provides several functions for viewing Phobos documentation
|
;; phobos.el provides several functions for viewing Phobos documentation
|
||||||
;; and documentation for other D libraries. These functions open the
|
;; and documentation for other D libraries. These functions open the
|
||||||
;; documentation in a web browser, calling the process `phobos-browser'.
|
;; documentation in a web browser, calling the process `phobos-browser'.
|
||||||
|
|
||||||
;; These functions are provided:
|
;; These functions are provided:
|
||||||
|
@ -43,19 +43,22 @@
|
||||||
|
|
||||||
(defcustom phobos-browser "xdg-open"
|
(defcustom phobos-browser "xdg-open"
|
||||||
"Web browser to use when opening documentation with `phobos'."
|
"Web browser to use when opening documentation with `phobos'."
|
||||||
|
:group 'phobos
|
||||||
:type 'string)
|
:type 'string)
|
||||||
(defcustom phobos-root "https://dlang.org/library"
|
(defcustom phobos-root "https://dlang.org/library"
|
||||||
"Root URL to use when viewing documentation with `phobos'."
|
"Root URL to use when viewing documentation with `phobos'."
|
||||||
|
:group 'phobos
|
||||||
:type 'string)
|
:type 'string)
|
||||||
(defcustom phobos-dpldocs-domain "dpldocs.info"
|
(defcustom phobos-dpldocs-domain "dpldocs.info"
|
||||||
"Root domain to use when viewing documentation on dub packages with `dub-doc'."
|
"Root domain to use when viewing documentation on dub packages with `dub-doc'."
|
||||||
|
:group 'phobos
|
||||||
:type 'string)
|
:type 'string)
|
||||||
(defcustom phobos-registry-root "https://code.dlang.org"
|
(defcustom phobos-registry-root "https://code.dlang.org"
|
||||||
"Root URL of the D package registry used with `describe-dub-package'."
|
"Root URL of the D package registry used with `describe-dub-package'."
|
||||||
|
:group 'phobos
|
||||||
:type 'string)
|
:type 'string)
|
||||||
|
|
||||||
(defun phobos--visit (&rest format-args)
|
(defun phobos--visit (&rest format-args)
|
||||||
"Call `format' with FORMAT-ARGS and pass the result to a web browser."
|
|
||||||
(let ((url (apply #'format format-args)))
|
(let ((url (apply #'format format-args)))
|
||||||
(shell-command (concat phobos-browser " " url))
|
(shell-command (concat phobos-browser " " url))
|
||||||
(message url)))
|
(message url)))
|
||||||
|
@ -68,7 +71,7 @@ SYMBOL can be a module (e.g. std.sumtype), a submodule (e.g.
|
||||||
std.algorithm.searching), a function or type (e.g. std.stdio.File)
|
std.algorithm.searching), a function or type (e.g. std.stdio.File)
|
||||||
or any other symbol part of a standard module, such as object.Exception.
|
or any other symbol part of a standard module, such as object.Exception.
|
||||||
|
|
||||||
Phobos is the standard library for the D programming language. For more
|
Phobos is the standard library for the D programming language. For more
|
||||||
information on Phobos and the D programming language, see <https://dlang.org>."
|
information on Phobos and the D programming language, see <https://dlang.org>."
|
||||||
(interactive "MModule or symbol: ")
|
(interactive "MModule or symbol: ")
|
||||||
(phobos--visit "%s/%s.html" phobos-root (string-replace "." "/" symbol)))
|
(phobos--visit "%s/%s.html" phobos-root (string-replace "." "/" symbol)))
|
||||||
|
@ -78,7 +81,7 @@ information on Phobos and the D programming language, see <https://dlang.org>."
|
||||||
"View the documentation on SYMBOL from the dub package PACKAGE.
|
"View the documentation on SYMBOL from the dub package PACKAGE.
|
||||||
|
|
||||||
PACKAGE is the name of a package listed on the code.dlang.org registry.
|
PACKAGE is the name of a package listed on the code.dlang.org registry.
|
||||||
For more information on SYMBOL, see the documentation for `phobos'. If
|
For more information on SYMBOL, see the documentation for `phobos'. If
|
||||||
SYMBOL is not provided, the contents of PACKAGE is displayed instead.
|
SYMBOL is not provided, the contents of PACKAGE is displayed instead.
|
||||||
|
|
||||||
Support for dub package documentation is provided by Adam Ruppe's
|
Support for dub package documentation is provided by Adam Ruppe's
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue