Add lambda: as a font-lock keyword

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Add lambda: as a font-lock keyword

Dan Davison-2
Is there any reason not to highlight "lambda:" as a keyword, i.e. when
it's immediately followed by a colon? The patch below takes a stab at
that. I guess it might be ideal if the colon were not highlighted; I
didn't look into that.

Thanks very much for the python-mode code and please tell me if there's
a more convenient way that I should submit a patch.

Dan


    Highlight lambda as keyword when followed immediately by colon
   
    * python-mode.el (python-font-lock-keywords): Add "lambda:"

        Modified python-mode.el
diff --git a/python-mode.el b/python-mode.el
index 447c691..79d12d4 100644
--- a/python-mode.el
+++ b/python-mode.el
@@ -588,7 +588,7 @@ support for features needed by `python-mode'.")
                           )
                         "\\|"))
         (kw2 (mapconcat 'identity
-                        '("else:" "except:" "finally:" "try:")
+                        '("else:" "except:" "finally:" "try:" "lambda:")
                         "\\|"))
         (kw3 (mapconcat 'identity
                         ;; Don't include Ellipsis in this list, since it is

_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|

Re: Add lambda: as a font-lock keyword

Georg Brandl-3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Right, this has bothered me as well a few times. +1 for the patch.

Georg

Am 03.02.2011 20:10, schrieb Dan Davison:

> Is there any reason not to highlight "lambda:" as a keyword, i.e. when
> it's immediately followed by a colon? The patch below takes a stab at
> that. I guess it might be ideal if the colon were not highlighted; I
> didn't look into that.
>
> Thanks very much for the python-mode code and please tell me if there's
> a more convenient way that I should submit a patch.
>
> Dan
>
>
>     Highlight lambda as keyword when followed immediately by colon
>    
>     * python-mode.el (python-font-lock-keywords): Add "lambda:"
>
> Modified python-mode.el
> diff --git a/python-mode.el b/python-mode.el
> index 447c691..79d12d4 100644
> --- a/python-mode.el
> +++ b/python-mode.el
> @@ -588,7 +588,7 @@ support for features needed by `python-mode'.")
>                            )
>                          "\\|"))
>          (kw2 (mapconcat 'identity
> -                        '("else:" "except:" "finally:" "try:")
> +                        '("else:" "except:" "finally:" "try:" "lambda:")
>                          "\\|"))
>          (kw3 (mapconcat 'identity
>                          ;; Don't include Ellipsis in this list, since it is
>
> _______________________________________________
> Python-mode mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/python-mode
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk1LIYAACgkQN9GcIYhpnLACzQCgjrIpYB+xelkN4806GDDczjtd
9Y4AnRRzwLSIXP8T3o3QuKVxFJ1MEFjH
=SXfI
-----END PGP SIGNATURE-----
_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|

Re: Add lambda: as a font-lock keyword

Barry Warsaw
In reply to this post by Dan Davison-2
On Feb 03, 2011, at 07:10 PM, Dan Davison wrote:

>Is there any reason not to highlight "lambda:" as a keyword, i.e. when
>it's immediately followed by a colon? The patch below takes a stab at
>that. I guess it might be ideal if the colon were not highlighted; I
>didn't look into that.

Nope, it's fine for consistency with else: and the others.

>Thanks very much for the python-mode code and please tell me if there's
>a more convenient way that I should submit a patch.

Dan, thanks for your contribution!

Patches in emails do tend to get lost in the shuffle.  The best way to ensure
someone looks at it is to file a bug report here:

    https://bugs.launchpad.net/python-mode

Then you can attach the patch to the bug report, or if you feel comfortable
with Bazaar, create a branch, link it to the bug report, and propose a merge
with trunk.

But a patch attached to a bug, especially for one so small and simple as this,
is fine too. :)  No worries though, I applied this one in r394.  Thanks again!

-Barry

_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode

signature.asc (853 bytes) Download Attachment