summaryrefslogtreecommitdiff
path: root/lisp/man-wrapper/man-wrapper.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/man-wrapper/man-wrapper.el')
-rw-r--r--lisp/man-wrapper/man-wrapper.el36
1 files changed, 0 insertions, 36 deletions
diff --git a/lisp/man-wrapper/man-wrapper.el b/lisp/man-wrapper/man-wrapper.el
deleted file mode 100644
index 56544c3..0000000
--- a/lisp/man-wrapper/man-wrapper.el
+++ /dev/null
@@ -1,36 +0,0 @@
-(defun man-wrapper-find-pages ()
- (let* ((manpath (getenv "MANPATH"))
- (directories (split-string manpath ":" t))
- (that-exist (seq-filter 'file-exists-p directories))
- (files (mapcar (lambda (d)
- (directory-files-recursively d ".*" nil))
- that-exist))
- (flattened (flatten-list files))
- (pages (mapcar 'file-name-nondirectory flattened))
- (without-second-ext (mapcar (lambda (p)
- (let ((extension (file-name-extension p)))
- (if (string-match-p "^[0-9+]$" extension)
- p
- (file-name-sans-extension p))))
- pages)))
- without-second-ext))
-
-(defun man-wrapper-locate-page (page)
- (with-temp-buffer
- (let ((exit-code (call-process "man" nil (current-buffer) nil "--where" page)))
- (when exit-code
- (let* ((output (buffer-string))
- (trimmed (string-trim-right output "\n")))
- trimmed)))))
-
-(defun man-wrapper (orig &rest args)
- (interactive)
- (let* ((arg (if args
- (nth 0 args)
- (completing-read "Select page: " (man-wrapper-find-pages))))
- (page (man-wrapper-locate-page arg)))
- (funcall orig page)))
-
-(advice-add 'man :around 'man-wrapper)
-
-(provide 'man-wrapper)