GNU bug report logs -
#9461
24.0.50; Weird behaviour in "show-paren-mode"
Previous Next
Reported by: Dani Moncayo <dmoncayo <at> gmail.com>
Date: Wed, 7 Sep 2011 17:26:01 UTC
Severity: normal
Found in version 24.0.50
Done: Juri Linkov <juri <at> jurta.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9461 in the body.
You can then email your comments to 9461 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Wed, 07 Sep 2011 17:26:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Dani Moncayo <dmoncayo <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 07 Sep 2011 17:26:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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
[emacs.png (image/png, attachment)]
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Wed, 07 Sep 2011 20:45:03 GMT)
Full text and
rfc822 format available.
Message #8 received at 9461 <at> debbugs.gnu.org (full text, mbox):
Dani Moncayo <dmoncayo <at> 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 <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Wed, 07 Sep 2011 20:58:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 9461 <at> debbugs.gnu.org (full text, mbox):
>> 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
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Wed, 07 Sep 2011 23:11:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 9461 <at> debbugs.gnu.org (full text, mbox):
Dani Moncayo <dmoncayo <at> 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 <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Thu, 08 Sep 2011 01:03:03 GMT)
Full text and
rfc822 format available.
Message #17 received at 9461 <at> debbugs.gnu.org (full text, mbox):
> 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'.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Thu, 08 Sep 2011 08:19:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 9461 <at> debbugs.gnu.org (full text, mbox):
On Thu, Sep 8, 2011 at 01:59, Juri Linkov <juri <at> 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
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Thu, 08 Sep 2011 10:47:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 9461 <at> debbugs.gnu.org (full text, mbox):
> 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
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Thu, 08 Sep 2011 20:08:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 9461 <at> debbugs.gnu.org (full text, mbox):
> So, definitely something is wrong here, IMO.
Perhaps nothing should be highlighted when syntax of the previous
character is `escape' `\'.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Fri, 09 Sep 2011 02:37:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 9461 <at> debbugs.gnu.org (full text, mbox):
>> 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"
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Fri, 09 Sep 2011 06:32:01 GMT)
Full text and
rfc822 format available.
Message #32 received at 9461 <at> debbugs.gnu.org (full text, mbox):
> 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
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Fri, 09 Sep 2011 10:02:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 9461 <at> debbugs.gnu.org (full text, mbox):
>> 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.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Fri, 09 Sep 2011 10:02:02 GMT)
Full text and
rfc822 format available.
Message #38 received at 9461 <at> debbugs.gnu.org (full text, mbox):
>> 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.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Fri, 09 Sep 2011 11:06:02 GMT)
Full text and
rfc822 format available.
Message #41 received at 9461 <at> debbugs.gnu.org (full text, mbox):
>> 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
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Fri, 09 Sep 2011 11:43:01 GMT)
Full text and
rfc822 format available.
Message #44 received at 9461 <at> debbugs.gnu.org (full text, mbox):
> So this bug can be closed.
Well, when/if Stefan gives his approval and the patch is committed (of course).
--
Dani Moncayo
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Fri, 09 Sep 2011 14:22:01 GMT)
Full text and
rfc822 format available.
Message #47 received at 9461 <at> debbugs.gnu.org (full text, mbox):
> 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
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Fri, 09 Sep 2011 15:07:01 GMT)
Full text and
rfc822 format available.
Message #50 received at 9461 <at> debbugs.gnu.org (full text, mbox):
> 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.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9461
; Package
emacs
.
(Fri, 09 Sep 2011 21:50:02 GMT)
Full text and
rfc822 format available.
Message #53 received at 9461 <at> debbugs.gnu.org (full text, mbox):
>> 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
Reply sent
to
Juri Linkov <juri <at> jurta.org>
:
You have taken responsibility.
(Sat, 10 Sep 2011 11:35:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Dani Moncayo <dmoncayo <at> gmail.com>
:
bug acknowledged by developer.
(Sat, 10 Sep 2011 11:35:02 GMT)
Full text and
rfc822 format available.
Message #58 received at 9461-done <at> debbugs.gnu.org (full text, mbox):
> Oh, well,
Installed.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 09 Oct 2011 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 179 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.