Re: Color highlighting code in manuals

Steven Allen <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Heime <[email protected]> writes:

> Can code in manuals be shown with colour highlighting?

I'm not aware of anything that works in "man" pages. However:

- The helpful package on MELPA will highlight elisp in help(ful) buffers.

- I use the info-colors package (also on MELPA) along with the following
advice to highlight elisp in info buffers:

    (define-advice info-colors-fontify-lisp-code-blocks (:after () fontify)
      (let ((buf (current-buffer)))
        (goto-char (point-min))
        (with-temp-buffer
          (delay-mode-hooks (emacs-lisp-mode))
          (let ((tmpbuf (current-buffer)))
            (with-current-buffer buf
              (while-let ((match
                           (text-property-search-forward
                            'font-lock-face
                            'info-colors-lisp-code-block
                            #'eq))
                          (beg (prop-match-beginning match))
                          (end (prop-match-end match)))
                (with-current-buffer tmpbuf
                  (erase-buffer)
                  (insert-buffer-substring buf beg end)
                  (font-lock-ensure)
                  (goto-char (point-min))
                  (while-let ((match (text-property-search-forward 'face))
                              (beg (prop-match-beginning match))
                              (end (prop-match-end match))
                              (val (prop-match-value match)))
                    (set-text-properties beg end
                                         `(font-lock-face (,val info-colors-lisp-code-block)
                                           fontified t))))
                (delete-region beg end)
                (insert-buffer-substring tmpbuf)))))))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.