all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#72068: show-paren-mode does not match Chinese parentheses correctly
@ 2024-07-12  5:03 Siyuan Chen
  2024-07-12  6:02 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Siyuan Chen @ 2024-07-12  5:03 UTC (permalink / raw)
  To: 72068

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

 Reproduce steps:

1. Emacs -Q

2. M-x eval-expression

```
(progn
  (setq cursor-type 'bar)
  (show-paren-mode 1))
```

3. Paste the following text in any .el file
```
(英文括号)
(英文 括号)
(中文括号)
(中文 括号)
```

4. Place the cursor at the first position (or last position) of each line.

The expected behavior: All of the four lines above match and highlight
correctly

The actual behavior: The 4th line mismatched. Note the middle SPC character.

P.s.

1. This issue only occurs in lisp-like modes. It is OK in c-mode and
python-mode.

2. 【】「」『』have the same problem. They are also commonly used in lisp comment.

3.  A simple investigation found that it may be related to `scan-sexps` or
syntax-table, because  `(scan-sexps outside dir)` in the
`show-paren--default` returns the wrong value in the 4th case.

4. More screenshots and test code can be found in
https://emacs-china.org/t/show-paren-mode/15160

Emacs 29.3 on Windows.

Thanks.

Best regards
Siyuan Chen

