2012-07-19 11:39:38 +00:00
|
|
|
;;; chart.el --- Draw charts (bar charts, etc) -*- lexical-binding: t -*-
|
2009-09-28 00:49:54 +00:00
|
|
|
|
2017-01-01 03:14:01 +00:00
|
|
|
;; Copyright (C) 1996, 1998-1999, 2001, 2004-2005, 2007-2017 Free
|
2014-01-01 07:43:34 +00:00
|
|
|
;; Software Foundation, Inc.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
;; Author: Eric M. Ludlam <zappo@gnu.org>
|
|
|
|
;; Version: 0.2
|
|
|
|
;; Keywords: OO, chart, graph
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;
|
|
|
|
;; This package is an experiment of mine aiding in the debugging of
|
|
|
|
;; eieio, and proved to be neat enough that others may like to use
|
|
|
|
;; it. To quickly see what you can do with chart, run the command
|
|
|
|
;; `chart-test-it-all'.
|
|
|
|
;;
|
|
|
|
;; Chart current can display bar-charts in either of two
|
|
|
|
;; directions. It also supports ranged (integer) axis, and axis
|
|
|
|
;; defined by some set of strings or names. These name can be
|
|
|
|
;; automatically derived from data sequences, which are just lists of
|
|
|
|
;; anything encapsulated in a nice eieio object.
|
|
|
|
;;
|
|
|
|
;; Current example apps for chart can be accessed via these commands:
|
|
|
|
;; `chart-file-count' - count files w/ matching extensions
|
|
|
|
;; `chart-space-usage' - display space used by files/directories
|
|
|
|
;; `chart-emacs-storage' - Emacs storage units used/free (garbage-collect)
|
|
|
|
;; `chart-emacs-lists' - length of Emacs lists
|
|
|
|
;; `chart-rmail-from' - who sends you the most mail (in -summary only)
|
|
|
|
;;
|
|
|
|
;; Customization:
|
|
|
|
;;
|
|
|
|
;; If you find the default colors and pixmaps unpleasant, or too
|
|
|
|
;; short, you can change them. The variable `chart-face-color-list'
|
|
|
|
;; contains a list of colors, and `chart-face-pixmap-list' contains
|
|
|
|
;; all the pixmaps to use. The current pixmaps are those found on
|
|
|
|
;; several systems I found. The two lists should be the same length,
|
|
|
|
;; as the long list will just be truncated.
|
|
|
|
;;
|
|
|
|
;; If you would like to draw your own stipples, simply create some
|
|
|
|
;; xbm's and put them in a directory, then you can add:
|
|
|
|
;;
|
|
|
|
;; (setq x-bitmap-file-path (cons "~/mybitmaps" x-bitmap-file-path))
|
|
|
|
;;
|
|
|
|
;; to your .emacs (or wherever) and load the `chart-face-pixmap-list'
|
|
|
|
;; with all the bitmaps you want to use.
|
|
|
|
|
|
|
|
(require 'eieio)
|
2016-11-12 00:05:23 +00:00
|
|
|
(eval-when-compile (require 'cl-lib))
|
2015-12-31 18:26:43 +00:00
|
|
|
(eval-when-compile (require 'cl-generic))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
;;; Code:
|
2011-01-13 23:14:30 +00:00
|
|
|
(define-obsolete-variable-alias 'chart-map 'chart-mode-map "24.1")
|
2012-05-13 03:05:06 +00:00
|
|
|
(defvar chart-mode-map (make-sparse-keymap) "Keymap used in chart mode.")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
(defvar chart-local-object nil
|
|
|
|
"Local variable containing the locally displayed chart object.")
|
|
|
|
(make-variable-buffer-local 'chart-local-object)
|
|
|
|
|
|
|
|
(defvar chart-face-color-list '("red" "green" "blue"
|
|
|
|
"cyan" "yellow" "purple")
|
|
|
|
"Colors to use when generating `chart-face-list'.
|
|
|
|
Colors will be the background color.")
|
|
|
|
|
|
|
|
(defvar chart-face-pixmap-list
|
|
|
|
(if (and (fboundp 'display-graphic-p)
|
|
|
|
(display-graphic-p))
|
|
|
|
'("dimple1" "scales" "dot" "cross_weave" "boxes" "dimple3"))
|
|
|
|
"If pixmaps are allowed, display these background pixmaps.
|
2009-10-05 15:32:08 +00:00
|
|
|
Useful if new Emacs is used on B&W display.")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
(defcustom chart-face-use-pixmaps nil
|
2012-04-09 13:05:48 +00:00
|
|
|
"Non-nil to use fancy pixmaps in the background of chart face colors."
|
2009-09-28 00:49:54 +00:00
|
|
|
:group 'eieio
|
|
|
|
:type 'boolean)
|
|
|
|
|
2013-09-18 05:04:41 +00:00
|
|
|
(declare-function x-display-color-cells "xfns.c" (&optional terminal))
|
|
|
|
|
2011-01-13 23:14:30 +00:00
|
|
|
(defvar chart-face-list
|
2013-09-18 05:04:41 +00:00
|
|
|
(if (display-color-p)
|
2011-01-13 23:14:30 +00:00
|
|
|
(let ((cl chart-face-color-list)
|
|
|
|
(pl chart-face-pixmap-list)
|
|
|
|
(faces ())
|
|
|
|
nf)
|
|
|
|
(while cl
|
|
|
|
(setq nf (make-face
|
|
|
|
(intern (concat "chart-" (car cl) "-" (car pl)))))
|
|
|
|
(set-face-background nf (if (condition-case nil
|
|
|
|
(> (x-display-color-cells) 4)
|
|
|
|
(error t))
|
|
|
|
(car cl)
|
|
|
|
"white"))
|
|
|
|
(set-face-foreground nf "black")
|
|
|
|
(if (and chart-face-use-pixmaps
|
|
|
|
pl
|
|
|
|
(fboundp 'set-face-background-pixmap))
|
|
|
|
(condition-case nil
|
|
|
|
(set-face-background-pixmap nf (car pl))
|
|
|
|
(error (message "Cannot set background pixmap %s" (car pl)))))
|
|
|
|
(push nf faces)
|
|
|
|
(setq cl (cdr cl)
|
|
|
|
pl (cdr pl)))
|
|
|
|
faces))
|
|
|
|
"Faces used to colorize charts.
|
|
|
|
List is limited currently, which is ok since you really can't display
|
|
|
|
too much in text characters anyways.")
|
|
|
|
|
2016-11-12 00:05:23 +00:00
|
|
|
(define-derived-mode chart-mode special-mode "Chart"
|
2009-09-28 00:49:54 +00:00
|
|
|
"Define a mode in Emacs for displaying a chart."
|
|
|
|
(buffer-disable-undo)
|
|
|
|
(set (make-local-variable 'font-lock-global-modes) nil)
|
2011-01-13 23:14:30 +00:00
|
|
|
(font-lock-mode -1) ;Isn't it off already? --Stef
|
2009-09-28 00:49:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
(defclass chart ()
|
|
|
|
((title :initarg :title
|
|
|
|
:initform "Emacs Chart")
|
|
|
|
(title-face :initarg :title-face
|
|
|
|
:initform 'bold-italic)
|
|
|
|
(x-axis :initarg :x-axis
|
|
|
|
:initform nil )
|
|
|
|
(x-margin :initarg :x-margin
|
|
|
|
:initform 5)
|
|
|
|
(x-width :initarg :x-width
|
|
|
|
)
|
|
|
|
(y-axis :initarg :y-axis
|
|
|
|
:initform nil)
|
|
|
|
(y-margin :initarg :y-margin
|
|
|
|
:initform 5)
|
|
|
|
(y-width :initarg :y-width
|
|
|
|
)
|
|
|
|
(key-label :initarg :key-label
|
|
|
|
:initform "Key")
|
|
|
|
(sequences :initarg :sequences
|
|
|
|
:initform nil)
|
|
|
|
)
|
2009-10-05 15:32:08 +00:00
|
|
|
"Superclass for all charts to be displayed in an Emacs buffer.")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
2015-12-31 18:33:35 +00:00
|
|
|
(defun chart-new-buffer (obj)
|
|
|
|
"Create a new buffer NAME in which the chart OBJ is displayed.
|
|
|
|
Returns the newly created buffer."
|
|
|
|
(with-current-buffer (get-buffer-create (format "*%s*" (oref obj title)))
|
|
|
|
(chart-mode)
|
|
|
|
(setq chart-local-object obj)
|
|
|
|
(current-buffer)))
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod initialize-instance :after ((obj chart) &rest _fields)
|
2009-09-28 00:49:54 +00:00
|
|
|
"Initialize the chart OBJ being created with FIELDS.
|
|
|
|
Make sure the width/height is correct."
|
|
|
|
(oset obj x-width (- (window-width) 10))
|
|
|
|
(oset obj y-width (- (window-height) 12)))
|
|
|
|
|
|
|
|
(defclass chart-axis ()
|
|
|
|
((name :initarg :name
|
|
|
|
:initform "Generic Axis")
|
|
|
|
(loweredge :initarg :loweredge
|
|
|
|
:initform t)
|
|
|
|
(name-face :initarg :name-face
|
|
|
|
:initform 'bold)
|
2011-11-19 09:18:31 +00:00
|
|
|
(labels-face :initarg :labels-face
|
2009-09-28 00:49:54 +00:00
|
|
|
:initform 'italic)
|
|
|
|
(chart :initarg :chart
|
|
|
|
:initform nil)
|
|
|
|
)
|
|
|
|
"Superclass used for display of an axis.")
|
|
|
|
|
|
|
|
(defclass chart-axis-range (chart-axis)
|
|
|
|
((bounds :initarg :bounds
|
|
|
|
:initform '(0.0 . 50.0))
|
|
|
|
)
|
2009-10-05 15:32:08 +00:00
|
|
|
"Class used to display an axis defined by a range of values.")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
(defclass chart-axis-names (chart-axis)
|
|
|
|
((items :initarg :items
|
|
|
|
:initform nil)
|
|
|
|
)
|
2009-10-05 15:32:08 +00:00
|
|
|
"Class used to display an axis which represents different named items.")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
(defclass chart-sequece ()
|
|
|
|
((data :initarg :data
|
|
|
|
:initform nil)
|
|
|
|
(name :initarg :name
|
|
|
|
:initform "Data")
|
|
|
|
)
|
2009-10-05 15:32:08 +00:00
|
|
|
"Class used for all data in different charts.")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
(defclass chart-bar (chart)
|
|
|
|
((direction :initarg :direction
|
|
|
|
:initform vertical))
|
2009-10-05 15:32:08 +00:00
|
|
|
"Subclass for bar charts (vertical or horizontal).")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-draw ((c chart) &optional buff)
|
2009-09-28 00:49:54 +00:00
|
|
|
"Start drawing a chart object C in optional BUFF.
|
2009-10-05 15:32:08 +00:00
|
|
|
Erases current contents of buffer."
|
2016-11-12 00:05:23 +00:00
|
|
|
(with-silent-modifications
|
|
|
|
(save-excursion
|
|
|
|
(if buff (set-buffer buff))
|
|
|
|
(erase-buffer)
|
|
|
|
(insert (make-string (window-height (selected-window)) ?\n))
|
|
|
|
;; Start by displaying the axis
|
|
|
|
(chart-draw-axis c)
|
|
|
|
;; Display title
|
|
|
|
(chart-draw-title c)
|
|
|
|
;; Display data
|
|
|
|
(message "Rendering chart...")
|
|
|
|
(sit-for 0)
|
|
|
|
(chart-draw-data c)
|
|
|
|
;; Display key
|
|
|
|
; (chart-draw-key c)
|
|
|
|
(message "Rendering chart...done")
|
|
|
|
)))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-draw-title ((c chart))
|
2009-09-28 00:49:54 +00:00
|
|
|
"Draw a title upon the chart.
|
|
|
|
Argument C is the chart object."
|
|
|
|
(chart-display-label (oref c title) 'horizontal 0 0 (window-width)
|
|
|
|
(oref c title-face)))
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-size-in-dir ((c chart) dir)
|
2009-09-28 00:49:54 +00:00
|
|
|
"Return the physical size of chart C in direction DIR."
|
|
|
|
(if (eq dir 'vertical)
|
|
|
|
(oref c y-width)
|
|
|
|
(oref c x-width)))
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-draw-axis ((c chart))
|
2009-09-28 00:49:54 +00:00
|
|
|
"Draw axis into the current buffer defined by chart C."
|
|
|
|
(let ((ymarg (oref c y-margin))
|
|
|
|
(xmarg (oref c x-margin))
|
|
|
|
(ylen (oref c y-width))
|
|
|
|
(xlen (oref c x-width)))
|
|
|
|
(chart-axis-draw (oref c y-axis) 'vertical ymarg
|
|
|
|
(if (oref (oref c y-axis) loweredge) nil xlen)
|
|
|
|
xmarg (+ xmarg ylen))
|
|
|
|
(chart-axis-draw (oref c x-axis) 'horizontal xmarg
|
|
|
|
(if (oref (oref c x-axis) loweredge) nil ylen)
|
|
|
|
ymarg (+ ymarg xlen)))
|
|
|
|
)
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-axis-draw ((a chart-axis) &optional dir margin zone start end)
|
2009-10-05 15:32:08 +00:00
|
|
|
"Draw some axis for A in direction DIR with MARGIN in boundary.
|
2009-09-28 00:49:54 +00:00
|
|
|
ZONE is a zone specification.
|
|
|
|
START and END represent the boundary."
|
|
|
|
(chart-draw-line dir (+ margin (if zone zone 0)) start end)
|
|
|
|
(chart-display-label (oref a name) dir (if zone (+ zone margin 3)
|
|
|
|
(if (eq dir 'horizontal)
|
|
|
|
1 0))
|
|
|
|
start end (oref a name-face)))
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-translate-xpos ((c chart) x)
|
2009-09-28 00:49:54 +00:00
|
|
|
"Translate in chart C the coordinate X into a screen column."
|
|
|
|
(let ((range (oref (oref c x-axis) bounds)))
|
|
|
|
(+ (oref c x-margin)
|
|
|
|
(round (* (float (- x (car range)))
|
|
|
|
(/ (float (oref c x-width))
|
|
|
|
(float (- (cdr range) (car range))))))))
|
|
|
|
)
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-translate-ypos ((c chart) y)
|
2009-09-28 00:49:54 +00:00
|
|
|
"Translate in chart C the coordinate Y into a screen row."
|
|
|
|
(let ((range (oref (oref c y-axis) bounds)))
|
|
|
|
(+ (oref c x-margin)
|
|
|
|
(- (oref c y-width)
|
|
|
|
(round (* (float (- y (car range)))
|
|
|
|
(/ (float (oref c y-width))
|
|
|
|
(float (- (cdr range) (car range)))))))))
|
|
|
|
)
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-axis-draw ((a chart-axis-range) &optional dir margin zone _start _end)
|
2009-09-28 00:49:54 +00:00
|
|
|
"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."
|
2015-05-12 06:50:08 +00:00
|
|
|
(cl-call-next-method)
|
2009-09-28 00:49:54 +00:00
|
|
|
;; We prefer about 5 spaces between each value
|
|
|
|
(let* ((i (car (oref a bounds)))
|
|
|
|
(e (cdr (oref a bounds)))
|
|
|
|
(z (if zone zone 0))
|
|
|
|
(s nil)
|
|
|
|
(rng (- e i))
|
|
|
|
;; want to jump by units of 5 spaces or so
|
|
|
|
(j (/ rng (/ (chart-size-in-dir (oref a chart) dir) 4)))
|
|
|
|
p1)
|
|
|
|
(if (= j 0) (setq j 1))
|
|
|
|
(while (<= i e)
|
|
|
|
(setq s
|
|
|
|
(cond ((> i 999999)
|
|
|
|
(format "%dM" (/ i 1000000)))
|
|
|
|
((> i 999)
|
|
|
|
(format "%dK" (/ i 1000)))
|
|
|
|
(t
|
|
|
|
(format "%d" i))))
|
|
|
|
(if (eq dir 'vertical)
|
|
|
|
(let ((x (+ (+ margin z) (if (oref a loweredge)
|
|
|
|
(- (length s)) 1))))
|
|
|
|
(if (< x 1) (setq x 1))
|
|
|
|
(chart-goto-xy x (chart-translate-ypos (oref a chart) i)))
|
|
|
|
(chart-goto-xy (chart-translate-xpos (oref a chart) i)
|
|
|
|
(+ margin z (if (oref a loweredge) -1 1))))
|
|
|
|
(setq p1 (point))
|
|
|
|
(insert s)
|
|
|
|
(chart-zap-chars (length s))
|
|
|
|
(put-text-property p1 (point) 'face (oref a labels-face))
|
|
|
|
(setq i (+ i j))))
|
|
|
|
)
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-translate-namezone ((c chart) n)
|
2009-09-28 00:49:54 +00:00
|
|
|
"Return a dot-pair representing a positional range for a name.
|
|
|
|
The name in chart C of the Nth name resides.
|
2010-01-16 02:51:50 +00:00
|
|
|
Automatically compensates for direction."
|
2009-09-28 00:49:54 +00:00
|
|
|
(let* ((dir (oref c direction))
|
|
|
|
(w (if (eq dir 'vertical) (oref c x-width) (oref c y-width)))
|
|
|
|
(m (if (eq dir 'vertical) (oref c y-margin) (oref c x-margin)))
|
|
|
|
(ns (length
|
|
|
|
(oref (if (eq dir 'vertical) (oref c x-axis) (oref c y-axis))
|
|
|
|
items)))
|
|
|
|
(lpn (/ (+ 1.0 (float w)) (float ns)))
|
|
|
|
)
|
|
|
|
(cons (+ m (round (* lpn (float n))))
|
|
|
|
(+ m -1 (round (* lpn (+ 1.0 (float n))))))
|
|
|
|
))
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-axis-draw ((a chart-axis-names) &optional dir margin zone _start _end)
|
2009-09-28 00:49:54 +00:00
|
|
|
"Draw axis information based upon A range to be spread along the edge.
|
2009-10-05 15:32:08 +00:00
|
|
|
Optional argument DIR is the direction of the chart.
|
|
|
|
Optional arguments MARGIN, ZONE, START and END specify boundaries of the drawing."
|
2015-05-12 06:50:08 +00:00
|
|
|
(cl-call-next-method)
|
2009-09-28 00:49:54 +00:00
|
|
|
;; We prefer about 5 spaces between each value
|
|
|
|
(let* ((i 0)
|
|
|
|
(s (oref a items))
|
|
|
|
(z (if zone zone 0))
|
|
|
|
(r nil)
|
|
|
|
(p nil)
|
|
|
|
(odd nil)
|
|
|
|
p1)
|
|
|
|
(while s
|
|
|
|
(setq odd (= (% (length s) 2) 1))
|
|
|
|
(setq r (chart-translate-namezone (oref a chart) i))
|
|
|
|
(if (eq dir 'vertical)
|
|
|
|
(setq p (/ (+ (car r) (cdr r)) 2))
|
|
|
|
(setq p (- (+ (car r) (/ (- (cdr r) (car r)) 2))
|
|
|
|
(/ (length (car s)) 2))))
|
|
|
|
(if (eq dir 'vertical)
|
|
|
|
(let ((x (+ (+ margin z) (if (oref a loweredge)
|
|
|
|
(- (length (car s)))
|
|
|
|
(length (car s))))))
|
|
|
|
(if (< x 1) (setq x 1))
|
|
|
|
(if (> (length (car s)) (1- margin))
|
|
|
|
(setq x (+ x margin)))
|
|
|
|
(chart-goto-xy x p))
|
|
|
|
(chart-goto-xy p (+ (+ margin z) (if (oref a loweredge)
|
|
|
|
(if odd -2 -1)
|
|
|
|
(if odd 2 1)))))
|
|
|
|
(setq p1 (point))
|
|
|
|
(insert (car s))
|
|
|
|
(chart-zap-chars (length (car s)))
|
|
|
|
(put-text-property p1 (point) 'face (oref a labels-face))
|
|
|
|
(setq i (+ i 1)
|
|
|
|
s (cdr s))))
|
|
|
|
)
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-draw-data ((c chart-bar))
|
2009-09-28 00:49:54 +00:00
|
|
|
"Display the data available in a bar chart C."
|
|
|
|
(let* ((data (oref c sequences))
|
|
|
|
(dir (oref c direction))
|
|
|
|
(odir (if (eq dir 'vertical) 'horizontal 'vertical))
|
|
|
|
)
|
|
|
|
(while data
|
|
|
|
(if (stringp (car (oref (car data) data)))
|
|
|
|
;; skip string lists...
|
|
|
|
nil
|
|
|
|
;; display number lists...
|
|
|
|
(let ((i 0)
|
|
|
|
(seq (oref (car data) data)))
|
|
|
|
(while seq
|
|
|
|
(let* ((rng (chart-translate-namezone c i))
|
|
|
|
(dp (if (eq dir 'vertical)
|
|
|
|
(chart-translate-ypos c (car seq))
|
|
|
|
(chart-translate-xpos c (car seq))))
|
|
|
|
(zp (if (eq dir 'vertical)
|
|
|
|
(chart-translate-ypos c 0)
|
|
|
|
(chart-translate-xpos c 0)))
|
|
|
|
(fc (if chart-face-list
|
|
|
|
(nth (% i (length chart-face-list)) chart-face-list)
|
|
|
|
'default))
|
|
|
|
)
|
|
|
|
(if (< dp zp)
|
|
|
|
(progn
|
|
|
|
(chart-draw-line dir (car rng) dp zp)
|
|
|
|
(chart-draw-line dir (cdr rng) dp zp))
|
|
|
|
(chart-draw-line dir (car rng) zp (1+ dp))
|
|
|
|
(chart-draw-line dir (cdr rng) zp (1+ dp)))
|
|
|
|
(if (= (car rng) (cdr rng)) nil
|
|
|
|
(chart-draw-line odir dp (1+ (car rng)) (cdr rng))
|
|
|
|
(chart-draw-line odir zp (car rng) (1+ (cdr rng))))
|
|
|
|
(if (< dp zp)
|
|
|
|
(chart-deface-rectangle dir rng (cons dp zp) fc)
|
|
|
|
(chart-deface-rectangle dir rng (cons zp dp) fc))
|
|
|
|
)
|
|
|
|
;; find the bounds, and chart it!
|
|
|
|
;; for now, only do one!
|
|
|
|
(setq i (1+ i)
|
|
|
|
seq (cdr seq)))))
|
|
|
|
(setq data (cdr data))))
|
|
|
|
)
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-add-sequence ((c chart) &optional seq axis-label)
|
2009-09-28 00:49:54 +00:00
|
|
|
"Add to chart object C the sequence object SEQ.
|
|
|
|
If AXIS-LABEL, then the axis stored in C is updated with the bounds of SEQ,
|
|
|
|
or is created with the bounds of SEQ."
|
|
|
|
(if axis-label
|
|
|
|
(let ((axis (eieio-oref c axis-label)))
|
|
|
|
(if (stringp (car (oref seq data)))
|
|
|
|
(let ((labels (oref seq data)))
|
|
|
|
(if (not axis)
|
2015-01-08 04:11:58 +00:00
|
|
|
(setq axis (make-instance 'chart-axis-names
|
2009-09-28 00:49:54 +00:00
|
|
|
:name (oref seq name)
|
|
|
|
:items labels
|
|
|
|
:chart c))
|
|
|
|
(oset axis items labels)))
|
|
|
|
(let ((range (cons 0 1))
|
|
|
|
(l (oref seq data)))
|
|
|
|
(if (not axis)
|
2015-01-08 04:11:58 +00:00
|
|
|
(setq axis (make-instance 'chart-axis-range
|
2009-09-28 00:49:54 +00:00
|
|
|
:name (oref seq name)
|
|
|
|
:chart c)))
|
2016-11-12 00:05:23 +00:00
|
|
|
(dolist (x l)
|
|
|
|
(if (< x (car range)) (setcar range x))
|
|
|
|
(if (> x (cdr range)) (setcdr range x)))
|
|
|
|
(oset axis bounds range)))
|
2009-09-28 00:49:54 +00:00
|
|
|
(if (eq axis-label 'x-axis) (oset axis loweredge nil))
|
|
|
|
(eieio-oset c axis-label axis)
|
|
|
|
))
|
|
|
|
(oset c sequences (append (oref c sequences) (list seq))))
|
|
|
|
|
|
|
|
;;; Charting optimizers
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-trim ((c chart) max)
|
2009-09-28 00:49:54 +00:00
|
|
|
"Trim all sequences in chart C to be at most MAX elements long."
|
|
|
|
(let ((s (oref c sequences)))
|
2016-11-12 00:05:23 +00:00
|
|
|
(dolist (x s)
|
|
|
|
(let ((sl (oref x data)))
|
2009-09-28 00:49:54 +00:00
|
|
|
(if (> (length sl) max)
|
2016-11-12 00:05:23 +00:00
|
|
|
(setcdr (nthcdr (1- max) sl) nil)))))
|
2009-09-28 00:49:54 +00:00
|
|
|
)
|
|
|
|
|
2015-12-31 18:26:43 +00:00
|
|
|
(cl-defmethod chart-sort ((c chart) pred)
|
2009-09-28 00:49:54 +00:00
|
|
|
"Sort the data in chart C using predicate PRED.
|
2009-10-05 15:32:08 +00:00
|
|
|
See `chart-sort-matchlist' for more details."
|
2009-09-28 00:49:54 +00:00
|
|
|
(let* ((sl (oref c sequences))
|
|
|
|
(s1 (car sl))
|
|
|
|
(s2 (car (cdr sl)))
|
|
|
|
(s nil))
|
|
|
|
(if (stringp (car (oref s1 data)))
|
|
|
|
(progn
|
|
|
|
(chart-sort-matchlist s1 s2 pred)
|
|
|
|
(setq s (oref s1 data)))
|
|
|
|
(if (stringp (car (oref s2 data)))
|
|
|
|
(progn
|
|
|
|
(chart-sort-matchlist s2 s1 pred)
|
|
|
|
(setq s (oref s2 data)))
|
2013-05-24 06:59:13 +00:00
|
|
|
(error "Sorting of chart %s not supported" (eieio-object-name c))))
|
2009-09-28 00:49:54 +00:00
|
|
|
(if (eq (oref c direction) 'horizontal)
|
|
|
|
(oset (oref c y-axis) items s)
|
|
|
|
(oset (oref c x-axis) items s)
|
|
|
|
))
|
|
|
|
)
|
|
|
|
|
|
|
|
(defun chart-sort-matchlist (namelst numlst pred)
|
2009-10-05 15:32:08 +00:00
|
|
|
"Sort NAMELST and NUMLST (both sequence objects) based on predicate PRED.
|
2015-11-17 23:28:50 +00:00
|
|
|
PRED should be the equivalent of `<', except it must expect two
|
2009-10-05 15:32:08 +00:00
|
|
|
cons cells of the form (NAME . NUM). See `sort' for more details."
|
2009-09-28 00:49:54 +00:00
|
|
|
;; 1 - create 1 list of cons cells
|
|
|
|
(let ((newlist nil)
|
|
|
|
(alst (oref namelst data))
|
|
|
|
(ulst (oref numlst data)))
|
|
|
|
(while alst
|
|
|
|
;; this is reversed, but were are sorting anyway
|
|
|
|
(setq newlist (cons (cons (car alst) (car ulst)) newlist))
|
|
|
|
(setq alst (cdr alst)
|
|
|
|
ulst (cdr ulst)))
|
|
|
|
;; 2 - Run sort routine on it
|
|
|
|
(setq newlist (sort newlist pred)
|
|
|
|
alst nil
|
|
|
|
ulst nil)
|
|
|
|
;; 3 - Separate the lists
|
|
|
|
(while newlist
|
|
|
|
(setq alst (cons (car (car newlist)) alst)
|
|
|
|
ulst (cons (cdr (car newlist)) ulst))
|
|
|
|
(setq newlist (cdr newlist)))
|
|
|
|
;; 4 - Store them back
|
|
|
|
(oset namelst data (reverse alst))
|
|
|
|
(oset numlst data (reverse ulst))))
|
|
|
|
|
|
|
|
;;; Utilities
|
|
|
|
|
|
|
|
(defun chart-goto-xy (x y)
|
|
|
|
"Move cursor to position X Y in buffer, and add spaces and CRs if needed."
|
|
|
|
(let ((indent-tabs-mode nil)
|
|
|
|
(num (progn (goto-char (point-min)) (forward-line y))))
|
|
|
|
(if (and (= 0 num) (/= 0 (current-column))) (newline 1))
|
|
|
|
(if (eobp) (newline num))
|
|
|
|
(if (< x 0) (setq x 0))
|
|
|
|
(if (< y 0) (setq y 0))
|
|
|
|
;; Now, a quicky column moveto/forceto method.
|
|
|
|
(or (= (move-to-column x) x)
|
|
|
|
(let ((p (point)))
|
|
|
|
(indent-to x)
|
|
|
|
(remove-text-properties p (point) '(face))))))
|
|
|
|
|
|
|
|
(defun chart-zap-chars (n)
|
2009-10-01 02:50:00 +00:00
|
|
|
"Zap up to N chars without deleting EOLs."
|
2009-09-28 00:49:54 +00:00
|
|
|
(if (not (eobp))
|
Replace end-of-line, save-excursion etc with point-at-eol, point-at-bol.
* lisp/mh-e/mh-seq.el (mh-read-msg-list): Use point-at-eol.
* lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-show-infos)
(gnus-bookmark-kill-line): Use point-at-eol.
* lisp/cedet/ede/proj-elisp.el (ede-proj-flush-autoconf): Use point-at-bol.
* lisp/emacs-lisp/chart.el (chart-zap-chars):
* lisp/play/decipher.el (decipher-set-map):
* lisp/progmodes/ada-mode.el (ada-get-current-indent)
(ada-search-ignore-string-comment, ada-tab-hard, ada-untab-hard):
* lisp/progmodes/ada-prj.el (ada-prj-load-from-file, ada-prj-display-help):
* lisp/progmodes/ada-xref.el (ada-initialize-runtime-library)
(ada-get-all-references):
* lisp/progmodes/cperl-mode.el (cperl-electric-paren)
(cperl-electric-rparen, cperl-electric-keyword, cperl-electric-else)
(cperl-linefeed, cperl-sniff-for-indent, cperl-to-comment-or-eol)
(cperl-find-pods-heres, cperl-indent-exp, cperl-fix-line-spacing)
(cperl-word-at-point-hard):
* lisp/progmodes/idlw-shell.el (idlwave-shell-move-or-history)
(idlwave-shell-filename-string, idlwave-shell-batch-command)
(idlwave-shell-display-line):
* lisp/progmodes/idlwave.el (idlwave-show-begin, idlwave-fill-paragraph)
(idlwave-calc-hanging-indent, idlwave-auto-fill, idlwave-template):
* lisp/progmodes/js.el (js--re-search-forward-inner)
(js--re-search-backward-inner):
* lisp/progmodes/vhdl-mode.el (vhdl-align-region-1, vhdl-align-region-2)
(vhdl-fix-clause, vhdl-compose-configuration-architecture):
* lisp/progmodes/ruby-mode.el (ruby-parse-partial, eval-when-compile):
* lisp/textmodes/flyspell.el (flyspell-process-localwords):
* lisp/textmodes/ispell.el (ispell-buffer-local-parsing)
(ispell-buffer-local-dict, ispell-buffer-local-words):
Use point-at-bol and point-at-eol.
2010-11-07 01:36:33 +00:00
|
|
|
(if (< n (- (point-at-eol) (point)))
|
2009-09-28 00:49:54 +00:00
|
|
|
(delete-char n)
|
Replace end-of-line, save-excursion etc with point-at-eol, point-at-bol.
* lisp/mh-e/mh-seq.el (mh-read-msg-list): Use point-at-eol.
* lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-show-infos)
(gnus-bookmark-kill-line): Use point-at-eol.
* lisp/cedet/ede/proj-elisp.el (ede-proj-flush-autoconf): Use point-at-bol.
* lisp/emacs-lisp/chart.el (chart-zap-chars):
* lisp/play/decipher.el (decipher-set-map):
* lisp/progmodes/ada-mode.el (ada-get-current-indent)
(ada-search-ignore-string-comment, ada-tab-hard, ada-untab-hard):
* lisp/progmodes/ada-prj.el (ada-prj-load-from-file, ada-prj-display-help):
* lisp/progmodes/ada-xref.el (ada-initialize-runtime-library)
(ada-get-all-references):
* lisp/progmodes/cperl-mode.el (cperl-electric-paren)
(cperl-electric-rparen, cperl-electric-keyword, cperl-electric-else)
(cperl-linefeed, cperl-sniff-for-indent, cperl-to-comment-or-eol)
(cperl-find-pods-heres, cperl-indent-exp, cperl-fix-line-spacing)
(cperl-word-at-point-hard):
* lisp/progmodes/idlw-shell.el (idlwave-shell-move-or-history)
(idlwave-shell-filename-string, idlwave-shell-batch-command)
(idlwave-shell-display-line):
* lisp/progmodes/idlwave.el (idlwave-show-begin, idlwave-fill-paragraph)
(idlwave-calc-hanging-indent, idlwave-auto-fill, idlwave-template):
* lisp/progmodes/js.el (js--re-search-forward-inner)
(js--re-search-backward-inner):
* lisp/progmodes/vhdl-mode.el (vhdl-align-region-1, vhdl-align-region-2)
(vhdl-fix-clause, vhdl-compose-configuration-architecture):
* lisp/progmodes/ruby-mode.el (ruby-parse-partial, eval-when-compile):
* lisp/textmodes/flyspell.el (flyspell-process-localwords):
* lisp/textmodes/ispell.el (ispell-buffer-local-parsing)
(ispell-buffer-local-dict, ispell-buffer-local-words):
Use point-at-bol and point-at-eol.
2010-11-07 01:36:33 +00:00
|
|
|
(delete-region (point) (point-at-eol)))))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
(defun chart-display-label (label dir zone start end &optional face)
|
|
|
|
"Display LABEL in direction DIR in column/row ZONE between START and END.
|
|
|
|
Optional argument FACE is the property we wish to place on this text."
|
|
|
|
(if (eq dir 'horizontal)
|
|
|
|
(let (p1)
|
|
|
|
(chart-goto-xy (+ start (- (/ (- end start) 2) (/ (length label) 2)))
|
|
|
|
zone)
|
|
|
|
(setq p1 (point))
|
|
|
|
(insert label)
|
|
|
|
(chart-zap-chars (length label))
|
|
|
|
(put-text-property p1 (point) 'face face)
|
|
|
|
)
|
|
|
|
(let ((i 0)
|
|
|
|
(stz (+ start (- (/ (- end start) 2) (/ (length label) 2)))))
|
|
|
|
(while (< i (length label))
|
|
|
|
(chart-goto-xy zone (+ stz i))
|
|
|
|
(insert (aref label i))
|
|
|
|
(chart-zap-chars 1)
|
|
|
|
(put-text-property (1- (point)) (point) 'face face)
|
|
|
|
(setq i (1+ i))))))
|
|
|
|
|
|
|
|
(defun chart-draw-line (dir zone start end)
|
|
|
|
"Draw a line using line-drawing characters in direction DIR.
|
2009-10-05 15:32:08 +00:00
|
|
|
Use column or row ZONE between START and END."
|
2009-09-28 00:49:54 +00:00
|
|
|
(chart-display-label
|
|
|
|
(make-string (- end start) (if (eq dir 'vertical) ?| ?\-))
|
|
|
|
dir zone start end))
|
|
|
|
|
|
|
|
(defun chart-deface-rectangle (dir r1 r2 face)
|
|
|
|
"Colorize a rectangle in direction DIR across range R1 by range R2.
|
|
|
|
R1 and R2 are dotted pairs. Colorize it with FACE."
|
|
|
|
(let* ((range1 (if (eq dir 'vertical) r1 r2))
|
|
|
|
(range2 (if (eq dir 'vertical) r2 r1))
|
|
|
|
(y (car range2)))
|
|
|
|
(while (<= y (cdr range2))
|
|
|
|
(chart-goto-xy (car range1) y)
|
|
|
|
(put-text-property (point) (+ (point) (1+ (- (cdr range1) (car range1))))
|
|
|
|
'face face)
|
|
|
|
(setq y (1+ y)))))
|
|
|
|
|
|
|
|
;;; Helpful `I don't want to learn eieio just now' washover functions
|
|
|
|
|
|
|
|
(defun chart-bar-quickie (dir title namelst nametitle numlst numtitle
|
|
|
|
&optional max sort-pred)
|
2009-10-05 15:32:08 +00:00
|
|
|
"Wash over the complex EIEIO stuff and create a nice bar chart.
|
2015-11-17 23:28:50 +00:00
|
|
|
Create it going in direction DIR [`horizontal' `vertical'] with TITLE
|
2009-09-28 00:49:54 +00:00
|
|
|
using a name sequence NAMELST labeled NAMETITLE with values NUMLST
|
|
|
|
labeled NUMTITLE.
|
|
|
|
Optional arguments:
|
2009-10-05 15:32:08 +00:00
|
|
|
Set the chart's max element display to MAX, and sort lists with
|
2009-09-28 00:49:54 +00:00
|
|
|
SORT-PRED if desired."
|
2015-01-08 04:11:58 +00:00
|
|
|
(let ((nc (make-instance 'chart-bar
|
2009-09-28 00:49:54 +00:00
|
|
|
:title title
|
|
|
|
:key-label "8-m" ; This is a text key pic
|
|
|
|
:direction dir
|
|
|
|
))
|
|
|
|
(iv (eq dir 'vertical)))
|
|
|
|
(chart-add-sequence nc
|
2015-01-08 04:11:58 +00:00
|
|
|
(make-instance 'chart-sequece
|
2009-09-28 00:49:54 +00:00
|
|
|
:data namelst
|
|
|
|
:name nametitle)
|
|
|
|
(if iv 'x-axis 'y-axis))
|
|
|
|
(chart-add-sequence nc
|
2015-01-08 04:11:58 +00:00
|
|
|
(make-instance 'chart-sequece
|
2009-09-28 00:49:54 +00:00
|
|
|
:data numlst
|
|
|
|
:name numtitle)
|
|
|
|
(if iv 'y-axis 'x-axis))
|
|
|
|
(if sort-pred (chart-sort nc sort-pred))
|
|
|
|
(if (integerp max) (chart-trim nc max))
|
|
|
|
(switch-to-buffer (chart-new-buffer nc))
|
|
|
|
(chart-draw nc)))
|
|
|
|
|
|
|
|
;;; Test code
|
|
|
|
|
|
|
|
(defun chart-test-it-all ()
|
|
|
|
"Test out various charting features."
|
|
|
|
(interactive)
|
|
|
|
(chart-bar-quickie 'vertical "Test Bar Chart"
|
|
|
|
'( "U1" "ME2" "C3" "B4" "QT" "EZ") "Items"
|
|
|
|
'( 5 -10 23 20 30 -3) "Values")
|
|
|
|
)
|
|
|
|
|
|
|
|
;;; Sample utility function
|
|
|
|
|
|
|
|
(defun chart-file-count (dir)
|
2009-10-01 02:50:00 +00:00
|
|
|
"Draw a chart displaying the number of different file extensions in DIR."
|
2009-09-28 00:49:54 +00:00
|
|
|
(interactive "DDirectory: ")
|
|
|
|
(message "Collecting statistics...")
|
|
|
|
(let ((flst (directory-files dir nil nil t))
|
|
|
|
(extlst (list "<dir>"))
|
|
|
|
(cntlst (list 0)))
|
2016-11-12 00:05:23 +00:00
|
|
|
(dolist (f flst)
|
|
|
|
(let* ((x (file-name-extension f))
|
|
|
|
(s (if (file-accessible-directory-p (expand-file-name f dir))
|
|
|
|
"<dir>" x))
|
2009-09-28 00:49:54 +00:00
|
|
|
(m (member s extlst)))
|
2016-11-12 00:05:23 +00:00
|
|
|
(unless (null s)
|
2009-09-28 00:49:54 +00:00
|
|
|
(if m
|
2016-11-12 00:05:23 +00:00
|
|
|
(cl-incf (car (nthcdr (- (length extlst) (length m)) cntlst)))
|
2009-09-28 00:49:54 +00:00
|
|
|
(setq extlst (cons s extlst)
|
2016-11-12 00:05:23 +00:00
|
|
|
cntlst (cons 1 cntlst))))))
|
2011-11-15 17:37:37 +00:00
|
|
|
;; Let's create the chart!
|
2009-09-28 00:49:54 +00:00
|
|
|
(chart-bar-quickie 'vertical "Files Extension Distribution"
|
|
|
|
extlst "File Extensions"
|
2010-01-18 04:39:40 +00:00
|
|
|
cntlst "# of occurrences"
|
2009-09-28 00:49:54 +00:00
|
|
|
10
|
2011-05-23 17:57:17 +00:00
|
|
|
(lambda (a b) (> (cdr a) (cdr b))))
|
2009-09-28 00:49:54 +00:00
|
|
|
))
|
|
|
|
|
|
|
|
(defun chart-space-usage (d)
|
|
|
|
"Display a top usage chart for directory D."
|
|
|
|
(interactive "DDirectory: ")
|
|
|
|
(message "Collecting statistics...")
|
|
|
|
(let ((nmlst nil)
|
|
|
|
(cntlst nil)
|
|
|
|
(b (get-buffer-create " *du-tmp*")))
|
|
|
|
(set-buffer b)
|
|
|
|
(erase-buffer)
|
|
|
|
(insert "cd " d ";du -sk * \n")
|
Go back to grave quoting in source-code docstrings etc.
This reverts almost all my recent changes to use curved quotes
in docstrings and/or strings used for error diagnostics.
There are a few exceptions, e.g., Bahá’í proper names.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet)
(outlineify-sticky):
* lisp/apropos.el (apropos-library):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/button.el (button-category-symbol, button-put)
(make-text-button):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-embed.el (calc-do-embedded):
* lisp/calc/calc-ext.el (calc-user-function-list):
* lisp/calc/calc-graph.el (calc-graph-show-dumb):
* lisp/calc/calc-help.el (calc-describe-key)
(calc-describe-thing, calc-full-help):
* lisp/calc/calc-lang.el (calc-c-language)
(math-parse-fortran-vector-end, math-parse-tex-sum)
(math-parse-eqn-matrix, math-parse-eqn-prime)
(calc-yacas-language, calc-maxima-language, calc-giac-language)
(math-read-giac-subscr, math-read-math-subscr)
(math-read-big-rec, math-read-big-balance):
* lisp/calc/calc-misc.el (calc-help, report-calc-bug):
* lisp/calc/calc-mode.el (calc-auto-why, calc-save-modes)
(calc-auto-recompute):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part, calc-user-define-invocation)
(math-do-arg-check):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-vec.el (math-read-brackets):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calc/calc.el (calc, calc-do, calc-user-invocation):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/diary-lib.el (diary-check-diary-file)
(diary-mail-entries, diary-from-outlook):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--convert-float-to-ical)
(icalendar--convert-date-to-ical)
(icalendar--convert-ical-to-diary)
(icalendar--convert-recurring-to-diary)
(icalendar--add-diary-entry):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/timeclock.el (timeclock-mode-line-display)
(timeclock-make-hours-explicit, timeclock-log-data):
* lisp/calendar/todo-mode.el (todo-prefix, todo-delete-category)
(todo-item-mark, todo-check-format)
(todo-insert-item--next-param, todo-edit-item--next-key)
(todo-mode):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/mode-local.el (describe-mode-local-overload)
(mode-local-print-binding, mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/cedet/srecode/srt-mode.el (srecode-macro-help):
* lisp/cus-start.el (standard):
* lisp/cus-theme.el (describe-theme-1):
* lisp/custom.el (custom-add-dependencies, custom-check-theme)
(custom--sort-vars-1, load-theme):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dired-x.el (dired-do-run-mail):
* lisp/dired.el (dired-log):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-enable-advice)
(ad-disable-advice, ad-remove-advice, ad-set-argument)
(ad-set-arguments, ad--defalias-fset, ad-activate)
(ad-deactivate):
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand)
(byte-compile-unfold-lambda, byte-optimize-form-code-walker)
(byte-optimize-while, byte-optimize-apply):
* lisp/emacs-lisp/byte-run.el (defun, defsubst):
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode)
(byte-compile-log-file, byte-compile-format-warn)
(byte-compile-nogroup-warn, byte-compile-arglist-warn)
(byte-compile-cl-warn)
(byte-compile-warn-about-unresolved-functions)
(byte-compile-file, byte-compile--declare-var)
(byte-compile-file-form-defmumble, byte-compile-form)
(byte-compile-normal-call, byte-compile-check-variable)
(byte-compile-variable-ref, byte-compile-variable-set)
(byte-compile-subr-wrong-args, byte-compile-setq-default)
(byte-compile-negation-optimizer)
(byte-compile-condition-case--old)
(byte-compile-condition-case--new, byte-compile-save-excursion)
(byte-compile-defvar, byte-compile-autoload)
(byte-compile-lambda-form)
(byte-compile-make-variable-buffer-local, display-call-tree)
(batch-byte-compile):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use):
* lisp/emacs-lisp/chart.el (chart-space-usage):
* lisp/emacs-lisp/check-declare.el (check-declare-scan)
(check-declare-warn, check-declare-file)
(check-declare-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine)
(checkdoc-message-text-engine):
* lisp/emacs-lisp/cl-extra.el (cl-parse-integer)
(cl--describe-class):
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric)
(cl--generic-describe, cl-generic-generalizers):
* lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause, cl-tagbody)
(cl-symbol-macrolet):
* lisp/emacs-lisp/cl.el (cl-unload-function, flet):
* lisp/emacs-lisp/copyright.el (copyright)
(copyright-update-directory):
* lisp/emacs-lisp/edebug.el (edebug-read-list):
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read):
* lisp/emacs-lisp/eieio-core.el (eieio--slot-override)
(eieio-oref):
* lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor):
* lisp/emacs-lisp/eieio-speedbar.el:
(eieio-speedbar-child-make-tag-lines)
(eieio-speedbar-child-description):
* lisp/emacs-lisp/eieio.el (defclass, change-class):
* lisp/emacs-lisp/elint.el (elint-file, elint-get-top-forms)
(elint-init-form, elint-check-defalias-form)
(elint-check-let-form):
* lisp/emacs-lisp/ert.el (ert-get-test, ert-results-mode-menu)
(ert-results-pop-to-backtrace-for-test-at-point)
(ert-results-pop-to-messages-for-test-at-point)
(ert-results-pop-to-should-forms-for-test-at-point)
(ert-describe-test):
* lisp/emacs-lisp/find-func.el (find-function-search-for-symbol)
(find-function-library):
* lisp/emacs-lisp/generator.el (iter-yield):
* lisp/emacs-lisp/gv.el (gv-define-simple-setter):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring)
(advice--make, define-advice):
* lisp/emacs-lisp/package-x.el (package-upload-file):
* lisp/emacs-lisp/package.el (package-version-join)
(package-disabled-p, package-activate-1, package-activate)
(package--download-one-archive)
(package--download-and-read-archives)
(package-compute-transaction, package-install-from-archive)
(package-install, package-install-selected-packages)
(package-delete, package-autoremove, describe-package-1)
(package-install-button-action, package-delete-button-action)
(package-menu-hide-package, package-menu--list-to-prompt)
(package-menu--perform-transaction)
(package-menu--find-and-notify-upgrades):
* lisp/emacs-lisp/pcase.el (pcase-exhaustive, pcase--u1):
* lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode):
* lisp/emacs-lisp/ring.el (ring-previous, ring-next):
* lisp/emacs-lisp/rx.el (rx-check, rx-anything)
(rx-check-any-string, rx-check-any, rx-check-not, rx-=)
(rx-repeat, rx-check-backref, rx-syntax, rx-check-category)
(rx-form):
* lisp/emacs-lisp/smie.el (smie-config-save):
* lisp/emacs-lisp/subr-x.el (internal--check-binding):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-put-tag):
* lisp/emacs-lisp/testcover.el (testcover-1value):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emulation/viper-cmd.el (viper-toggle-parse-sexp-ignore-comments)
(viper-toggle-search-style, viper-kill-buffer)
(viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/env.el (setenv):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login, english):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp)
(eshell-glob-entries):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/facemenu.el (facemenu-add-new-face)
(facemenu-add-new-color):
* lisp/faces.el (read-face-name, read-face-font, describe-face)
(x-resolve-font-name):
* lisp/files-x.el (modify-file-local-variable):
* lisp/files.el (locate-user-emacs-file, find-alternate-file)
(set-auto-mode, hack-one-local-variable--obsolete)
(dir-locals-set-directory-class, write-file, basic-save-buffer)
(delete-directory, copy-directory, recover-session)
(recover-session-finish, insert-directory)
(file-modes-char-to-who, file-modes-symbolic-to-number)
(move-file-to-trash):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/finder.el (finder-commentary):
* lisp/font-lock.el (font-lock-fontify-buffer):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/frame.el (get-device-terminal, select-frame-by-name):
* lisp/fringe.el (fringe--check-style):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--parent-mode)
(help-fns--obsolete, help-fns--interactive-only)
(describe-function-1, describe-variable):
* lisp/help.el (describe-mode)
(describe-minor-mode-from-indicator):
* lisp/image.el (image-type):
* lisp/international/ccl.el (ccl-dump):
* lisp/international/fontset.el (x-must-resolve-font-name):
* lisp/international/mule-cmds.el (prefer-coding-system)
(select-safe-coding-system-interactively)
(select-safe-coding-system, activate-input-method)
(toggle-input-method, describe-current-input-method)
(describe-language-environment):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/imap.el (imap-interactive-login):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/rlogin.el (rlogin):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-ctags.el (org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/proced.el (proced-log):
* lisp/progmodes/ada-mode.el (ada-get-indent-case)
(ada-check-matching-start, ada-goto-matching-start):
* lisp/progmodes/ada-prj.el (ada-prj-display-page):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/ebrowse.el (ebrowse-tags-apropos):
* lisp/progmodes/etags.el (etags-tags-apropos-additional):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-shell-get-process-or-error)
(python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/progmodes/vhdl-mode.el (vhdl-widget-directory-validate):
* lisp/recentf.el (recentf-open-files):
* lisp/replace.el (query-replace-read-from)
(occur-after-change-function, occur-1):
* lisp/scroll-bar.el (scroll-bar-columns):
* lisp/server.el (server-get-auth-key):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, list-processes--refresh)
(compose-mail, set-variable, choose-completion-string)
(define-alternatives):
* lisp/startup.el (site-run-file, tty-handle-args, command-line)
(command-line-1):
* lisp/subr.el (noreturn, define-error, add-to-list)
(read-char-choice, version-to-list):
* lisp/term/common-win.el (x-handle-xrm-switch)
(x-handle-name-switch, x-handle-args):
* lisp/term/x-win.el (x-handle-parent-id, x-handle-smid):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/textmodes/two-column.el (2C-split):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* lisp/type-break.el (type-break-noninteractive-query):
* lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes)
(wdired-do-perm-changes):
* lisp/whitespace.el (whitespace-report-region):
Prefer grave quoting in source-code strings used to generate help
and diagnostics.
* lisp/faces.el (face-documentation):
No need to convert quotes, since the result is a docstring.
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
Simplify by generating only curved quotes, since info files are
typically that ways nowadays anyway.
* lisp/international/mule-diag.el (list-input-methods):
Don’t assume text quoting style is curved.
* lisp/org/org-bibtex.el (org-bibtex-fields):
Revert my recent changes, going back to the old quoting style.
2015-09-07 15:41:44 +00:00
|
|
|
(message "Running `cd %s;du -sk *'..." d)
|
2009-09-28 00:49:54 +00:00
|
|
|
(call-process-region (point-min) (point-max) shell-file-name t
|
|
|
|
(current-buffer) nil)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(message "Scanning output ...")
|
|
|
|
(while (re-search-forward "^\\([0-9]+\\)[ \t]+\\([^ \n]+\\)$" nil t)
|
|
|
|
(let* ((nam (buffer-substring (match-beginning 2) (match-end 2)))
|
|
|
|
(num (buffer-substring (match-beginning 1) (match-end 1))))
|
|
|
|
(setq nmlst (cons nam nmlst)
|
|
|
|
;; * 1000 to put it into bytes
|
|
|
|
cntlst (cons (* (string-to-number num) 1000) cntlst))))
|
|
|
|
(if (not nmlst)
|
|
|
|
(error "No files found!"))
|
|
|
|
(chart-bar-quickie 'vertical (format "Largest files in %s" d)
|
|
|
|
nmlst "File Name"
|
|
|
|
cntlst "File Size"
|
|
|
|
10
|
2011-05-23 17:57:17 +00:00
|
|
|
(lambda (a b) (> (cdr a) (cdr b))))
|
2009-09-28 00:49:54 +00:00
|
|
|
))
|
|
|
|
|
|
|
|
(defun chart-emacs-storage ()
|
|
|
|
"Chart the current storage requirements of Emacs."
|
|
|
|
(interactive)
|
2012-07-19 11:39:38 +00:00
|
|
|
(let* ((data (garbage-collect)))
|
2011-11-15 17:37:37 +00:00
|
|
|
;; Let's create the chart!
|
2009-09-28 00:49:54 +00:00
|
|
|
(chart-bar-quickie 'vertical "Emacs Runtime Storage Usage"
|
2012-07-19 11:39:38 +00:00
|
|
|
(mapcar (lambda (x) (symbol-name (car x))) data)
|
|
|
|
"Storage Items"
|
|
|
|
(mapcar (lambda (x) (* (nth 1 x) (nth 2 x)))
|
|
|
|
data)
|
|
|
|
"Bytes")))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
(defun chart-emacs-lists ()
|
|
|
|
"Chart out the size of various important lists."
|
|
|
|
(interactive)
|
|
|
|
(let* ((names '("buffers" "frames" "processes" "faces"))
|
|
|
|
(nums (list (length (buffer-list))
|
|
|
|
(length (frame-list))
|
|
|
|
(length (process-list))
|
|
|
|
(length (face-list))
|
|
|
|
)))
|
|
|
|
(if (fboundp 'x-display-list)
|
|
|
|
(setq names (append names '("x-displays"))
|
|
|
|
nums (append nums (list (length (x-display-list))))))
|
2011-11-15 17:37:37 +00:00
|
|
|
;; Let's create the chart!
|
2009-09-28 00:49:54 +00:00
|
|
|
(chart-bar-quickie 'vertical "Emacs List Size Chart"
|
|
|
|
names "Various Lists"
|
|
|
|
nums "Objects")))
|
|
|
|
|
|
|
|
(defun chart-rmail-from ()
|
|
|
|
"If we are in an rmail summary buffer, then chart out the froms."
|
|
|
|
(interactive)
|
|
|
|
(if (not (eq major-mode 'rmail-summary-mode))
|
|
|
|
(error "You must invoke chart-rmail-from in an rmail summary buffer"))
|
|
|
|
(let ((nmlst nil)
|
|
|
|
(cntlst nil))
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "\\-[A-Z][a-z][a-z] +\\(\\w+\\)@\\w+" nil t)
|
|
|
|
(let* ((nam (buffer-substring (match-beginning 1) (match-end 1)))
|
|
|
|
(m (member nam nmlst)))
|
|
|
|
(message "Scanned username %s" nam)
|
|
|
|
(if m
|
|
|
|
(let ((cell (nthcdr (- (length nmlst) (length m)) cntlst)))
|
|
|
|
(setcar cell (1+ (car cell))))
|
|
|
|
(setq nmlst (cons nam nmlst)
|
|
|
|
cntlst (cons 1 cntlst))))))
|
2010-01-18 04:39:40 +00:00
|
|
|
(chart-bar-quickie 'vertical "Username Occurrence in RMAIL box"
|
2009-09-28 00:49:54 +00:00
|
|
|
nmlst "User Names"
|
2010-01-18 04:39:40 +00:00
|
|
|
cntlst "# of occurrences"
|
2009-09-28 00:49:54 +00:00
|
|
|
10
|
2011-05-23 17:57:17 +00:00
|
|
|
(lambda (a b) (> (cdr a) (cdr b))))
|
2009-09-28 00:49:54 +00:00
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
(provide 'chart)
|
|
|
|
|
|
|
|
;;; chart.el ends here
|