From: Juanma Barranquero <lektu@terra.es>
Subject: Re: ruler support in hexl mode
Date: Thu, 18 Mar 2004 01:53:43 +0100 [thread overview]
Message-ID: <20040318014101.C364.LEKTU@terra.es> (raw)
In-Reply-To: <buollm0cee4.fsf@mcspd15.ucom.lsi.nec.co.jp>
On 17 Mar 2004 12:59:31 +0900, Miles Bader <miles@lsi.nec.co.jp> wrote:
> Juanma Barranquero <jmbarranquero@wke.es> 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
next prev parent reply other threads:[~2004-03-18 0:53 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-05 5:29 ruler support in hexl mode Masatake YAMATO
2004-03-08 20:05 ` Stefan Monnier
2004-03-09 12:11 ` Masatake YAMATO
2004-03-11 6:59 ` Masatake YAMATO
2004-03-11 16:27 ` Kim F. Storm
2004-03-11 17:43 ` Stefan Monnier
2004-03-11 23:56 ` Kim F. Storm
2004-03-12 6:05 ` Masatake YAMATO
2004-03-12 21:24 ` Stefan Monnier
2004-03-13 18:13 ` Masatake YAMATO
2004-03-15 7:37 ` Masatake YAMATO
2004-03-15 4:55 ` Richard Stallman
2004-03-15 11:00 ` Kim F. Storm
2004-03-16 19:02 ` Richard Stallman
2004-03-17 0:08 ` Kim F. Storm
2004-03-17 0:42 ` Stefan Monnier
2004-03-17 2:23 ` Kim F. Storm
2004-03-19 5:01 ` Richard Stallman
2004-03-19 10:06 ` Kim F. Storm
2004-03-19 13:33 ` Kim F. Storm
2004-03-08 21:00 ` Miles Bader
2004-03-11 14:41 ` Juanma Barranquero
2004-03-17 3:59 ` Miles Bader
2004-03-18 0:53 ` Juanma Barranquero [this message]
2004-03-20 4:48 ` Richard Stallman
2004-03-22 11:52 ` Juanma Barranquero
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040318014101.C364.LEKTU@terra.es \
--to=lektu@terra.es \
--cc=lektu@mi.madritel.es \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.