[-- Attachment #2: Type: text/html, Size: 3853 bytes --]

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

* bug#72068: show-paren-mode does not match Chinese parentheses correctly
  2024-07-12  5:03 bug#72068: show-paren-mode does not match Chinese parentheses correctly Siyuan Chen
@ 2024-07-12  6:02 ` Eli Zaretskii
  2024-07-12 12:45   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2024-07-12  6:02 UTC (permalink / raw)
  To: Siyuan Chen, Stefan Monnier; +Cc: 72068

> From: Siyuan Chen <chansey97@gmail.com>
> Date: Fri, 12 Jul 2024 13:03:42 +0800
> 
> Reproduce steps:
> 
> 1. Emacs -Q
> 
> 2. M-x eval-expression
> 
> ```
> (progn
>   (setq cursor-type 'bar)
>   (show-paren-mode 1))
> ```
> 
> 3. Paste the following text in any .el file
> ```
> (英文括号)
> (英文 括号)
> (中文括号)
> (中文 括号)
> ```
> 
> 4. Place the cursor at the first position (or last position) of each line.
> 
> The expected behavior: All of the four lines above match and highlight correctly
> 
> The actual behavior: The 4th line mismatched. Note the middle SPC character.
> 
> P.s.
> 
> 1. This issue only occurs in lisp-like modes. It is OK in c-mode and python-mode.
> 
> 2. 【】「」『』have the same problem. They are also commonly used in lisp comment. 
> 
> 3.  A simple investigation found that it may be related to `scan-sexps` or syntax-table, because  `(scan-sexps
> outside dir)` in the `show-paren--default` returns the wrong value in the 4th case.
> 
> 4. More screenshots and test code can be found in https://emacs-china.org/t/show-paren-mode/15160 
> 
> Emacs 29.3 on Windows.

I'm not sure this is a bug, since I think Lisp allows those characters
to be treated as symbol-constituent.  Stefan, am I right?





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

* bug#72068: show-paren-mode does not match Chinese parentheses correctly
  2024-07-12  6:02 ` Eli Zaretskii
@ 2024-07-12 12:45   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-07-24 20:11     ` Stefan Kangas
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-12 12:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72068, Siyuan Chen

Eli Zaretskii [2024-07-12 09:02:49] wrote:
> I'm not sure this is a bug, since I think Lisp allows those characters
> to be treated as symbol-constituent.  Stefan, am I right?

I think that's the idea, indeed.  Of course, we don't have to obey the
Emacs Lisp syntax, but I think it makes sense to do so.
Admittedly, it would be nice to allow the use of other syntax rules inside
comments and string for these kinds of situations.


        Stefan






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

* bug#72068: show-paren-mode does not match Chinese parentheses correctly
  2024-07-12 12:45   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-07-24 20:11     ` Stefan Kangas
  2024-07-25  5:20       ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Kangas @ 2024-07-24 20:11 UTC (permalink / raw)
  To: Stefan Monnier, Eli Zaretskii; +Cc: 72068, Siyuan Chen

severity 72068 wishlist
thanks

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@gnu.org> writes:

> Eli Zaretskii [2024-07-12 09:02:49] wrote:
>> I'm not sure this is a bug, since I think Lisp allows those characters
>> to be treated as symbol-constituent.  Stefan, am I right?
>
> I think that's the idea, indeed.  Of course, we don't have to obey the
> Emacs Lisp syntax, but I think it makes sense to do so.
> Admittedly, it would be nice to allow the use of other syntax rules inside
> comments and string for these kinds of situations.

I'm not sure if this should be closed as notabug or not, but I'm tagging
it as wishlist at least.  Feel free to close if that makes more sense.





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

* bug#72068: show-paren-mode does not match Chinese parentheses correctly
  2024-07-24 20:11     ` Stefan Kangas
@ 2024-07-25  5:20       ` Eli Zaretskii
  2024-07-25 11:34         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2024-07-25  5:20 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 72068, monnier, chansey97

> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Wed, 24 Jul 2024 13:11:37 -0700
> Cc: 72068@debbugs.gnu.org, Siyuan Chen <chansey97@gmail.com>
> 
> severity 72068 wishlist
> thanks
> 
> Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <bug-gnu-emacs@gnu.org> writes:
> 
> > Eli Zaretskii [2024-07-12 09:02:49] wrote:
> >> I'm not sure this is a bug, since I think Lisp allows those characters
> >> to be treated as symbol-constituent.  Stefan, am I right?
> >
> > I think that's the idea, indeed.  Of course, we don't have to obey the
> > Emacs Lisp syntax, but I think it makes sense to do so.
> > Admittedly, it would be nice to allow the use of other syntax rules inside
> > comments and string for these kinds of situations.
> 
> I'm not sure if this should be closed as notabug or not, but I'm tagging
> it as wishlist at least.  Feel free to close if that makes more sense.

What solution is possible except changing the syntax table?  And if
changing the syntax table is the solution, users can already do that
if they want, right?





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

* bug#72068: show-paren-mode does not match Chinese parentheses correctly
  2024-07-25  5:20       ` Eli Zaretskii
@ 2024-07-25 11:34         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-08-01  1:10           ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-25 11:34 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72068, Stefan Kangas, chansey97

>> > I think that's the idea, indeed.  Of course, we don't have to obey the
>> > Emacs Lisp syntax, but I think it makes sense to do so.
>> > Admittedly, it would be nice to allow the use of other syntax rules inside
>> > comments and string for these kinds of situations.
>> 
>> I'm not sure if this should be closed as notabug or not, but I'm tagging
>> it as wishlist at least.  Feel free to close if that makes more sense.
>
> What solution is possible except changing the syntax table?

A solution would be to make "syntax tables" more complex so as to be
able to have a notion of "context" (so the same character can behave
differently inside a string than outside), or equivalently a way to
use different syntax tables in different contexts.

> And if changing the syntax table is the solution, users can already do
> that if they want, right?

Other than via things like `mmm-mode` (which I've never seen used to
use different modes in strings than in code), I don't think they can.


        Stefan






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

* bug#72068: show-paren-mode does not match Chinese parentheses correctly
  2024-07-25 11:34         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-08-01  1:10           ` Dmitry Gutov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Gutov @ 2024-08-01  1:10 UTC (permalink / raw)
  To: Stefan Monnier, Eli Zaretskii; +Cc: 72068, Stefan Kangas, chansey97

On 25/07/2024 14:34, Stefan Monnier via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
>> And if changing the syntax table is the solution, users can already do
>> that if they want, right?
> Other than via things like `mmm-mode` (which I've never seen used to
> use different modes in strings than in code), I don't think they can.

IIRC Steve Purcell (who shares his config publicly for many other users) 
used to have mmm-mode apply sql-mode inside Ruby heredocs (which are 
fancy multiline strings, basically) that are "tagged" to contain SQL.

And here's somebody else who wanted to have html-mode inside a JS 
string: https://github.com/dgutov/mmm-mode/issues/142 The intermediate 
conclusion there is to use a ts-based config, though.

And as far as show-paren-mode goes, this might be something that 
mmm-mode itself could have workarounds for anyway.






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

end of thread, other threads:[~2024-08-01  1:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-12  5:03 bug#72068: show-paren-mode does not match Chinese parentheses correctly Siyuan Chen
2024-07-12  6:02 ` Eli Zaretskii
2024-07-12 12:45   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-24 20:11     ` Stefan Kangas
2024-07-25  5:20       ` Eli Zaretskii
2024-07-25 11:34         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-01  1:10           ` Dmitry Gutov

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.