Initial Commit
[packages] / xemacs-packages / w3 / lisp / w3-style.el
1 ;;; w3-style.el --- Emacs/W3 binding style sheet mechanism
2 ;; Author: $Author: fx $
3 ;; Created: $Date: 2001/10/11 13:04:58 $
4 ;; Version: $Revision: 1.4 $
5 ;; Keywords: faces, hypermedia
6
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;;; Copyright (c) 1993 - 1996 by William M. Perry <wmperry@cs.indiana.edu>
9 ;;; Copyright (c) 1996 - 1999 Free Software Foundation, Inc.
10 ;;;
11 ;;; This file is part of GNU Emacs.
12 ;;;
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;;; it under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 2, or (at your option)
16 ;;; any later version.
17 ;;;
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Emacs; see the file COPYING.  If not, write to the
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;;; Boston, MA 02111-1307, USA.
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
30 ;;; A style sheet mechanism for emacs-w3
31 ;;;
32 ;;; This will eventually be able to under DSSSL[-lite] as well as the
33 ;;; experimental W3C mechanism
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35 (require 'font)
36 (eval-when-compile (require 'cl))
37 (require 'css)
38
39 ;;;###autoload
40 (defun w3-handle-style (&optional plist)
41   (let ((url (or (plist-get plist 'href)
42                  (plist-get plist 'src)
43                  (plist-get plist 'uri)))
44         (media (intern (downcase (or (plist-get plist 'media) "all"))))
45         (type (downcase (or (plist-get plist 'notation) "text/css")))
46         (stylesheet nil)
47         (defines nil)
48         (buffer nil)
49         (cur-sheet w3-current-stylesheet)
50         (string (plist-get plist 'data)))
51     (if (not (memq media (css-active-device-types)))
52         nil                             ; Not applicable to us!
53       (save-excursion
54         (cond
55          ((member type '("experimental" "arena" "w3c-style" "css" "text/css"))
56           (setq stylesheet (css-parse url string cur-sheet)))
57          (t
58           (w3-warn 'html "Unknown stylesheet notation: %s" type))))
59       (setq w3-current-stylesheet stylesheet))))
60
61 ;;;###autoload
62 (defun w3-display-stylesheet (&optional sheet)
63   "Display the stylesheet for the current document."
64   (interactive)
65   (setq sheet (or sheet w3-current-stylesheet w3-user-stylesheet))
66   (if (not sheet)
67       (error "No stylesheet available!"))
68   (css-display sheet))
69
70 (provide 'w3-style)