67 lines
1.8 KiB
EmacsLisp
67 lines
1.8 KiB
EmacsLisp
;;; man-plus.el --- Fix the ugly emacs manpages
|
|
|
|
;;; Commentary:
|
|
;; Loosely based on neovim's `man.vim' functionality.
|
|
;;
|
|
;; Feature goals:
|
|
;; - MANWIDTH based on size of new window
|
|
;; - Lots of different colors for headings, options,
|
|
;; sh snippets, etc
|
|
|
|
;;; Code:
|
|
|
|
(defvar man-plus-highlights
|
|
(let* (
|
|
(manReference "[^()[:space:]]\\+(\\%([0-9][a-z]*\\|[nlpox]\\))")
|
|
(manSectionHeading "^\\S.*$")
|
|
(manHeader "^\\%1l.*$")
|
|
(manSubHeading "^ \\{3\\}\\S.*$")
|
|
(manOptionDesc "^\\s\\+\\%(+\\|-\\)\\S\\+"))
|
|
`(
|
|
(,manReference . 'link)
|
|
(,manSectionHeading . 'outline-1)
|
|
(,manHeader . 'org-document-title)
|
|
(,manSubHeading . 'font-lock-function-name-face)
|
|
(,manOptionDesc . 'font-lock-constant-face)
|
|
)))
|
|
|
|
(defface manHeader
|
|
'((t (:inherit org-document-title)))
|
|
"Top-level heading for Man pages..."
|
|
:group 'man)
|
|
(defface manSectionHeading
|
|
'((t (:inherit outline-1)))
|
|
"Man section titles..."
|
|
:group 'man)
|
|
(defface manOptionDesc
|
|
'((t (:inherit font-lock-constant-face)))
|
|
"Man option descriptions..."
|
|
:group 'man)
|
|
(defface manReference
|
|
'((t (:inherit link)))
|
|
"Man references to other pages..."
|
|
:group 'man)
|
|
(defface manSubHeading
|
|
'((t (:inherit font-lock-function-name-face)))
|
|
"Manual sub headings..."
|
|
:group 'man)
|
|
|
|
(defun man-plus-setall ()
|
|
"Do all of the things that Man wants. To be run as `Man-mode-hook'."
|
|
(interactive)
|
|
(setq font-lock-defaults '((man-plus-highlights))))
|
|
|
|
(add-hook 'man-common-hook #'man-plus-setall)
|
|
(add-hook 'man-common-hook #'turn-off-line-numbers)
|
|
|
|
(define-derived-mode man-plus-mode man-common "Man Plus"
|
|
"Custom child mode for man mode, structured like the `nvim' builtin plugin."
|
|
(buffer-disable-undo)
|
|
(auto-fill-mode -1)
|
|
(man-plus-setall)
|
|
(turn-off-line-numbers))
|
|
|
|
(provide 'man-plus)
|
|
;;; man-plus.el ends here
|
|
; LocalWords: nlpox
|