Next: , Previous: Function Cells, Up: Functions

12.9 Declaring Functions Obsolete

You can use make-obsolete to declare a function obsolete. This indicates that the function may be removed at some stage in the future.

— Function: make-obsolete obsolete-name current-name &optional when

This function makes the byte compiler warn that the function obsolete-name is obsolete. If current-name is a symbol, the warning message says to use current-name instead of obsolete-name. current-name does not need to be an alias for obsolete-name; it can be a different function with similar functionality. If current-name is a string, it is the warning message.

If provided, when should be a string indicating when the function was first made obsolete—for example, a date or a release number.

You can define a function as an alias and declare it obsolete at the same time using the macro define-obsolete-function-alias:

— Macro: define-obsolete-function-alias obsolete-name current-name &optional when docstring

This macro marks the function obsolete-name obsolete and also defines it as an alias for the function current-name. It is equivalent to the following:

          (defalias obsolete-name current-name docstring)
          (make-obsolete obsolete-name current-name when)

In addition, you can mark a certain a particular calling convention for a function as obsolete:

— Function: set-advertised-calling-convention function signature

This function specifies the argument list signature as the correct way to call function. This causes the Emacs byte compiler to issue a warning whenever it comes across an Emacs Lisp program that calls function any other way (however, it will still allow the code to be byte compiled).

For instance, in old versions of Emacs the sit-for function accepted three arguments, like this

            (sit-for seconds milliseconds nodisp)

However, calling sit-for this way is considered obsolete (see Waiting). The old calling convention is deprecated like this:

          (set-advertised-calling-convention
            'sit-for '(seconds &optional nodisp))