all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Dmitry Gutov'" <dgutov@yandex.ru>,
	"'Eric James Michael Ritz'" <lobbyjones@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: RE: [Warning] cl-count (And Other Options)
Date: Fri, 30 Nov 2012 14:58:06 -0800	[thread overview]
Message-ID: <1C723B4918BC442B97682400DF447633@us.oracle.com> (raw)
In-Reply-To: <87hao6hgwd.fsf@yandex.ru>

> > (let ((count-func (if (fboundp 'cl-count) #'cl-count #'count)())))
> >   ...
> >   (delete-char (* (cl-count ...)...
> >
> > php-mode.el:436:8:Warning: malformed let binding: 
>
> The warning tries to tell you that ...

the let binding is malformed. ;-)

> 2) Replace that (cl-count ...) with (funcall count-func ...).

Yes.  Calling `cl-count' just, well, calls `cl-count'. ;-)

The point was to call `cl-count' if it exists, or call `count' if not.  `count'
is defined if `cl-count' is not defined.  Older Emacs uses the name `count';
newer Emacs uses the name `cl-count'.

> 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.

That's OK too.

But all I really meant was to call the function that exists, whether it is named
`cl-count' or `count'.  One or the other is available, and they presumably do
the same thing.

Look first for a function with the newer name, `cl-count'.  If that does not
exist then use `count', which must exist prior to the introduction of
`cl-count'.

If you have only one or a few occurrences of `cl-count' in your code, you could
just replace them with a funcall of the right function, as indicated above.  If
you have a lot of them, or if you prefer (e.g. to ease maintenance), you can
create your own (non-local) function that calls the right one, and then use that
everywhere in your code.

(defun my-count (&rest args)
  (if (fboundp 'cl-count)
      (apply #'cl-count args)
    (apply #'count args)))

Or just:

(defalias 'my-count (if (fboundp 'cl-count) #'cl-count #'count))

Then (delete-char (* (my-count ...)... etc.




      reply	other threads:[~2012-11-30 22:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-30 22:01 [Warning] cl-count (And Other Options) Eric James Michael Ritz
2012-11-30 22:20 ` Dmitry Gutov
2012-11-30 22:58   ` Drew Adams [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1C723B4918BC442B97682400DF447633@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=dgutov@yandex.ru \
    --cc=help-gnu-emacs@gnu.org \
    --cc=lobbyjones@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.