From 995f9988729e50958eb13d2ac9cba3cb092f37fd Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 25 Jan 2022 16:57:30 -0600 Subject: Fix finger --- init.el | 5 +++++ lisp/+finger.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 lisp/+finger.el diff --git a/init.el b/init.el index 2a6dab5..88102be 100644 --- a/init.el +++ b/init.el @@ -431,6 +431,11 @@ (global-set-key (vector 'right-margin click) 'mwheel-scroll) (global-set-key (vector 'left-margin click) 'mwheel-scroll))) +(setup net-utils + (:require +finger) ; fixes `finger' to use var below + (:option finger-X.500-host-regexps '(".") ; only send username + )) + (setup org ;; Plain org with the `setup' form for sorting, but I install with straight. (:straight (org diff --git a/lisp/+finger.el b/lisp/+finger.el new file mode 100644 index 0000000..1a878bc --- /dev/null +++ b/lisp/+finger.el @@ -0,0 +1,46 @@ +;;; +finger.el --- Finger bugfix -*- lexical-binding: t; -*- + +;;; Commentary: + +;; `net-utils' defines `finger', which purportedly consults +;; `finger-X.500-host-regexps' to determine what hosts to only send a username +;; to. I've found that that is not the case, and so I've patched it. At some +;; point I'll submit this to Emacs itself. + +;;; Code: + +(require 'net-utils) ; this requires everything else I'll need. +(require 'seq) + +(defun finger (user host) + "Finger USER on HOST. +This command uses `finger-X.500-host-regexps' +and `network-connection-service-alist', which see." + ;; One of those great interactive statements that's actually + ;; longer than the function call! The idea is that if the user + ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the + ;; host name. If we don't see an "@", we'll prompt for the host. + (interactive + (let* ((answer (read-from-minibuffer "Finger User: " + (net-utils-url-at-point))) + (index (string-match (regexp-quote "@") answer))) + (if index + (list (substring answer 0 index) + (substring answer (1+ index))) + (list answer + (read-from-minibuffer "At Host: " + (net-utils-machine-at-point)))))) + (let* ((user-and-host (concat user "@" host)) + (process-name (concat "Finger [" user-and-host "]")) + (regexps finger-X.500-host-regexps) + ) ;; found + (when (seq-some (lambda (r) (string-match-p r host)) regexps) + (setq user-and-host user)) + (run-network-program + process-name + host + (cdr (assoc 'finger network-connection-service-alist)) + user-and-host))) + +(provide '+finger) +;;; +finger.el ends here -- cgit 1.4.1-21-gabe81