unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Barzilay <eli@barzilay.org>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] trunk r117340: * lisp/calculator.el: Lots of revisions
Date: Wed, 18 Jun 2014 11:21:59 -0400	[thread overview]
Message-ID: <jwvzjha5k7t.fsf-monnier+emacsdiffs@gnu.org> (raw)
In-Reply-To: <E1Ww2Qw-0002aL-HF@vcs.savannah.gnu.org> (Eli Barzilay's message of "Sun, 15 Jun 2014 04:52:46 +0000")

> -          (cl-letf (((symbol-function 'F)
> -                     (lambda (&optional x y) (calculator-funcall f x y)))
> -                    ((symbol-function 'D)
> -                     (lambda (x) (if calculator-deg (/ (* x 180) float-pi) x))))
> -            (eval f `((X . ,X)
> -                      (Y . ,Y)
> -                      (TX . ,TX)
> -                      (TY . ,TY)
> -                      (DX . ,DX)
> -                      (L . ,L))))))
> -    (error 0)))
> +      (cl-flet ((F (&optional x y) (calculator-funcall f x y))
> +                (D (x) (if calculator-deg (/ (* x 180) float-pi) x)))
> +        (eval `(let ((X ,X) (Y ,Y) (DX ,DX) (TX ,TX) (TY ,TY) (L ',L))
> +                 ,f)
> +              t)))))

Hmm... have you tested this?  `cl-flet' creates lexically-scoped
function bindings (contrary to the old `flet'), so the F and D above in
your new code aren't accessible to the `f' expression.

As for changing the `eval' call, the form I used is more efficient than
the (eval `(let ...)) you're using now: what was the motivation for
this change?

>    (let ((inp (or keys (this-command-keys))))
[...]
> +      ;; translates kp-x to x and [tries to] create a string to lookup
> +      ;; operators; assume all symbols are translatable via
> +      ;; `function-key-map' or with an 'ascii-character property
> +      (concat (mapcar (lambda (k)
> +                        (if (numberp k) k (or (get k 'ascii-character)
> +                                              (error "??bad key??"))))
> +                      (or (lookup-key function-key-map inp) inp))))))

(this-command-keys) should return "fully decoded events", i.e. after
passing through the keyboard-coding-system, input-decode-map,
function-key-map, and key-translation-map.  So neither (lookup-key
function-key-map inp) nor (get k 'ascii-character) should be necessary.

IOW if this code really is needed, it deserves a comment explaining
why it's needed despite the fact that function-key-map was
already applied.


        Stefan



  parent reply	other threads:[~2014-06-18 15:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1Ww2Qw-0002aL-HF@vcs.savannah.gnu.org>
2014-06-16 21:22 ` [Emacs-diffs] trunk r117340: * lisp/calculator.el: Lots of revisions Stefan Monnier
2014-06-18 10:08   ` Eli Barzilay
2014-06-18 18:49     ` Stefan Monnier
2014-06-23  5:21       ` Eli Barzilay
2014-06-23  5:48         ` Nicolas Semrau
2014-06-23 14:24         ` Stefan Monnier
2014-06-18 15:21 ` Stefan Monnier [this message]
2014-06-22 12:23   ` Eli Barzilay
2014-06-23 13:24     ` Stefan Monnier
2014-06-24  7:47       ` Eli Barzilay
2014-06-25  1:11       ` Stephen J. Turnbull

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwvzjha5k7t.fsf-monnier+emacsdiffs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=eli@barzilay.org \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).