GNU bug report logs - #18845
24.4; cc-mode derived modes broken because cl is used but not required

Previous Next

Packages: emacs, cc-mode;

Reported by: Joris Steyn <jorissteyn <at> gmail.com>

Date: Sun, 26 Oct 2014 22:10:02 UTC

Severity: normal

Found in version 24.4

Fixed in version 24.5

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18845 in the body.
You can then email your comments to 18845 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18845; Package emacs. (Sun, 26 Oct 2014 22:10:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Joris Steyn <jorissteyn <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 26 Oct 2014 22:10:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Joris Steyn <jorissteyn <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4; cc-mode derived modes broken because cl is used but not required
Date: Sun, 26 Oct 2014 23:02:38 +0100
[Message part 1 (text/plain, inline)]
cc-mode in emacs 24.4 uses the cl compatibility package at compile-time
but does not require it when used like this:

  (require 'cc-mode)

  (eval-when-compile
    (require 'cc-langs))

  ; Symbol's function definition is void: set-difference
  (c-lang-const c-matchers-2 c)

  ; Symbol's function definition is void: cl-macroexpand-all
  (c-lang-defconst c-other-kwds t nil)

I observed breakage of php-mode and csharp-mode, but this affects any
derived mode that does not require cl or requires cl-lib instead of cl.

This seems to be recently fixed in trunk (revno 118032) so maybe no
further action is required and this bug report can be closed.

What would be the most appropriate way for affected derived modes to
work around this issue? Suppose I add:

  (eval-when-compile
    (if (and (= emacs-major-version 24) (= emacs-minor-version 4))
      (require 'cl)))

would that be fine and won't there be a future 24.4 release that fixes
this issue?



In GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.3)
 of 2014-10-21 on bitzer.hoetzel.info
Windowing system distributor `The X.Org Foundation', version 11.0.11601000
System Description:    Arch Linux

Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 --param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'

Important settings:
  value of $LANG: C
  locale-coding-system: nil

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x r e p o <tab> r <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Making completion list...

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
help-fns mail-prsvr mail-utils help-mode easymenu time-date tooltip
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 72116 7225)
 (symbols 48 17651 0)
 (miscs 40 37 96)
 (strings 32 9247 4331)
 (string-bytes 1 253012)
 (vectors 16 8990)
 (vector-slots 8 383789 17145)
 (floats 8 64 304)
 (intervals 56 210 111)
 (buffers 960 12)
 (heap 1024 26191 1090))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#18845; Package emacs,cc-mode. (Thu, 30 Oct 2014 03:55:02 GMT) Full text and rfc822 format available.

Message #8 received at 18845 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Joris Steyn <jorissteyn <at> gmail.com>
Cc: bug-cc-mode <at> gnu.org, 18845 <at> debbugs.gnu.org
Subject: Re: bug#18845: 24.4;
 cc-mode derived modes broken because cl is used but not required
Date: Wed, 29 Oct 2014 23:54:28 -0400
>   ; Symbol's function definition is void: set-difference
>   (c-lang-const c-matchers-2 c)

Indeed.  One way to solve these problems is to replace those calls with
calls to cl-set-difference.  Alan, what do you think?

>   ; Symbol's function definition is void: cl-macroexpand-all
>   (c-lang-defconst c-other-kwds t nil)

I fixed this one with the patch below,

>   (eval-when-compile
>     (if (and (= emacs-major-version 24) (= emacs-minor-version 4))
>       (require 'cl)))

It's pretty ugly, but yes that should work.

> would that be fine and won't there be a future 24.4 release that fixes
> this issue?

The 24.4 release is over, so no there won't be another 24.4.
And hopefully this will be fixed in 24.5.


        Stefan


=== modified file 'lisp/progmodes/cc-defs.el'
--- lisp/progmodes/cc-defs.el	2014-02-09 12:34:25 +0000
+++ lisp/progmodes/cc-defs.el	2014-10-30 03:46:48 +0000
@@ -169,6 +169,10 @@
 
   (put 'cc-eval-when-compile 'lisp-indent-hook 0))
 
+(eval-and-compile
+  (defalias 'c--macroexpand-all
+    (if (fboundp 'macroexpand-all)
+        'macroexpand-all 'cl-macroexpand-all)))
 
 ;;; Macros.
 
@@ -1834,12 +1838,9 @@
 immediately, i.e. at the same time as the `c-lang-defconst' form
 itself is evaluated."
   ;; Evaluate at macro expansion time, i.e. in the
-  ;; `cl-macroexpand-all' inside `c-lang-defconst'.
+  ;; `c--macroexpand-all' inside `c-lang-defconst'.
   (eval form))
 
-;; Only used at compile time - suppress "might not be defined at runtime".
-(declare-function cl-macroexpand-all "cl" (form &optional env))
-
 (defmacro c-lang-defconst (name &rest args)
   "Set the language specific values of the language constant NAME.
 The second argument can optionally be a docstring.  The rest of the
@@ -1881,7 +1882,7 @@
 
   (let* ((sym (intern (symbol-name name) c-lang-constants))
 	 ;; Make `c-lang-const' expand to a straightforward call to
-	 ;; `c-get-lang-constant' in `cl-macroexpand-all' below.
+	 ;; `c-get-lang-constant' in `c--macroexpand-all' below.
 	 ;;
 	 ;; (The default behavior, i.e. to expand to a call inside
 	 ;; `eval-when-compile' should be equivalent, since that macro
@@ -1944,7 +1945,7 @@
 	;; reason, but we also use this expansion handle
 	;; `c-lang-defconst-eval-immediately' and to register
 	;; dependencies on the `c-lang-const's in VAL.)
-	(setq val (cl-macroexpand-all val))
+	(setq val (c--macroexpand-all val))
 
 	(setq bindings (cons (cons assigned-mode val) bindings)
 	      args (cdr args))))

=== modified file 'lisp/progmodes/cc-langs.el'
--- lisp/progmodes/cc-langs.el	2014-06-14 23:54:39 +0000
+++ lisp/progmodes/cc-langs.el	2014-10-30 03:47:12 +0000
@@ -213,7 +213,6 @@
 ;; These are defined in cl as aliases to the cl- versions.
 ;(declare-function delete-duplicates "cl-seq" (cl-seq &rest cl-keys) t)
 ;(declare-function mapcan "cl-extra" (cl-func cl-seq &rest cl-rest) t)
-;(declare-function cl-macroexpand-all "cl" (form &optional env))
 
 (eval-and-compile
   ;; Some helper functions used when building the language constants.
@@ -3183,7 +3182,7 @@
       `(lambda ()
 
 	 ;; This let sets up the context for `c-mode-var' and similar
-	 ;; that could be in the result from `cl-macroexpand-all'.
+	 ;; that could be in the result from `c--macroexpand-all'.
 	 (let ((c-buffer-is-cc-mode ',mode)
 	       current-var source-eval)
 	   (c-make-emacs-variables-local)
@@ -3193,12 +3192,12 @@
 		   (setq ,@(let ((c-buffer-is-cc-mode mode)
 				 (c-lang-const-expansion 'immediate))
 			     ;; `c-lang-const' will expand to the evaluated
-			     ;; constant immediately in `cl-macroexpand-all'
+			     ;; constant immediately in `c--macroexpand-all'
 			     ;; below.
 			      (cl-mapcan
 			       (lambda (init)
 				 `(current-var ',(car init)
-				   ,(car init) ,(macroexpand-all
+				   ,(car init) ,(c--macroexpand-all
 						 (elt init 1))))
 			       ;; Note: The following `append' copies the
 			       ;; first argument.  That list is small, so





bug marked as fixed in version 24.5, send any further explanations to 18845 <at> debbugs.gnu.org and Joris Steyn <jorissteyn <at> gmail.com> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 17 Feb 2015 19:13:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 18 Mar 2015 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 14 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.