unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#67703: Fix python-ts-mode syntax higlighting as to account for default arguments
@ 2023-12-08  4:36 Maciej Kalandyk
  2023-12-08  6:51 ` Eli Zaretskii
  2023-12-10 16:35 ` Maciej Kalandyk
  0 siblings, 2 replies; 6+ messages in thread
From: Maciej Kalandyk @ 2023-12-08  4:36 UTC (permalink / raw)
  To: 67703

[-- Attachment #1: Type: text/plain, Size: 688 bytes --]

Tags: patch


Patch fixes lack of syntax highlighting for default arguments using
python-ts-mode

In GNU Emacs 29.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.37, cairo version 1.16.0)
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Guix System

Configured using:
 'configure
 CONFIG_SHELL=/gnu/store/rib9g2ig1xf3kclyl076w28parmncg4k-bash-minimal-5.1.16/bin/bash
 SHELL=/gnu/store/rib9g2ig1xf3kclyl076w28parmncg4k-bash-minimal-5.1.16/bin/bash
 --prefix=/gnu/store/475y8j60g7ixylvfh3viwnfl6i5j4fcj-emacs-next-tree-sitter-29.0.91
 --enable-fast-install --with-modules --with-cairo
 --with-native-compilation --disable-build-details'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch.patch --]
[-- Type: text/patch, Size: 2718 bytes --]

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 4b940b3..b625948 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1121,7 +1121,8 @@ fontified."
       name: (identifier) @font-lock-function-name-face)
      (class_definition
       name: (identifier) @font-lock-type-face)
-     (parameters (identifier) @font-lock-variable-name-face))
+     (parameters (identifier) @font-lock-variable-name-face)
+     (parameters (default_parameter name: (identifier) @font-lock-variable-name-face)))
 
    :feature 'function
    :language 'python
@@ -2825,26 +2826,26 @@ of `exec-path'."
   (let ((env (append (when (fboundp 'tramp-get-remote-locale)
                        ;; Emacs<24.4 compat.
                        (list (tramp-get-remote-locale vec)))
-		     (copy-sequence env)))
+                     (copy-sequence env)))
         (tramp-end-of-heredoc
          (if (boundp 'tramp-end-of-heredoc)
              tramp-end-of-heredoc
            (md5 tramp-end-of-output)))
-	unset vars item)
+        unset vars item)
     (while env
       (setq item (split-string (car env) "=" 'omit))
       (setcdr item (mapconcat #'identity (cdr item) "="))
       (if (and (stringp (cdr item)) (not (string-equal (cdr item) "")))
-	  (push (format "%s %s" (car item) (cdr item)) vars)
-	(push (car item) unset))
+          (push (format "%s %s" (car item) (cdr item)) vars)
+        (push (car item) unset))
       (setq env (cdr env)))
     (when vars
       (tramp-send-command
        vec
        (format "while read var val; do export $var=$val; done <<'%s'\n%s\n%s"
-	       tramp-end-of-heredoc
-	       (mapconcat #'identity vars "\n")
-	       tramp-end-of-heredoc)
+               tramp-end-of-heredoc
+               (mapconcat #'identity vars "\n")
+               tramp-end-of-heredoc)
        t))
     (when unset
       (tramp-send-command
@@ -6538,9 +6539,9 @@ recursively."
         (python--list-imports-check-status status)
         (goto-char (point-min))
         (while (not (eobp))
-	  (push (buffer-substring-no-properties (point) (pos-eol))
+          (push (buffer-substring-no-properties (point) (pos-eol))
                 lines)
-	  (forward-line 1))
+          (forward-line 1))
         (nreverse lines)))))
 
 (defun python--query-import (name source prompt)
@@ -6666,7 +6667,7 @@ asking."
                  (push (match-string 1) undefined))
                 ((looking-at ".*'\\([^']+\\)' imported but unused$")
                  (push (match-string 1) unused)))
-	  (forward-line 1))))
+          (forward-line 1))))
     ;; Compute imports to be added
     (dolist (name (seq-uniq undefined))
       (when-let ((statement (python--query-import name

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#67703: Fix python-ts-mode syntax higlighting as to account for default arguments
  2023-12-08  4:36 bug#67703: Fix python-ts-mode syntax higlighting as to account for default arguments Maciej Kalandyk
@ 2023-12-08  6:51 ` Eli Zaretskii
       [not found]   ` <AM0PR10MB3586579D3A383D635692D5F88088A@AM0PR10MB3586.EURPRD10.PROD.OUTLOOK.COM>
  2023-12-10 16:35 ` Maciej Kalandyk
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2023-12-08  6:51 UTC (permalink / raw)
  To: Maciej Kalandyk; +Cc: 67703

> From: Maciej Kalandyk <m.kalandyk@outlook.com>
> Date: Fri, 08 Dec 2023 05:36:52 +0100
> 
> Patch fixes lack of syntax highlighting for default arguments using
> python-ts-mode

