;;; overlay-fix.el --- overlay bug workaround

;; Copyright (C) 2001 by David Ponce

;; Author: David Ponce <[EMAIL PROTECTED]>
;; Maintainer: David Ponce <[EMAIL PROTECTED]>
;; Created: 12 Feb 2001
;; X-RCS: $Id$

;; This file is not part of Emacs

;; This program 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 2, or (at
;; your option) any later version.

;; This program 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 this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:
;; 
;; In GNU Emacs versions before 21 when the overlay 'face property is
;; nil it can disable the overlayed text face property.  The most
;; visible issue is that overlayed text is not syntax highlighted.
;; This library advices the built-in functions `make-overlay',
;; `overlay-put' and `overlay-get' to ensure that the overlay 'face
;; property will never be nil but `overlay-fix-empty-face' instead.
;; And that callers will continue to see nil for the corresponding
;; 'face property.

;;; History:
;; 

;;; Code:
(if (or (featurep 'xemacs) (> emacs-major-version 20))
    ;; Not needed for Emacs since v21 nor XEmacs
    nil

  ;; Define an empty face
  (make-empty-face 'overlay-fix-empty-face)

  (defadvice make-overlay (after after-make-overlay activate)
    "Ensure overlay 'face property is never nil."
    (or (overlay-get ad-return-value 'face)
        (overlay-put ad-return-value 'face 'overlay-fix-empty-face)))

  (defadvice overlay-put (around before-overlay-put activate)
    "Ensure overlay 'face property is never nil."
    (if (and (eq (ad-get-arg 1) 'face)
             (null (ad-get-arg 2)))
        (ad-set-arg 2 'overlay-fix-empty-face))
    ad-do-it
    (and  (eq (ad-get-arg 1) 'face)
          (eq (ad-get-arg 2) 'overlay-fix-empty-face)
          (setq ad-return-value nil)))
  
  (defadvice overlay-get (after after-overlay-get activate)
    "Ensure overlay 'face property is never nil."
    (if (and (eq (ad-get-arg 1) 'face)
             (eq ad-return-value 'overlay-fix-empty-face))
        (setq ad-return-value nil)))

  )

(provide 'overlay-fix)

;;; overlay-fix.el ends here
MOUSSAUD Beno�t writes:
 > I can not found  <ftp://cedet.sourceforge.net/pub/cedet/overlay-fix.el>
 > overlay-fix.el  in the ftp server [ cedet.sourceforge.net/pub/cedet] working
 > with the lastest beta
 > some one can post this file on the jde mailing list ?
 > regards,
 > Benoit
 >  
 > 
 > --------------------------------------------
 > Benoit Moussaud - Software Team Leader
 > [EMAIL PROTECTED]
 > CTS - Cril Telecom Software
 > http://www.criltelecom.com <http://www.criltelecom.com/> 
 > 8 rue danjou
 > 92517 Boulogne Billancourt - France
 > Tel: (33) 1 58 17 04 78
 > 
 > 
 > 
 >  
 > 
 > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 > <HTML><HEAD>
 > <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
 > 
 > 
 > <META content="MSHTML 5.50.4611.1300" name=GENERATOR>
 > <STYLE></STYLE>
 > </HEAD>
 > <BODY bgColor=#ffffff>
 > <DIV><SPAN class=850092809-01102001><FONT face=Arial color=#0000ff size=2>I can 
 > not found <A href="ftp://cedet.sourceforge.net/pub/cedet/overlay-fix.el";><FONT 
 > face="Times New Roman" size=3>overlay-fix.el</FONT></A>&nbsp; in the ftp server 
 > [ cedet.sourceforge.net/pub/cedet] working with the lastest 
 > beta</FONT></SPAN></DIV>
 > <DIV><SPAN class=850092809-01102001><FONT face=Arial color=#0000ff size=2>some 
 > one can post this file on the jde mailing list ?</FONT></SPAN></DIV>
 > <DIV><SPAN class=850092809-01102001><FONT face=Arial color=#0000ff 
 > size=2>regards,</FONT></SPAN></DIV>
 > <DIV><SPAN class=850092809-01102001><FONT face=Arial color=#0000ff 
 > size=2>Benoit</FONT></SPAN></DIV>
 > <DIV>&nbsp;</DIV>
 > <P><FONT size=2>--------------------------------------------<BR>Benoit Moussaud 
 > - Software Team Leader<BR>[EMAIL PROTECTED]<BR>CTS - Cril Telecom 
 > Software<BR><A target=_blank 
 > href="http://www.criltelecom.com/";>http://www.criltelecom.com</A><BR>8 rue 
 > danjou<BR>92517 Boulogne Billancourt - France<BR>Tel: (33) 1 58 17 04 
 > 78<BR><BR></FONT></P>
 > <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><FONT face=Arial color=#0000ff 
 >   size=2></FONT>&nbsp;</BLOCKQUOTE></BODY></HTML>

Reply via email to