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

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

[elpa] master d30ae7d 08/14: For #116: Provide a way to disable highligh


From: Leo Liu
Subject: [elpa] master d30ae7d 08/14: For #116: Provide a way to disable highlighting tag at point
Date: Mon, 14 Dec 2015 21:52:42 +0000

branch: master
commit d30ae7d1384f84f93b7eb605634b6ec701bd433f
Author: Leo Liu <address@hidden>
Commit: Leo Liu <address@hidden>

    For #116: Provide a way to disable highlighting tag at point
---
 README.rst |   10 ++++++++++
 ggtags.el  |   39 +++++++++++++++++++++++++++------------
 2 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/README.rst b/README.rst
index 34c51aa..13b4140 100644
--- a/README.rst
+++ b/README.rst
@@ -313,6 +313,16 @@ Integration with other packages
 NEWS
 ~~~~
 
+(devel) 0.8.11
+++++++++++++++
+
+#. ``ggtags-highlight-tag-delay`` is renamed to
+   ``ggtags-highlight-tag``.
+#. Tag highlighting can be disabled by setting
+   ``ggtags-highlight-tag`` to nil.
+
+ggtags-highlight-tag
+
 [2015-06-12 Fri] 0.8.10
 +++++++++++++++++++++++
 
diff --git a/ggtags.el b/ggtags.el
index b628763..d991ba4 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -331,13 +331,17 @@ Nil means using the value of `completing-read-function'."
                  function)
   :group 'ggtags)
 
-(defcustom ggtags-highlight-tag-delay 0.25
-  "Time in seconds before highlighting tag at point."
+(define-obsolete-variable-alias 'ggtags-highlight-tag-delay 
'ggtags-highlight-tag
+  "0.8.11")
+
+(defcustom ggtags-highlight-tag 0.25
+  "If non-nil time in seconds before highlighting tag at point.
+Set to `nil' to disable tag highlighting."
   :set (lambda (sym value)
-         (when (bound-and-true-p ggtags-highlight-tag-timer)
-           (timer-set-idle-time ggtags-highlight-tag-timer value t))
+         (when (fboundp 'ggtags-setup-highlight-tag-at-point)
+           (ggtags-setup-highlight-tag-at-point value))
          (set-default sym value))
-  :type 'number
+  :type '(choice (const :tag "Disable" nil) number)
   :group 'ggtags)
 
 (defcustom ggtags-bounds-of-tag-function (lambda ()
@@ -2204,10 +2208,7 @@ to nil disables displaying this information.")
 ;;;###autoload
 (define-minor-mode ggtags-mode nil
   :lighter (:eval (if ggtags-navigation-mode "" " GG"))
-  (unless (timerp ggtags-highlight-tag-timer)
-    (setq ggtags-highlight-tag-timer
-          (run-with-idle-timer
-           ggtags-highlight-tag-delay t #'ggtags-highlight-tag-at-point)))
+  (ggtags-setup-highlight-tag-at-point ggtags-highlight-tag)
   (if ggtags-mode
       (progn
         (add-hook 'after-save-hook 'ggtags-after-save-function nil t)
@@ -2230,9 +2231,7 @@ to nil disables displaying this information.")
     (remove-function (local 'eldoc-documentation-function) 
'ggtags-eldoc-function)
     (setq mode-line-buffer-identification
           (delq 'ggtags-mode-line-project-name 
mode-line-buffer-identification))
-    (and (overlayp ggtags-highlight-tag-overlay)
-         (delete-overlay ggtags-highlight-tag-overlay))
-    (setq ggtags-highlight-tag-overlay nil)))
+    (ggtags-cancel-highlight-tag-at-point 'keep-timer)))
 
 (defvar ggtags-highlight-tag-map
   (let ((map (make-sparse-keymap)))
@@ -2252,6 +2251,22 @@ to nil disables displaying this information.")
 (put 'ggtags-active-tag 'help-echo
      "S-mouse-1 for definitions\nS-mouse-3 for references")
 
+(defun ggtags-setup-highlight-tag-at-point (flag)
+  (cond ((null flag) (ggtags-cancel-highlight-tag-at-point))
+        ((not (timerp ggtags-highlight-tag-timer))
+         (setq ggtags-highlight-tag-timer
+               (run-with-idle-timer flag t #'ggtags-highlight-tag-at-point)))
+        (t (timer-set-idle-time ggtags-highlight-tag-timer flag t))))
+
+(defun ggtags-cancel-highlight-tag-at-point (&optional keep-timer)
+  (when (and (not keep-timer)
+             (timerp ggtags-highlight-tag-timer))
+    (cancel-timer ggtags-highlight-tag-timer)
+    (setq ggtags-highlight-tag-timer nil))
+  (when ggtags-highlight-tag-overlay
+    (delete-overlay ggtags-highlight-tag-overlay)
+    (setq ggtags-highlight-tag-overlay nil)))
+
 (defun ggtags-highlight-tag-at-point ()
   (when (and ggtags-mode ggtags-project-root (ggtags-find-project))
     (unless (overlayp ggtags-highlight-tag-overlay)



reply via email to

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