Browse Source

Use `font-lock-ensure' where available. (#14)

Hrvoje Niksic 1 year ago
parent
commit
75c21c7f4d
2 changed files with 7 additions and 8 deletions
  1. 3 4
      README.md
  2. 4 4
      htmlize.el

+ 3 - 4
README.md

@@ -28,10 +28,9 @@ buffer or move the point.  htmlize will do its best to work on
 non-windowing Emacs sessions but the result will be limited to
 colors supported by the terminal.
 
-htmlize aims for compatibility with Emacsen version 22 and later.
-Please let me know if it doesn't work on the version of XEmacs or
-GNU Emacs that you are using.  The package relies on the presence
-of CL extensions, especially for cross-emacs compatibility.
+htmlize aims for compatibility with older Emacs versions.  Please
+let me know if it doesn't work on the version of GNU Emacs that you
+are using.
 
 
 [1]: http://htmlpreview.github.io/?https://github.com/hniksic/emacs-htmlize/blob/master/htmlize.el.html

+ 4 - 4
htmlize.el

@@ -1822,10 +1822,10 @@ does not name a directory, it will be used as output file name."
       (let ((buffer-file-name file))
 	;; Set the major mode for the sake of font-lock.
 	(normal-mode)
-	(font-lock-mode 1)
-	(unless font-lock-mode
-	  ;; In GNU Emacs (font-lock-mode 1) doesn't force font-lock,
-	  ;; contrary to the documentation.  This seems to work.
+        (if (fboundp 'font-lock-ensure)
+            (font-lock-ensure)
+          ;; Emacs prior to 25.1
+          (font-lock-mode 1)
 	  (font-lock-fontify-buffer))
 	;; htmlize the buffer and save the HTML.
 	(with-current-buffer (htmlize-buffer-1)