Thanks, but could you please show a snippet of Python code where the
problem and the fix are visible?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#67703: Fix python-ts-mode syntax higlighting as to account for default arguments
       [not found]   ` <AM0PR10MB3586579D3A383D635692D5F88088A@AM0PR10MB3586.EURPRD10.PROD.OUTLOOK.COM>
@ 2023-12-10  6:19     ` Eli Zaretskii
  2023-12-10 10:15       ` Yuan Fu
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2023-12-10  6:19 UTC (permalink / raw)
  To: Maciej Kalandyk; +Cc: 67703

[Please use Reply All to keep the bug tracker on the CC list.]

Forwarding to the bug tracker:

> From: Maciej Kalandyk <m.kalandyk@outlook.com>
> Date: Sun, 10 Dec 2023 00:57:15 +0000
> msip_labels:
> 
> in this code without patch
> 
> def test(x=None):
>       return x
> 
> x=None in function signature won't be highlighted as definition





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#67703: Fix python-ts-mode syntax higlighting as to account for default arguments
  2023-12-10  6:19     ` Eli Zaretskii
@ 2023-12-10 10:15       ` Yuan Fu
  0 siblings, 0 replies; 6+ messages in thread
From: Yuan Fu @ 2023-12-10 10:15 UTC (permalink / raw)
  To: Eli Zaretskii, Maciej Kalandyk; +Cc: 67703



On 12/9/23 10:19 PM, Eli Zaretskii wrote:
> [Please use Reply All to keep the bug tracker on the CC list.]
>
> Forwarding to the bug tracker:
>
>> From: Maciej Kalandyk <m.kalandyk@outlook.com>
>> Date: Sun, 10 Dec 2023 00:57:15 +0000
>> msip_labels:
>>
>> in this code without patch
>>
>> def test(x=None):
>>       return x
>>
>> x=None in function signature won't be highlighted as definition
Ok, the fix makes sense. Basically, in such a function:


"a" is fontified but "b" isn't, the patch will fontify "b".

One thing though, the patch contains some indentation changes to 
unrelated code.

Yuan





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#67703: Fix python-ts-mode syntax higlighting as to account for default arguments
  2023-12-08  4:36 bug#67703: Fix python-ts-mode syntax higlighting as to account for default arguments Maciej Kalandyk
  2023-12-08  6:51 ` Eli Zaretskii
@ 2023-12-10 16:35 ` Maciej Kalandyk
  2023-12-10 23:16   ` Dmitry Gutov
  1 sibling, 1 reply; 6+ messages in thread
From: Maciej Kalandyk @ 2023-12-10 16:35 UTC (permalink / raw)
  To: 67703@debbugs.gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 83 bytes --]

Sorry for that, i am quite new to git.
Attaching patch with only important parts

[-- Attachment #1.2: Type: text/html, Size: 568 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch.patch --]
[-- Type: text/x-patch; name="patch.patch", Size: 582 bytes --]

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 4b940b3..b625948 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1121,7 +1121,8 @@ fontified."
       name: (identifier) @font-lock-function-name-face)
      (class_definition
       name: (identifier) @font-lock-type-face)
-     (parameters (identifier) @font-lock-variable-name-face))
+     (parameters (identifier) @font-lock-variable-name-face)
+     (parameters (default_parameter name: (identifier) @font-lock-variable-name-face)))
 
    :feature 'function
    :language 'python


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#67703: Fix python-ts-mode syntax higlighting as to account for default arguments
  2023-12-10 16:35 ` Maciej Kalandyk
@ 2023-12-10 23:16   ` Dmitry Gutov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Gutov @ 2023-12-10 23:16 UTC (permalink / raw)
  To: Maciej Kalandyk, 67703-done

Version: 29.2

On 10/12/2023 18:35, Maciej Kalandyk wrote:
> Sorry for that, i am quite new to git.
> Attaching patch with only important parts
> 
> patch.patch
> 
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index 4b940b3..b625948 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -1121,7 +1121,8 @@ fontified."
>         name: (identifier) @font-lock-function-name-face)
>        (class_definition
>         name: (identifier) @font-lock-type-face)
> -     (parameters (identifier) @font-lock-variable-name-face))
> +     (parameters (identifier) @font-lock-variable-name-face)
> +     (parameters (default_parameter name: (identifier) @font-lock-variable-name-face)))
>   
>      :feature 'function
>      :language 'python

Thanks! Installed.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-12-10 23:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-08  4:36 bug#67703: Fix python-ts-mode syntax higlighting as to account for default arguments Maciej Kalandyk
2023-12-08  6:51 ` Eli Zaretskii
     [not found]   ` <AM0PR10MB3586579D3A383D635692D5F88088A@AM0PR10MB3586.EURPRD10.PROD.OUTLOOK.COM>
2023-12-10  6:19     ` Eli Zaretskii
2023-12-10 10:15       ` Yuan Fu
2023-12-10 16:35 ` Maciej Kalandyk
2023-12-10 23:16   ` Dmitry Gutov

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