]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/chart.el
Update copyright year to 2015
[gnu-emacs] / lisp / emacs-lisp / chart.el
index 56930a74693a2e232ae08bf5a08b764d916f72d8..62b2b5cc6dac440ff4232b2c9730cb8dabc72d96 100644 (file)
@@ -1,7 +1,7 @@
-;;; chart.el --- Draw charts (bar charts, etc)
+;;; chart.el --- Draw charts (bar charts, etc)  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1996, 1998-1999, 2001, 2004-2005, 2007-2011
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1998-1999, 2001, 2004-2005, 2007-2015 Free
+;; Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam  <zappo@gnu.org>
 ;; Version: 0.2
@@ -62,8 +62,8 @@
 (require 'eieio)
 
 ;;; Code:
-(defvar chart-mode-map (make-sparse-keymap) "Keymap used in chart mode.")
 (define-obsolete-variable-alias 'chart-map 'chart-mode-map "24.1")
+(defvar chart-mode-map (make-sparse-keymap) "Keymap used in chart mode.")
 
 (defvar chart-local-object nil
   "Local variable containing the locally displayed chart object.")
@@ -82,14 +82,14 @@ Colors will be the background color.")
 Useful if new Emacs is used on B&W display.")
 
 (defcustom chart-face-use-pixmaps nil
-  "*Non-nil to use fancy pixmaps in the background of chart face colors."
+  "Non-nil to use fancy pixmaps in the background of chart face colors."
   :group 'eieio
   :type 'boolean)
 
+(declare-function x-display-color-cells "xfns.c" (&optional terminal))
+
 (defvar chart-face-list
-  (if (if (fboundp 'display-color-p)
-          (display-color-p)
-        window-system)
+  (if (display-color-p)
       (let ((cl chart-face-color-list)
             (pl chart-face-pixmap-list)
             (faces ())
@@ -156,7 +156,7 @@ Returns the newly created buffer."
    )
   "Superclass for all charts to be displayed in an Emacs buffer.")
 
-(defmethod initialize-instance :AFTER ((obj chart) &rest fields)
+(defmethod initialize-instance :AFTER ((obj chart) &rest _fields)
   "Initialize the chart OBJ being created with FIELDS.
 Make sure the width/height is correct."
   (oset obj x-width (- (window-width) 10))
@@ -169,7 +169,7 @@ Make sure the width/height is correct."
              :initform t)
    (name-face :initarg :name-face
              :initform 'bold)
-   (labels-face :initarg :lables-face
+   (labels-face :initarg :labels-face
                :initform 'italic)
    (chart :initarg :chart
          :initform nil)
@@ -276,7 +276,7 @@ START and END represent the boundary."
                       (float (- (cdr range) (car range)))))))))
   )
 
-(defmethod chart-axis-draw ((a chart-axis-range) &optional dir margin zone start end)
+(defmethod chart-axis-draw ((a chart-axis-range) &optional dir margin zone _start _end)
   "Draw axis information based upon a range to be spread along the edge.
 A is the chart to draw.  DIR is the direction.
 MARGIN, ZONE, START, and END specify restrictions in chart space."
@@ -329,7 +329,7 @@ Automatically compensates for direction."
          (+ m -1 (round (* lpn (+ 1.0 (float n))))))
     ))
 
-(defmethod chart-axis-draw ((a chart-axis-names) &optional dir margin zone start end)
+(defmethod chart-axis-draw ((a chart-axis-names) &optional dir margin zone _start _end)
   "Draw axis information based upon A range to be spread along the edge.
 Optional argument DIR is the direction of the chart.
 Optional arguments MARGIN, ZONE, START and END specify boundaries of the drawing."
@@ -470,7 +470,7 @@ See `chart-sort-matchlist' for more details."
          (progn
            (chart-sort-matchlist s2 s1 pred)
            (setq s (oref s2 data)))
-       (error "Sorting of chart %s not supported" (object-name c))))
+       (error "Sorting of chart %s not supported" (eieio-object-name c))))
     (if (eq (oref c direction) 'horizontal)
        (oset (oref c y-axis) items s)
       (oset (oref c x-axis) items s)
@@ -634,7 +634,7 @@ SORT-PRED if desired."
            (setq extlst (cons s extlst)
                  cntlst (cons 1 cntlst)))))
       (setq flst (cdr flst)))
-    ;; Lets create the chart!
+    ;; Let's create the chart!
     (chart-bar-quickie 'vertical "Files Extension Distribution"
                       extlst "File Extensions"
                       cntlst "# of occurrences"
@@ -675,28 +675,14 @@ SORT-PRED if desired."
 (defun chart-emacs-storage ()
   "Chart the current storage requirements of Emacs."
   (interactive)
-  (let* ((data (garbage-collect))
-        (names '("strings/2" "vectors"
-                 "conses" "free cons"
-                 "syms" "free syms"
-                 "markers" "free mark"
-                 ;; "floats" "free flt"
-                 ))
-        (nums (list (/ (nth 3 data) 2)
-                    (nth 4 data)
-                    (car (car data))   ; conses
-                    (cdr (car data))
-                    (car (nth 1 data)) ; syms
-                    (cdr (nth 1 data))
-                    (car (nth 2 data)) ; markers
-                    (cdr (nth 2 data))
-                    ;(car (nth 5 data)) ; floats are Emacs only
-                    ;(cdr (nth 5 data))
-                    )))
-    ;; Lets create the chart!
+  (let* ((data (garbage-collect)))
+    ;; Let's create the chart!
     (chart-bar-quickie 'vertical "Emacs Runtime Storage Usage"
-                      names "Storage Items"
-                      nums "Objects")))
+                      (mapcar (lambda (x) (symbol-name (car x))) data)
+                       "Storage Items"
+                      (mapcar (lambda (x) (* (nth 1 x) (nth 2 x)))
+                               data)
+                       "Bytes")))
 
 (defun chart-emacs-lists ()
   "Chart out the size of various important lists."
@@ -710,7 +696,7 @@ SORT-PRED if desired."
     (if (fboundp 'x-display-list)
        (setq names (append names '("x-displays"))
              nums (append nums (list (length (x-display-list))))))
-    ;; Lets create the chart!
+    ;; Let's create the chart!
     (chart-bar-quickie 'vertical "Emacs List Size Chart"
                       names "Various Lists"
                       nums "Objects")))