]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/data-debug.el
Auto-commit of loaddefs files.
[gnu-emacs] / lisp / cedet / data-debug.el
index cd910f35a6a93a2b3ef1d97283af1d1d380b3091..dec3c7b2af2a8d4ac509f6e1da222e6b4c7b0b77 100644 (file)
@@ -1,6 +1,6 @@
 ;;; data-debug.el --- Datastructure Debugger
 
-;; Copyright (C) 2007-201 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam  <zappo@gnu.org>
 ;; Version: 0.2
@@ -821,20 +821,30 @@ FCN is a function that will display stuff in the data debug buffer."
 PREBUTTONTEXT is some text to insert between prefix and the thing
 that is not included in the indentation calculation of any children.
 If PARENT is non-nil, it is somehow related as a parent to thing."
-  (when (catch 'done
-         (dolist (test data-debug-thing-alist)
-           (when (funcall (car test) thing)
-             (condition-case nil
-                 (funcall (cdr test) thing prefix prebuttontext parent)
-               (error
-                (funcall (cdr test) thing prefix prebuttontext)))
-             (throw 'done nil))
-           )
-         nil)
-    (data-debug-insert-simple-thing (format "%S" thing)
-                                   prefix
-                                   prebuttontext
-                                   'bold)))
+  (let ((inhibit-read-only t))
+    (when (catch 'done
+           (dolist (test data-debug-thing-alist)
+             (when (funcall (car test) thing)
+               (condition-case nil
+                   (progn
+                     (funcall (cdr test) thing prefix prebuttontext parent)
+                     (throw 'done nil))
+                 (error
+                  (condition-case nil
+                      (progn
+                        (funcall (cdr test) thing prefix prebuttontext)
+                        (throw 'done nil))
+                    (error nil))))
+               ;; Only throw the 'done if no error was caught.
+               ;; If an error was caught, skip this predicate as being
+               ;; unsuccessful, and move on.
+               ))
+           nil)
+      (data-debug-insert-simple-thing (format "%S" thing)
+                                     prefix
+                                     prebuttontext
+                                     'bold)))
+  (set-buffer-modified-p nil))
 
 ;;; MAJOR MODE
 ;;
@@ -861,6 +871,7 @@ If PARENT is non-nil, it is somehow related as a parent to thing."
 
 (defvar data-debug-map
   (let ((km (make-sparse-keymap)))
+    (suppress-keymap km)
     (define-key km [mouse-2] 'data-debug-expand-or-contract-mouse)
     (define-key km " " 'data-debug-expand-or-contract)
     (define-key km "\C-m" 'data-debug-expand-or-contract)
@@ -872,7 +883,7 @@ If PARENT is non-nil, it is somehow related as a parent to thing."
   "Keymap used in data-debug.")
 
 (defcustom data-debug-mode-hook nil
-  "*Hook run when data-debug starts."
+  "Hook run when data-debug starts."
   :group 'data-debug
   :type 'hook)
 
@@ -885,7 +896,8 @@ If PARENT is non-nil, it is somehow related as a parent to thing."
   (setq major-mode 'data-debug-mode
         mode-name "DATA-DEBUG"
        comment-start ";;"
-       comment-end "")
+       comment-end ""
+       buffer-read-only t)
   (set (make-local-variable 'comment-start-skip)
        "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
   (set-syntax-table data-debug-mode-syntax-table)
@@ -902,6 +914,7 @@ If PARENT is non-nil, it is somehow related as a parent to thing."
   (let ((b (get-buffer-create name)))
     (pop-to-buffer b)
     (set-buffer b)
+    (setq buffer-read-only nil) ; disable read-only
     (erase-buffer)
     (data-debug-mode)
     b))
@@ -916,7 +929,7 @@ If PARENT is non-nil, it is somehow related as a parent to thing."
   (skip-chars-forward " *-><[]" (point-at-eol)))
 
 (defun data-debug-prev ()
-  "Go to the next line in the Ddebug buffer."
+  "Go to the previous line in the Ddebug buffer."
   (interactive)
   (forward-line -1)
   (beginning-of-line)
@@ -955,7 +968,7 @@ we move to."
 
 (defun data-debug-line-expandable-p ()
   "Return non-nil if the current line is expandable.
-Lines that are not expandable are assumed to not be contractable."
+Lines that are not expandable are assumed to not be contractible."
   (not (get-text-property (point) 'ddebug-noexpand)))
 
 (defun data-debug-expand-current-line ()
@@ -964,7 +977,8 @@ Do nothing if already expanded."
   (when (or (not (data-debug-line-expandable-p))
            (not (data-debug-current-line-expanded-p)))
     ;; If the next line is the same or less indentation, expand.
-    (let ((fcn (get-text-property (point) 'ddebug-function)))
+    (let ((fcn (get-text-property (point) 'ddebug-function))
+         (inhibit-read-only t))
       (when fcn
        (funcall fcn (point))
        (beginning-of-line)
@@ -972,11 +986,12 @@ Do nothing if already expanded."
 
 (defun data-debug-contract-current-line ()
   "Contract the current line (if possible).
-Do nothing if already expanded."
+Do nothing if already contracted."
   (when (and (data-debug-current-line-expanded-p)
             ;; Don't contract if the current line is not expandable.
             (get-text-property (point) 'ddebug-function))
     (let ((ti (current-indentation))
+         (inhibit-read-only t)
          )
       ;; If next indentation is larger, collapse.
       (end-of-line)
@@ -995,7 +1010,8 @@ Do nothing if already expanded."
          (error (setq end (point-max))))
        (delete-region start end)
        (forward-char -1)
-       (beginning-of-line)))))
+       (beginning-of-line))))
+  (set-buffer-modified-p nil))
 
 (defun data-debug-expand-or-contract ()
   "Expand or contract anything at the current point."
@@ -1060,11 +1076,11 @@ If the result is a list or vector, then use the data debugger to display it."
       (setq values (cons (eval expr) values))
     (let ((old-value (make-symbol "t")) new-value)
       ;; Bind debug-on-error to something unique so that we can
-      ;; detect when evaled code changes it.
+      ;; detect when evalled code changes it.
       (let ((debug-on-error old-value))
        (setq values (cons (eval expr) values))
        (setq new-value debug-on-error))
-      ;; If evaled code has changed the value of debug-on-error,
+      ;; If evalled code has changed the value of debug-on-error,
       ;; propagate that change to the global binding.
       (unless (eq old-value new-value)
        (setq debug-on-error new-value))))
@@ -1080,7 +1096,4 @@ If the result is a list or vector, then use the data debugger to display it."
 
 (provide 'data-debug)
 
-(if (featurep 'eieio)
-    (require 'eieio-datadebug))
-
 ;;; data-debug.el ends here