help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: [Warning] cl-count (And Other Options)


From: Dmitry Gutov
Subject: Re: [Warning] cl-count (And Other Options)
Date: Sat, 01 Dec 2012 02:20:34 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

Eric James Michael Ritz <address@hidden> writes:

> First my apologies if this email would be more appropriate elsewhere.
>
> I am currently using GNU Emacs 24.2.90.1 (i686-pc-linux-gnu, GTK+
> Version 2.24.13), compiled on the 24th of November 2012.  In a
> function in my php-mode [1] I have the following function definition:
>
>     (defun php-unindent-closure ()
>       (let ((syntax (mapcar 'car c-syntactic-context)))
>         (if (and (member 'arglist-cont-nonempty syntax)
>                  (or
>                   (member 'statement-block-intro syntax)
>                   (member 'brace-list-intro syntax)
>                   (member 'brace-list-close syntax)
>                   (member 'block-close syntax)))
>             (save-excursion
>               (let ((count-func (if (fboundp 'cl-count) #'cl-count 
> #'count)())))
>               (beginning-of-line)
>               (delete-char (* (cl-count 'arglist-cont-nonempty syntax)
>                               c-basic-offset))))))
>
> The key thing to note (unless you see something glaringly wrong with
> it) is the call to `cl-count`.  When I compile the file containing the
> function I receive the following warning:
>
>     Compiling file /home/eric/Projects/php-mode/php-mode.el at Fri Nov 30
> 16:49:05 2012
>
>     In php-unindent-closure:
>     php-mode.el:436:8:Warning: malformed let binding: `(count-func (if 
> (fboundp
>         (quote cl-count)) (function cl-count) (function count)) nil)
>
> The warning leads me to believe that use of `cl-count` is not
> encouraged.  Is that the case?  And if so, what would be my best
> alternative which would not trigger a warning?

The warning tries to tell you that you have a spurious "()" in the let
binding form, after the value you are assigning to count-func.

It doesn't mention the actual problems:
1) The let form's body is empty, while it should contain the code that
goes after it.
2) Replace that (cl-count ...) with (funcall count-func ...).

But what Drew meant, I think, if for you the create a prefixed function
alias, not local value binding. The former would just look better in
code.



reply via email to

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