aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/subr.el47
1 files changed, 43 insertions, 4 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index f30e6db3a1f..6d2f0161b1f 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1,4 +1,4 @@
1;;; subr.el --- basic lisp subroutines for Emacs -*- coding: utf-8 -*- 1;;; subr.el --- basic lisp subroutines for Emacs -*- coding: utf-8; lexical-binding:t -*-
2 2
3;; Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2013 Free Software 3;; Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2013 Free Software
4;; Foundation, Inc. 4;; Foundation, Inc.
@@ -39,7 +39,7 @@ Each element of this list holds the arguments to one call to `defcustom'.")
39 (setq custom-declare-variable-list 39 (setq custom-declare-variable-list
40 (cons arguments custom-declare-variable-list))) 40 (cons arguments custom-declare-variable-list)))
41 41
42(defmacro declare-function (fn file &optional arglist fileonly) 42(defmacro declare-function (_fn _file &optional _arglist _fileonly)
43 "Tell the byte-compiler that function FN is defined, in FILE. 43 "Tell the byte-compiler that function FN is defined, in FILE.
44Optional ARGLIST is the argument list used by the function. The 44Optional ARGLIST is the argument list used by the function. The
45FILE argument is not used by the byte-compiler, but by the 45FILE argument is not used by the byte-compiler, but by the
@@ -1261,6 +1261,8 @@ is converted into a string by expressing it in decimal."
1261(make-obsolete-variable 'redisplay-end-trigger-functions 'jit-lock-register "23.1") 1261(make-obsolete-variable 'redisplay-end-trigger-functions 'jit-lock-register "23.1")
1262(make-obsolete-variable 'deferred-action-list 'post-command-hook "24.1") 1262(make-obsolete-variable 'deferred-action-list 'post-command-hook "24.1")
1263(make-obsolete-variable 'deferred-action-function 'post-command-hook "24.1") 1263(make-obsolete-variable 'deferred-action-function 'post-command-hook "24.1")
1264(make-obsolete-variable 'overriding-local-map
1265 'overriding-terminal-local-map "24.4" 'set)
1264(make-obsolete 'window-redisplay-end-trigger nil "23.1") 1266(make-obsolete 'window-redisplay-end-trigger nil "23.1")
1265(make-obsolete 'set-window-redisplay-end-trigger nil "23.1") 1267(make-obsolete 'set-window-redisplay-end-trigger nil "23.1")
1266 1268
@@ -1478,11 +1480,48 @@ ELEMENT is added at the end.
1478 1480
1479The return value is the new value of LIST-VAR. 1481The return value is the new value of LIST-VAR.
1480 1482
1483This is handy to add some elements to configuration variables,
1484but please do not abuse it in Elisp code, where you are usually better off
1485using `push' or `cl-pushnew'.
1486
1481If you want to use `add-to-list' on a variable that is not defined 1487If you want to use `add-to-list' on a variable that is not defined
1482until a certain package is loaded, you should put the call to `add-to-list' 1488until a certain package is loaded, you should put the call to `add-to-list'
1483into a hook function that will be run only after loading the package. 1489into a hook function that will be run only after loading the package.
1484`eval-after-load' provides one way to do this. In some cases 1490`eval-after-load' provides one way to do this. In some cases
1485other hooks, such as major mode hooks, can do the job." 1491other hooks, such as major mode hooks, can do the job."
1492 (declare
1493 (compiler-macro
1494 (lambda (exp)
1495 ;; FIXME: Something like this could be used for `set' as well.
1496 (if (or (not (eq 'quote (car-safe list-var)))
1497 (special-variable-p (cadr list-var))
1498 (and append compare-fn))
1499 exp
1500 (let* ((sym (cadr list-var))
1501 (msg (format "`add-to-list' can't use lexical var `%s'; use `push' or `cl-pushnew'"
1502 sym))
1503 ;; Big ugly hack so we only output a warning during
1504 ;; byte-compilation, and so we can use
1505 ;; byte-compile-not-lexical-var-p to silence the warning
1506 ;; when a defvar has been seen but not yet executed.
1507 (warnfun (lambda ()
1508 ;; FIXME: We should also emit a warning for let-bound
1509 ;; variables with dynamic binding.
1510 (when (assq sym byte-compile--lexical-environment)
1511 (byte-compile-log-warning msg t :error))))
1512 (code
1513 (if append
1514 (macroexp-let2 macroexp-copyable-p x element
1515 `(unless (member ,x ,sym)
1516 (setq ,sym (append ,sym (list ,x)))))
1517 (require 'cl-lib)
1518 `(cl-pushnew ,element ,sym
1519 :test ,(or compare-fn '#'equal)))))
1520 (if (not (macroexp--compiling-p))
1521 code
1522 `(progn
1523 (macroexp--funcall-if-compiled ',warnfun)
1524 ,code)))))))
1486 (if (cond 1525 (if (cond
1487 ((null compare-fn) 1526 ((null compare-fn)
1488 (member element (symbol-value list-var))) 1527 (member element (symbol-value list-var)))
@@ -2054,8 +2093,8 @@ some sort of escape sequence, the ambiguity is resolved via `read-key-delay'."
2054 ;; disable quail's input methods, so although read-key-sequence 2093 ;; disable quail's input methods, so although read-key-sequence
2055 ;; always inherits the input method, in practice read-key does not 2094 ;; always inherits the input method, in practice read-key does not
2056 ;; inherit the input method (at least not if it's based on quail). 2095 ;; inherit the input method (at least not if it's based on quail).
2057 (let ((overriding-terminal-local-map read-key-empty-map) 2096 (let ((overriding-terminal-local-map nil)
2058 (overriding-local-map nil) 2097 (overriding-local-map read-key-empty-map)
2059 (echo-keystrokes 0) 2098 (echo-keystrokes 0)
2060 (old-global-map (current-global-map)) 2099 (old-global-map (current-global-map))
2061 (timer (run-with-idle-timer 2100 (timer (run-with-idle-timer