[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ruler support in hexl mode
From: |
Juanma Barranquero |
Subject: |
Re: ruler support in hexl mode |
Date: |
Thu, 18 Mar 2004 01:53:43 +0100 |
On 17 Mar 2004 12:59:31 +0900, Miles Bader <address@hidden> wrote:
> Juanma Barranquero <address@hidden> writes:
> > Time for a `make-obsolete-face' function? :)
>
> It'd be nice...
Well, if there's really interest, I could commit the following patch:
------ cut here ------ cut here ------ cut here ------ cut here ------
Index: faces.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/faces.el,v
retrieving revision 1.282
diff -u -2 -r1.282 faces.el
--- faces.el 27 Feb 2004 17:30:23 -0000 1.282
+++ faces.el 17 Mar 2004 10:16:35 -0000
@@ -1243,5 +1243,6 @@
(if (not (facep f))
(insert " undefined face.\n")
- (let ((customize-label "customize this face"))
+ (let ((customize-label "customize this face")
+ (obsolete (get f 'byte-obsolete-face)))
(princ (concat " (" customize-label ")\n"))
(insert "Documentation: "
@@ -1249,4 +1250,12 @@
"Not documented as a face.")
"\n\n")
+ (when obsolete
+ (princ "This face is obsolete")
+ (if (cdr obsolete) (princ (format " since %s" (cdr obsolete))))
+ (princ ";") (terpri)
+ (princ (if (stringp (car obsolete)) (car obsolete)
+ (format "use `%s' instead." (car obsolete))))
+ (terpri)
+ (terpri))
(with-current-buffer standard-output
(save-excursion
Index: emacs-lisp/byte-run.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/byte-run.el,v
retrieving revision 1.3
diff -u -2 -r1.3 byte-run.el
--- emacs-lisp/byte-run.el 18 Mar 2004 00:17:17 -0000 1.3
+++ emacs-lisp/byte-run.el 17 Mar 2004 10:21:16 -0000
@@ -106,4 +106,21 @@
var)
+(defun make-obsolete-face (face new &optional when)
+ "Make the byte-compiler warn that FACE is obsolete.
+The warning will say that NEW should be used instead.
+If NEW is a string, that is the `use instead' message.
+If provided, WHEN should be a string indicating when the face
+was first made obsolete, for example a date or a release number."
+ (interactive
+ (list
+ (let ((old (read-face-name "Make face obsolete")))
+ (if (equal old nil) (error ""))
+ old)
+ (let ((new (read-face-name "Obsoletion replacement")))
+ (if (equal new nil) (error "No replacement face"))
+ new)))
+ (put face 'byte-obsolete-face (cons new when))
+ face)
+
(put 'dont-compile 'lisp-indent-hook 0)
(defmacro dont-compile (&rest body)
------ cut here ------ cut here ------ cut here ------ cut here ------
but the problem is, how to make the byte-compiler warn when using an
obsolete face? AFAICS, face names are just symbols, so other uses of the
symbol would trigger the warning too. For example, with this patch (just
a proof of concept, I know almost nothing about bytecomp.el):
------ cut here ------ cut here ------ cut here ------ cut here ------
Index: bytecomp.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/bytecomp.el,v
retrieving revision 2.143
diff -u -2 -r2.143 bytecomp.el
--- bytecomp.el 12 Mar 2004 10:09:59 -0000 2.143
+++ bytecomp.el 18 Mar 2004 00:47:31 -0000
@@ -2788,5 +2788,14 @@
(setq for-effect nil)
(when (symbolp const)
- (byte-compile-set-symbol-position const))
+ (byte-compile-set-symbol-position const)
+ (if (and (get const 'byte-obsolete-face)
+ (memq 'obsolete byte-compiler-warnings))
+ (let* ((ob (get const 'byte-obsolete-face))
+ (when (cdr ob)))
+ (byte-compile-warn "%s is an obsolete face%s; %s" const
+ (if when (concat " since " when) "")
+ (if (stringp (car ob))
+ (car ob)
+ (format "use %s instead." (car ob)))))))
(byte-compile-out 'byte-constant (byte-compile-get-constant const))))
------ cut here ------ cut here ------ cut here ------ cut here ------
you can certainly do (make-obsolete-face 'modeline 'mode-line "21.5")
and get a warning in compilation, but then so does every other use of
'modeline, even if it's not used as a a face. Any easy way to solve this
or do it right?
/L/e/k/t/u
- Re: ruler support in hexl mode, (continued)
- Re: ruler support in hexl mode, Kim F. Storm, 2004/03/16
- Re: ruler support in hexl mode, Stefan Monnier, 2004/03/16
- Re: ruler support in hexl mode, Kim F. Storm, 2004/03/16
- Re: ruler support in hexl mode, Richard Stallman, 2004/03/19
- Re: ruler support in hexl mode, Kim F. Storm, 2004/03/19
- Re: ruler support in hexl mode, Kim F. Storm, 2004/03/19
Re: ruler support in hexl mode, Masatake YAMATO, 2004/03/12
Re: ruler support in hexl mode, Miles Bader, 2004/03/10