PEP 312 - Making lambdas implicit worries me, surely it's just the name 'lambda' that is bad...
Jack Diederich
jack at performancedrivers.com
Fri Mar 14 13:10:06 EST 2003
As the butterfly that flapped its wings a week ago causing an ensuing
shift storm, I hereby declare the thread over.
I use this .emacs bit which was posted about a year ago in this thread.
I still type 'lambda' but it is displayed in context as
newlist = map(L x: x.a + x.b, oldlist)
# vs the standard
newlist = map(lambda x: x.a + x.b, oldlist)
The L snuggles up to the opening paren. Plus it isn't a real word so you
can see it without having to 'read' it.
All in all, a much quicker and more low maintenance solution than a custom
Grammar [pun very much intended].
-jackdied
;;Stefan Monnier's hack to make "lambda" display as (a greek lambda symbol)
;; EDIT - I use it to display 'L' instead
(defun pretty-lambdas ()
(font-lock-add-keywords
nil `(("\\<lambda\\>"
(0 (progn (compose-region (match-beginning 0) (match-end 0)
,'"L")
nil))))))
(add-hook 'emacs-lisp-mode-hook 'pretty-lambdas)
(add-hook 'python-mode-hook 'pretty-lambdas)
(add-hook 'ilisp-mode-hook 'pretty-lambdas)
More information about the Python-list
mailing list