emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] master e4de91d: Introduce new macros to cover Emacs's


From: Stefan Monnier
Subject: Re: [Emacs-diffs] master e4de91d: Introduce new macros to cover Emacs's new names in cl-lib.el.
Date: Tue, 18 Aug 2015 12:05:37 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

>> > The (eval-when-compile (require 'cl)) was inadequate, because
>> > cl.el (now cl-lib.el) is now required at run-time, too.  Without the
>> > change, the error "cl-mapcan not known" gets thrown when attempting to
>> > visit the first file.c in an Emacs session.
>> Oh, right, sorry, so the question becomes: what is the difference
>> between `require' and `cc-external-require' here?
> Not a great deal, to be honest.  The main difference is that symbols
> whose function cell has been given a placeholder value to inhibit
> compiler warnings have these function cells restored to their correct
> values in `cc-external-require' around the actual `require'.

Ah, so it tries to restore temporary sanity while loading the file.
That makes sense, thank you.

> An example of an XEmacs function which gets this treatment is
> `buffer-syntactic-context'.  An example of an Emacs function is
> `string-to-syntax'.

BTW, how 'bout using something like the patch below, to try and avoid
messing with function cells when we can?


        Stefan


diff --git a/lisp/progmodes/cc-bytecomp.el b/lisp/progmodes/cc-bytecomp.el
index b63eeb4..fe7cac7 100644
--- a/lisp/progmodes/cc-bytecomp.el
+++ b/lisp/progmodes/cc-bytecomp.el
@@ -377,6 +377,8 @@
 about incorrect number of arguments.  It's dangerous to try to replace
 existing functions since the byte compiler might need the definition
 at compile time, e.g. for macros and inline functions."
+  (if (fboundp 'declare-function)
+      `(declare-function ,fun nil)
   `(eval-when-compile
      (if (fboundp ',fun)
         (cc-bytecomp-debug-msg
@@ -393,7 +395,7 @@
             (fset ',fun (intern (concat "cc-bytecomp-ignore-fun:"
                                         (symbol-name ',fun))))
             (cc-bytecomp-debug-msg
-             "cc-bytecomp-defun: Covered function %s" ',fun))))))
+               "cc-bytecomp-defun: Covered function %s" ',fun)))))))
 
 (defmacro cc-bytecomp-put (symbol propname value)
   "Set a property on a symbol during compilation (and evaluation) of
@@ -428,13 +428,15 @@
 the compilation.  This is the same as using `fboundp' but additionally
 exclude any functions that have been bound during compilation with
 `cc-bytecomp-defun'."
+  (if (fboundp 'declare-function)
+      `(fboundp ,symbol)
   (let (fun-elem)
     (if (and (cc-bytecomp-is-compiling)
             (setq fun-elem (assq (car (cdr symbol))
                                  cc-bytecomp-original-functions))
             (eq (elt fun-elem 2) 'unbound))
        nil
-      `(fboundp ,symbol))))
+       `(fboundp ,symbol)))))
 
 
 (provide 'cc-bytecomp)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]