1 ;;; chart.el --- Draw charts (bar charts, etc)
3 ;;; Copyright (C) 1996, 1998, 1999, 2001, 2004, 2005, 2007, 2008, 2009
4 ;;; Free Software Foundation, Inc.
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
8 ;; Keywords: OO, chart, graph
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; This package is an experiment of mine aiding in the debugging of
28 ;; eieio, and proved to be neat enough that others may like to use
29 ;; it. To quickly see what you can do with chart, run the command
30 ;; `chart-test-it-all'.
32 ;; Chart current can display bar-charts in either of two
33 ;; directions. It also supports ranged (integer) axis, and axis
34 ;; defined by some set of strings or names. These name can be
35 ;; automatically derived from data sequences, which are just lists of
36 ;; anything encapsulated in a nice eieio object.
38 ;; Current example apps for chart can be accessed via these commands:
39 ;; `chart-file-count' - count files w/ matching extensions
40 ;; `chart-space-usage' - display space used by files/directories
41 ;; `chart-emacs-storage' - Emacs storage units used/free (garbage-collect)
42 ;; `chart-emacs-lists' - length of Emacs lists
43 ;; `chart-rmail-from' - who sends you the most mail (in -summary only)
47 ;; If you find the default colors and pixmaps unpleasant, or too
48 ;; short, you can change them. The variable `chart-face-color-list'
49 ;; contains a list of colors, and `chart-face-pixmap-list' contains
50 ;; all the pixmaps to use. The current pixmaps are those found on
51 ;; several systems I found. The two lists should be the same length,
52 ;; as the long list will just be truncated.
54 ;; If you would like to draw your own stipples, simply create some
55 ;; xbm's and put them in a directory, then you can add:
57 ;; (setq x-bitmap-file-path (cons "~/mybitmaps" x-bitmap-file-path))
59 ;; to your .emacs (or wherever) and load the `chart-face-pixmap-list'
60 ;; with all the bitmaps you want to use.
65 (defvar chart-map nil
"Keymap used in chart mode.")
68 (setq chart-map
(make-sparse-keymap))
71 (defvar chart-local-object nil
72 "Local variable containing the locally displayed chart object.")
73 (make-variable-buffer-local 'chart-local-object
)
75 (defvar chart-face-list nil
76 "Faces used to colorize charts.
77 List is limited currently, which is ok since you really can't display
78 too much in text characters anyways.")
80 (defvar chart-face-color-list
'("red" "green" "blue"
81 "cyan" "yellow" "purple")
82 "Colors to use when generating `chart-face-list'.
83 Colors will be the background color.")
85 (defvar chart-face-pixmap-list
86 (if (and (fboundp 'display-graphic-p
)
88 '("dimple1" "scales" "dot" "cross_weave" "boxes" "dimple3"))
89 "If pixmaps are allowed, display these background pixmaps.
90 Useful if new Emacs is used on B&W display")
92 (defcustom chart-face-use-pixmaps nil
93 "*Non-nil to use fancy pixmaps in the background of chart face colors."
97 (if (and (if (fboundp 'display-color-p
)
100 (not chart-face-list
))
101 (let ((cl chart-face-color-list
)
102 (pl chart-face-pixmap-list
)
105 (setq nf
(make-face (intern (concat "chart-" (car cl
) "-" (car pl
)))))
106 (if (condition-case nil
107 (> (x-display-color-cells) 4)
109 (set-face-background nf
(car cl
))
110 (set-face-background nf
"white"))
111 (set-face-foreground nf
"black")
112 (if (and chart-face-use-pixmaps
114 (fboundp 'set-face-background-pixmap
))
116 (set-face-background-pixmap nf
(car pl
))
117 (error (message "Cannot set background pixmap %s" (car pl
)))))
118 (setq chart-face-list
(cons nf chart-face-list
))
123 "Define a mode in Emacs for displaying a chart."
124 (kill-all-local-variables)
125 (use-local-map chart-map
)
126 (setq major-mode
'chart-mode
128 (buffer-disable-undo)
129 (set (make-local-variable 'font-lock-global-modes
) nil
)
131 (run-hooks 'chart-mode-hook
)
134 (defun chart-new-buffer (obj)
135 "Create a new buffer NAME in which the chart OBJ is displayed.
136 Returns the newly created buffer"
138 (set-buffer (get-buffer-create (format "*%s*" (oref obj title
))))
140 (setq chart-local-object obj
)
144 ((title :initarg
:title
145 :initform
"Emacs Chart")
146 (title-face :initarg
:title-face
147 :initform
'bold-italic
)
148 (x-axis :initarg
:x-axis
150 (x-margin :initarg
:x-margin
152 (x-width :initarg
:x-width
154 (y-axis :initarg
:y-axis
156 (y-margin :initarg
:y-margin
158 (y-width :initarg
:y-width
160 (key-label :initarg
:key-label
162 (sequences :initarg
:sequences
165 "Superclass for all charts to be displayed in an emacs buffer")
167 (defmethod initialize-instance :AFTER
((obj chart
) &rest fields
)
168 "Initialize the chart OBJ being created with FIELDS.
169 Make sure the width/height is correct."
170 (oset obj x-width
(- (window-width) 10))
171 (oset obj y-width
(- (window-height) 12)))
173 (defclass chart-axis
()
174 ((name :initarg
:name
175 :initform
"Generic Axis")
176 (loweredge :initarg
:loweredge
178 (name-face :initarg
:name-face
180 (labels-face :initarg
:lables-face
182 (chart :initarg
:chart
185 "Superclass used for display of an axis.")
187 (defclass chart-axis-range
(chart-axis)
188 ((bounds :initarg
:bounds
189 :initform
'(0.0 .
50.0))
191 "Class used to display an axis defined by a range of values")
193 (defclass chart-axis-names
(chart-axis)
194 ((items :initarg
:items
197 "Class used to display an axis which represents different named items")
199 (defclass chart-sequece
()
200 ((data :initarg
:data
205 "Class used for all data in different charts")
207 (defclass chart-bar
(chart)
208 ((direction :initarg
:direction
210 "Subclass for bar charts. (Vertical or horizontal)")
212 (defmethod chart-draw ((c chart
) &optional buff
)
213 "Start drawing a chart object C in optional BUFF.
214 Erases current contents of buffer"
216 (if buff
(set-buffer buff
))
218 (insert (make-string 100 ?
\n))
219 ;; Start by displaying the axis
224 (message "Rendering chart...")
229 (message "Rendering chart...done")
232 (defmethod chart-draw-title ((c chart
))
233 "Draw a title upon the chart.
234 Argument C is the chart object."
235 (chart-display-label (oref c title
) 'horizontal
0 0 (window-width)
236 (oref c title-face
)))
238 (defmethod chart-size-in-dir ((c chart
) dir
)
239 "Return the physical size of chart C in direction DIR."
240 (if (eq dir
'vertical
)
244 (defmethod chart-draw-axis ((c chart
))
245 "Draw axis into the current buffer defined by chart C."
246 (let ((ymarg (oref c y-margin
))
247 (xmarg (oref c x-margin
))
248 (ylen (oref c y-width
))
249 (xlen (oref c x-width
)))
250 (chart-axis-draw (oref c y-axis
) 'vertical ymarg
251 (if (oref (oref c y-axis
) loweredge
) nil xlen
)
252 xmarg
(+ xmarg ylen
))
253 (chart-axis-draw (oref c x-axis
) 'horizontal xmarg
254 (if (oref (oref c x-axis
) loweredge
) nil ylen
)
255 ymarg
(+ ymarg xlen
)))
258 (defmethod chart-axis-draw ((a chart-axis
) &optional dir margin zone start end
)
259 "Draw some axis for A in direction DIR at with MARGIN in boundry.
260 ZONE is a zone specification.
261 START and END represent the boundary."
262 (chart-draw-line dir
(+ margin
(if zone zone
0)) start end
)
263 (chart-display-label (oref a name
) dir
(if zone
(+ zone margin
3)
264 (if (eq dir
'horizontal
)
266 start end
(oref a name-face
)))
268 (defmethod chart-translate-xpos ((c chart
) x
)
269 "Translate in chart C the coordinate X into a screen column."
270 (let ((range (oref (oref c x-axis
) bounds
)))
272 (round (* (float (- x
(car range
)))
273 (/ (float (oref c x-width
))
274 (float (- (cdr range
) (car range
))))))))
277 (defmethod chart-translate-ypos ((c chart
) y
)
278 "Translate in chart C the coordinate Y into a screen row."
279 (let ((range (oref (oref c y-axis
) bounds
)))
282 (round (* (float (- y
(car range
)))
283 (/ (float (oref c y-width
))
284 (float (- (cdr range
) (car range
)))))))))
287 (defmethod chart-axis-draw ((a chart-axis-range
) &optional dir margin zone start end
)
288 "Draw axis information based upon a range to be spread along the edge.
289 A is the chart to draw. DIR is the direction.
290 MARGIN, ZONE, START, and END specify restrictions in chart space."
292 ;; We prefer about 5 spaces between each value
293 (let* ((i (car (oref a bounds
)))
294 (e (cdr (oref a bounds
)))
298 ;; want to jump by units of 5 spaces or so
299 (j (/ rng
(/ (chart-size-in-dir (oref a chart
) dir
) 4)))
301 (if (= j
0) (setq j
1))
305 (format "%dM" (/ i
1000000)))
307 (format "%dK" (/ i
1000)))
310 (if (eq dir
'vertical
)
311 (let ((x (+ (+ margin z
) (if (oref a loweredge
)
313 (if (< x
1) (setq x
1))
314 (chart-goto-xy x
(chart-translate-ypos (oref a chart
) i
)))
315 (chart-goto-xy (chart-translate-xpos (oref a chart
) i
)
316 (+ margin z
(if (oref a loweredge
) -
1 1))))
319 (chart-zap-chars (length s
))
320 (put-text-property p1
(point) 'face
(oref a labels-face
))
324 (defmethod chart-translate-namezone ((c chart
) n
)
325 "Return a dot-pair representing a positional range for a name.
326 The name in chart C of the Nth name resides.
327 Automatically compensates for for direction."
328 (let* ((dir (oref c direction
))
329 (w (if (eq dir
'vertical
) (oref c x-width
) (oref c y-width
)))
330 (m (if (eq dir
'vertical
) (oref c y-margin
) (oref c x-margin
)))
332 (oref (if (eq dir
'vertical
) (oref c x-axis
) (oref c y-axis
))
334 (lpn (/ (+ 1.0 (float w
)) (float ns
)))
336 (cons (+ m
(round (* lpn
(float n
))))
337 (+ m -
1 (round (* lpn
(+ 1.0 (float n
))))))
340 (defmethod chart-axis-draw ((a chart-axis-names
) &optional dir margin zone start end
)
341 "Draw axis information based upon A range to be spread along the edge.
342 Optional argument DIR the direction of the chart.
343 Optional argument MARGIN , ZONE, START and END specify boundaries of the drawing."
345 ;; We prefer about 5 spaces between each value
354 (setq odd
(= (%
(length s
) 2) 1))
355 (setq r
(chart-translate-namezone (oref a chart
) i
))
356 (if (eq dir
'vertical
)
357 (setq p
(/ (+ (car r
) (cdr r
)) 2))
358 (setq p
(- (+ (car r
) (/ (- (cdr r
) (car r
)) 2))
359 (/ (length (car s
)) 2))))
360 (if (eq dir
'vertical
)
361 (let ((x (+ (+ margin z
) (if (oref a loweredge
)
364 (if (< x
1) (setq x
1))
365 (if (> (length (car s
)) (1- margin
))
366 (setq x
(+ x margin
)))
368 (chart-goto-xy p
(+ (+ margin z
) (if (oref a loweredge
)
373 (chart-zap-chars (length (car s
)))
374 (put-text-property p1
(point) 'face
(oref a labels-face
))
379 (defmethod chart-draw-data ((c chart-bar
))
380 "Display the data available in a bar chart C."
381 (let* ((data (oref c sequences
))
382 (dir (oref c direction
))
383 (odir (if (eq dir
'vertical
) 'horizontal
'vertical
))
386 (if (stringp (car (oref (car data
) data
)))
387 ;; skip string lists...
389 ;; display number lists...
391 (seq (oref (car data
) data
)))
393 (let* ((rng (chart-translate-namezone c i
))
394 (dp (if (eq dir
'vertical
)
395 (chart-translate-ypos c
(car seq
))
396 (chart-translate-xpos c
(car seq
))))
397 (zp (if (eq dir
'vertical
)
398 (chart-translate-ypos c
0)
399 (chart-translate-xpos c
0)))
400 (fc (if chart-face-list
401 (nth (% i
(length chart-face-list
)) chart-face-list
)
406 (chart-draw-line dir
(car rng
) dp zp
)
407 (chart-draw-line dir
(cdr rng
) dp zp
))
408 (chart-draw-line dir
(car rng
) zp
(1+ dp
))
409 (chart-draw-line dir
(cdr rng
) zp
(1+ dp
)))
410 (if (= (car rng
) (cdr rng
)) nil
411 (chart-draw-line odir dp
(1+ (car rng
)) (cdr rng
))
412 (chart-draw-line odir zp
(car rng
) (1+ (cdr rng
))))
414 (chart-deface-rectangle dir rng
(cons dp zp
) fc
)
415 (chart-deface-rectangle dir rng
(cons zp dp
) fc
))
417 ;; find the bounds, and chart it!
418 ;; for now, only do one!
421 (setq data
(cdr data
))))
424 (defmethod chart-add-sequence ((c chart
) &optional seq axis-label
)
425 "Add to chart object C the sequence object SEQ.
426 If AXIS-LABEL, then the axis stored in C is updated with the bounds of SEQ,
427 or is created with the bounds of SEQ."
429 (let ((axis (eieio-oref c axis-label
)))
430 (if (stringp (car (oref seq data
)))
431 (let ((labels (oref seq data
)))
433 (setq axis
(make-instance chart-axis-names
434 :name
(oref seq name
)
437 (oset axis items labels
)))
438 (let ((range (cons 0 1))
441 (setq axis
(make-instance chart-axis-range
442 :name
(oref seq name
)
445 (if (< (car l
) (car range
)) (setcar range
(car l
)))
446 (if (> (car l
) (cdr range
)) (setcdr range
(car l
)))
448 (oset axis bounds range
)))
449 (if (eq axis-label
'x-axis
) (oset axis loweredge nil
))
450 (eieio-oset c axis-label axis
)
452 (oset c sequences
(append (oref c sequences
) (list seq
))))
454 ;;; Charting optimizers
456 (defmethod chart-trim ((c chart
) max
)
457 "Trim all sequences in chart C to be at most MAX elements long."
458 (let ((s (oref c sequences
)))
460 (let ((sl (oref (car s
) data
)))
461 (if (> (length sl
) max
)
462 (setcdr (nthcdr (1- max
) sl
) nil
)))
466 (defmethod chart-sort ((c chart
) pred
)
467 "Sort the data in chart C using predicate PRED.
468 See `chart-sort-matchlist' for more details"
469 (let* ((sl (oref c sequences
))
473 (if (stringp (car (oref s1 data
)))
475 (chart-sort-matchlist s1 s2 pred
)
476 (setq s
(oref s1 data
)))
477 (if (stringp (car (oref s2 data
)))
479 (chart-sort-matchlist s2 s1 pred
)
480 (setq s
(oref s2 data
)))
481 (error "Sorting of chart %s not supported" (object-name c
))))
482 (if (eq (oref c direction
) 'horizontal
)
483 (oset (oref c y-axis
) items s
)
484 (oset (oref c x-axis
) items s
)
488 (defun chart-sort-matchlist (namelst numlst pred
)
489 "Sort NAMELST and NUMLST (both SEQUENCE objects) based on predicate PRED.
490 PRED should be the equivalent of '<, except it must expect two
491 cons cells of the form (NAME . NUM). See SORT for more details."
492 ;; 1 - create 1 list of cons cells
494 (alst (oref namelst data
))
495 (ulst (oref numlst data
)))
497 ;; this is reversed, but were are sorting anyway
498 (setq newlist
(cons (cons (car alst
) (car ulst
)) newlist
))
499 (setq alst
(cdr alst
)
501 ;; 2 - Run sort routine on it
502 (setq newlist
(sort newlist pred
)
505 ;; 3 - Separate the lists
507 (setq alst
(cons (car (car newlist
)) alst
)
508 ulst
(cons (cdr (car newlist
)) ulst
))
509 (setq newlist
(cdr newlist
)))
510 ;; 4 - Store them back
511 (oset namelst data
(reverse alst
))
512 (oset numlst data
(reverse ulst
))))
516 (defun chart-goto-xy (x y
)
517 "Move cursor to position X Y in buffer, and add spaces and CRs if needed."
518 (let ((indent-tabs-mode nil
)
519 (num (progn (goto-char (point-min)) (forward-line y
))))
520 (if (and (= 0 num
) (/= 0 (current-column))) (newline 1))
521 (if (eobp) (newline num
))
522 (if (< x
0) (setq x
0))
523 (if (< y
0) (setq y
0))
524 ;; Now, a quicky column moveto/forceto method.
525 (or (= (move-to-column x
) x
)
528 (remove-text-properties p
(point) '(face))))))
530 (defun chart-zap-chars (n)
531 "Zap up to N chars without deleteting EOLs."
533 (if (< n
(- (save-excursion (end-of-line) (point)) (point)))
535 (delete-region (point) (save-excursion (end-of-line) (point))))))
537 (defun chart-display-label (label dir zone start end
&optional face
)
538 "Display LABEL in direction DIR in column/row ZONE between START and END.
539 Optional argument FACE is the property we wish to place on this text."
540 (if (eq dir
'horizontal
)
542 (chart-goto-xy (+ start
(- (/ (- end start
) 2) (/ (length label
) 2)))
546 (chart-zap-chars (length label
))
547 (put-text-property p1
(point) 'face face
)
550 (stz (+ start
(- (/ (- end start
) 2) (/ (length label
) 2)))))
551 (while (< i
(length label
))
552 (chart-goto-xy zone
(+ stz i
))
553 (insert (aref label i
))
555 (put-text-property (1- (point)) (point) 'face face
)
558 (defun chart-draw-line (dir zone start end
)
559 "Draw a line using line-drawing characters in direction DIR.
560 Use column or row ZONE between START and END"
562 (make-string (- end start
) (if (eq dir
'vertical
) ?| ?\-
))
565 (defun chart-deface-rectangle (dir r1 r2 face
)
566 "Colorize a rectangle in direction DIR across range R1 by range R2.
567 R1 and R2 are dotted pairs. Colorize it with FACE."
568 (let* ((range1 (if (eq dir
'vertical
) r1 r2
))
569 (range2 (if (eq dir
'vertical
) r2 r1
))
571 (while (<= y
(cdr range2
))
572 (chart-goto-xy (car range1
) y
)
573 (put-text-property (point) (+ (point) (1+ (- (cdr range1
) (car range1
))))
577 ;;; Helpful `I don't want to learn eieio just now' washover functions
579 (defun chart-bar-quickie (dir title namelst nametitle numlst numtitle
580 &optional max sort-pred
)
581 "Wash over the complex eieio stuff and create a nice bar chart.
582 Creat it going in direction DIR ['horizontal 'vertical] with TITLE
583 using a name sequence NAMELST labeled NAMETITLE with values NUMLST
586 Set the charts' max element display to MAX, and sort lists with
587 SORT-PRED if desired."
588 (let ((nc (make-instance chart-bar
590 :key-label
"8-m" ; This is a text key pic
593 (iv (eq dir
'vertical
)))
594 (chart-add-sequence nc
595 (make-instance chart-sequece
598 (if iv
'x-axis
'y-axis
))
599 (chart-add-sequence nc
600 (make-instance chart-sequece
603 (if iv
'y-axis
'x-axis
))
604 (if sort-pred
(chart-sort nc sort-pred
))
605 (if (integerp max
) (chart-trim nc max
))
606 (switch-to-buffer (chart-new-buffer nc
))
611 (defun chart-test-it-all ()
612 "Test out various charting features."
614 (chart-bar-quickie 'vertical
"Test Bar Chart"
615 '( "U1" "ME2" "C3" "B4" "QT" "EZ") "Items"
616 '( 5 -
10 23 20 30 -
3) "Values")
619 ;;; Sample utility function
621 (defun chart-file-count (dir)
622 "Draw a chart displaying the number of different file extentions in DIR."
623 (interactive "DDirectory: ")
624 (if (not (string-match "/$" dir
))
625 (setq dir
(concat dir
"/")))
626 (message "Collecting statistics...")
627 (let ((flst (directory-files dir nil nil t
))
628 (extlst (list "<dir>"))
631 (let* ((j (string-match "[^\\.]\\(\\.[a-zA-Z]+\\|~\\|#\\)$" (car flst
)))
632 (s (if (file-accessible-directory-p (concat dir
(car flst
)))
635 (substring (car flst
) (match-beginning 1) (match-end 1))
637 (m (member s extlst
)))
640 (let ((cell (nthcdr (- (length extlst
) (length m
)) cntlst
)))
641 (setcar cell
(1+ (car cell
))))
642 (setq extlst
(cons s extlst
)
643 cntlst
(cons 1 cntlst
)))))
644 (setq flst
(cdr flst
)))
645 ;; Lets create the chart!
646 (chart-bar-quickie 'vertical
"Files Extension Distribution"
647 extlst
"File Extensions"
648 cntlst
"# of occurances"
650 '(lambda (a b
) (> (cdr a
) (cdr b
))))
653 (defun chart-space-usage (d)
654 "Display a top usage chart for directory D."
655 (interactive "DDirectory: ")
656 (message "Collecting statistics...")
659 (b (get-buffer-create " *du-tmp*")))
662 (insert "cd " d
";du -sk * \n")
663 (message "Running `cd %s;du -sk *'..." d
)
664 (call-process-region (point-min) (point-max) shell-file-name t
665 (current-buffer) nil
)
666 (goto-char (point-min))
667 (message "Scanning output ...")
668 (while (re-search-forward "^\\([0-9]+\\)[ \t]+\\([^ \n]+\\)$" nil t
)
669 (let* ((nam (buffer-substring (match-beginning 2) (match-end 2)))
670 (num (buffer-substring (match-beginning 1) (match-end 1))))
671 (setq nmlst
(cons nam nmlst
)
672 ;; * 1000 to put it into bytes
673 cntlst
(cons (* (string-to-number num
) 1000) cntlst
))))
675 (error "No files found!"))
676 (chart-bar-quickie 'vertical
(format "Largest files in %s" d
)
680 '(lambda (a b
) (> (cdr a
) (cdr b
))))
683 (defun chart-emacs-storage ()
684 "Chart the current storage requirements of Emacs."
686 (let* ((data (garbage-collect))
687 (names '("strings/2" "vectors"
690 "markers" "free mark"
691 ;; "floats" "free flt"
693 (nums (list (/ (nth 3 data
) 2)
695 (car (car data
)) ; conses
697 (car (nth 1 data
)) ; syms
699 (car (nth 2 data
)) ; markers
701 ;(car (nth 5 data)) ; floats are Emacs only
704 ;; Lets create the chart!
705 (chart-bar-quickie 'vertical
"Emacs Runtime Storage Usage"
706 names
"Storage Items"
709 (defun chart-emacs-lists ()
710 "Chart out the size of various important lists."
712 (let* ((names '("buffers" "frames" "processes" "faces"))
713 (nums (list (length (buffer-list))
714 (length (frame-list))
715 (length (process-list))
718 (if (fboundp 'x-display-list
)
719 (setq names
(append names
'("x-displays"))
720 nums
(append nums
(list (length (x-display-list))))))
721 ;; Lets create the chart!
722 (chart-bar-quickie 'vertical
"Emacs List Size Chart"
723 names
"Various Lists"
726 (defun chart-rmail-from ()
727 "If we are in an rmail summary buffer, then chart out the froms."
729 (if (not (eq major-mode
'rmail-summary-mode
))
730 (error "You must invoke chart-rmail-from in an rmail summary buffer"))
734 (goto-char (point-min))
735 (while (re-search-forward "\\-[A-Z][a-z][a-z] +\\(\\w+\\)@\\w+" nil t
)
736 (let* ((nam (buffer-substring (match-beginning 1) (match-end 1)))
737 (m (member nam nmlst
)))
738 (message "Scanned username %s" nam
)
740 (let ((cell (nthcdr (- (length nmlst
) (length m
)) cntlst
)))
741 (setcar cell
(1+ (car cell
))))
742 (setq nmlst
(cons nam nmlst
)
743 cntlst
(cons 1 cntlst
))))))
744 (chart-bar-quickie 'vertical
"Username Occurance in RMAIL box"
746 cntlst
"# of occurances"
748 '(lambda (a b
) (> (cdr a
) (cdr b
))))
754 ;;; chart.el ends here