auctex-devel
[Top][All Lists]
Advanced

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

Re: [AUCTeX-devel] [gmane.emacs.auctex.diffs] GNU AUCTeX branch, master,


From: Ikumi Keita
Subject: Re: [AUCTeX-devel] [gmane.emacs.auctex.diffs] GNU AUCTeX branch, master, updated. a16a5107845aee83e6e52dd6d8cfbbe90bd6303d
Date: Thu, 10 May 2018 23:53:35 +0900

Hi Arash,

>>>>> Arash Esbati <address@hidden> writes:
> I think this patch will not work as expected.  `cl-caddr' is a function
> and not a macro[1].  Thus, `eval-when-compile' will not expand
> `cl-caddr' at compile-time and you get a dependency at run-time.

Yes, `cl-caddr' is a function, but I think it is expanded as a macro at
byte compilation nevertheless :-).

This is a quote from the output of C-h f cl-caddr RET:
----------------------------------------------------------------------
cl-caddr is a compiled Lisp function in `cl-lib.el'.

(cl-caddr X)

This function has a compiler macro `internal--compiler-macro-cXXr'.
----------------------------------------------------------------------
And `cl-caddr' is defined in cl-lib.el as
----------------------------------------------------------------------
(defun cl-caddr (x)
  "Return the `car' of the `cdr' of the `cdr' of X."
  (declare (compiler-macro internal--compiler-macro-cXXr))
  (car (cdr (cdr x))))
----------------------------------------------------------------------
Thanks to this compiler macro, `eval-when-compile' works without
introducing run-time dependency on `cl-lib'.

You can confirm that the run-time dependency is really absent in
pstricks.elc, compiled after my patch is applied by the following two
methods:
(1) Evaluate the following form in a new emacs session:

(progn
  (load "tex.elc")
  ; a trick to do without loading latex.elc
  (defconst LaTeX-dialect :latex)
  (load "style/pstricks.elc")
  (let ((LaTeX-auto-pstricks
         '(("object" "a" "b" "c" "d"))))
    (LaTeX-pst-cleanup))
  (featurep 'cl-lib))

(2) Open pstriks.elc and just search for the string `cl-addr'.  No
occurence will be found, which means the function call to `cl-addr' is
not there.  It was expanded already at compile time.

It is true that (featurep 'cl-lib) returns t after opening a latex
document with \usepackage{pstricks}, but that's not due to `cl-caddr'.
It is some other element such as latex.elc, reftex, preview-latex etc.
that introduces dependency on cl-lib.  You can confirm that by typing
(in another new emacs session):
C-x b abc RET
M-x latex-mode RET
M-: (featurep 'cl-lib) RET

(I don't know which piece of code actually pulls in the run-time
dependency on cl-lib in this example.)

It is of course very easy to rewrite not to use cl-lib in this case.
I'll replace (cl-caddr ...) with (nth 2 ...) and delete
(eval-when-compile ...) if you prefer.

Best regards,
Ikumi Keita



reply via email to

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