summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/chart.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/chart.el')
-rw-r--r--lisp/emacs-lisp/chart.el84
1 files changed, 38 insertions, 46 deletions
diff --git a/lisp/emacs-lisp/chart.el b/lisp/emacs-lisp/chart.el
index ace94c2bc6d..01eb1efdc3b 100644
--- a/lisp/emacs-lisp/chart.el
+++ b/lisp/emacs-lisp/chart.el
@@ -1,6 +1,6 @@
;;; chart.el --- Draw charts (bar charts, etc)
-;; Copyright (C) 1996, 1998, 1999, 2001, 2004, 2005, 2007, 2008, 2009, 2010, 2011
+;; Copyright (C) 1996, 1998-1999, 2001, 2004-2005, 2007-2011
;; Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
@@ -62,21 +62,13 @@
(require 'eieio)
;;; Code:
-(defvar chart-map nil "Keymap used in chart mode.")
-(if chart-map
- ()
- (setq chart-map (make-sparse-keymap))
- )
+(defvar chart-mode-map (make-sparse-keymap) "Keymap used in chart mode.")
+(define-obsolete-variable-alias 'chart-map 'chart-mode-map "24.1")
(defvar chart-local-object nil
"Local variable containing the locally displayed chart object.")
(make-variable-buffer-local 'chart-local-object)
-(defvar chart-face-list nil
- "Faces used to colorize charts.
-List is limited currently, which is ok since you really can't display
-too much in text characters anyways.")
-
(defvar chart-face-color-list '("red" "green" "blue"
"cyan" "yellow" "purple")
"Colors to use when generating `chart-face-list'.
@@ -94,41 +86,42 @@ Useful if new Emacs is used on B&W display.")
:group 'eieio
:type 'boolean)
-(if (and (if (fboundp 'display-color-p)
- (display-color-p)
- window-system)
- (not chart-face-list))
- (let ((cl chart-face-color-list)
- (pl chart-face-pixmap-list)
- nf)
- (while cl
- (setq nf (make-face (intern (concat "chart-" (car cl) "-" (car pl)))))
- (if (condition-case nil
- (> (x-display-color-cells) 4)
- (error t))
- (set-face-background nf (car cl))
- (set-face-background nf "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)))))
- (setq chart-face-list (cons nf chart-face-list))
- (setq cl (cdr cl)
- pl (cdr pl)))))
-
-(defun chart-mode ()
+(defvar chart-face-list
+ (if (if (fboundp 'display-color-p)
+ (display-color-p)
+ window-system)
+ (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 fundamental-mode "CHART"
"Define a mode in Emacs for displaying a chart."
- (kill-all-local-variables)
- (use-local-map chart-map)
- (setq major-mode 'chart-mode
- mode-name "CHART")
(buffer-disable-undo)
(set (make-local-variable 'font-lock-global-modes) nil)
- (font-lock-mode -1)
- (run-hooks 'chart-mode-hook)
+ (font-lock-mode -1) ;Isn't it off already? --Stef
)
(defun chart-new-buffer (obj)
@@ -529,9 +522,9 @@ cons cells of the form (NAME . NUM). See `sort' for more details."
(defun chart-zap-chars (n)
"Zap up to N chars without deleting EOLs."
(if (not (eobp))
- (if (< n (- (save-excursion (end-of-line) (point)) (point)))
+ (if (< n (- (point-at-eol) (point)))
(delete-char n)
- (delete-region (point) (save-excursion (end-of-line) (point))))))
+ (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.
@@ -750,5 +743,4 @@ SORT-PRED if desired."
(provide 'chart)
-;; arch-tag: 43847e44-5b45-465e-adc9-e505490a6b59
;;; chart.el ends here