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

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

[elpa] 26/38: New macro ignore-errors-unless-debug and use it


From: Leo Liu
Subject: [elpa] 26/38: New macro ignore-errors-unless-debug and use it
Date: Mon, 24 Mar 2014 09:31:37 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit 030251c21c0f0c76d0898bc83ae5d32ee17197ba
Author: Leo Liu <address@hidden>
Date:   Thu Mar 20 11:03:03 2014 +0800

    New macro ignore-errors-unless-debug and use it
---
 ggtags.el |   39 ++++++++++++++++++++++-----------------
 1 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/ggtags.el b/ggtags.el
index b3def18..1b1dc84 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -71,7 +71,12 @@
     (defmacro defvar-local (var val &optional docstring)
       (declare (debug defvar) (doc-string 3))
       (list 'progn (list 'defvar var val docstring)
-            (list 'make-variable-buffer-local (list 'quote var))))))
+            (list 'make-variable-buffer-local (list 'quote var)))))
+
+  (defmacro ignore-errors-unless-debug (&rest body)
+    "Ignore all errors while executing BODY unless debug is on."
+    (declare (debug t) (indent 0))
+    `(condition-case-unless-debug nil (progn ,@body) (error nil))))
 
 (eval-and-compile
   (or (fboundp 'user-error)             ;24.3
@@ -400,10 +405,11 @@ Value is new modtime if updated."
               (ggtags-find-project))
           project)
       (setq ggtags-project-root
-            (or (ignore-errors (file-name-as-directory
-                                (concat (file-remote-p default-directory)
-                                        ;; Resolves symbolic links
-                                        (ggtags-process-string "global" 
"-pr"))))
+            (or (ignore-errors-unless-debug
+                  (file-name-as-directory
+                   (concat (file-remote-p default-directory)
+                           ;; Resolves symbolic links
+                           (ggtags-process-string "global" "-pr"))))
                 ;; 'global -pr' resolves symlinks before checking the
                 ;; GTAGS file which could cause issues such as
                 ;; https://github.com/leoliu/ggtags/issues/22, so
@@ -592,18 +598,17 @@ non-nil."
        (unless (equal cache-key (car ggtags-completion-cache))
          (setq ggtags-completion-cache
                (cons cache-key
-                     (condition-case-unless-debug nil
-                         ;; May throw global: only name char is
-                         ;; allowed with -c option.
-                         (ggtags-with-current-project
-                          (split-string
-                           (apply #'ggtags-process-string
-                                  "global"
-                                  (append (and completion-ignore-case 
'("--ignore-case"))
-                                          ;; Note -c alone returns only 
definitions
-                                          (list (concat "-c" 
ggtags-completion-flag) prefix)))
-                           "\n" t))
-                       (error nil))))))
+                     (ignore-errors-unless-debug
+                       ;; May throw global: only name char is allowed
+                       ;; with -c option.
+                       (ggtags-with-current-project
+                        (split-string
+                         (apply #'ggtags-process-string
+                                "global"
+                                (append (and completion-ignore-case 
'("--ignore-case"))
+                                        ;; Note -c alone returns only 
definitions
+                                        (list (concat "-c" 
ggtags-completion-flag) prefix)))
+                         "\n" t)))))))
      (cdr ggtags-completion-cache))))
 
 (defun ggtags-completion-at-point ()



reply via email to

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