Commit 98fbbe49e9e6
Changed files (2)
.emacs.d
.emacs.d/lisp/color-theme-buffer-local.el
@@ -1,150 +0,0 @@
-;;; color-theme-buffer-local.el --- Install color-themes by buffer.
-;;; Version: 0.0.2
-;;; Author: Victor Borja <vic.borja@gmail.com>
-;;; URL: http://github.com/vic/color-theme-buffer-local
-;;; Description: Set color-theme by buffer.
-;;; Keywords: faces
-
-
-;; This file is not part of GNU Emacs. Licensed on the same terms as
-;; 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/>.
-
-
-;;;
-;;; Usage for color-theme.el themes:
-;;;
-;;; (add-hook 'java-mode-hook (lambda nil
-;;; (color-theme-buffer-local 'color-theme-robin-hood (current-buffer))))
-;;;
-
-(require 'color-theme)
-
-(defun color-theme-buffer-local-install-variables (vars buffer)
- (with-current-buffer buffer
- (let ((vars (color-theme-filter vars color-theme-legal-variables)))
- (dolist (var vars)
- (set (make-variable-buffer-local (car var)) (cdr var))))))
-
-(defun color-theme-buffer-local-reset-faces (buffer)
- (with-current-buffer buffer
- (dolist (face (color-theme-get-faces))
- (make-variable-buffer-local 'face-remapping-alist)
- (face-remap-reset-base face))))
-
-
-(defun color-theme-buffer-local-spec-compat (spec)
- (let ((props (cadar spec)))
- ;; remove stipple attribute because it causes error :( FIXME
- (when (plist-member props :stipple)
- (setq props (color-theme-plist-delete props :stipple)))
- `((t ,props))))
-
-(defun color-theme-buffer-local-install-face (face spec)
- (or (facep face)
- (make-empty-face face))
- ;; remove weird properties from the default face only
- (when (eq face 'default)
- (setq spec (color-theme-spec-filter spec)))
- ;; Emacs/XEmacs customization issues: filter out :bold when
- ;; the spec contains :weight, etc, such that the spec remains
- ;; "valid" for custom.
- (setq spec (color-theme-spec-compat spec))
- ;; using a spec of ((t (nil))) to reset a face doesn't work
- ;; in Emacs 21, we use the new function face-spec-reset-face
- ;; instead
-
- (setq spec (color-theme-buffer-local-spec-compat spec))
-
- (if (eq 'default face)
- (buffer-face-set (face-spec-choose spec)))
-
- (face-remap-set-base face (face-spec-choose spec)))
-
-(defvar color-theme-buffer-local-face-alias
- '(
- (modeline . mode-line)
- (modeline-buffer-id . mode-line-buffer-id)
- (modeline-mousable . mode-line-mousable)
- ))
-
-(defun color-theme-buffer-local-install-faces (faces buffer)
- (with-current-buffer buffer
- (make-variable-buffer-local 'face-remapping-alist)
- (when (not color-theme-is-cumulative)
- (color-theme-buffer-local-reset-faces buffer))
- (let ((faces (color-theme-filter faces color-theme-illegal-faces t)))
- (dolist (entry faces)
- (let ((face (nth 0 entry)) (spec (nth 1 entry)))
- (color-theme-buffer-local-install-face face spec)))
-
- (dolist (alias color-theme-buffer-local-face-alias)
- (when (and (assoc (car alias) faces)
- (not (assoc (cdr alias) faces)))
- (color-theme-buffer-local-install-face
- (cdr alias)
- (cadr (assoc (car alias) faces)))))
- )))
-
-
-(defun color-theme-buffer-local-install-params (params buffer)
- (setq params (color-theme-filter
- params color-theme-legal-frame-parameters))
- (make-variable-buffer-local 'buffer-face-mode-face)
- (let (default)
- (dolist (param params)
- (when (eq (car param) 'foreground-color)
- (setq default (append default (list :foreground (cdr param)))))
- (when (eq (car param) 'background-color)
- (setq default (append default (list :background (cdr param)))))
- )
- (when default
- (setq default (append (if (listp buffer-face-mode-face)
- (cddr buffer-face-mode-face)
- (list buffer-face-mode-face))
- (list default)))
- (funcall 'buffer-face-set default))))
-
-
-(defun color-theme-buffer-local-install (theme buffer)
- (setq theme (color-theme-canonic theme))
- (with-current-buffer buffer
- (color-theme-buffer-local-install-variables (color-theme-variables theme) buffer)
- (color-theme-buffer-local-install-faces (color-theme-faces theme) buffer)
- (color-theme-buffer-local-install-params (color-theme-frame-params theme)
- buffer)))
-
-
-;;;###autoload
-(defun color-theme-buffer-local (theme &optional buffer)
- "Install the color-theme defined by THEME on BUFFER.
-
- THEME must be a symbol whose value as a function calls
- `color-theme-install' to install a theme.
-
- BUFFER defaults to the current buffer if not explicitly given."
- (interactive
- (list (intern (completing-read "Install color-theme: "
- (mapcar 'symbol-name
- (mapcar 'car color-themes))))
- (read-buffer "on Buffer: " (current-buffer) t)))
- (flet ((color-theme-install (theme)
- (color-theme-buffer-local-install
- theme (or buffer (current-buffer)))))
- (funcall theme)))
-
-(provide 'color-theme-buffer-local)
-
-;;; color-theme-buffer-local.el ends here
.emacs.d/lisp/load-theme-buffer-local.el
@@ -1,106 +0,0 @@
-;;; load-theme-buffer-local.el --- Install emacs24 color themes by buffer.
-;;; Version: 0.0.2
-;;; Author: Victor Borja <vic.borja@gmail.com>
-;;; URL: http://github.com/vic/color-theme-buffer-local
-;;; Description: Set color-theme by buffer.
-;;; Keywords: faces
-
-
-;; This file is not part of GNU Emacs. Licensed on the same terms as
-;; 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/>.
-
-
-;;;
-;;; Usage for emacs24 builtin themes:
-;;;
-;;;
-;;; (add-hook 'java-mode-hook (lambda nil
-;;; (load-theme-buffer-local 'misterioso (current-buffer))))
-(require 'noflet)
-
-(defun custom-theme-buffer-local-spec-attrs (spec)
- (let* ((spec (face-spec-choose spec))
- attrs)
- (while spec
- (when (assq (car spec) face-x-resources)
- (push (car spec) attrs)
- (push (cadr spec) attrs))
- (setq spec (cddr spec)))
- (nreverse attrs)))
-
-(defun custom-theme-buffer-local-recalc-face (face buffer)
- (with-current-buffer buffer
- (let (attrs)
-
- (if (get face 'face-alias)
- (setq face (get face 'face-alias)))
-
- ;; first set the default spec
- (or (get face 'customized-face)
- (get face 'saved-face)
- (setq attrs
- (append
- attrs
- (custom-theme-buffer-local-spec-attrs
- (face-default-spec face)))))
-
- (let ((theme-faces (reverse (get face 'theme-face))))
- (dolist (spec theme-faces)
- (setq attrs (append
- attrs
- (custom-theme-buffer-local-spec-attrs (cadr spec))))))
-
- (and (get face 'face-override-spec)
- (setq attrs (append
- attrs
- (custom-theme-buffer-local-spec-attrs
- (get face 'face-override-spec)))))
-
- (face-remap-set-base face attrs))))
-
-(defun custom-theme-buffer-local-recalc-variable (variable buffer)
- (with-current-buffer buffer
- (make-variable-buffer-local variable)
- (let ((valspec (custom-variable-theme-value variable)))
- (if valspec
- (put variable 'saved-value valspec)
- (setq valspec (get variable 'standard-value)))
- (if (and valspec
- (or (get variable 'force-value)
- (default-boundp variable)))
- (funcall (or (get variable 'custom-set) 'set-default) variable
- (eval (car valspec)))))))
-
-
-;;;###autoload
-(defun load-theme-buffer-local (theme &optional buffer no-confirm no-enable)
- "Load an Emacs24 THEME only in BUFFER."
- (interactive
- (list (intern (completing-read
- "Install theme: "
- (mapcar 'symbol-name (custom-available-themes))))
- (read-buffer "on Buffer: " (current-buffer) t)))
- (or buffer (setq buffer (current-buffer)))
- (noflet ((custom-theme-recalc-face
- (symbol) (custom-theme-buffer-local-recalc-face symbol buffer))
- (custom-theme-recalc-variable
- (symbol) (custom-theme-buffer-local-recalc-variable symbol buffer)))
- (load-theme theme no-confirm no-enable)))
-
-
-(provide 'load-theme-buffer-local)
-
-;;; load-theme-buffer-local.el ends here