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

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

[elpa] 01/06: New function ggtags-fontify-code


From: Leo Liu
Subject: [elpa] 01/06: New function ggtags-fontify-code
Date: Fri, 12 Sep 2014 00:24:51 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit 6411b9472058b6524942930611b10698b8fcf136
Author: Leo Liu <address@hidden>
Date:   Thu Aug 7 21:53:10 2014 +0800

    New function ggtags-fontify-code
---
 README.rst |   11 +++++++++--
 ggtags.el  |   24 ++++++++++++++++++++++--
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/README.rst b/README.rst
index f00d69b..70c797c 100644
--- a/README.rst
+++ b/README.rst
@@ -8,8 +8,9 @@ list-packages``) and is also available on `MELPA
 
 The goal is to make working with GNU Global in Emacs as effortlessly
 and intuitively as possible and to integrate tightly with standard
-emacs packages. ``ggtags.el`` is tested in emacs 24.1, 24.2, 24.3 and
-trunk. Patches, feature requests and bug reports are welcome. Thanks.
+emacs packages. ``ggtags.el`` is tested in emacs 24.1, 24.2, 24.3,
+24.4 and trunk. Patches, feature requests and bug reports are welcome.
+Thanks.
 
 Features
 ~~~~~~~~
@@ -294,6 +295,12 @@ Integration with other packages
 NEWS
 ~~~~
 
+[devel]
+~~~~~~~
+
+#. ``ggtags-show-definition`` shows definition with font locking.
+
+
 [2014-06-22 Sun] 0.8.5
 ++++++++++++++++++++++
 
diff --git a/ggtags.el b/ggtags.el
index 09e3af7..2b95daa 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2013-2014  Free Software Foundation, Inc.
 
 ;; Author: Leo Liu <address@hidden>
-;; Version: 0.8.5
+;; Version: 0.8.6
 ;; Keywords: tools, convenience
 ;; Created: 2013-01-29
 ;; URL: https://github.com/leoliu/ggtags
@@ -1897,9 +1897,29 @@ When finished invoke CALLBACK in BUFFER with process 
exit status."
     (set-process-sentinel proc sentinel)
     proc))
 
+(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*")
+                            (delay-mode-hooks (funcall mode))
+                            (setq font-lock-mode t)
+                            (funcall font-lock-function font-lock-mode)
+                            (current-buffer))))
+              (with-current-buffer (prepare-buffer)
+                (let ((inhibit-read-only t))
+                  (erase-buffer)
+                  (insert code)
+                  (font-lock-default-fontify-region
+                   (point-min) (point-max) nil))
+                (buffer-string))))))
+
 (defun ggtags-get-definition-default (defs)
   (and (caar defs)
-       (concat (caar defs) (and (cdr defs) " [guess]"))))
+       (concat (ggtags-fontify-code (caar defs))
+               (and (cdr defs) " [guess]"))))
 
 (defun ggtags-show-definition (name)
   (interactive (list (ggtags-read-tag 'definition current-prefix-arg)))



reply via email to

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