From: Stefan Monnier Date: Wed, 3 Dec 2014 18:51:36 +0000 (-0500) Subject: * lisp/emacs-lisp/inline.el: Cosmetic and minor fixes. X-Git-Tag: emacs-25.0.90~2635^2~213 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c263a40a9ac76a87b919ca8d425736797c3c399c;p=emacs.git * lisp/emacs-lisp/inline.el: Cosmetic and minor fixes. * lisp/emacs-lisp/inline.el: Fix up copyright header. (inline-quote, inline-const-p, inline-const-val, inline-error): Silence compiler warnings. (inline-letevals): Fix edebug spec. (inline--testconst-p): Consider lambda expressions as const-p. (inline--getconst-val): Use inline--testconst-p. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a70917e7b92..e9f98340fad 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,12 @@ 2014-12-03 Stefan Monnier + * emacs-lisp/inline.el: Fix up copyright header. + (inline-quote, inline-const-p, inline-const-val, inline-error): + Silence compiler warnings. + (inline-letevals): Fix edebug spec. + (inline--testconst-p): Consider lambda expressions as const-p. + (inline--getconst-val): Use inline--testconst-p. + * minibuffer.el (completion-table-dynamic): Add arg `switch-buffer' and change default to stay in the minibuffer when called from the minibuffer (bug#19250). diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el index 3f11781aec0..679e875e1a0 100644 --- a/lisp/emacs-lisp/inline.el +++ b/lisp/emacs-lisp/inline.el @@ -1,21 +1,23 @@ ;;; inline.el --- Define functions by their inliner -*- lexical-binding:t; -*- -;; Copyright (C) 2014 Stefan Monnier +;; Copyright (C) 2014 Free Software Foundation, Inc. ;; Author: Stefan Monnier -;; This program is free software; you can redistribute it and/or modify +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. -;; This program is distributed in the hope that it will be useful, +;; 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 -;; along with this program. If not, see . +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -67,22 +69,22 @@ (require 'macroexp) -(defmacro inline-quote (exp) +(defmacro inline-quote (_exp) "Similar to backquote, but quotes code and only accepts , and not ,@." (declare (debug t)) (error "inline-quote can only be used within define-inline")) -(defmacro inline-const-p (exp) +(defmacro inline-const-p (_exp) "Return non-nil if the value of EXP is already known." (declare (debug t)) (error "inline-const-p can only be used within define-inline")) -(defmacro inline-const-val (exp) +(defmacro inline-const-val (_exp) "Return the value of EXP." (declare (debug t)) (error "inline-const-val can only be used within define-inline")) -(defmacro inline-error (format &rest args) +(defmacro inline-error (_format &rest _args) "Signal an error." (declare (debug t)) (error "inline-error can only be used within define-inline")) @@ -104,14 +106,21 @@ of arguments,in which case each argument is evaluated and the resulting new list is re-bound to VAR. After VARS is handled, BODY is evaluated in the new environment." - (declare (indent 1) (debug (sexp &rest body))) + (declare (indent 1) (debug (sexp &rest form))) (cond ((consp vars) `(inline--leteval ,(pop vars) (inline-letevals ,vars ,@body))) (vars `(inline--letlisteval ,vars ,@body)) (t (macroexp-progn body)))) - + +;; (defmacro inline-if (testfun testexp then else) +;; (declare (indent 2) (debug (sexp symbolp form form))) +;; (macroexp-let2 macroexp-copyable-p testsym testexp +;; `(if (inline-const-p ,testexp) +;; (if (,testfun (inline-const-val ,testexp)) ,then ,else) +;; (inline-quote (if (,testfun ,testexp) ,(list '\, then) +;; ,(list '\, else)))))) ;;;###autoload (defmacro define-inline (name args &rest body) @@ -220,7 +229,9 @@ After VARS is handled, BODY is evaluated in the new environment." (macroexp-progn body)) (defun inline--testconst-p (exp) - `(macroexp-const-p ,exp)) + (macroexp-let2 macroexp-copyable-p exp exp + `(or (macroexp-const-p ,exp) + (eq (car-safe ,exp) 'function)))) (defun inline--alwaysconst-p (_exp) t) @@ -228,7 +239,7 @@ After VARS is handled, BODY is evaluated in the new environment." (defun inline--getconst-val (exp) (macroexp-let2 macroexp-copyable-p exp exp `(cond - ((not (macroexp-const-p ,exp)) + ((not ,(inline--testconst-p exp)) (throw 'inline--just-use inline--form)) ((consp ,exp) (cadr ,exp)) (t ,exp))))