about summary refs log tree commit diff stats
path: root/lisp/+finger.el
blob: 1a878bcb9461d0fe91e7a6eefc3a90584a816f7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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