I'm using general.el and evil-mode in #Emacs. I'm trying to write a basic man pager.
(defun open-man-page (program)
"Open the man page for the specified PROGRAM in the terminal."
(progn
;; Close any existing man page buffers (with the pattern *Man *).
(dolist (buf (buffer-list))
(when (string-match-p "^\\*Man " (buffer-name buf)) ;; Match any *Man * buffer
(kill-buffer buf)))
;; Open the man page without interactive prompts
(man program)))
(defun quit-man-page ()
"Quit the *Man * buffer if it exists."
(interactive)
(let ((man-buffer (cl-find-if (lambda (buf)
(string-match-p "^\\*Man " (buffer-name buf))) ;; Match any *Man buffer
(buffer-list)))) ;; Check all buffers
(if man-buffer
(progn
;; (kill-buffer man-buffer) ;; Kill the *Man * buffer
(Man-kill)
(execute-kbd-macro (kbd "C-x C-c")))
(message "No man page buffer found"))))
(add-hook 'Man-mode-hook #'center-document-mode)
This is what I have so far. I want to bind q to close the pager (i.e execute quit-man-page). No matter how I try to bind it, q is set to quit-window.
Any ideas? How do i get this working?
Embed Notice
HTML Code
Corresponding Notice
- Embed this notice
ZeStig (zstg@fedia.social)'s status on Thursday, 26-Dec-2024 17:09:03 JST ZeStig