2012-05-30 21:41:17 -04:00
|
|
|
|
;;; byte-run.el --- byte-compiler support for inlining -*- lexical-binding: t -*-
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2014-01-01 07:43:34 +00:00
|
|
|
|
;; Copyright (C) 1992, 2001-2014 Free Software Foundation, Inc.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Jamie Zawinski <jwz@lucid.com>
|
|
|
|
|
;; Hallvard Furuseth <hbf@ulrik.uio.no>
|
2014-02-09 17:34:22 -08:00
|
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; Keywords: internal
|
2010-08-29 12:17:13 -04:00
|
|
|
|
;; Package: emacs
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs 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
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; interface to selectively inlining functions.
|
|
|
|
|
;; This only happens when source-code optimization is turned on.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2012-05-30 21:41:17 -04:00
|
|
|
|
;; `macro-declaration-function' are both obsolete (as marked at the end of this
|
|
|
|
|
;; file) but used in many .elc files.
|
2005-03-14 14:05:13 +00:00
|
|
|
|
|
2012-05-29 23:59:42 -04:00
|
|
|
|
(defvar macro-declaration-function #'macro-declaration-function
|
|
|
|
|
"Function to process declarations in a macro definition.
|
|
|
|
|
The function will be called with two args MACRO and DECL.
|
|
|
|
|
MACRO is the name of the macro being defined.
|
|
|
|
|
DECL is a list `(declare ...)' containing the declarations.
|
|
|
|
|
The value the function returns is not used.")
|
|
|
|
|
|
|
|
|
|
(defalias 'macro-declaration-function
|
|
|
|
|
#'(lambda (macro decl)
|
|
|
|
|
"Process a declaration found in a macro definition.
|
2005-03-14 14:05:13 +00:00
|
|
|
|
This is set as the value of the variable `macro-declaration-function'.
|
|
|
|
|
MACRO is the name of the macro being defined.
|
|
|
|
|
DECL is a list `(declare ...)' containing the declarations.
|
|
|
|
|
The return value of this function is not used."
|
2012-05-29 23:59:42 -04:00
|
|
|
|
;; We can't use `dolist' or `cadr' yet for bootstrapping reasons.
|
|
|
|
|
(let (d)
|
|
|
|
|
;; Ignore the first element of `decl' (it's always `declare').
|
|
|
|
|
(while (setq decl (cdr decl))
|
|
|
|
|
(setq d (car decl))
|
|
|
|
|
(if (and (consp d)
|
|
|
|
|
(listp (cdr d))
|
|
|
|
|
(null (cdr (cdr d))))
|
|
|
|
|
(cond ((eq (car d) 'indent)
|
|
|
|
|
(put macro 'lisp-indent-function (car (cdr d))))
|
|
|
|
|
((eq (car d) 'debug)
|
|
|
|
|
(put macro 'edebug-form-spec (car (cdr d))))
|
|
|
|
|
((eq (car d) 'doc-string)
|
|
|
|
|
(put macro 'doc-string-elt (car (cdr d))))
|
|
|
|
|
(t
|
|
|
|
|
(message "Unknown declaration %s" d)))
|
|
|
|
|
(message "Invalid declaration %s" d))))))
|
|
|
|
|
|
2012-05-30 21:41:17 -04:00
|
|
|
|
;; We define macro-declaration-alist here because it is needed to
|
|
|
|
|
;; handle declarations in macro definitions and this is the first file
|
|
|
|
|
;; loaded by loadup.el that uses declarations in macros.
|
|
|
|
|
|
2014-03-22 15:12:52 -07:00
|
|
|
|
;; Add any new entries to info node `(elisp)Declare Form'.
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(defvar defun-declarations-alist
|
|
|
|
|
(list
|
2012-06-08 22:26:47 -04:00
|
|
|
|
;; We can only use backquotes inside the lambdas and not for those
|
|
|
|
|
;; properties that are used by functions loaded before backquote.el.
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(list 'advertised-calling-convention
|
2012-06-08 22:26:47 -04:00
|
|
|
|
#'(lambda (f _args arglist when)
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(list 'set-advertised-calling-convention
|
|
|
|
|
(list 'quote f) (list 'quote arglist) (list 'quote when))))
|
2012-06-08 22:26:47 -04:00
|
|
|
|
(list 'obsolete
|
|
|
|
|
#'(lambda (f _args new-name when)
|
2013-03-12 22:19:31 -04:00
|
|
|
|
(list 'make-obsolete
|
|
|
|
|
(list 'quote f) (list 'quote new-name) (list 'quote when))))
|
2014-03-22 15:12:52 -07:00
|
|
|
|
(list 'interactive-only
|
|
|
|
|
#'(lambda (f _args instead)
|
|
|
|
|
(list 'put (list 'quote f) ''interactive-only
|
|
|
|
|
(list 'quote instead))))
|
2012-06-08 22:26:47 -04:00
|
|
|
|
(list 'compiler-macro
|
2012-11-19 16:30:55 -05:00
|
|
|
|
#'(lambda (f args compiler-function)
|
|
|
|
|
`(eval-and-compile
|
|
|
|
|
(put ',f 'compiler-macro
|
|
|
|
|
,(if (eq (car-safe compiler-function) 'lambda)
|
|
|
|
|
`(lambda ,(append (cadr compiler-function) args)
|
|
|
|
|
,@(cddr compiler-function))
|
2012-11-20 12:54:00 -05:00
|
|
|
|
`#',compiler-function)))))
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(list 'doc-string
|
2012-06-08 22:26:47 -04:00
|
|
|
|
#'(lambda (f _args pos)
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(list 'put (list 'quote f) ''doc-string-elt (list 'quote pos))))
|
|
|
|
|
(list 'indent
|
2012-06-08 22:26:47 -04:00
|
|
|
|
#'(lambda (f _args val)
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(list 'put (list 'quote f)
|
|
|
|
|
''lisp-indent-function (list 'quote val)))))
|
|
|
|
|
"List associating function properties to their macro expansion.
|
|
|
|
|
Each element of the list takes the form (PROP FUN) where FUN is
|
|
|
|
|
a function. For each (PROP . VALUES) in a function's declaration,
|
2012-06-08 22:26:47 -04:00
|
|
|
|
the FUN corresponding to PROP is called with the function name,
|
|
|
|
|
the function's arglist, and the VALUES and should return the code to use
|
2014-03-22 15:12:52 -07:00
|
|
|
|
to set this property.
|
|
|
|
|
|
|
|
|
|
This is used by `declare'.")
|
2012-05-30 21:41:17 -04:00
|
|
|
|
|
|
|
|
|
(defvar macro-declarations-alist
|
|
|
|
|
(cons
|
|
|
|
|
(list 'debug
|
2012-06-08 22:26:47 -04:00
|
|
|
|
#'(lambda (name _args spec)
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(list 'progn :autoload-end
|
|
|
|
|
(list 'put (list 'quote name)
|
|
|
|
|
''edebug-form-spec (list 'quote spec)))))
|
|
|
|
|
defun-declarations-alist)
|
|
|
|
|
"List associating properties of macros to their macro expansion.
|
2013-11-20 21:46:00 -05:00
|
|
|
|
Each element of the list takes the form (PROP FUN) where FUN is a function.
|
|
|
|
|
For each (PROP . VALUES) in a macro's declaration, the FUN corresponding
|
|
|
|
|
to PROP is called with the macro name, the macro's arglist, and the VALUES
|
2014-03-22 15:12:52 -07:00
|
|
|
|
and should return the code to use to set this property.
|
|
|
|
|
|
|
|
|
|
This is used by `declare'.")
|
2012-05-30 21:41:17 -04:00
|
|
|
|
|
2012-05-29 23:59:42 -04:00
|
|
|
|
(put 'defmacro 'doc-string-elt 3)
|
2013-11-04 15:06:02 -05:00
|
|
|
|
(put 'defmacro 'lisp-indent-function 2)
|
2012-05-29 23:59:42 -04:00
|
|
|
|
(defalias 'defmacro
|
|
|
|
|
(cons
|
|
|
|
|
'macro
|
2012-12-31 22:53:33 +01:00
|
|
|
|
#'(lambda (name arglist &optional docstring &rest body)
|
2012-05-29 23:59:42 -04:00
|
|
|
|
"Define NAME as a macro.
|
|
|
|
|
When the macro is called, as in (NAME ARGS...),
|
|
|
|
|
the function (lambda ARGLIST BODY...) is applied to
|
|
|
|
|
the list ARGS... as it appears in the expression,
|
|
|
|
|
and the result should be a form to be evaluated instead of the original.
|
2012-05-30 21:41:17 -04:00
|
|
|
|
DECL is a declaration, optional, of the form (declare DECLS...) where
|
|
|
|
|
DECLS is a list of elements of the form (PROP . VALUES). These are
|
2012-06-18 11:57:41 -04:00
|
|
|
|
interpreted according to `macro-declarations-alist'.
|
2012-12-31 22:53:33 +01:00
|
|
|
|
The return value is undefined.
|
|
|
|
|
|
|
|
|
|
\(fn NAME ARGLIST &optional DOCSTRING DECL &rest BODY)"
|
|
|
|
|
;; We can't just have `decl' as an &optional argument, because we need
|
|
|
|
|
;; to distinguish
|
|
|
|
|
;; (defmacro foo (arg) (bar) nil)
|
|
|
|
|
;; from
|
|
|
|
|
;; (defmacro foo (arg) (bar)).
|
|
|
|
|
(let ((decls (cond
|
|
|
|
|
((eq (car-safe docstring) 'declare)
|
|
|
|
|
(prog1 (cdr docstring) (setq docstring nil)))
|
|
|
|
|
((and (stringp docstring)
|
|
|
|
|
(eq (car-safe (car body)) 'declare))
|
|
|
|
|
(prog1 (cdr (car body)) (setq body (cdr body)))))))
|
|
|
|
|
(if docstring (setq body (cons docstring body))
|
|
|
|
|
(if (null body) (setq body '(nil))))
|
|
|
|
|
;; Can't use backquote because it's not defined yet!
|
|
|
|
|
(let* ((fun (list 'function (cons 'lambda (cons arglist body))))
|
|
|
|
|
(def (list 'defalias
|
|
|
|
|
(list 'quote name)
|
|
|
|
|
(list 'cons ''macro fun)))
|
|
|
|
|
(declarations
|
|
|
|
|
(mapcar
|
|
|
|
|
#'(lambda (x)
|
|
|
|
|
(let ((f (cdr (assq (car x) macro-declarations-alist))))
|
|
|
|
|
(if f (apply (car f) name arglist (cdr x))
|
|
|
|
|
(message "Warning: Unknown macro property %S in %S"
|
|
|
|
|
(car x) name))))
|
|
|
|
|
decls)))
|
|
|
|
|
(if declarations
|
|
|
|
|
(cons 'prog1 (cons def declarations))
|
|
|
|
|
def))))))
|
2012-05-29 23:59:42 -04:00
|
|
|
|
|
|
|
|
|
;; Now that we defined defmacro we can use it!
|
|
|
|
|
(defmacro defun (name arglist &optional docstring &rest body)
|
|
|
|
|
"Define NAME as a function.
|
|
|
|
|
The definition is (lambda ARGLIST [DOCSTRING] BODY...).
|
2012-05-30 21:41:17 -04:00
|
|
|
|
See also the function `interactive'.
|
|
|
|
|
DECL is a declaration, optional, of the form (declare DECLS...) where
|
|
|
|
|
DECLS is a list of elements of the form (PROP . VALUES). These are
|
|
|
|
|
interpreted according to `defun-declarations-alist'.
|
2012-06-18 11:57:41 -04:00
|
|
|
|
The return value is undefined.
|
2012-05-30 21:41:17 -04:00
|
|
|
|
|
|
|
|
|
\(fn NAME ARGLIST &optional DOCSTRING DECL &rest BODY)"
|
|
|
|
|
;; We can't just have `decl' as an &optional argument, because we need
|
|
|
|
|
;; to distinguish
|
|
|
|
|
;; (defun foo (arg) (toto) nil)
|
|
|
|
|
;; from
|
|
|
|
|
;; (defun foo (arg) (toto)).
|
2013-11-04 15:06:02 -05:00
|
|
|
|
(declare (doc-string 3) (indent 2))
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(let ((decls (cond
|
|
|
|
|
((eq (car-safe docstring) 'declare)
|
|
|
|
|
(prog1 (cdr docstring) (setq docstring nil)))
|
2012-12-31 22:53:33 +01:00
|
|
|
|
((and (stringp docstring)
|
|
|
|
|
(eq (car-safe (car body)) 'declare))
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(prog1 (cdr (car body)) (setq body (cdr body)))))))
|
|
|
|
|
(if docstring (setq body (cons docstring body))
|
|
|
|
|
(if (null body) (setq body '(nil))))
|
|
|
|
|
(let ((declarations
|
|
|
|
|
(mapcar
|
|
|
|
|
#'(lambda (x)
|
|
|
|
|
(let ((f (cdr (assq (car x) defun-declarations-alist))))
|
|
|
|
|
(cond
|
2012-06-08 22:26:47 -04:00
|
|
|
|
(f (apply (car f) name arglist (cdr x)))
|
2012-05-30 21:41:17 -04:00
|
|
|
|
;; Yuck!!
|
|
|
|
|
((and (featurep 'cl)
|
|
|
|
|
(memq (car x) ;C.f. cl-do-proclaim.
|
|
|
|
|
'(special inline notinline optimize warn)))
|
2012-09-07 16:14:55 -04:00
|
|
|
|
(push (list 'declare x)
|
2013-01-02 16:43:46 -08:00
|
|
|
|
(if (stringp docstring)
|
|
|
|
|
(if (eq (car-safe (cadr body)) 'interactive)
|
|
|
|
|
(cddr body)
|
|
|
|
|
(cdr body))
|
|
|
|
|
(if (eq (car-safe (car body)) 'interactive)
|
|
|
|
|
(cdr body)
|
|
|
|
|
body)))
|
2012-05-30 21:41:17 -04:00
|
|
|
|
nil)
|
2012-09-07 16:14:55 -04:00
|
|
|
|
(t (message "Warning: Unknown defun property `%S' in %S"
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(car x) name)))))
|
|
|
|
|
decls))
|
|
|
|
|
(def (list 'defalias
|
|
|
|
|
(list 'quote name)
|
|
|
|
|
(list 'function
|
|
|
|
|
(cons 'lambda
|
|
|
|
|
(cons arglist body))))))
|
|
|
|
|
(if declarations
|
|
|
|
|
(cons 'prog1 (cons def declarations))
|
|
|
|
|
def))))
|
2005-03-14 14:05:13 +00:00
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; Redefined in byte-optimize.el.
|
|
|
|
|
;; This is not documented--it's not clear that we should promote it.
|
|
|
|
|
(fset 'inline 'progn)
|
|
|
|
|
|
|
|
|
|
;;; Interface to inline functions.
|
|
|
|
|
|
|
|
|
|
;; (defmacro proclaim-inline (&rest fns)
|
|
|
|
|
;; "Cause the named functions to be open-coded when called from compiled code.
|
|
|
|
|
;; They will only be compiled open-coded when byte-compile-optimize is true."
|
|
|
|
|
;; (cons 'eval-and-compile
|
2011-05-23 14:57:17 -03:00
|
|
|
|
;; (mapcar (lambda (x)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; (or (memq (get x 'byte-optimizer)
|
|
|
|
|
;; '(nil byte-compile-inline-expand))
|
|
|
|
|
;; (error
|
|
|
|
|
;; "%s already has a byte-optimizer, can't make it inline"
|
|
|
|
|
;; x))
|
|
|
|
|
;; (list 'put (list 'quote x)
|
|
|
|
|
;; ''byte-optimizer ''byte-compile-inline-expand))
|
|
|
|
|
;; fns)))
|
|
|
|
|
|
|
|
|
|
;; (defmacro proclaim-notinline (&rest fns)
|
|
|
|
|
;; "Cause the named functions to no longer be open-coded."
|
|
|
|
|
;; (cons 'eval-and-compile
|
2011-05-23 14:57:17 -03:00
|
|
|
|
;; (mapcar (lambda (x)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; (if (eq (get x 'byte-optimizer) 'byte-compile-inline-expand)
|
|
|
|
|
;; (put x 'byte-optimizer nil))
|
|
|
|
|
;; (list 'if (list 'eq (list 'get (list 'quote x) ''byte-optimizer)
|
|
|
|
|
;; ''byte-compile-inline-expand)
|
|
|
|
|
;; (list 'put x ''byte-optimizer nil)))
|
|
|
|
|
;; fns)))
|
|
|
|
|
|
|
|
|
|
(defmacro defsubst (name arglist &rest body)
|
2012-10-15 12:03:04 +08:00
|
|
|
|
"Define an inline function. The syntax is just like that of `defun'.
|
|
|
|
|
\(fn NAME ARGLIST &optional DOCSTRING DECL &rest BODY)"
|
2012-05-17 21:46:20 -04:00
|
|
|
|
(declare (debug defun) (doc-string 3))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(or (memq (get name 'byte-optimizer)
|
|
|
|
|
'(nil byte-compile-inline-expand))
|
|
|
|
|
(error "`%s' is a primitive" name))
|
2004-03-22 15:22:34 +00:00
|
|
|
|
`(prog1
|
|
|
|
|
(defun ,name ,arglist ,@body)
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
(put ',name 'byte-optimizer 'byte-compile-inline-expand))))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2009-10-01 16:54:21 +00:00
|
|
|
|
(defvar advertised-signature-table (make-hash-table :test 'eq :weakness 'key))
|
|
|
|
|
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(defun set-advertised-calling-convention (function signature _when)
|
2009-10-01 16:54:21 +00:00
|
|
|
|
"Set the advertised SIGNATURE of FUNCTION.
|
|
|
|
|
This will allow the byte-compiler to warn the programmer when she uses
|
2010-09-14 13:11:44 +02:00
|
|
|
|
an obsolete calling convention. WHEN specifies since when the calling
|
|
|
|
|
convention was modified."
|
2009-10-01 16:54:21 +00:00
|
|
|
|
(puthash (indirect-function function) signature
|
|
|
|
|
advertised-signature-table))
|
|
|
|
|
|
2005-06-14 15:50:22 +00:00
|
|
|
|
(defun make-obsolete (obsolete-name current-name &optional when)
|
Use declare forms, where possible, to mark obsolete functions.
* lisp/allout.el (allout-passphrase-hint-string): Likewise.
(allout-init): Use a declare form to mark obsolete.
* lisp/calendar/calendar.el (calendar-version):
* lisp/calendar/icalendar.el (icalendar-extract-ical-from-buffer)
(icalendar-convert-diary-to-ical):
* lisp/cus-edit.el (custom-mode):
* lisp/ansi-color.el (ansi-color-unfontify-region):
* lisp/international/latin1-disp.el (latin1-char-displayable-p):
* lisp/progmodes/cwarn.el (turn-on-cwarn-mode):
* lisp/progmodes/which-func.el (which-func-update-1): Use
define-obsolete-function-alias.
* lisp/bookmark.el (bookmark-jump-noselect): Use a declare form to mark
this function obsolete.
* lisp/calendar/cal-x.el (calendar-two-frame-setup)
(calendar-only-one-frame-setup, calendar-one-frame-setup):
* lisp/calendar/calendar.el (american-calendar, european-calendar)
(calendar-for-loop):
* lisp/comint.el (comint-dynamic-simple-complete)
(comint-dynamic-complete-as-filename, comint-unquote-filename):
* lisp/desktop.el (desktop-load-default):
* lisp/dired-x.el (dired-omit-here-always)
(dired-hack-local-variables, dired-default-directory):
* lisp/emacs-lisp/derived.el (derived-mode-class):
* lisp/emacs-lisp/timer.el (timer-set-time-with-usecs):
* lisp/emacs-lock.el (toggle-emacs-lock):
* lisp/epa.el (epa-display-verify-result):
* lisp/epg.el (epg-sign-keys, epg-start-sign-keys)
(epg-passphrase-callback-function):
* lisp/eshell/esh-util.el (eshell-for):
* lisp/eshell/eshell.el (eshell-remove-from-window-buffer-names)
(eshell-add-to-window-buffer-names):
* lisp/files.el (locate-file-completion):
* lisp/imenu.el (imenu-example--create-c-index)
(imenu-example--create-lisp-index)
(imenu-example--lisp-extract-index-name)
(imenu-example--name-and-position):
* lisp/international/mule-cmds.el (princ-list):
* lisp/international/mule-diag.el (decode-codepage-char):
* lisp/international/mule-util.el (detect-coding-with-priority):
* lisp/iswitchb.el (iswitchb-read-buffer):
* lisp/mail/mailalias.el (mail-complete):
* lisp/mail/sendmail.el (mail-sent-via):
* lisp/mouse.el (mouse-popup-menubar-stuff, mouse-popup-menubar)
(mouse-major-mode-menu):
* lisp/password-cache.el (password-read-and-add):
* lisp/pcomplete.el (pcomplete-parse-comint-arguments):
* lisp/progmodes/sh-script.el (sh-maybe-here-document):
* lisp/replace.el (query-replace-regexp-eval):
* lisp/savehist.el (savehist-load):
* lisp/simple.el (choose-completion-delete-max-match):
* lisp/term.el (term-dynamic-simple-complete):
* lisp/vc/ediff-init.el (ediff-check-version):
* lisp/vc/ediff-wind.el (ediff-choose-window-setup-function-automatically):
* lisp/vc/vc.el (vc-diff-switches-list):
* lisp/view.el (view-return-to-alist-update): Likewise.
* lisp/iswitchb.el (iswitchb-read-buffer): Move code of
iswitchb-define-mode-map here, and delete that obsolete function.
* lisp/subr.el (eval-next-after-load, makehash, insert-string)
(assoc-ignore-representation, assoc-ignore-case): Use declare to
mark obsolete.
(mode-line-inverse-video): Variable deleted.
* lisp/emacs-lisp/byte-run.el (make-obsolete): Doc fix; emphasize that
this applies to functions.
* lisp/erc/erc.el (erc-send-command): Use define-obsolete-function-alias.
* lisp/international/mule-util.el (string-to-sequence): Remove.
* lisp/net/newst-backend.el (newsticker-cache-filename):
* lisp/net/newst-treeview.el (newsticker-groups-filename): Fix
incorrect obsolescence declaration.
* lisp/net/snmp-mode.el (snmp-font-lock-keywords-3): Don't use obsolete
font-lock-reference-face.
* lisp/url/url-parse.el (url-recreate-url-attributes):
* lisp/url/url-util.el (url-generate-unique-filename): Use declare to mark
obsolete.
* src/xdisp.c (mode_line_inverse_video): Delete obsolete variable.
2012-09-25 12:13:02 +08:00
|
|
|
|
"Make the byte-compiler warn that function OBSOLETE-NAME is obsolete.
|
|
|
|
|
OBSOLETE-NAME should be a function name or macro name (a symbol).
|
|
|
|
|
|
2005-06-14 15:50:22 +00:00
|
|
|
|
The warning will say that CURRENT-NAME should be used instead.
|
2008-02-28 03:47:59 +00:00
|
|
|
|
If CURRENT-NAME is a string, that is the `use instead' message
|
|
|
|
|
\(it should end with a period, and not start with a capital).
|
2011-06-01 11:19:45 -03:00
|
|
|
|
WHEN should be a string indicating when the function
|
2003-05-30 23:31:15 +00:00
|
|
|
|
was first made obsolete, for example a date or a release number."
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(declare (advertised-calling-convention
|
|
|
|
|
;; New code should always provide the `when' argument.
|
|
|
|
|
(obsolete-name current-name when) "23.1"))
|
2011-02-26 10:19:08 -05:00
|
|
|
|
(put obsolete-name 'byte-obsolete-info
|
|
|
|
|
;; The second entry used to hold the `byte-compile' handler, but
|
|
|
|
|
;; is not used any more nowadays.
|
2011-06-01 11:19:45 -03:00
|
|
|
|
(purecopy (list current-name nil when)))
|
2005-06-14 15:50:22 +00:00
|
|
|
|
obsolete-name)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2005-06-14 15:50:22 +00:00
|
|
|
|
(defmacro define-obsolete-function-alias (obsolete-name current-name
|
2005-04-26 09:03:56 +00:00
|
|
|
|
&optional when docstring)
|
2005-06-14 15:50:22 +00:00
|
|
|
|
"Set OBSOLETE-NAME's function definition to CURRENT-NAME and mark it obsolete.
|
2005-05-05 22:58:40 +00:00
|
|
|
|
|
|
|
|
|
\(define-obsolete-function-alias 'old-fun 'new-fun \"22.1\" \"old-fun's doc.\")
|
|
|
|
|
|
|
|
|
|
is equivalent to the following two lines of code:
|
|
|
|
|
|
|
|
|
|
\(defalias 'old-fun 'new-fun \"old-fun's doc.\")
|
|
|
|
|
\(make-obsolete 'old-fun 'new-fun \"22.1\")
|
|
|
|
|
|
|
|
|
|
See the docstrings of `defalias' and `make-obsolete' for more details."
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(declare (doc-string 4)
|
|
|
|
|
(advertised-calling-convention
|
|
|
|
|
;; New code should always provide the `when' argument.
|
|
|
|
|
(obsolete-name current-name when &optional docstring) "23.1"))
|
2005-04-26 09:03:56 +00:00
|
|
|
|
`(progn
|
2005-06-14 15:50:22 +00:00
|
|
|
|
(defalias ,obsolete-name ,current-name ,docstring)
|
|
|
|
|
(make-obsolete ,obsolete-name ,current-name ,when)))
|
2005-04-26 09:03:56 +00:00
|
|
|
|
|
2011-06-01 16:32:04 -03:00
|
|
|
|
(defun make-obsolete-variable (obsolete-name current-name &optional when access-type)
|
2005-06-14 15:50:22 +00:00
|
|
|
|
"Make the byte-compiler warn that OBSOLETE-NAME is obsolete.
|
|
|
|
|
The warning will say that CURRENT-NAME should be used instead.
|
|
|
|
|
If CURRENT-NAME is a string, that is the `use instead' message.
|
2011-06-01 16:32:04 -03:00
|
|
|
|
WHEN should be a string indicating when the variable
|
|
|
|
|
was first made obsolete, for example a date or a release number.
|
|
|
|
|
ACCESS-TYPE if non-nil should specify the kind of access that will trigger
|
|
|
|
|
obsolescence warnings; it can be either `get' or `set'."
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(declare (advertised-calling-convention
|
|
|
|
|
;; New code should always provide the `when' argument.
|
|
|
|
|
(obsolete-name current-name when &optional access-type) "23.1"))
|
2009-10-24 06:32:03 +00:00
|
|
|
|
(put obsolete-name 'byte-obsolete-variable
|
2011-06-01 16:32:04 -03:00
|
|
|
|
(purecopy (list current-name access-type when)))
|
2005-06-14 15:50:22 +00:00
|
|
|
|
obsolete-name)
|
2012-05-30 21:41:17 -04:00
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2005-06-14 15:50:22 +00:00
|
|
|
|
(defmacro define-obsolete-variable-alias (obsolete-name current-name
|
2005-04-22 04:08:08 +00:00
|
|
|
|
&optional when docstring)
|
2005-06-14 15:50:22 +00:00
|
|
|
|
"Make OBSOLETE-NAME a variable alias for CURRENT-NAME and mark it obsolete.
|
2009-10-16 06:48:24 +00:00
|
|
|
|
This uses `defvaralias' and `make-obsolete-variable' (which see).
|
|
|
|
|
See the Info node `(elisp)Variable Aliases' for more details.
|
2005-05-05 22:58:40 +00:00
|
|
|
|
|
2008-04-12 03:13:27 +00:00
|
|
|
|
If CURRENT-NAME is a defcustom (more generally, any variable
|
2012-09-17 13:41:04 +08:00
|
|
|
|
where OBSOLETE-NAME may be set, e.g. in an init file, before the
|
2008-04-12 03:13:27 +00:00
|
|
|
|
alias is defined), then the define-obsolete-variable-alias
|
2009-10-16 06:48:24 +00:00
|
|
|
|
statement should be evaluated before the defcustom, if user
|
|
|
|
|
customizations are to be respected. The simplest way to achieve
|
|
|
|
|
this is to place the alias statement before the defcustom (this
|
|
|
|
|
is not necessary for aliases that are autoloaded, or in files
|
|
|
|
|
dumped with Emacs). This is so that any user customizations are
|
|
|
|
|
applied before the defcustom tries to initialize the
|
|
|
|
|
variable (this is due to the way `defvaralias' works).
|
|
|
|
|
|
|
|
|
|
For the benefit of `custom-set-variables', if OBSOLETE-NAME has
|
|
|
|
|
any of the following properties, they are copied to
|
|
|
|
|
CURRENT-NAME, if it does not already have them:
|
|
|
|
|
'saved-value, 'saved-variable-comment."
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(declare (doc-string 4)
|
|
|
|
|
(advertised-calling-convention
|
|
|
|
|
;; New code should always provide the `when' argument.
|
|
|
|
|
(obsolete-name current-name when &optional docstring) "23.1"))
|
2005-04-22 04:08:08 +00:00
|
|
|
|
`(progn
|
2005-06-14 15:50:22 +00:00
|
|
|
|
(defvaralias ,obsolete-name ,current-name ,docstring)
|
2009-10-16 06:48:24 +00:00
|
|
|
|
;; See Bug#4706.
|
2009-11-03 15:28:13 +00:00
|
|
|
|
(dolist (prop '(saved-value saved-variable-comment))
|
|
|
|
|
(and (get ,obsolete-name prop)
|
|
|
|
|
(null (get ,current-name prop))
|
|
|
|
|
(put ,current-name prop (get ,obsolete-name prop))))
|
2005-10-24 16:44:55 +00:00
|
|
|
|
(make-obsolete-variable ,obsolete-name ,current-name ,when)))
|
2005-04-22 04:08:08 +00:00
|
|
|
|
|
2009-08-31 01:32:36 +00:00
|
|
|
|
;; FIXME This is only defined in this file because the variable- and
|
|
|
|
|
;; function- versions are too. Unlike those two, this one is not used
|
|
|
|
|
;; by the byte-compiler (would be nice if it could warn about obsolete
|
|
|
|
|
;; faces, but it doesn't really do anything special with faces).
|
|
|
|
|
;; It only really affects M-x describe-face output.
|
2009-10-01 16:54:21 +00:00
|
|
|
|
(defmacro define-obsolete-face-alias (obsolete-face current-face when)
|
2009-08-31 01:32:36 +00:00
|
|
|
|
"Make OBSOLETE-FACE a face alias for CURRENT-FACE and mark it obsolete.
|
2009-10-06 03:43:23 +00:00
|
|
|
|
The string WHEN gives the Emacs version where OBSOLETE-FACE became
|
|
|
|
|
obsolete."
|
2009-08-31 01:32:36 +00:00
|
|
|
|
`(progn
|
|
|
|
|
(put ,obsolete-face 'face-alias ,current-face)
|
|
|
|
|
;; Used by M-x describe-face.
|
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
(tex-dvi-print-command, tex-bibtex-command, tex-start-commands)
(tex-start-options, slitex-run-command, latex-run-command)
(tex-run-command, tex-directory):
* textmodes/ispell.el (ispell-html-skip-alists)
(ispell-tex-skip-alists, ispell-tex-skip-alists):
* textmodes/fill.el (adaptive-fill-first-line-regexp):
(adaptive-fill-regexp):
* textmodes/dns-mode.el (auto-mode-alist):
* progmodes/python.el (interpreter-mode-alist):
* progmodes/etags.el (tags-compression-info-list):
* progmodes/etags.el (tags-file-name):
* net/browse-url.el (browse-url-galeon-program)
(browse-url-firefox-program):
* mail/sendmail.el (mail-signature-file)
(mail-citation-prefix-regexp):
* international/mule-conf.el (eight-bit):
* international/latexenc.el (latex-inputenc-coding-alist):
* international/fontset.el (x-pixel-size-width-font-regexp):
* emacs-lisp/warnings.el (warning-type-format):
* emacs-lisp/trace.el (trace-buffer):
* emacs-lisp/lisp-mode.el (lisp-interaction-mode-map)
(emacs-lisp-mode-map):
* calendar/holidays.el (holiday-solar-holidays)
(holiday-bahai-holidays, holiday-islamic-holidays)
(holiday-christian-holidays, holiday-hebrew-holidays)
(hebrew-holidays-4, hebrew-holidays-3, hebrew-holidays-2)
(hebrew-holidays-1, holiday-oriental-holidays)
(holiday-general-holidays):
* x-dnd.el (x-dnd-known-types):
* tool-bar.el (tool-bar):
* startup.el (site-run-file):
* shell.el (shell-dumb-shell-regexp):
* rfn-eshadow.el (file-name-shadow-tty-properties)
(file-name-shadow-properties):
* paths.el (remote-shell-program, news-directory):
* mouse.el ([C-down-mouse-3]):
* menu-bar.el (menu-bar-tools-menu):
* jka-cmpr-hook.el (jka-compr-load-suffixes)
(jka-compr-mode-alist-additions, jka-compr-compression-info-list)
(jka-compr-compression-info-list):
* isearch.el (search-whitespace-regexp):
* image-file.el (image-file-name-extensions):
* find-dired.el (find-ls-option):
* files.el (directory-listing-before-filename-regexp)
(directory-free-space-args, insert-directory-program)
(list-directory-brief-switches, magic-fallback-mode-alist)
(magic-fallback-mode-alist, auto-mode-interpreter-regexp)
(automount-dir-prefix):
* faces.el (face-x-resources, x-font-regexp, x-font-regexp-head)
(x-font-regexp-slant, x-font-regexp-weight, face-x-resources)
(face-font-registry-alternatives, face-font-registry-alternatives)
(face-font-family-alternatives):
* facemenu.el (facemenu-add-new-face, facemenu-background-menu)
(facemenu-foreground-menu, facemenu-face-menu):
* epa-hook.el (epa-file-name-regexp):
* dnd.el (dnd-protocol-alist):
* textmodes/rst.el (auto-mode-alist):
* button.el (default-button): Purecopy strings.
2009-11-06 05:16:23 +00:00
|
|
|
|
(put ,obsolete-face 'obsolete-face (or (purecopy ,when) t))))
|
2009-08-31 01:32:36 +00:00
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(defmacro dont-compile (&rest body)
|
|
|
|
|
"Like `progn', but the body always runs interpreted (not compiled).
|
|
|
|
|
If you think you need this, you're probably making a mistake somewhere."
|
2013-03-10 17:40:55 -04:00
|
|
|
|
(declare (debug t) (indent 0) (obsolete nil "24.4"))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body)))))
|
|
|
|
|
|
|
|
|
|
|
2005-10-24 16:44:55 +00:00
|
|
|
|
;; interface to evaluating things at compile time and/or load time
|
|
|
|
|
;; these macro must come after any uses of them in this file, as their
|
|
|
|
|
;; definition in the file overrides the magic definitions on the
|
|
|
|
|
;; byte-compile-macro-environment.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
(defmacro eval-when-compile (&rest body)
|
2005-05-19 15:39:56 +00:00
|
|
|
|
"Like `progn', but evaluates the body at compile time if you're compiling.
|
|
|
|
|
Thus, the result of the body appears to the compiler as a quoted constant.
|
|
|
|
|
In interpreted code, this is entirely equivalent to `progn'."
|
2013-12-25 22:37:04 +00:00
|
|
|
|
(declare (debug (&rest def-form)) (indent 0))
|
2013-02-08 11:17:18 -05:00
|
|
|
|
(list 'quote (eval (cons 'progn body) lexical-binding)))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
(defmacro eval-and-compile (&rest body)
|
|
|
|
|
"Like `progn', but evaluates the body at compile time and at load time."
|
2005-03-14 14:05:13 +00:00
|
|
|
|
(declare (debug t) (indent 0))
|
2013-02-08 11:17:18 -05:00
|
|
|
|
;; When the byte-compiler expands code, this macro is not used, so we're
|
|
|
|
|
;; either about to run `body' (plain interpretation) or we're doing eager
|
|
|
|
|
;; macroexpansion.
|
|
|
|
|
(list 'quote (eval (cons 'progn body) lexical-binding)))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2004-04-21 19:10:29 +00:00
|
|
|
|
(defun with-no-warnings (&rest body)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
"Like `progn', but prevents compiler warnings in the body."
|
2013-03-10 17:40:55 -04:00
|
|
|
|
(declare (indent 0))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; The implementation for the interpreter is basically trivial.
|
2004-04-21 19:10:29 +00:00
|
|
|
|
(car (last body)))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
|
2005-10-24 16:44:55 +00:00
|
|
|
|
;; I nuked this because it's not a good idea for users to think of using it.
|
|
|
|
|
;; These options are a matter of installation preference, and have nothing to
|
|
|
|
|
;; with particular source files; it's a mistake to suggest to users
|
|
|
|
|
;; they should associate these with particular source files.
|
|
|
|
|
;; There is hardly any reason to change these parameters, anyway.
|
|
|
|
|
;; --rms.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2005-03-12 17:24:29 +00:00
|
|
|
|
;; (put 'byte-compiler-options 'lisp-indent-function 0)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; (defmacro byte-compiler-options (&rest args)
|
|
|
|
|
;; "Set some compilation-parameters for this file. This will affect only the
|
|
|
|
|
;; file in which it appears; this does nothing when evaluated, and when loaded
|
|
|
|
|
;; from a .el file.
|
|
|
|
|
;;
|
|
|
|
|
;; Each argument to this macro must be a list of a key and a value.
|
|
|
|
|
;;
|
|
|
|
|
;; Keys: Values: Corresponding variable:
|
|
|
|
|
;;
|
|
|
|
|
;; verbose t, nil byte-compile-verbose
|
|
|
|
|
;; optimize t, nil, source, byte byte-compile-optimize
|
|
|
|
|
;; warnings list of warnings byte-compile-warnings
|
2008-02-05 11:51:30 +00:00
|
|
|
|
;; Valid elements: (callargs redefine free-vars unresolved)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; file-format emacs18, emacs19 byte-compile-compatibility
|
|
|
|
|
;;
|
|
|
|
|
;; For example, this might appear at the top of a source file:
|
|
|
|
|
;;
|
|
|
|
|
;; (byte-compiler-options
|
|
|
|
|
;; (optimize t)
|
|
|
|
|
;; (warnings (- free-vars)) ; Don't warn about free variables
|
|
|
|
|
;; (file-format emacs19))"
|
|
|
|
|
;; nil)
|
|
|
|
|
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(make-obsolete-variable 'macro-declaration-function
|
2012-08-15 09:29:11 -07:00
|
|
|
|
'macro-declarations-alist "24.3")
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(make-obsolete 'macro-declaration-function
|
2012-08-15 09:29:11 -07:00
|
|
|
|
'macro-declarations-alist "24.3")
|
2012-05-30 21:41:17 -04:00
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;;; byte-run.el ends here
|