Commit 4d789d84 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

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
parent b49a2dbf
2011-01-13 Stefan Monnier <monnier@iro.umontreal.ca>
Use run-mode-hooks for major mode hooks (bug#513).
* textmodes/reftex-toc.el (reftex-toc-mode-map):
Rename from reftex-toc-map.
(reftex-toc-mode): Use define-derived-mode.
* 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.
* 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.
* 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.
* recentf.el (recentf-mode): Don't run hook (or message) redundantly.
* net/rcirc.el (rcirc-mode): Use run-mode-hooks.
* emacs-lisp/chart.el (chart-mode-map): Rename from chart-map.
(chart-face-list): Move initialization into declaration.
(chart-mode): Use define-derived-mode.
* calculator.el (calculator-mode-map): Move init into declaration.
(calculator-mode): Use define-derived-mode.
* mail/mail-utils.el (mail-strip-quoted-names): Make the regexp code
work for nested comments.
......
;;; calculator.el --- a [not so] simple calculator for Emacs
;; Copyright (C) 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
;; 2008, 2009, 2010 Free Software Foundation, Inc.
;; 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
;; Author: Eli Barzilay <eli@barzilay.org>
;; Keywords: tools, convenience
......@@ -382,10 +382,7 @@ Used for repeating operations in calculator-repR/L.")
;;;---------------------------------------------------------------------
;;; Key bindings
(defvar calculator-mode-map nil
"The calculator key map.")
(or calculator-mode-map
(defvar calculator-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map t)
(define-key map "i" nil)
......@@ -471,113 +468,114 @@ Used for repeating operations in calculator-repR/L.")
("Binary" bin "B")
("Octal" oct "O")
("Hexadecimal" hex "H"))))
(op '(lambda (name key)
`[,name (calculator-op ,key) :keys ,key])))
(op (lambda (name key)
`[,name (calculator-op ,key) :keys ,key])))
(easy-menu-define
calculator-menu map "Calculator menu."
`("Calculator"
["Help"
(let ((last-command 'calculator-help)) (calculator-help))
:keys "?"]
"---"
["Copy" calculator-copy]
["Paste" calculator-paste]
"---"
["Electric mode"
(progn (calculator-quit)
(setq calculator-restart-other-mode t)
(run-with-timer 0.1 nil '(lambda () (message nil)))
;; the message from the menu will be visible,
;; couldn't make it go away...
(calculator))
:active (not calculator-electric-mode)]
["Normal mode"
(progn (setq calculator-restart-other-mode t)
(calculator-quit))
:active calculator-electric-mode]
"---"
("Functions"
,(funcall op "Repeat-right" ">")
,(funcall op "Repeat-left" "<")
"------General------"
,(funcall op "Reciprocal" ";")
,(funcall op "Log" "L")
,(funcall op "Square-root" "Q")
,(funcall op "Factorial" "!")
"------Trigonometric------"
,(funcall op "Sinus" "S")
,(funcall op "Cosine" "C")
,(funcall op "Tangent" "T")
,(funcall op "Inv-Sinus" "IS")
,(funcall op "Inv-Cosine" "IC")
,(funcall op "Inv-Tangent" "IT")
"------Bitwise------"
,(funcall op "Or" "|")
,(funcall op "Xor" "#")
,(funcall op "And" "&")
,(funcall op "Not" "~"))
("Saved List"
["Eval+Save" calculator-save-on-list]
["Prev number" calculator-saved-up]
["Next number" calculator-saved-down]
["Delete current" calculator-clear
:active (and calculator-display-fragile
calculator-saved-list
(= (car calculator-stack)
(nth calculator-saved-ptr
calculator-saved-list)))]
["Delete all" calculator-clear-saved]
calculator-menu map "Calculator menu."
`("Calculator"
["Help"
(let ((last-command 'calculator-help)) (calculator-help))
:keys "?"]
"---"
,(funcall op "List-total" "l")
,(funcall op "List-average" "v"))
("Registers"
["Get register" calculator-get-register]
["Set register" calculator-set-register])
("Modes"
["Radians"
(progn
(and (or calculator-input-radix calculator-output-radix)
(calculator-radix-mode "D"))
(and calculator-deg (calculator-dec/deg-mode)))
:keys "D"
:style radio
:selected (not (or calculator-input-radix
calculator-output-radix
calculator-deg))]
["Degrees"
(progn
(and (or calculator-input-radix calculator-output-radix)
(calculator-radix-mode "D"))
(or calculator-deg (calculator-dec/deg-mode)))
:keys "D"
:style radio
:selected (and calculator-deg
(not (or calculator-input-radix
calculator-output-radix)))]
["Copy" calculator-copy]
["Paste" calculator-paste]
"---"
,@(mapcar 'car radix-selectors)
("Separate I/O"
,@(mapcar (lambda (x) (nth 1 x)) radix-selectors)
["Electric mode"
(progn (calculator-quit)
(setq calculator-restart-other-mode t)
(run-with-timer 0.1 nil '(lambda () (message nil)))
;; the message from the menu will be visible,
;; couldn't make it go away...
(calculator))
:active (not calculator-electric-mode)]
["Normal mode"
(progn (setq calculator-restart-other-mode t)
(calculator-quit))
:active calculator-electric-mode]
"---"
("Functions"
,(funcall op "Repeat-right" ">")
,(funcall op "Repeat-left" "<")
"------General------"
,(funcall op "Reciprocal" ";")
,(funcall op "Log" "L")
,(funcall op "Square-root" "Q")
,(funcall op "Factorial" "!")
"------Trigonometric------"
,(funcall op "Sinus" "S")
,(funcall op "Cosine" "C")
,(funcall op "Tangent" "T")
,(funcall op "Inv-Sinus" "IS")
,(funcall op "Inv-Cosine" "IC")
,(funcall op "Inv-Tangent" "IT")
"------Bitwise------"
,(funcall op "Or" "|")
,(funcall op "Xor" "#")
,(funcall op "And" "&")
,(funcall op "Not" "~"))
("Saved List"
["Eval+Save" calculator-save-on-list]
["Prev number" calculator-saved-up]
["Next number" calculator-saved-down]
["Delete current" calculator-clear
:active (and calculator-display-fragile
calculator-saved-list
(= (car calculator-stack)
(nth calculator-saved-ptr
calculator-saved-list)))]
["Delete all" calculator-clear-saved]
"---"
,(funcall op "List-total" "l")
,(funcall op "List-average" "v"))
("Registers"
["Get register" calculator-get-register]
["Set register" calculator-set-register])
("Modes"
["Radians"
(progn
(and (or calculator-input-radix calculator-output-radix)
(calculator-radix-mode "D"))
(and calculator-deg (calculator-dec/deg-mode)))
:keys "D"
:style radio
:selected (not (or calculator-input-radix
calculator-output-radix
calculator-deg))]
["Degrees"
(progn
(and (or calculator-input-radix calculator-output-radix)
(calculator-radix-mode "D"))
(or calculator-deg (calculator-dec/deg-mode)))
:keys "D"
:style radio
:selected (and calculator-deg
(not (or calculator-input-radix
calculator-output-radix)))]
"---"
,@(mapcar (lambda (x) (nth 2 x)) radix-selectors)))
("Decimal Display"
,@(mapcar (lambda (d)
(vector (cadr d)
;; Note: inserts actual object here
`(calculator-rotate-displayer ',d)))
calculator-displayers)
,@(mapcar 'car radix-selectors)
("Separate I/O"
,@(mapcar (lambda (x) (nth 1 x)) radix-selectors)
"---"
,@(mapcar (lambda (x) (nth 2 x)) radix-selectors)))
("Decimal Display"
,@(mapcar (lambda (d)
(vector (cadr d)
;; Note: inserts actual object here
`(calculator-rotate-displayer ',d)))
calculator-displayers)
"---"
["Change Prev Display" calculator-displayer-prev]
["Change Next Display" calculator-displayer-next])
"---"
["Change Prev Display" calculator-displayer-prev]
["Change Next Display" calculator-displayer-next])
"---"
["Copy+Quit" calculator-save-and-quit]
["Quit" calculator-quit]))))
(setq calculator-mode-map map)))
["Copy+Quit" calculator-save-and-quit]
["Quit" calculator-quit]))))
map)
"The calculator key map.")
;;;---------------------------------------------------------------------
;;; Startup and mode stuff
(defun calculator-mode ()
(define-derived-mode calculator-mode fundamental-mode "Calculator"
;; this help is also used as the major help screen
"A [not so] simple calculator for Emacs.
......@@ -671,13 +669,7 @@ Some interesting customization variables are:
See the documentation for these variables, and \"calculator.el\" for
more information.
\\{calculator-mode-map}"
(interactive)
(kill-all-local-variables)
(setq major-mode 'calculator-mode)
(setq mode-name "Calculator")
(use-local-map calculator-mode-map)
(run-mode-hooks 'calculator-mode-hook))
\\{calculator-mode-map}")
(eval-when-compile (require 'electric) (require 'ehelp))
......
2011-01-13 Stefan Monnier <monnier@iro.umontreal.ca>
* srecode/srt-mode.el (srecode-template-mode): Use define-derived-mode.
* semantic/symref/list.el (semantic-symref-results-mode):
Use run-mode-hooks.
2010-11-12 Glenn Morris <rgm@gnu.org>
* semantic/wisent/comp.el: Remove unnecessary eval-when-compiles.
......@@ -60,8 +66,8 @@
* semantic/db-typecache.el (semanticdb-typecache-find-default):
* semantic/imenu.el (semantic-create-imenu-index):
* semantic/grammar.el (semantic--grammar-macro-function-tag):
* semantic/fw.el (semanticdb-without-unloaded-file-searches): Fix
require. Suggested by David Engster.
* semantic/fw.el (semanticdb-without-unloaded-file-searches):
Fix require. Suggested by David Engster.
* semantic/bovine/c-by.el: Regenerate.
......@@ -105,8 +111,8 @@
* srecode/texi.el (srecode-texi-insert-tag-as-doc): New function.
(semantic-insert-foreign-tag): Use it.
* srecode/mode.el (srecode-bind-insert): Call
srecode-load-tables-for-mode.
* srecode/mode.el (srecode-bind-insert):
Call srecode-load-tables-for-mode.
(srecode-minor-mode-templates-menu): Do not list templates that
are not in the current project.
(srecode-menu-bar): Add binding for srecode-macro-help.
......@@ -159,8 +165,8 @@
compare of built-in templates. Give built-ins lower piority.
Support special variable "project".
(srecode-compile-template-table): Set :project slot of new tables.
(srecode-compile-one-template-tag): Use
srecode-create-dictionaries-from-tags.
(srecode-compile-one-template-tag):
Use srecode-create-dictionaries-from-tags.
2010-09-21 Eric Ludlam <zappo@gnu.org>
......@@ -210,8 +216,8 @@
(autoconf-new-automake-string): Deleted.
(autoconf-new-program): Use SRecode to fill an empty file.
* ede/cpp-root.el (ede-create-lots-of-projects-under-dir): New
function.
* ede/cpp-root.el (ede-create-lots-of-projects-under-dir):
New function.
* ede/files.el (ede-flush-project-hash): New command.
(ede-convert-path): Add optional PROJECT arg.
......@@ -232,8 +238,8 @@
list whether or not the vars are already in the Makefile.
(ede-pmake-insert-variable-once): New macro.
* ede/project-am.el (project-am-with-makefile-current): Add
recentf-exclude.
* ede/project-am.el (project-am-with-makefile-current):
Add recentf-exclude.
(project-am-load-makefile): Obey an optional suggested name.
(project-am-expand-subdirlist): New function.
(project-am-makefile::project-rescan): Use it. Combine SUBDIRS
......@@ -248,16 +254,16 @@
(project-am-extract-package-info): Fix separators.
* ede/proj.el (project-run-target): New method.
(project-make-dist, project-compile-project): Use
ede-proj-automake-p to determine which kind of compile to use.
(project-make-dist, project-compile-project):
Use ede-proj-automake-p to determine which kind of compile to use.
(project-rescan): Call ede-load-project-file.
(ede-buffer-mine): Add more file names that belong to the project.
(ede-proj-compilers): Improve error message.
* ede/proj-obj.el (ede-ld-linker): Use the LDDEPS variable.
(ede-source-c++): Add more C++ extensions.
(ede-proj-target-makefile-objectcode): Quote initforms. Support
lex and yacc.
(ede-proj-target-makefile-objectcode): Quote initforms.
Support lex and yacc.
* ede/proj-prog.el (ede-proj-makefile-insert-rules): Removed.
(ede-proj-makefile-insert-variables): New, add LDDEPS.
......@@ -267,8 +273,8 @@
they show up in the same order as in the command line.
(ede-proj-target-makefile-program): Add ldlibs-local slot.
* ede/proj-shared.el (ede-g++-libtool-shared-compiler): Fix
inference rule to use cpp files.
* ede/proj-shared.el (ede-g++-libtool-shared-compiler):
Fix inference rule to use cpp files.
(ede-proj-target-makefile-shared-object): Quote initforms.
* ede/proj-misc.el (ede-proj-target-makefile-miscelaneous):
......@@ -327,8 +333,8 @@
(semantic-analyze-scoped-inherited-tag-map): Take the tag we are
looking for as part of the scoped tags list.
* semantic/html.el (semantic-default-html-setup): Add
senator-step-at-tag-classes.
* semantic/html.el (semantic-default-html-setup):
Add senator-step-at-tag-classes.
* semantic/decorate/include.el
(semantic-decoration-on-unknown-includes): Change light bgcolor.
......@@ -355,8 +361,8 @@
* semantic/util.el (semantic-hack-search)
(semantic-recursive-find-nonterminal-by-name)
(semantic-current-tag-interactive): Deleted.
(semantic-describe-buffer): Fix expand-nonterminal. Add
lex-syntax-mods, type relation separator char, and command
(semantic-describe-buffer): Fix expand-nonterminal.
Add lex-syntax-mods, type relation separator char, and command
separation char.
(semantic-sanity-check): Only message if called interactively.
......@@ -372,8 +378,8 @@
* semantic/idle.el: Add breadcrumbs support.
(semantic-idle-summary-current-symbol-info-default)
(semantic-idle-tag-highlight)
(semantic-idle-completion-list-default): Use
semanticdb-without-unloaded-file-searches for speed, and to
(semantic-idle-completion-list-default):
Use semanticdb-without-unloaded-file-searches for speed, and to
conform to the controls that specify if the idle timer is supposed
to be parsing unparsed includes.
(semantic-idle-symbol-highlight-face)
......@@ -448,8 +454,8 @@
(semantic-analyze-find-tag-sequence-default): Be robust to
calculated scopes being nil.
* semantic/bovine/c.el (semantic-c-describe-environment): Add
project macro symbol array.
* semantic/bovine/c.el (semantic-c-describe-environment):
Add project macro symbol array.
(semantic-c-parse-lexical-token): Add recursion limit.
(semantic-ctxt-imported-packages, semanticdb-expand-nested-tag):
New overrides.
......@@ -458,8 +464,8 @@
(semantic-expand-c-tag-namelist): Do not split out a typedef'd
inline type if it is an anonymous type.
(semantic-c-reconstitute-token): Use the optional initializers as
a clue that some function is probably a constructor. When
defining the type of these constructors, split the parent name,
a clue that some function is probably a constructor.
When defining the type of these constructors, split the parent name,
and use only the class part, if applicable.
* semantic/bovine/c-by.el:
......@@ -594,8 +600,8 @@
* semantic/db-find.el
(semanticdb-find-translate-path-brutish-default):
* ede/make.el (ede-make-check-version): Use
with-current-buffer instead of save-excursion.
* ede/make.el (ede-make-check-version):
Use with-current-buffer instead of save-excursion.
2010-02-24 Eduard Wiebe <usenet@pusto.de>
......@@ -783,8 +789,8 @@
* ede.el (ede-apply-preprocessor-map): Accept lists of
ede-objects as targets.
* ede/pmake.el (ede-proj-makefile-insert-variables): Output
a target's object list even if compiler vars are already in the
* ede/pmake.el (ede-proj-makefile-insert-variables):
Output a target's object list even if compiler vars are already in the
Makefile.
* ede/emacs.el (ede-preprocessor-map): Add config.h to the
......@@ -880,8 +886,8 @@
2009-11-08 Chong Yidong <cyd@stupidchicken.com>
* semantic/ctxt.el (semantic-get-local-variables): Disable
the progress reporter entirely.
* semantic/ctxt.el (semantic-get-local-variables):
Disable the progress reporter entirely.
2009-11-03 Stefan Monnier <monnier@iro.umontreal.ca>
......
;;; semantic/symref/list.el --- Symref Output List UI.
;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
;; Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <eric@siege-engine.com>
......@@ -189,6 +189,7 @@ Display the references in`semantic-symref-results-mode'."
"The current results in a results mode buffer.")
(defun semantic-symref-results-mode (results)
;; FIXME: Use define-derived-mode.
"Major-mode for displaying Semantic Symbol Reference RESULTS.
RESULTS is an object of class `semantic-symref-results'."
(interactive)
......@@ -204,7 +205,7 @@ RESULTS is an object of class `semantic-symref-results'."
(buffer-disable-undo)
(set (make-local-variable 'font-lock-global-modes) nil)
(font-lock-mode -1)
(run-hooks 'semantic-symref-results-mode-hook)
(run-mode-hooks 'semantic-symref-results-mode-hook)
)
(defun semantic-symref-hide-buffer ()
......
;;; srecode/srt-mode.el --- Major mode for writing screcode macros
;; Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
......@@ -183,27 +183,20 @@ we can tell font lock about them.")
"Keymap used in srecode mode.")
;;;###autoload
(defun srecode-template-mode ()
(define-derived-mode srecode-template-mode fundamental-mode "SRecorder"
"Major-mode for writing SRecode macros."
(interactive)
(kill-all-local-variables)
(setq major-mode 'srecode-template-mode
mode-name "SRecoder"
comment-start ";;"
(setq comment-start ";;"
comment-end "")
(set (make-local-variable 'parse-sexp-ignore-comments) t)
(set (make-local-variable 'comment-start-skip)
"\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
(set-syntax-table srecode-template-mode-syntax-table)
(use-local-map srecode-template-mode-map)
(set (make-local-variable 'font-lock-defaults)
'(srecode-font-lock-keywords
nil ;; perform string/comment fontification
nil ;; keywords are case sensitive.
;; This puts _ & - as a word constituant,
;; simplifying our keywords significantly
((?_ . "w") (?- . "w"))))
(run-hooks 'srecode-template-mode-hook))
((?_ . "w") (?- . "w")))))
;;;###autoload
(defalias 'srt-mode 'srecode-template-mode)
......
......@@ -4021,7 +4021,7 @@ true then the type of the file linked to by FILE is printed instead.
;;;***
;;;### (autoloads (dired-do-relsymlink dired-jump) "dired-x" "dired-x.el"
;;;;;; "27c312d6d5d40d8cb4ef8d62e30d5f4a")
;;;;;; "6181a5bcc2b61255676a7a41549b9f40")
;;; Generated autoloads from dired-x.el
(autoload 'dired-jump "dired-x" "\
......
;;; chart.el --- Draw charts (bar charts, etc)
;; Copyright (C) 1996, 1998, 1999, 2001, 2004, 2005, 2007, 2008, 2009,
;; 2010 Free Software Foundation, Inc.
;; 2010, 2011 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; Version: 0.2
......@@ -62,17 +62,13 @@
(require 'eieio)
;;; Code:
(defvar chart-map (make-sparse-keymap) "Keymap used in chart mode.")
(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'.
......@@ -90,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)