From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] trunk r117340: * lisp/calculator.el: Lots of revisions Date: Wed, 18 Jun 2014 11:21:59 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1403104950 21637 80.91.229.3 (18 Jun 2014 15:22:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 18 Jun 2014 15:22:30 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Barzilay Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 18 17:22:22 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WxHgr-0000Jm-Oq for ged-emacs-devel@m.gmane.org; Wed, 18 Jun 2014 17:22:21 +0200 Original-Received: from localhost ([::1]:58092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxHgr-0001io-82 for ged-emacs-devel@m.gmane.org; Wed, 18 Jun 2014 11:22:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxHgf-0001XA-PU for emacs-devel@gnu.org; Wed, 18 Jun 2014 11:22:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxHgX-000787-Bp for emacs-devel@gnu.org; Wed, 18 Jun 2014 11:22:09 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:15991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxHgX-000783-7w for emacs-devel@gnu.org; Wed, 18 Jun 2014 11:22:01 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUGAIDvNVNLd+D9/2dsb2JhbABZgwaDSsA9gRcXdIImAQEEViMQCzQSFBgNJIgM0hkXjnoHhDgEqRmBaoNMIQ X-IPAS-Result: ArUGAIDvNVNLd+D9/2dsb2JhbABZgwaDSsA9gRcXdIImAQEEViMQCzQSFBgNJIgM0hkXjnoHhDgEqRmBaoNMIQ X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="67655399" Original-Received: from 75-119-224-253.dsl.teksavvy.com (HELO ceviche.home) ([75.119.224.253]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 18 Jun 2014 11:21:59 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 48F556608C; Wed, 18 Jun 2014 11:21:59 -0400 (EDT) In-Reply-To: (Eli Barzilay's message of "Sun, 15 Jun 2014 04:52:46 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:172504 Archived-At: > - (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