]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/data-debug.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / cedet / data-debug.el
index 03dca6ceccc96d1524e948226f7ba64a91bcb72f..330c7757511a45b70a1fe3b0b0f7f4853ba9bdd0 100644 (file)
@@ -1,9 +1,9 @@
-;;; data-debug.el --- Datastructure Debugger
+;;; data-debug.el --- Data structure debugger
 
-;; Copyright (C) 2007-201 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2016 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam  <zappo@gnu.org>
-;; Version: 0.2
+;; Old-Version: 0.2
 ;; Keywords: OO, lisp
 ;; Package: cedet
 
@@ -55,7 +55,7 @@
       (defalias 'data-debug-overlay-p 'extentp)
       (if (not (fboundp 'propertize))
          (defun dd-propertize (string &rest properties)
-           "Mimic 'propertize' in from Emacs 23."
+           "Mimic `propertize' in from Emacs 23."
            (add-text-properties 0 (length string) properties string)
            string
            )
@@ -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
 ;;
@@ -859,8 +869,10 @@ If PARENT is non-nil, it is somehow related as a parent to thing."
     table)
   "Syntax table used in data-debug macro buffers.")
 
-(defvar data-debug-map
+(define-obsolete-variable-alias 'data-debug-map 'data-debug-mode-map "24.1")
+(defvar data-debug-mode-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)
@@ -876,21 +888,15 @@ If PARENT is non-nil, it is somehow related as a parent to thing."
   :group 'data-debug
   :type 'hook)
 
-(defun data-debug-mode ()
+(define-derived-mode data-debug-mode fundamental-mode "DATA-DEBUG"
   "Major-mode for the Analyzer debugger.
 
-\\{data-debug-map}"
-  (interactive)
-  (kill-all-local-variables)
-  (setq major-mode 'data-debug-mode
-        mode-name "DATA-DEBUG"
-       comment-start ";;"
-       comment-end "")
-  (set (make-local-variable 'comment-start-skip)
+\\{data-debug-mode-map}"
+  (setq comment-start ";;"
+       comment-end ""
+       buffer-read-only t)
+  (setq-local comment-start-skip
        "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
-  (set-syntax-table data-debug-mode-syntax-table)
-  (use-local-map data-debug-map)
-  (run-hooks 'data-debug-hook)
   (buffer-disable-undo)
   (set (make-local-variable 'font-lock-global-modes) nil)
   (font-lock-mode -1)
@@ -902,6 +908,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))
@@ -964,7 +971,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)
@@ -977,6 +985,7 @@ Do nothing if already contracted."
             ;; 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 +1004,8 @@ Do nothing if already contracted."
          (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."
@@ -1080,7 +1090,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