* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Support face colors. * textmodes/tex-mode.el (tex-facemenu-add-face-function): New function. Support face colors (Bug#1168). (tex-common-initialization): Use it. * facemenu.el (facemenu-enable-faces-p): Enable facemenu if the mode allows it (Bug#1168).
This commit is contained in:
parent
c9349f0a05
commit
673c1168a0
4 changed files with 48 additions and 10 deletions
|
|
@ -1,3 +1,15 @@
|
|||
2009-10-31 Chong Yidong <cyd@stupidchicken.com>
|
||||
|
||||
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
|
||||
Support face colors.
|
||||
|
||||
* textmodes/tex-mode.el (tex-facemenu-add-face-function): New
|
||||
function. Support face colors (Bug#1168).
|
||||
(tex-common-initialization): Use it.
|
||||
|
||||
* facemenu.el (facemenu-enable-faces-p): Enable facemenu if the
|
||||
mode allows it (Bug#1168).
|
||||
|
||||
2009-10-31 Juri Linkov <juri@jurta.org>
|
||||
|
||||
* facemenu.el (list-colors-display): Don't mark buffer as
|
||||
|
|
|
|||
|
|
@ -187,7 +187,10 @@ it will remove any faces not explicitly in the list."
|
|||
|
||||
;;; Condition for enabling menu items that set faces.
|
||||
(defun facemenu-enable-faces-p ()
|
||||
(not (and font-lock-mode font-lock-defaults)))
|
||||
;; Enable the facemenu if facemenu-add-face-function is defined
|
||||
;; (e.g. in Tex-mode and SGML mode), or if font-lock is off.
|
||||
(or (not (and font-lock-mode font-lock-defaults))
|
||||
facemenu-add-face-function))
|
||||
|
||||
(defvar facemenu-special-menu
|
||||
(let ((map (make-sparse-keymap "Special")))
|
||||
|
|
|
|||
|
|
@ -397,12 +397,24 @@ a DOCTYPE or an XML declaration."
|
|||
(comment-indent-new-line soft)))
|
||||
|
||||
(defun sgml-mode-facemenu-add-face-function (face end)
|
||||
(if (setq face (cdr (assq face sgml-face-tag-alist)))
|
||||
(progn
|
||||
(setq face (funcall skeleton-transformation-function face))
|
||||
(setq facemenu-end-add-face (concat "</" face ">"))
|
||||
(concat "<" face ">"))
|
||||
(error "Face not configured for %s mode" (format-mode-line mode-name))))
|
||||
(let ((tag-face (cdr (assq face sgml-face-tag-alist))))
|
||||
(cond (tag-face
|
||||
(setq tag-face (funcall skeleton-transformation-function tag-face))
|
||||
(setq facemenu-end-add-face (concat "</" tag-face ">"))
|
||||
(concat "<" tag-face ">"))
|
||||
((and (consp face)
|
||||
(consp (car face))
|
||||
(null (cdr face))
|
||||
(memq (caar face) '(:foreground :background)))
|
||||
(setq facemenu-end-add-face "</span>")
|
||||
(format "<span style=\"%s:%s\">"
|
||||
(if (eq (caar face) :foreground)
|
||||
"color"
|
||||
"background-color")
|
||||
(cadr (car face))))
|
||||
(t
|
||||
(error "Face not configured for %s mode"
|
||||
(format-mode-line mode-name))))))
|
||||
|
||||
(defun sgml-fill-nobreak ()
|
||||
;; Don't break between a tag name and its first argument.
|
||||
|
|
|
|||
|
|
@ -860,6 +860,19 @@ Inherits `shell-mode-map' with a few additions.")
|
|||
,@tex-face-alist)
|
||||
"Alist of face and LaTeX font name for facemenu.")
|
||||
|
||||
(defun tex-facemenu-add-face-function (face end)
|
||||
(or (cdr (assq face tex-face-alist))
|
||||
(or (and (consp face)
|
||||
(consp (car face))
|
||||
(null (cdr face))
|
||||
(eq major-mode 'latex-mode)
|
||||
;; This actually requires the `color' LaTeX package.
|
||||
(cond ((eq (caar face) :foreground)
|
||||
(format "{\\color{%s} " (cadr (car face))))
|
||||
((eq (caar face) :background)
|
||||
(format "\\colorbox{%s}{" (cadr (car face))))))
|
||||
(error "Face %s not configured for %s mode" face mode-name))))
|
||||
|
||||
;; This would be a lot simpler if we just used a regexp search,
|
||||
;; but then it would be too slow.
|
||||
(defun tex-guess-mode ()
|
||||
|
|
@ -1131,9 +1144,7 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook
|
|||
(set (make-local-variable 'compare-windows-whitespace)
|
||||
'tex-categorize-whitespace)
|
||||
(set (make-local-variable 'facemenu-add-face-function)
|
||||
(lambda (face end)
|
||||
(or (cdr (assq face tex-face-alist))
|
||||
(error "Face %s not configured for %s mode" face mode-name))))
|
||||
'tex-facemenu-add-face-function)
|
||||
(set (make-local-variable 'facemenu-end-add-face) "}")
|
||||
(set (make-local-variable 'facemenu-remove-face-function) t)
|
||||
(set (make-local-variable 'font-lock-defaults)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue