* lisp/emacs-lisp/cl-macs.el (cl--transform-lambda): Defend against
[bpt/emacs.git] / lisp / emacs-lisp / chart.el
index b269642..31aeb1f 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, 2008, 2009,
-;;   2010, 2011  Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1998-1999, 2001, 2004-2005, 2007-2012
+;;   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,7 +82,7 @@ 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)
 
@@ -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."
@@ -634,12 +634,12 @@ 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"
                       10
-                      '(lambda (a b) (> (cdr a) (cdr b))))
+                      (lambda (a b) (> (cdr a) (cdr b))))
     ))
 
 (defun chart-space-usage (d)
@@ -669,34 +669,20 @@ SORT-PRED if desired."
                       nmlst "File Name"
                       cntlst "File Size"
                       10
-                      '(lambda (a b) (> (cdr a) (cdr b))))
+                      (lambda (a b) (> (cdr a) (cdr b))))
     ))
 
 (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")))
@@ -737,7 +723,7 @@ SORT-PRED if desired."
                       nmlst "User Names"
                       cntlst "# of occurrences"
                       10
-                      '(lambda (a b) (> (cdr a) (cdr b))))
+                      (lambda (a b) (> (cdr a) (cdr b))))
     ))