emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ggtags c737181 2/9: Fix #158: ggtags-fontify-code impro


From: Stefan Monnier
Subject: [elpa] externals/ggtags c737181 2/9: Fix #158: ggtags-fontify-code improvement suggestion
Date: Fri, 26 Mar 2021 22:46:19 -0400 (EDT)

branch: externals/ggtags
commit c737181c16a673d36e81b4c8ec4f389d630ec49d
Author: Leo Liu <sdl.web@gmail.com>
Commit: Leo Liu <sdl.web@gmail.com>

    Fix #158: ggtags-fontify-code improvement suggestion
    
    Thanks to Stefan Monnier.
---
 ggtags.el | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/ggtags.el b/ggtags.el
index 3d614c0..a61ae7d 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -2008,23 +2008,13 @@ When finished invoke CALLBACK in BUFFER with process 
exit status."
 
 (cl-defun ggtags-fontify-code (code &optional (mode major-mode))
   (cl-check-type mode function)
-  (cl-typecase code
-    ((not string) code)
-    (string (cl-labels ((prepare-buffer ()
-                          (with-current-buffer
-                              (get-buffer-create " *Code-Fontify*")
-                            (let ((inhibit-read-only t))
-                              (erase-buffer))
-                            (funcall mode)
-                            (setq font-lock-mode t)
-                            (funcall font-lock-function font-lock-mode)
-                            (setq jit-lock-mode nil)
-                            (current-buffer))))
-              (with-current-buffer (prepare-buffer)
-                (let ((inhibit-read-only t))
-                  (insert code)
-                  (font-lock-default-fontify-region (point-min) (point-max) 
nil))
-                (buffer-string))))))
+  (if (stringp code)
+      (with-temp-buffer
+        (insert code)
+        (funcall mode)
+        (font-lock-ensure)
+        (buffer-string))
+    code))
 
 (defun ggtags-get-definition-default (defs)
   (and (caar defs)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]