From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: ruler support in hexl mode Date: Thu, 18 Mar 2004 01:53:43 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040318014101.C364.LEKTU@terra.es> References: <20040311152724.4EF0.JMBARRANQUERO@wke.es> Reply-To: lektu@mi.madritel.es NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1079571984 15208 80.91.224.253 (18 Mar 2004 01:06:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 18 Mar 2004 01:06:24 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Mar 18 02:06:17 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1B3lzF-0001o0-00 for ; Thu, 18 Mar 2004 02:06:17 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1B3lzE-0007Q1-00 for ; Thu, 18 Mar 2004 02:06:17 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B3ly9-0006pb-Ot for emacs-devel@quimby.gnus.org; Wed, 17 Mar 2004 20:05:09 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1B3lxh-0006pA-F1 for emacs-devel@gnu.org; Wed, 17 Mar 2004 20:04:41 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1B3lx7-0006Su-Ct for emacs-devel@gnu.org; Wed, 17 Mar 2004 20:04:36 -0500 Original-Received: from [213.4.129.129] (helo=tsmtp5.mail.isp) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B3lx6-000621-IO for emacs-devel@gnu.org; Wed, 17 Mar 2004 20:04:04 -0500 Original-Received: from [127.0.0.1] ([213.37.34.41]) by tsmtp5.mail.isp (terra.es) with ESMTP id HUQYHJ00.537 for ; Thu, 18 Mar 2004 01:53:45 +0100 Original-To: emacs-devel@gnu.org In-Reply-To: X-Mailer: Becky! ver. 2.08.01 [en] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:20565 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:20565 On 17 Mar 2004 12:59:31 +0900, Miles Bader wrote: > Juanma Barranquero 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