Does anyone know how to print with the line numbers of the code in the margin? I can display the line number, cannot have that in the printout. Thanks!
You can add the line numbers with temporary overlays and convert the buffer to HTML using the htmlize
package, after which you can save the HTML and print using lpr
or a browser.
(defun htmlize-with-line-numbers ()
(interactive)
(goto-char (point-min))
(let ((n 1))
(while (not (eobp))
(htmlize-make-tmp-overlay (point) (point) `(before-string ,(format "%4d " n)))
(setq n (1+ n))
(forward-line 1)))
(switch-to-buffer (htmlize-buffer)))
This will require a recent version of htmlize
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With