Port chart.el methods to cl-generic.
cl-call-next-method cannot be used inside EIEIO's defmethod. * lisp/emacs-lisp/chart.el: Require cl-generic at compile time. * lisp/emacs-lisp/chart.el (initialize-instance, chart-draw): (chart-draw-title, chart-size-in-dir, chart-draw-axis): (chart-axis-draw, chart-translate-xpos, chart-translate-ypos): (chart-translate-namezone, chart-draw-data, chart-add-sequence): (chart-trim, chart-sort): Use cl-defmethod instead of defmethod.
This commit is contained in:
parent
410bb697ad
commit
526d80ce6f
1 changed files with 16 additions and 15 deletions
|
@ -60,6 +60,7 @@
|
||||||
;; with all the bitmaps you want to use.
|
;; with all the bitmaps you want to use.
|
||||||
|
|
||||||
(require 'eieio)
|
(require 'eieio)
|
||||||
|
(eval-when-compile (require 'cl-generic))
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(define-obsolete-variable-alias 'chart-map 'chart-mode-map "24.1")
|
(define-obsolete-variable-alias 'chart-map 'chart-mode-map "24.1")
|
||||||
|
@ -156,7 +157,7 @@ Returns the newly created buffer."
|
||||||
)
|
)
|
||||||
"Superclass for all charts to be displayed in an Emacs buffer.")
|
"Superclass for all charts to be displayed in an Emacs buffer.")
|
||||||
|
|
||||||
(defmethod initialize-instance :AFTER ((obj chart) &rest _fields)
|
(cl-defmethod initialize-instance :after ((obj chart) &rest _fields)
|
||||||
"Initialize the chart OBJ being created with FIELDS.
|
"Initialize the chart OBJ being created with FIELDS.
|
||||||
Make sure the width/height is correct."
|
Make sure the width/height is correct."
|
||||||
(oset obj x-width (- (window-width) 10))
|
(oset obj x-width (- (window-width) 10))
|
||||||
|
@ -201,7 +202,7 @@ Make sure the width/height is correct."
|
||||||
:initform vertical))
|
:initform vertical))
|
||||||
"Subclass for bar charts (vertical or horizontal).")
|
"Subclass for bar charts (vertical or horizontal).")
|
||||||
|
|
||||||
(defmethod chart-draw ((c chart) &optional buff)
|
(cl-defmethod chart-draw ((c chart) &optional buff)
|
||||||
"Start drawing a chart object C in optional BUFF.
|
"Start drawing a chart object C in optional BUFF.
|
||||||
Erases current contents of buffer."
|
Erases current contents of buffer."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
@ -221,19 +222,19 @@ Erases current contents of buffer."
|
||||||
(message "Rendering chart...done")
|
(message "Rendering chart...done")
|
||||||
))
|
))
|
||||||
|
|
||||||
(defmethod chart-draw-title ((c chart))
|
(cl-defmethod chart-draw-title ((c chart))
|
||||||
"Draw a title upon the chart.
|
"Draw a title upon the chart.
|
||||||
Argument C is the chart object."
|
Argument C is the chart object."
|
||||||
(chart-display-label (oref c title) 'horizontal 0 0 (window-width)
|
(chart-display-label (oref c title) 'horizontal 0 0 (window-width)
|
||||||
(oref c title-face)))
|
(oref c title-face)))
|
||||||
|
|
||||||
(defmethod chart-size-in-dir ((c chart) dir)
|
(cl-defmethod chart-size-in-dir ((c chart) dir)
|
||||||
"Return the physical size of chart C in direction DIR."
|
"Return the physical size of chart C in direction DIR."
|
||||||
(if (eq dir 'vertical)
|
(if (eq dir 'vertical)
|
||||||
(oref c y-width)
|
(oref c y-width)
|
||||||
(oref c x-width)))
|
(oref c x-width)))
|
||||||
|
|
||||||
(defmethod chart-draw-axis ((c chart))
|
(cl-defmethod chart-draw-axis ((c chart))
|
||||||
"Draw axis into the current buffer defined by chart C."
|
"Draw axis into the current buffer defined by chart C."
|
||||||
(let ((ymarg (oref c y-margin))
|
(let ((ymarg (oref c y-margin))
|
||||||
(xmarg (oref c x-margin))
|
(xmarg (oref c x-margin))
|
||||||
|
@ -247,7 +248,7 @@ Argument C is the chart object."
|
||||||
ymarg (+ ymarg xlen)))
|
ymarg (+ ymarg xlen)))
|
||||||
)
|
)
|
||||||
|
|
||||||
(defmethod chart-axis-draw ((a chart-axis) &optional dir margin zone start end)
|
(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.
|
"Draw some axis for A in direction DIR with MARGIN in boundary.
|
||||||
ZONE is a zone specification.
|
ZONE is a zone specification.
|
||||||
START and END represent the boundary."
|
START and END represent the boundary."
|
||||||
|
@ -257,7 +258,7 @@ START and END represent the boundary."
|
||||||
1 0))
|
1 0))
|
||||||
start end (oref a name-face)))
|
start end (oref a name-face)))
|
||||||
|
|
||||||
(defmethod chart-translate-xpos ((c chart) x)
|
(cl-defmethod chart-translate-xpos ((c chart) x)
|
||||||
"Translate in chart C the coordinate X into a screen column."
|
"Translate in chart C the coordinate X into a screen column."
|
||||||
(let ((range (oref (oref c x-axis) bounds)))
|
(let ((range (oref (oref c x-axis) bounds)))
|
||||||
(+ (oref c x-margin)
|
(+ (oref c x-margin)
|
||||||
|
@ -266,7 +267,7 @@ START and END represent the boundary."
|
||||||
(float (- (cdr range) (car range))))))))
|
(float (- (cdr range) (car range))))))))
|
||||||
)
|
)
|
||||||
|
|
||||||
(defmethod chart-translate-ypos ((c chart) y)
|
(cl-defmethod chart-translate-ypos ((c chart) y)
|
||||||
"Translate in chart C the coordinate Y into a screen row."
|
"Translate in chart C the coordinate Y into a screen row."
|
||||||
(let ((range (oref (oref c y-axis) bounds)))
|
(let ((range (oref (oref c y-axis) bounds)))
|
||||||
(+ (oref c x-margin)
|
(+ (oref c x-margin)
|
||||||
|
@ -276,7 +277,7 @@ START and END represent the boundary."
|
||||||
(float (- (cdr range) (car range)))))))))
|
(float (- (cdr range) (car range)))))))))
|
||||||
)
|
)
|
||||||
|
|
||||||
(defmethod chart-axis-draw ((a chart-axis-range) &optional dir margin zone _start _end)
|
(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.
|
"Draw axis information based upon a range to be spread along the edge.
|
||||||
A is the chart to draw. DIR is the direction.
|
A is the chart to draw. DIR is the direction.
|
||||||
MARGIN, ZONE, START, and END specify restrictions in chart space."
|
MARGIN, ZONE, START, and END specify restrictions in chart space."
|
||||||
|
@ -313,7 +314,7 @@ MARGIN, ZONE, START, and END specify restrictions in chart space."
|
||||||
(setq i (+ i j))))
|
(setq i (+ i j))))
|
||||||
)
|
)
|
||||||
|
|
||||||
(defmethod chart-translate-namezone ((c chart) n)
|
(cl-defmethod chart-translate-namezone ((c chart) n)
|
||||||
"Return a dot-pair representing a positional range for a name.
|
"Return a dot-pair representing a positional range for a name.
|
||||||
The name in chart C of the Nth name resides.
|
The name in chart C of the Nth name resides.
|
||||||
Automatically compensates for direction."
|
Automatically compensates for direction."
|
||||||
|
@ -329,7 +330,7 @@ Automatically compensates for direction."
|
||||||
(+ m -1 (round (* lpn (+ 1.0 (float n))))))
|
(+ m -1 (round (* lpn (+ 1.0 (float n))))))
|
||||||
))
|
))
|
||||||
|
|
||||||
(defmethod chart-axis-draw ((a chart-axis-names) &optional dir margin zone _start _end)
|
(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.
|
"Draw axis information based upon A range to be spread along the edge.
|
||||||
Optional argument DIR is the direction of the chart.
|
Optional argument DIR is the direction of the chart.
|
||||||
Optional arguments MARGIN, ZONE, START and END specify boundaries of the drawing."
|
Optional arguments MARGIN, ZONE, START and END specify boundaries of the drawing."
|
||||||
|
@ -368,7 +369,7 @@ Optional arguments MARGIN, ZONE, START and END specify boundaries of the drawing
|
||||||
s (cdr s))))
|
s (cdr s))))
|
||||||
)
|
)
|
||||||
|
|
||||||
(defmethod chart-draw-data ((c chart-bar))
|
(cl-defmethod chart-draw-data ((c chart-bar))
|
||||||
"Display the data available in a bar chart C."
|
"Display the data available in a bar chart C."
|
||||||
(let* ((data (oref c sequences))
|
(let* ((data (oref c sequences))
|
||||||
(dir (oref c direction))
|
(dir (oref c direction))
|
||||||
|
@ -413,7 +414,7 @@ Optional arguments MARGIN, ZONE, START and END specify boundaries of the drawing
|
||||||
(setq data (cdr data))))
|
(setq data (cdr data))))
|
||||||
)
|
)
|
||||||
|
|
||||||
(defmethod chart-add-sequence ((c chart) &optional seq axis-label)
|
(cl-defmethod chart-add-sequence ((c chart) &optional seq axis-label)
|
||||||
"Add to chart object C the sequence object SEQ.
|
"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,
|
If AXIS-LABEL, then the axis stored in C is updated with the bounds of SEQ,
|
||||||
or is created with the bounds of SEQ."
|
or is created with the bounds of SEQ."
|
||||||
|
@ -445,7 +446,7 @@ or is created with the bounds of SEQ."
|
||||||
|
|
||||||
;;; Charting optimizers
|
;;; Charting optimizers
|
||||||
|
|
||||||
(defmethod chart-trim ((c chart) max)
|
(cl-defmethod chart-trim ((c chart) max)
|
||||||
"Trim all sequences in chart C to be at most MAX elements long."
|
"Trim all sequences in chart C to be at most MAX elements long."
|
||||||
(let ((s (oref c sequences)))
|
(let ((s (oref c sequences)))
|
||||||
(while s
|
(while s
|
||||||
|
@ -455,7 +456,7 @@ or is created with the bounds of SEQ."
|
||||||
(setq s (cdr s))))
|
(setq s (cdr s))))
|
||||||
)
|
)
|
||||||
|
|
||||||
(defmethod chart-sort ((c chart) pred)
|
(cl-defmethod chart-sort ((c chart) pred)
|
||||||
"Sort the data in chart C using predicate PRED.
|
"Sort the data in chart C using predicate PRED.
|
||||||
See `chart-sort-matchlist' for more details."
|
See `chart-sort-matchlist' for more details."
|
||||||
(let* ((sl (oref c sequences))
|
(let* ((sl (oref c sequences))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue