* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
@ 2011-09-07 17:21 Dani Moncayo
2011-09-07 20:39 ` Andreas Schwab
2011-09-07 23:59 ` Juri Linkov
0 siblings, 2 replies; 18+ messages in thread
From: Dani Moncayo @ 2011-09-07 17:21 UTC (permalink / raw)
To: 9461
[-- Attachment #1: Type: text/plain, Size: 1114 bytes --]
From "emacs -Q":
1. Create a new buffer: C-x b tmp <RET>
2. Turn "show-paren-mode" on: M-x show-paren-mode <RET>
3. Write "\(hello\)".
The resulting buffer appearance is shown in the attached file.
Why is Emacs trying to match the first "\" with the last ")"?
In GNU Emacs 24.0.50.1 (i386-mingw-nt6.1.7601)
of 2011-09-03 on DANI-PC
Windowing system distributor `Microsoft Corp.', version 6.1.7601
configured using `configure --with-gcc (4.5)'
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: ESN
value of $XMODIFIERS: nil
locale-coding-system: cp1252
default enable-multibyte-characters: t
Major mode: Fundamental
Minor modes in effect:
show-paren-mode: t
tooltip-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
--
Dani Moncayo
[-- Attachment #2: emacs.png --]
[-- Type: image/png, Size: 40604 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-07 17:21 bug#9461: 24.0.50; Weird behaviour in "show-parent-mode" Dani Moncayo
@ 2011-09-07 20:39 ` Andreas Schwab
2011-09-07 20:53 ` Dani Moncayo
2011-09-07 23:59 ` Juri Linkov
1 sibling, 1 reply; 18+ messages in thread
From: Andreas Schwab @ 2011-09-07 20:39 UTC (permalink / raw)
To: Dani Moncayo; +Cc: 9461
Dani Moncayo <dmoncayo@gmail.com> writes:
>>From "emacs -Q":
> 1. Create a new buffer: C-x b tmp <RET>
> 2. Turn "show-paren-mode" on: M-x show-paren-mode <RET>
> 3. Write "\(hello\)".
>
> The resulting buffer appearance is shown in the attached file.
>
> Why is Emacs trying to match the first "\" with the last ")"?
Because that's where scan-sexps moves to.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-07 20:39 ` Andreas Schwab
@ 2011-09-07 20:53 ` Dani Moncayo
2011-09-07 23:06 ` Andreas Schwab
0 siblings, 1 reply; 18+ messages in thread
From: Dani Moncayo @ 2011-09-07 20:53 UTC (permalink / raw)
To: Andreas Schwab; +Cc: 9461
>> Why is Emacs trying to match the first "\" with the last ")"?
>
> Because that's where scan-sexps moves to.
The question is: does that make sense?
To put it more clear: write "abc\(def\)". Just after typing the ")",
Emacs tries to match that ")" with the "a". That doesn't make much
sense, no?
--
Dani Moncayo
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-07 20:53 ` Dani Moncayo
@ 2011-09-07 23:06 ` Andreas Schwab
0 siblings, 0 replies; 18+ messages in thread
From: Andreas Schwab @ 2011-09-07 23:06 UTC (permalink / raw)
To: Dani Moncayo; +Cc: 9461
Dani Moncayo <dmoncayo@gmail.com> writes:
>>> Why is Emacs trying to match the first "\" with the last ")"?
>>
>> Because that's where scan-sexps moves to.
>
> The question is: does that make sense?
>
> To put it more clear: write "abc\(def\)". Just after typing the ")",
> Emacs tries to match that ")" with the "a". That doesn't make much
> sense, no?
abc\(def\) is a single sexp (a symbol).
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-07 17:21 bug#9461: 24.0.50; Weird behaviour in "show-parent-mode" Dani Moncayo
2011-09-07 20:39 ` Andreas Schwab
@ 2011-09-07 23:59 ` Juri Linkov
2011-09-08 8:14 ` Dani Moncayo
1 sibling, 1 reply; 18+ messages in thread
From: Juri Linkov @ 2011-09-07 23:59 UTC (permalink / raw)
To: Dani Moncayo; +Cc: 9461
> 1. Create a new buffer: C-x b tmp <RET>
> 2. Turn "show-paren-mode" on: M-x show-paren-mode <RET>
> 3. Write "\(hello\)".
> The resulting buffer appearance is shown in the attached file.
> Why is Emacs trying to match the first "\" with the last ")"?
It highlights with the face `show-paren-mismatch', not `show-paren-match'.
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-07 23:59 ` Juri Linkov
@ 2011-09-08 8:14 ` Dani Moncayo
2011-09-08 10:42 ` Dani Moncayo
2011-09-08 19:54 ` Juri Linkov
0 siblings, 2 replies; 18+ messages in thread
From: Dani Moncayo @ 2011-09-08 8:14 UTC (permalink / raw)
To: Juri Linkov; +Cc: 9461
On Thu, Sep 8, 2011 at 01:59, Juri Linkov <juri@jurta.org> wrote:
>> 1. Create a new buffer: C-x b tmp <RET>
>> 2. Turn "show-paren-mode" on: M-x show-paren-mode <RET>
>> 3. Write "\(hello\)".
>> The resulting buffer appearance is shown in the attached file.
>> Why is Emacs trying to match the first "\" with the last ")"?
>
> It highlights with the face `show-paren-mismatch', not `show-paren-match'.
Yes, I know...
I didn't write the expected behavior because I thought it was obvious.
But well, here we go:
As I see it, if I write "abc(def]", "(" and "]" are _both_ highlighted
with the mismatch font, which is logical, because there is a mismatch
on _both_ characters: the "(" should have a ")" after it (without any
"]" in between), and likely for the "]".
But if I write "abc\(def\)", there is a "(" that matches the ")", so I
don't understand why "a" and ")" are highlighted with the mismatch
font. TRT would be to highlight both parentheses with the "match"
font. Even if the ")" didn't have a matching "(", the "a" should
_never_ be highlighted, because that character doesn't expect any
other to match it (at least in fundamental mode, which is the current
one).
Also, one could think that the "close delimiter" meaning of ")" is
cancelled by the previous escape ("\"), but then I would expect that
no highlighting took place at all, because both parentheses are
escaped.
So, definitely something is wrong here, IMO.
--
Dani Moncayo
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-08 8:14 ` Dani Moncayo
@ 2011-09-08 10:42 ` Dani Moncayo
2011-09-08 19:54 ` Juri Linkov
1 sibling, 0 replies; 18+ messages in thread
From: Dani Moncayo @ 2011-09-08 10:42 UTC (permalink / raw)
To: Juri Linkov; +Cc: 9461
> As I see it, if I write "abc(def]", "(" and "]" are _both_ highlighted
> with the mismatch font, which is logical, because there is a mismatch
> on _both_ characters: the "(" should have a ")" after it (without any
> "]" in between), and likely for the "]".
^^^^^^
I meant "likewise", sorry.
--
Dani Moncayo
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-08 8:14 ` Dani Moncayo
2011-09-08 10:42 ` Dani Moncayo
@ 2011-09-08 19:54 ` Juri Linkov
2011-09-09 2:32 ` Stefan Monnier
2011-09-09 6:26 ` martin rudalics
1 sibling, 2 replies; 18+ messages in thread
From: Juri Linkov @ 2011-09-08 19:54 UTC (permalink / raw)
To: Dani Moncayo; +Cc: 9461
> So, definitely something is wrong here, IMO.
Perhaps nothing should be highlighted when syntax of the previous
character is `escape' `\'.
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-08 19:54 ` Juri Linkov
@ 2011-09-09 2:32 ` Stefan Monnier
2011-09-09 9:54 ` Juri Linkov
2011-09-09 6:26 ` martin rudalics
1 sibling, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2011-09-09 2:32 UTC (permalink / raw)
To: Juri Linkov; +Cc: 9461
>> So, definitely something is wrong here, IMO.
> Perhaps nothing should be highlighted when syntax of the previous
> character is `escape' `\'.
I think show-paren-mode should at least follow the same heuristic as the
default blink-paren behavior, which indeed refrains from blinking the
"open paren" when the close-paren is escaped.
Stefan "happy to see this bug is not new in Emacs-24"
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-08 19:54 ` Juri Linkov
2011-09-09 2:32 ` Stefan Monnier
@ 2011-09-09 6:26 ` martin rudalics
2011-09-09 9:55 ` Juri Linkov
1 sibling, 1 reply; 18+ messages in thread
From: martin rudalics @ 2011-09-09 6:26 UTC (permalink / raw)
To: Juri Linkov; +Cc: 9461
> Perhaps nothing should be highlighted when syntax of the previous
> character is `escape' `\'.
IIUC the syntax of `\' is punctuation here, so there's no mismatch.
Or am I missing something?
martin
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-09 2:32 ` Stefan Monnier
@ 2011-09-09 9:54 ` Juri Linkov
2011-09-09 11:01 ` Dani Moncayo
2011-09-09 14:17 ` Stefan Monnier
0 siblings, 2 replies; 18+ messages in thread
From: Juri Linkov @ 2011-09-09 9:54 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 9461
>> Perhaps nothing should be highlighted when syntax of the previous
>> character is `escape' `\'.
>
> I think show-paren-mode should at least follow the same heuristic as the
> default blink-paren behavior, which indeed refrains from blinking the
> "open paren" when the close-paren is escaped.
I verified that the following patch provides this result:
=== modified file 'lisp/paren.el'
--- lisp/paren.el 2011-01-25 04:08:28 +0000
+++ lisp/paren.el 2011-09-09 09:46:03 +0000
@@ -135,13 +135,23 @@ (define-minor-mode show-paren-mode
;; and show it until input arrives.
(defun show-paren-function ()
(if show-paren-mode
- (let ((oldpos (point))
+ (let* ((oldpos (point))
(dir (cond ((eq (syntax-class (syntax-after (1- (point)))) 5) -1)
((eq (syntax-class (syntax-after (point))) 4) 1)))
+ (unescaped
+ (when dir
+ ;; Verify an even number of quoting characters precede the paren.
+ ;; Follow the same logic as in `blink-matching-open'.
+ (= (if (= dir -1) 1 0)
+ (logand 1 (- (point)
+ (save-excursion
+ (if (= dir -1) (forward-char -1))
+ (skip-syntax-backward "/\\")
+ (point)))))))
pos mismatch face)
;;
;; Find the other end of the sexp.
- (when dir
+ (when unescaped
(save-excursion
(save-restriction
;; Determine the range within which to look for a match.
BTW, I don't understand one comment about escaped parens in `show-paren-function':
;; Move back the other way and verify we get back to the
;; starting point. If not, these two parens don't really match.
;; Maybe the one at point is escaped and doesn't really count.
It seems irrelevant to the current problem.
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-09 6:26 ` martin rudalics
@ 2011-09-09 9:55 ` Juri Linkov
0 siblings, 0 replies; 18+ messages in thread
From: Juri Linkov @ 2011-09-09 9:55 UTC (permalink / raw)
To: martin rudalics; +Cc: 9461
>> Perhaps nothing should be highlighted when syntax of the previous
>> character is `escape' `\'.
>
> IIUC the syntax of `\' is punctuation here, so there's no mismatch.
> Or am I missing something?
text-mode changes the syntax of `\' to punctuation.
But (skip-syntax-backward "/\\") like in `blink-matching-open'
in the patch I just sent will work correctly in text-mode
where the syntax of `\' is punctuation.
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-09 9:54 ` Juri Linkov
@ 2011-09-09 11:01 ` Dani Moncayo
2011-09-09 11:38 ` Dani Moncayo
2011-09-09 14:17 ` Stefan Monnier
1 sibling, 1 reply; 18+ messages in thread
From: Dani Moncayo @ 2011-09-09 11:01 UTC (permalink / raw)
To: Juri Linkov; +Cc: 9461
>> I think show-paren-mode should at least follow the same heuristic as the
>> default blink-paren behavior, which indeed refrains from blinking the
>> "open paren" when the close-paren is escaped.
>
> I verified that the following patch provides this result:
I've done a quick test and your patch seems to work. So this bug can
be closed. If I find other anomalies I'll reopen it.
Thanks a lot!
--
Dani Moncayo
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-09 11:01 ` Dani Moncayo
@ 2011-09-09 11:38 ` Dani Moncayo
0 siblings, 0 replies; 18+ messages in thread
From: Dani Moncayo @ 2011-09-09 11:38 UTC (permalink / raw)
To: Juri Linkov; +Cc: 9461
> So this bug can be closed.
Well, when/if Stefan gives his approval and the patch is committed (of course).
--
Dani Moncayo
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-09 9:54 ` Juri Linkov
2011-09-09 11:01 ` Dani Moncayo
@ 2011-09-09 14:17 ` Stefan Monnier
2011-09-09 15:01 ` Juri Linkov
1 sibling, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2011-09-09 14:17 UTC (permalink / raw)
To: Juri Linkov; +Cc: 9461
> I verified that the following patch provides this result:
Would it be possible to use another patch which shares code between
blink-paren and show-paren?
> ;; Move back the other way and verify we get back to the
> ;; starting point. If not, these two parens don't really match.
> ;; Maybe the one at point is escaped and doesn't really count.
> It seems irrelevant to the current problem.
It's trying to detect another case, yes. It would make sense for
show-paren to use the same sanity check, tho.
Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-09 14:17 ` Stefan Monnier
@ 2011-09-09 15:01 ` Juri Linkov
2011-09-09 21:45 ` Stefan Monnier
0 siblings, 1 reply; 18+ messages in thread
From: Juri Linkov @ 2011-09-09 15:01 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 9461
> Would it be possible to use another patch which shares code between
> blink-paren and show-paren?
In theory, `blink-paren' and `show-paren' both do a similar job of
displaying the opposite side of a balanced expression. But looking at code
in `blink-paren' and `show-paren', I see absolutely nothing in common.
The first small piece of common code will be counting an even number of
quoting characters, but even this part will differ significantly
because unlike `blink-paren', `show-paren' needs to work in both
directions: backwards and forwards.
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-09 15:01 ` Juri Linkov
@ 2011-09-09 21:45 ` Stefan Monnier
2011-09-10 11:28 ` Juri Linkov
0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2011-09-09 21:45 UTC (permalink / raw)
To: Juri Linkov; +Cc: 9461
>> Would it be possible to use another patch which shares code between
>> blink-paren and show-paren?
> In theory, `blink-paren' and `show-paren' both do a similar job of
> displaying the opposite side of a balanced expression. But looking at code
> in `blink-paren' and `show-paren', I see absolutely nothing in common.
> The first small piece of common code will be counting an even number of
> quoting characters, but even this part will differ significantly
> because unlike `blink-paren', `show-paren' needs to work in both
> directions: backwards and forwards.
Oh, well,
Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
2011-09-09 21:45 ` Stefan Monnier
@ 2011-09-10 11:28 ` Juri Linkov
0 siblings, 0 replies; 18+ messages in thread
From: Juri Linkov @ 2011-09-10 11:28 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 9461-done
> Oh, well,
Installed.
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2011-09-10 11:28 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-07 17:21 bug#9461: 24.0.50; Weird behaviour in "show-parent-mode" Dani Moncayo
2011-09-07 20:39 ` Andreas Schwab
2011-09-07 20:53 ` Dani Moncayo
2011-09-07 23:06 ` Andreas Schwab
2011-09-07 23:59 ` Juri Linkov
2011-09-08 8:14 ` Dani Moncayo
2011-09-08 10:42 ` Dani Moncayo
2011-09-08 19:54 ` Juri Linkov
2011-09-09 2:32 ` Stefan Monnier
2011-09-09 9:54 ` Juri Linkov
2011-09-09 11:01 ` Dani Moncayo
2011-09-09 11:38 ` Dani Moncayo
2011-09-09 14:17 ` Stefan Monnier
2011-09-09 15:01 ` Juri Linkov
2011-09-09 21:45 ` Stefan Monnier
2011-09-10 11:28 ` Juri Linkov
2011-09-09 6:26 ` martin rudalics
2011-09-09 9:55 ` Juri Linkov
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).