1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-23 07:19:15 +00:00
emacs/lisp/emacs-lisp/chart.el

727 lines
24 KiB
EmacsLisp
Raw Normal View History

;;; chart.el --- Draw charts (bar charts, etc) -*- lexical-binding: t -*-
;; Copyright (C) 1996, 1998-1999, 2001, 2004-2005, 2007-2017 Free
;; Software Foundation, Inc.
;; 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)
(eval-when-compile (require 'cl-lib))
(eval-when-compile (require 'cl-generic))
;;; Code:
Use run-mode-hooks for major mode hooks. * lisp/textmodes/reftex-toc.el (reftex-toc-mode-map): Rename from reftex-toc-map. (reftex-toc-mode): Use define-derived-mode. * lisp/textmodes/reftex-sel.el (reftex-select-shared-map): New map. (reftex-select-label-mode-map, reftex-select-bib-mode-map): Rename from reftex-select-(label|bib)-map. Move init into declaration. (reftex-select-label-mode, reftex-select-bib-mode): Use define-derived-mode. * lisp/textmodes/reftex-index.el (reftex-index-phrases-mode-map) (reftex-index-mode-map): Rename from reftex-index(-phrases)-map. Move init into delcaration. (reftex-index-mode, reftex-index-phrases-mode): Use define-derived-mode. * lisp/speedbar.el (speedbar-mode-syntax-table): Renaqme from speedbar-syntax-table. Move init into declaration. (speedbar-mode-map): Rename from speedbar-key-map. Move init into declaration. (speedbar-file-key-map): Move init into declaration. (speedbar-mode): Use define-derived-mode. * lisp/recentf.el (recentf-mode): Don't run hook (or message) redundantly. * lisp/net/rcirc.el (rcirc-mode): Use run-mode-hooks. * lisp/emacs-lisp/chart.el (chart-mode-map): Rename from chart-map. (chart-face-list): Move initialization into declaration. (chart-mode): Use define-derived-mode. * lisp/calculator.el (calculator-mode-map): Move init into declaration. (calculator-mode): Use define-derived-mode. * lisp/cedet/srecode/srt-mode.el (srecode-template-mode): Use define-derived-mode. * lisp/cedet/semantic/symref/list.el (semantic-symref-results-mode): Use run-mode-hooks. * lisp/erc/erc.el (erc-mode): * lisp/erc/erc-dcc.el (erc-dcc-chat-mode): Use define-derived-mode. * lisp/org/org-remember.el (org-remember-mode): * lisp/org/org-capture.el (org-capture-mode): Don't run hook redundantly. Fixes: debbugs:513
2011-01-13 23:14:30 +00:00
(define-obsolete-variable-alias 'chart-map 'chart-mode-map "24.1")
Move define-obsolete-variable-alias before the var's definition. * lisp/vc/log-edit.el (vc-comment-ring, vc-comment-ring-index): * lisp/tooltip.el (tooltip-hook): * lisp/textmodes/reftex-toc.el (reftex-toc-map): * lisp/textmodes/reftex-sel.el (reftex-select-label-map) (reftex-select-bib-map): * lisp/textmodes/reftex-index.el (reftex-index-map) (reftex-index-phrases-map): * lisp/speedbar.el (speedbar-syntax-table, speedbar-key-map): * lisp/progmodes/meta-mode.el (meta-mode-map): * lisp/novice.el (disabled-command-hook): * lisp/loadhist.el (unload-hook-features-list): * lisp/frame.el (blink-cursor): * lisp/files.el (find-file-not-found-hooks, write-file-hooks) (write-contents-hooks): * lisp/emulation/tpu-edt.el (GOLD-map): * lisp/emacs-lock.el (emacs-lock-from-exiting): * lisp/emacs-lisp/generic.el (generic-font-lock-defaults): * lisp/emacs-lisp/chart.el (chart-map): * lisp/dos-fns.el (register-name-alist): * lisp/dired-x.el (dired-omit-files-p): * lisp/desktop.el (desktop-enable): * lisp/cus-edit.el (custom-mode-hook): * lisp/buff-menu.el (buffer-menu-mode-hook): * lisp/bookmark.el (bookmark-read-annotation-text-func) (bookmark-exit-hooks): * lisp/allout.el (allout-mode-deactivate-hook) (allout-exposure-change-hook, allout-structure-added-hook) (allout-structure-deleted-hook, allout-structure-shifted-hook): * lisp/dirtrack.el (dirtrack-toggle, dirtrackp, dirtrack-debug-toggle) (dirtrack-debug): Move call to define-obsolete-variable-alias so it comes before the corresponding variable's definition.
2012-05-13 03:05:06 +00:00
(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.")
(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.
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."
:group 'eieio
:type 'boolean)
(declare-function x-display-color-cells "xfns.c" (&optional terminal))
Use run-mode-hooks for major mode hooks. * lisp/textmodes/reftex-toc.el (reftex-toc-mode-map): Rename from reftex-toc-map. (reftex-toc-mode): Use define-derived-mode. * lisp/textmodes/reftex-sel.el (reftex-select-shared-map): New map. (reftex-select-label-mode-map, reftex-select-bib-mode-map): Rename from reftex-select-(label|bib)-map. Move init into declaration. (reftex-select-label-mode, reftex-select-bib-mode): Use define-derived-mode. * lisp/textmodes/reftex-index.el (reftex-index-phrases-mode-map) (reftex-index-mode-map): Rename from reftex-index(-phrases)-map. Move init into delcaration. (reftex-index-mode, reftex-index-phrases-mode): Use define-derived-mode. * lisp/speedbar.el (speedbar-mode-syntax-table): Renaqme from speedbar-syntax-table. Move init into declaration. (speedbar-mode-map): Rename from speedbar-key-map. Move init into declaration. (speedbar-file-key-map): Move init into declaration. (speedbar-mode): Use define-derived-mode. * lisp/recentf.el (recentf-mode): Don't run hook (or message) redundantly. * lisp/net/rcirc.el (rcirc-mode): Use run-mode-hooks. * lisp/emacs-lisp/chart.el (chart-mode-map): Rename from chart-map. (chart-face-list): Move initialization into declaration. (chart-mode): Use define-derived-mode. * lisp/calculator.el (calculator-mode-map): Move init into declaration. (calculator-mode): Use define-derived-mode. * lisp/cedet/srecode/srt-mode.el (srecode-template-mode): Use define-derived-mode. * lisp/cedet/semantic/symref/list.el (semantic-symref-results-mode): Use run-mode-hooks. * lisp/erc/erc.el (erc-mode): * lisp/erc/erc-dcc.el (erc-dcc-chat-mode): Use define-derived-mode. * lisp/org/org-remember.el (org-remember-mode): * lisp/org/org-capture.el (org-capture-mode): Don't run hook redundantly. Fixes: debbugs:513
2011-01-13 23:14:30 +00:00
(defvar chart-face-list
(if (display-color-p)
Use run-mode-hooks for major mode hooks. * lisp/textmodes/reftex-toc.el (reftex-toc-mode-map): Rename from reftex-toc-map. (reftex-toc-mode): Use define-derived-mode. * lisp/textmodes/reftex-sel.el (reftex-select-shared-map): New map. (reftex-select-label-mode-map, reftex-select-bib-mode-map): Rename from reftex-select-(label|bib)-map. Move init into declaration. (reftex-select-label-mode, reftex-select-bib-mode): Use define-derived-mode. * lisp/textmodes/reftex-index.el (reftex-index-phrases-mode-map) (reftex-index-mode-map): Rename from reftex-index(-phrases)-map. Move init into delcaration. (reftex-index-mode, reftex-index-phrases-mode): Use define-derived-mode. * lisp/speedbar.el (speedbar-mode-syntax-table): Renaqme from speedbar-syntax-table. Move init into declaration. (speedbar-mode-map): Rename from speedbar-key-map. Move init into declaration. (speedbar-file-key-map): Move init into declaration. (speedbar-mode): Use define-derived-mode. * lisp/recentf.el (recentf-mode): Don't run hook (or message) redundantly. * lisp/net/rcirc.el (rcirc-mode): Use run-mode-hooks. * lisp/emacs-lisp/chart.el (chart-mode-map): Rename from chart-map. (chart-face-list): Move initialization into declaration. (chart-mode): Use define-derived-mode. * lisp/calculator.el (calculator-mode-map): Move init into declaration. (calculator-mode): Use define-derived-mode. * lisp/cedet/srecode/srt-mode.el (srecode-template-mode): Use define-derived-mode. * lisp/cedet/semantic/symref/list.el (semantic-symref-results-mode): Use run-mode-hooks. * lisp/erc/erc.el (erc-mode): * lisp/erc/erc-dcc.el (erc-dcc-chat-mode): Use define-derived-mode. * lisp/org/org-remember.el (org-remember-mode): * lisp/org/org-capture.el (org-capture-mode): Don't run hook redundantly. Fixes: debbugs:513
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.")
(define-derived-mode chart-mode special-mode "Chart"
"Define a mode in Emacs for displaying a chart."
(buffer-disable-undo)
(set (make-local-variable 'font-lock-global-modes) nil)
Use run-mode-hooks for major mode hooks. * lisp/textmodes/reftex-toc.el (reftex-toc-mode-map): Rename from reftex-toc-map. (reftex-toc-mode): Use define-derived-mode. * lisp/textmodes/reftex-sel.el (reftex-select-shared-map): New map. (reftex-select-label-mode-map, reftex-select-bib-mode-map): Rename from reftex-select-(label|bib)-map. Move init into declaration. (reftex-select-label-mode, reftex-select-bib-mode): Use define-derived-mode. * lisp/textmodes/reftex-index.el (reftex-index-phrases-mode-map) (reftex-index-mode-map): Rename from reftex-index(-phrases)-map. Move init into delcaration. (reftex-index-mode, reftex-index-phrases-mode): Use define-derived-mode. * lisp/speedbar.el (speedbar-mode-syntax-table): Renaqme from speedbar-syntax-table. Move init into declaration. (speedbar-mode-map): Rename from speedbar-key-map. Move init into declaration. (speedbar-file-key-map): Move init into declaration. (speedbar-mode): Use define-derived-mode. * lisp/recentf.el (recentf-mode): Don't run hook (or message) redundantly. * lisp/net/rcirc.el (rcirc-mode): Use run-mode-hooks. * lisp/emacs-lisp/chart.el (chart-mode-map): Rename from chart-map. (chart-face-list): Move initialization into declaration. (chart-mode): Use define-derived-mode. * lisp/calculator.el (calculator-mode-map): Move init into declaration. (calculator-mode): Use define-derived-mode. * lisp/cedet/srecode/srt-mode.el (srecode-template-mode): Use define-derived-mode. * lisp/cedet/semantic/symref/list.el (semantic-symref-results-mode): Use run-mode-hooks. * lisp/erc/erc.el (erc-mode): * lisp/erc/erc-dcc.el (erc-dcc-chat-mode): Use define-derived-mode. * lisp/org/org-remember.el (org-remember-mode): * lisp/org/org-capture.el (org-capture-mode): Don't run hook redundantly. Fixes: debbugs:513
2011-01-13 23:14:30 +00:00
(font-lock-mode -1) ;Isn't it off already? --Stef
)
(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)
)
"Superclass for all charts to be displayed in an Emacs buffer.")
(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)))
(cl-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))
(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
: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))
)
"Class used to display an axis defined by a range of values.")
(defclass chart-axis-names (chart-axis)
((items :initarg :items
:initform nil)
)
"Class used to display an axis which represents different named items.")
(defclass chart-sequece ()
((data :initarg :data
:initform nil)
(name :initarg :name
:initform "Data")
)
"Class used for all data in different charts.")
(defclass chart-bar (chart)
((direction :initarg :direction
:initform vertical))
"Subclass for bar charts (vertical or horizontal).")
(cl-defmethod chart-draw ((c chart) &optional buff)
"Start drawing a chart object C in optional BUFF.
Erases current contents of buffer."
(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")
)))
(cl-defmethod chart-draw-title ((c chart))
"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)))
(cl-defmethod chart-size-in-dir ((c chart) dir)
"Return the physical size of chart C in direction DIR."
(if (eq dir 'vertical)
(oref c y-width)
(oref c x-width)))
(cl-defmethod chart-draw-axis ((c chart))
"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)))
)
(cl-defmethod chart-axis-draw ((a chart-axis) &optional dir margin zone start end)
"Draw some axis for A in direction DIR with MARGIN in boundary.
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)))
(cl-defmethod chart-translate-xpos ((c chart) x)
"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))))))))
)
(cl-defmethod chart-translate-ypos ((c chart) y)
"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)))))))))
)
(cl-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."
(cl-call-next-method)
;; 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))))
)
(cl-defmethod chart-translate-namezone ((c chart) n)
"Return a dot-pair representing a positional range for a name.
The name in chart C of the Nth name resides.
Automatically compensates for direction."
(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))))))
))
(cl-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."
(cl-call-next-method)
;; 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))))
)
(cl-defmethod chart-draw-data ((c chart-bar))
"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))))
)
(cl-defmethod chart-add-sequence ((c chart) &optional seq axis-label)
"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)
lisp/emacs-lisp/eieio-core.el (eieio-backward-compatibility): New var. * lisp/cedet/ede/speedbar.el (ede-speedbar-compile-line) (ede-speedbar-get-top-project-for-line): * lisp/cedet/ede.el (ede-buffer-belongs-to-target-p) (ede-buffer-belongs-to-project-p, ede-build-forms-menu) (ede-add-project-to-global-list): * lisp/cedet/semantic/db-typecache.el (semanticdb-get-typecache): * lisp/cedet/semantic/db-file.el (semanticdb-load-database): * lisp/cedet/semantic/db-el.el (semanticdb-elisp-sym->tag): * lisp/cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-load-helper): * lisp/cedet/ede/project-am.el (project-am-preferred-target-type): * lisp/cedet/ede/proj.el (ede-proj-load): * lisp/cedet/ede/custom.el (ede-customize-current-target, ede-customize-target): * lisp/cedet/semantic/ede-grammar.el ("semantic grammar"): * lisp/cedet/semantic/scope.el (semantic-scope-reset-cache) (semantic-calculate-scope): * lisp/cedet/srecode/map.el (srecode-map-update-map): * lisp/cedet/srecode/insert.el (srecode-insert-show-error-report) (srecode-insert-method, srecode-insert-include-lookup) (srecode-insert-method): * lisp/cedet/srecode/fields.el (srecode-active-template-region): * lisp/cedet/srecode/compile.el (srecode-flush-active-templates) (srecode-compile-inserter): Don't use <class> as a variable. Use `oref-default' for class slots. * lisp/cedet/semantic/grammar.el (semantic-grammar-eldoc-last-data): New var. (semantic-grammar-eldoc-get-macro-docstring): Use it instead of eldoc-last-data. * lisp/cedet/semantic/fw.el (semantic-exit-on-input): Use `declare'. (semantic-throw-on-input): Use `with-current-buffer'. * lisp/cedet/semantic/db.el (semanticdb-abstract-table-list): Define if not pre-defined. * lisp/cedet/semantic/db-find.el (semanticdb-find-tags-collector): Use save-current-buffer. (semanticdb-find-tags-collector): Don't use <class> as a variable. * lisp/cedet/semantic/complete.el (semantic-complete-active-default) (semantic-complete-current-matched-tag): Declare. (semantic-complete-inline-custom-type): Don't use <class> as a variable. * lisp/cedet/semantic/bovine/make.el (semantic-analyze-possible-completions): Use with-current-buffer. * lisp/cedet/semantic.el (semantic-parser-warnings): Declare. * lisp/cedet/ede/base.el (ede-target-list): Define if not pre-defined. (ede-with-projectfile): Prefer find-file-noselect over save-window-excursion. * lisp/emacs-lisp/chart.el (chart-add-sequence, chart-bar-quickie): Don't use <class> as a variable. * lisp/emacs-lisp/eieio-base.el (eieio-persistent-validate/fix-slot-value): Improve error messages. (eieio-persistent-slot-type-is-class-p): Handle `list-of' types, as well as user-defined types. Emit errors for legacy types like <class>-child and <class>-list, if not eieio-backward-compatibility. * lisp/emacs-lisp/eieio-core.el (eieio-backward-compatibility): New var. (eieio-defclass-autoload): Obey it. (eieio--class-object): Improve error behavior. (eieio-class-children-fast, same-class-fast-p): Remove. Inline at every use site. (eieio--defgeneric-form-primary-only): Rename from eieio-defgeneric-form-primary-only; update all callers. (eieio--defgeneric-form-primary-only-one): Rename from eieio-defgeneric-form-primary-only-one; update all callers. (eieio-defgeneric-reset-generic-form) (eieio-defgeneric-reset-generic-form-primary-only) (eieio-defgeneric-reset-generic-form-primary-only-one): Remove. (eieio--method-optimize-primary): New function to replace them. (eieio--defmethod, eieio-defmethod): Use it. (eieio--perform-slot-validation): Rename from eieio-perform-slot-validation; update all callers. (eieio--validate-slot-value): Rename from eieio-validate-slot-value. Change `class' to be a class object. Update all callers. (eieio--validate-class-slot-value): Rename from eieio-validate-class-slot-value. Change `class' to be a class object. Update all callers. (eieio-oset-default): Accept class object as well. (eieio--generic-call-primary-only): Rename from eieio-generic-call-primary-only. Update all callers. * lisp/emacs-lisp/eieio-opt.el (eieio-read-generic-p): Remove. (eieio-read-generic): Use `generic-p' instead. * lisp/emacs-lisp/eieio.el (same-class-p): Accept class object as well. (call-next-method): Simplify. (clone): Obey eieio-backward-compatibility. * lisp/gnus/registry.el: Don't use <class> as a variable. * test/automated/eieio-test-methodinvoke.el (eieio-test-method-order-list-4): Don't use <class> as a variable. * test/automated/eieio-test-persist.el (persistent-with-objs-list-slot): Don't use <class>-list type. * test/automated/eieio-tests.el: Use cl-lib. Don't use <class> as a variable. Don't use <class>-list types and <class>-list-p predicates.
2015-01-08 04:11:58 +00:00
(setq axis (make-instance 'chart-axis-names
:name (oref seq name)
:items labels
:chart c))
(oset axis items labels)))
(let ((range (cons 0 1))
(l (oref seq data)))
(if (not axis)
lisp/emacs-lisp/eieio-core.el (eieio-backward-compatibility): New var. * lisp/cedet/ede/speedbar.el (ede-speedbar-compile-line) (ede-speedbar-get-top-project-for-line): * lisp/cedet/ede.el (ede-buffer-belongs-to-target-p) (ede-buffer-belongs-to-project-p, ede-build-forms-menu) (ede-add-project-to-global-list): * lisp/cedet/semantic/db-typecache.el (semanticdb-get-typecache): * lisp/cedet/semantic/db-file.el (semanticdb-load-database): * lisp/cedet/semantic/db-el.el (semanticdb-elisp-sym->tag): * lisp/cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-load-helper): * lisp/cedet/ede/project-am.el (project-am-preferred-target-type): * lisp/cedet/ede/proj.el (ede-proj-load): * lisp/cedet/ede/custom.el (ede-customize-current-target, ede-customize-target): * lisp/cedet/semantic/ede-grammar.el ("semantic grammar"): * lisp/cedet/semantic/scope.el (semantic-scope-reset-cache) (semantic-calculate-scope): * lisp/cedet/srecode/map.el (srecode-map-update-map): * lisp/cedet/srecode/insert.el (srecode-insert-show-error-report) (srecode-insert-method, srecode-insert-include-lookup) (srecode-insert-method): * lisp/cedet/srecode/fields.el (srecode-active-template-region): * lisp/cedet/srecode/compile.el (srecode-flush-active-templates) (srecode-compile-inserter): Don't use <class> as a variable. Use `oref-default' for class slots. * lisp/cedet/semantic/grammar.el (semantic-grammar-eldoc-last-data): New var. (semantic-grammar-eldoc-get-macro-docstring): Use it instead of eldoc-last-data. * lisp/cedet/semantic/fw.el (semantic-exit-on-input): Use `declare'. (semantic-throw-on-input): Use `with-current-buffer'. * lisp/cedet/semantic/db.el (semanticdb-abstract-table-list): Define if not pre-defined. * lisp/cedet/semantic/db-find.el (semanticdb-find-tags-collector): Use save-current-buffer. (semanticdb-find-tags-collector): Don't use <class> as a variable. * lisp/cedet/semantic/complete.el (semantic-complete-active-default) (semantic-complete-current-matched-tag): Declare. (semantic-complete-inline-custom-type): Don't use <class> as a variable. * lisp/cedet/semantic/bovine/make.el (semantic-analyze-possible-completions): Use with-current-buffer. * lisp/cedet/semantic.el (semantic-parser-warnings): Declare. * lisp/cedet/ede/base.el (ede-target-list): Define if not pre-defined. (ede-with-projectfile): Prefer find-file-noselect over save-window-excursion. * lisp/emacs-lisp/chart.el (chart-add-sequence, chart-bar-quickie): Don't use <class> as a variable. * lisp/emacs-lisp/eieio-base.el (eieio-persistent-validate/fix-slot-value): Improve error messages. (eieio-persistent-slot-type-is-class-p): Handle `list-of' types, as well as user-defined types. Emit errors for legacy types like <class>-child and <class>-list, if not eieio-backward-compatibility. * lisp/emacs-lisp/eieio-core.el (eieio-backward-compatibility): New var. (eieio-defclass-autoload): Obey it. (eieio--class-object): Improve error behavior. (eieio-class-children-fast, same-class-fast-p): Remove. Inline at every use site. (eieio--defgeneric-form-primary-only): Rename from eieio-defgeneric-form-primary-only; update all callers. (eieio--defgeneric-form-primary-only-one): Rename from eieio-defgeneric-form-primary-only-one; update all callers. (eieio-defgeneric-reset-generic-form) (eieio-defgeneric-reset-generic-form-primary-only) (eieio-defgeneric-reset-generic-form-primary-only-one): Remove. (eieio--method-optimize-primary): New function to replace them. (eieio--defmethod, eieio-defmethod): Use it. (eieio--perform-slot-validation): Rename from eieio-perform-slot-validation; update all callers. (eieio--validate-slot-value): Rename from eieio-validate-slot-value. Change `class' to be a class object. Update all callers. (eieio--validate-class-slot-value): Rename from eieio-validate-class-slot-value. Change `class' to be a class object. Update all callers. (eieio-oset-default): Accept class object as well. (eieio--generic-call-primary-only): Rename from eieio-generic-call-primary-only. Update all callers. * lisp/emacs-lisp/eieio-opt.el (eieio-read-generic-p): Remove. (eieio-read-generic): Use `generic-p' instead. * lisp/emacs-lisp/eieio.el (same-class-p): Accept class object as well. (call-next-method): Simplify. (clone): Obey eieio-backward-compatibility. * lisp/gnus/registry.el: Don't use <class> as a variable. * test/automated/eieio-test-methodinvoke.el (eieio-test-method-order-list-4): Don't use <class> as a variable. * test/automated/eieio-test-persist.el (persistent-with-objs-list-slot): Don't use <class>-list type. * test/automated/eieio-tests.el: Use cl-lib. Don't use <class> as a variable. Don't use <class>-list types and <class>-list-p predicates.
2015-01-08 04:11:58 +00:00
(setq axis (make-instance 'chart-axis-range
:name (oref seq name)
:chart c)))
(dolist (x l)
(if (< x (car range)) (setcar range x))
(if (> x (cdr range)) (setcdr range x)))
(oset axis bounds range)))
(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
(cl-defmethod chart-trim ((c chart) max)
"Trim all sequences in chart C to be at most MAX elements long."
(let ((s (oref c sequences)))
(dolist (x s)
(let ((sl (oref x data)))
(if (> (length sl) max)
(setcdr (nthcdr (1- max) sl) nil)))))
)
(cl-defmethod chart-sort ((c chart) pred)
"Sort the data in chart C using predicate PRED.
See `chart-sort-matchlist' for more details."
(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)))
(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)
))
)
(defun chart-sort-matchlist (namelst numlst pred)
"Sort NAMELST and NUMLST (both sequence objects) based on predicate PRED.
PRED should be the equivalent of `<', except it must expect two
cons cells of the form (NAME . NUM). See `sort' for more details."
;; 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."
(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)))
(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)))))
(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.
Use column or row ZONE between START and END."
(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)
"Wash over the complex EIEIO stuff and create a nice bar chart.
Create it going in direction DIR [`horizontal' `vertical'] with TITLE
using a name sequence NAMELST labeled NAMETITLE with values NUMLST
labeled NUMTITLE.
Optional arguments:
Set the chart's max element display to MAX, and sort lists with
SORT-PRED if desired."
lisp/emacs-lisp/eieio-core.el (eieio-backward-compatibility): New var. * lisp/cedet/ede/speedbar.el (ede-speedbar-compile-line) (ede-speedbar-get-top-project-for-line): * lisp/cedet/ede.el (ede-buffer-belongs-to-target-p) (ede-buffer-belongs-to-project-p, ede-build-forms-menu) (ede-add-project-to-global-list): * lisp/cedet/semantic/db-typecache.el (semanticdb-get-typecache): * lisp/cedet/semantic/db-file.el (semanticdb-load-database): * lisp/cedet/semantic/db-el.el (semanticdb-elisp-sym->tag): * lisp/cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-load-helper): * lisp/cedet/ede/project-am.el (project-am-preferred-target-type): * lisp/cedet/ede/proj.el (ede-proj-load): * lisp/cedet/ede/custom.el (ede-customize-current-target, ede-customize-target): * lisp/cedet/semantic/ede-grammar.el ("semantic grammar"): * lisp/cedet/semantic/scope.el (semantic-scope-reset-cache) (semantic-calculate-scope): * lisp/cedet/srecode/map.el (srecode-map-update-map): * lisp/cedet/srecode/insert.el (srecode-insert-show-error-report) (srecode-insert-method, srecode-insert-include-lookup) (srecode-insert-method): * lisp/cedet/srecode/fields.el (srecode-active-template-region): * lisp/cedet/srecode/compile.el (srecode-flush-active-templates) (srecode-compile-inserter): Don't use <class> as a variable. Use `oref-default' for class slots. * lisp/cedet/semantic/grammar.el (semantic-grammar-eldoc-last-data): New var. (semantic-grammar-eldoc-get-macro-docstring): Use it instead of eldoc-last-data. * lisp/cedet/semantic/fw.el (semantic-exit-on-input): Use `declare'. (semantic-throw-on-input): Use `with-current-buffer'. * lisp/cedet/semantic/db.el (semanticdb-abstract-table-list): Define if not pre-defined. * lisp/cedet/semantic/db-find.el (semanticdb-find-tags-collector): Use save-current-buffer. (semanticdb-find-tags-collector): Don't use <class> as a variable. * lisp/cedet/semantic/complete.el (semantic-complete-active-default) (semantic-complete-current-matched-tag): Declare. (semantic-complete-inline-custom-type): Don't use <class> as a variable. * lisp/cedet/semantic/bovine/make.el (semantic-analyze-possible-completions): Use with-current-buffer. * lisp/cedet/semantic.el (semantic-parser-warnings): Declare. * lisp/cedet/ede/base.el (ede-target-list): Define if not pre-defined. (ede-with-projectfile): Prefer find-file-noselect over save-window-excursion. * lisp/emacs-lisp/chart.el (chart-add-sequence, chart-bar-quickie): Don't use <class> as a variable. * lisp/emacs-lisp/eieio-base.el (eieio-persistent-validate/fix-slot-value): Improve error messages. (eieio-persistent-slot-type-is-class-p): Handle `list-of' types, as well as user-defined types. Emit errors for legacy types like <class>-child and <class>-list, if not eieio-backward-compatibility. * lisp/emacs-lisp/eieio-core.el (eieio-backward-compatibility): New var. (eieio-defclass-autoload): Obey it. (eieio--class-object): Improve error behavior. (eieio-class-children-fast, same-class-fast-p): Remove. Inline at every use site. (eieio--defgeneric-form-primary-only): Rename from eieio-defgeneric-form-primary-only; update all callers. (eieio--defgeneric-form-primary-only-one): Rename from eieio-defgeneric-form-primary-only-one; update all callers. (eieio-defgeneric-reset-generic-form) (eieio-defgeneric-reset-generic-form-primary-only) (eieio-defgeneric-reset-generic-form-primary-only-one): Remove. (eieio--method-optimize-primary): New function to replace them. (eieio--defmethod, eieio-defmethod): Use it. (eieio--perform-slot-validation): Rename from eieio-perform-slot-validation; update all callers. (eieio--validate-slot-value): Rename from eieio-validate-slot-value. Change `class' to be a class object. Update all callers. (eieio--validate-class-slot-value): Rename from eieio-validate-class-slot-value. Change `class' to be a class object. Update all callers. (eieio-oset-default): Accept class object as well. (eieio--generic-call-primary-only): Rename from eieio-generic-call-primary-only. Update all callers. * lisp/emacs-lisp/eieio-opt.el (eieio-read-generic-p): Remove. (eieio-read-generic): Use `generic-p' instead. * lisp/emacs-lisp/eieio.el (same-class-p): Accept class object as well. (call-next-method): Simplify. (clone): Obey eieio-backward-compatibility. * lisp/gnus/registry.el: Don't use <class> as a variable. * test/automated/eieio-test-methodinvoke.el (eieio-test-method-order-list-4): Don't use <class> as a variable. * test/automated/eieio-test-persist.el (persistent-with-objs-list-slot): Don't use <class>-list type. * test/automated/eieio-tests.el: Use cl-lib. Don't use <class> as a variable. Don't use <class>-list types and <class>-list-p predicates.
2015-01-08 04:11:58 +00:00
(let ((nc (make-instance 'chart-bar
:title title
:key-label "8-m" ; This is a text key pic
:direction dir
))
(iv (eq dir 'vertical)))
(chart-add-sequence nc
lisp/emacs-lisp/eieio-core.el (eieio-backward-compatibility): New var. * lisp/cedet/ede/speedbar.el (ede-speedbar-compile-line) (ede-speedbar-get-top-project-for-line): * lisp/cedet/ede.el (ede-buffer-belongs-to-target-p) (ede-buffer-belongs-to-project-p, ede-build-forms-menu) (ede-add-project-to-global-list): * lisp/cedet/semantic/db-typecache.el (semanticdb-get-typecache): * lisp/cedet/semantic/db-file.el (semanticdb-load-database): * lisp/cedet/semantic/db-el.el (semanticdb-elisp-sym->tag): * lisp/cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-load-helper): * lisp/cedet/ede/project-am.el (project-am-preferred-target-type): * lisp/cedet/ede/proj.el (ede-proj-load): * lisp/cedet/ede/custom.el (ede-customize-current-target, ede-customize-target): * lisp/cedet/semantic/ede-grammar.el ("semantic grammar"): * lisp/cedet/semantic/scope.el (semantic-scope-reset-cache) (semantic-calculate-scope): * lisp/cedet/srecode/map.el (srecode-map-update-map): * lisp/cedet/srecode/insert.el (srecode-insert-show-error-report) (srecode-insert-method, srecode-insert-include-lookup) (srecode-insert-method): * lisp/cedet/srecode/fields.el (srecode-active-template-region): * lisp/cedet/srecode/compile.el (srecode-flush-active-templates) (srecode-compile-inserter): Don't use <class> as a variable. Use `oref-default' for class slots. * lisp/cedet/semantic/grammar.el (semantic-grammar-eldoc-last-data): New var. (semantic-grammar-eldoc-get-macro-docstring): Use it instead of eldoc-last-data. * lisp/cedet/semantic/fw.el (semantic-exit-on-input): Use `declare'. (semantic-throw-on-input): Use `with-current-buffer'. * lisp/cedet/semantic/db.el (semanticdb-abstract-table-list): Define if not pre-defined. * lisp/cedet/semantic/db-find.el (semanticdb-find-tags-collector): Use save-current-buffer. (semanticdb-find-tags-collector): Don't use <class> as a variable. * lisp/cedet/semantic/complete.el (semantic-complete-active-default) (semantic-complete-current-matched-tag): Declare. (semantic-complete-inline-custom-type): Don't use <class> as a variable. * lisp/cedet/semantic/bovine/make.el (semantic-analyze-possible-completions): Use with-current-buffer. * lisp/cedet/semantic.el (semantic-parser-warnings): Declare. * lisp/cedet/ede/base.el (ede-target-list): Define if not pre-defined. (ede-with-projectfile): Prefer find-file-noselect over save-window-excursion. * lisp/emacs-lisp/chart.el (chart-add-sequence, chart-bar-quickie): Don't use <class> as a variable. * lisp/emacs-lisp/eieio-base.el (eieio-persistent-validate/fix-slot-value): Improve error messages. (eieio-persistent-slot-type-is-class-p): Handle `list-of' types, as well as user-defined types. Emit errors for legacy types like <class>-child and <class>-list, if not eieio-backward-compatibility. * lisp/emacs-lisp/eieio-core.el (eieio-backward-compatibility): New var. (eieio-defclass-autoload): Obey it. (eieio--class-object): Improve error behavior. (eieio-class-children-fast, same-class-fast-p): Remove. Inline at every use site. (eieio--defgeneric-form-primary-only): Rename from eieio-defgeneric-form-primary-only; update all callers. (eieio--defgeneric-form-primary-only-one): Rename from eieio-defgeneric-form-primary-only-one; update all callers. (eieio-defgeneric-reset-generic-form) (eieio-defgeneric-reset-generic-form-primary-only) (eieio-defgeneric-reset-generic-form-primary-only-one): Remove. (eieio--method-optimize-primary): New function to replace them. (eieio--defmethod, eieio-defmethod): Use it. (eieio--perform-slot-validation): Rename from eieio-perform-slot-validation; update all callers. (eieio--validate-slot-value): Rename from eieio-validate-slot-value. Change `class' to be a class object. Update all callers. (eieio--validate-class-slot-value): Rename from eieio-validate-class-slot-value. Change `class' to be a class object. Update all callers. (eieio-oset-default): Accept class object as well. (eieio--generic-call-primary-only): Rename from eieio-generic-call-primary-only. Update all callers. * lisp/emacs-lisp/eieio-opt.el (eieio-read-generic-p): Remove. (eieio-read-generic): Use `generic-p' instead. * lisp/emacs-lisp/eieio.el (same-class-p): Accept class object as well. (call-next-method): Simplify. (clone): Obey eieio-backward-compatibility. * lisp/gnus/registry.el: Don't use <class> as a variable. * test/automated/eieio-test-methodinvoke.el (eieio-test-method-order-list-4): Don't use <class> as a variable. * test/automated/eieio-test-persist.el (persistent-with-objs-list-slot): Don't use <class>-list type. * test/automated/eieio-tests.el: Use cl-lib. Don't use <class> as a variable. Don't use <class>-list types and <class>-list-p predicates.
2015-01-08 04:11:58 +00:00
(make-instance 'chart-sequece
:data namelst
:name nametitle)
(if iv 'x-axis 'y-axis))
(chart-add-sequence nc
lisp/emacs-lisp/eieio-core.el (eieio-backward-compatibility): New var. * lisp/cedet/ede/speedbar.el (ede-speedbar-compile-line) (ede-speedbar-get-top-project-for-line): * lisp/cedet/ede.el (ede-buffer-belongs-to-target-p) (ede-buffer-belongs-to-project-p, ede-build-forms-menu) (ede-add-project-to-global-list): * lisp/cedet/semantic/db-typecache.el (semanticdb-get-typecache): * lisp/cedet/semantic/db-file.el (semanticdb-load-database): * lisp/cedet/semantic/db-el.el (semanticdb-elisp-sym->tag): * lisp/cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-load-helper): * lisp/cedet/ede/project-am.el (project-am-preferred-target-type): * lisp/cedet/ede/proj.el (ede-proj-load): * lisp/cedet/ede/custom.el (ede-customize-current-target, ede-customize-target): * lisp/cedet/semantic/ede-grammar.el ("semantic grammar"): * lisp/cedet/semantic/scope.el (semantic-scope-reset-cache) (semantic-calculate-scope): * lisp/cedet/srecode/map.el (srecode-map-update-map): * lisp/cedet/srecode/insert.el (srecode-insert-show-error-report) (srecode-insert-method, srecode-insert-include-lookup) (srecode-insert-method): * lisp/cedet/srecode/fields.el (srecode-active-template-region): * lisp/cedet/srecode/compile.el (srecode-flush-active-templates) (srecode-compile-inserter): Don't use <class> as a variable. Use `oref-default' for class slots. * lisp/cedet/semantic/grammar.el (semantic-grammar-eldoc-last-data): New var. (semantic-grammar-eldoc-get-macro-docstring): Use it instead of eldoc-last-data. * lisp/cedet/semantic/fw.el (semantic-exit-on-input): Use `declare'. (semantic-throw-on-input): Use `with-current-buffer'. * lisp/cedet/semantic/db.el (semanticdb-abstract-table-list): Define if not pre-defined. * lisp/cedet/semantic/db-find.el (semanticdb-find-tags-collector): Use save-current-buffer. (semanticdb-find-tags-collector): Don't use <class> as a variable. * lisp/cedet/semantic/complete.el (semantic-complete-active-default) (semantic-complete-current-matched-tag): Declare. (semantic-complete-inline-custom-type): Don't use <class> as a variable. * lisp/cedet/semantic/bovine/make.el (semantic-analyze-possible-completions): Use with-current-buffer. * lisp/cedet/semantic.el (semantic-parser-warnings): Declare. * lisp/cedet/ede/base.el (ede-target-list): Define if not pre-defined. (ede-with-projectfile): Prefer find-file-noselect over save-window-excursion. * lisp/emacs-lisp/chart.el (chart-add-sequence, chart-bar-quickie): Don't use <class> as a variable. * lisp/emacs-lisp/eieio-base.el (eieio-persistent-validate/fix-slot-value): Improve error messages. (eieio-persistent-slot-type-is-class-p): Handle `list-of' types, as well as user-defined types. Emit errors for legacy types like <class>-child and <class>-list, if not eieio-backward-compatibility. * lisp/emacs-lisp/eieio-core.el (eieio-backward-compatibility): New var. (eieio-defclass-autoload): Obey it. (eieio--class-object): Improve error behavior. (eieio-class-children-fast, same-class-fast-p): Remove. Inline at every use site. (eieio--defgeneric-form-primary-only): Rename from eieio-defgeneric-form-primary-only; update all callers. (eieio--defgeneric-form-primary-only-one): Rename from eieio-defgeneric-form-primary-only-one; update all callers. (eieio-defgeneric-reset-generic-form) (eieio-defgeneric-reset-generic-form-primary-only) (eieio-defgeneric-reset-generic-form-primary-only-one): Remove. (eieio--method-optimize-primary): New function to replace them. (eieio--defmethod, eieio-defmethod): Use it. (eieio--perform-slot-validation): Rename from eieio-perform-slot-validation; update all callers. (eieio--validate-slot-value): Rename from eieio-validate-slot-value. Change `class' to be a class object. Update all callers. (eieio--validate-class-slot-value): Rename from eieio-validate-class-slot-value. Change `class' to be a class object. Update all callers. (eieio-oset-default): Accept class object as well. (eieio--generic-call-primary-only): Rename from eieio-generic-call-primary-only. Update all callers. * lisp/emacs-lisp/eieio-opt.el (eieio-read-generic-p): Remove. (eieio-read-generic): Use `generic-p' instead. * lisp/emacs-lisp/eieio.el (same-class-p): Accept class object as well. (call-next-method): Simplify. (clone): Obey eieio-backward-compatibility. * lisp/gnus/registry.el: Don't use <class> as a variable. * test/automated/eieio-test-methodinvoke.el (eieio-test-method-order-list-4): Don't use <class> as a variable. * test/automated/eieio-test-persist.el (persistent-with-objs-list-slot): Don't use <class>-list type. * test/automated/eieio-tests.el: Use cl-lib. Don't use <class> as a variable. Don't use <class>-list types and <class>-list-p predicates.
2015-01-08 04:11:58 +00:00
(make-instance 'chart-sequece
: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."
(interactive "DDirectory: ")
(message "Collecting statistics...")
(let ((flst (directory-files dir nil nil t))
(extlst (list "<dir>"))
(cntlst (list 0)))
(dolist (f flst)
(let* ((x (file-name-extension f))
(s (if (file-accessible-directory-p (expand-file-name f dir))
"<dir>" x))
(m (member s extlst)))
(unless (null s)
(if m
(cl-incf (car (nthcdr (- (length extlst) (length m)) cntlst)))
(setq extlst (cons s extlst)
cntlst (cons 1 cntlst))))))
2011-11-15 17:37:37 +00:00
;; 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))))
))
(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)
(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
(lambda (a b) (> (cdr a) (cdr b))))
))
(defun chart-emacs-storage ()
"Chart the current storage requirements of Emacs."
(interactive)
(let* ((data (garbage-collect)))
2011-11-15 17:37:37 +00:00
;; Let's create the chart!
(chart-bar-quickie 'vertical "Emacs Runtime Storage Usage"
(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."
(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!
(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))))))
(chart-bar-quickie 'vertical "Username Occurrence in RMAIL box"
nmlst "User Names"
cntlst "# of occurrences"
10
(lambda (a b) (> (cdr a) (cdr b))))
))
(provide 'chart)
;;; chart.el ends here