From: Oleh Krehel <ohwoeowho@gmail.com>
To: emacs-devel@gnu.org
Subject: Proposed patch: ignore show-paren-mode fails in comments
Date: Tue, 08 Sep 2015 16:12:32 +0200 [thread overview]
Message-ID: <87vbblrodr.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 269 bytes --]
Hi all,
I like to have `show-paren-mode' in my Lisp buffers. However, it will
fail to match the parens in commented multi-line expressions like this
one:
;; =>
;; (0
;; (1
;; (2
;; (3 (4 (5 (6 (7 (8 (9 ()))))))))))
I attach a patch to ignore these failures.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-paren.el-show-paren-default-Ignore-fails-in-com.patch --]
[-- Type: text/x-diff, Size: 955 bytes --]
From 91ba1c3dee055ac4617445b944f28af63408f90c Mon Sep 17 00:00:00 2001
From: Oleh Krehel <ohwoeowho@gmail.com>
Date: Tue, 8 Sep 2015 16:04:06 +0200
Subject: [PATCH] lisp/paren.el (show-paren--default): Ignore fails in comments
---
lisp/paren.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/paren.el b/lisp/paren.el
index 30314c2..adf2849 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -210,7 +210,9 @@ Where HERE-BEG..HERE-END is expected to be near point.")
;; If found a "matching" paren, see if it is the right
;; kind of paren to match the one we started at.
(if (not (integerp pos))
- (if mismatch (list here-beg here-end nil nil t))
+ (if mismatch
+ (unless (nth 4 (syntax-ppss))
+ (list here-beg here-end nil nil t)))
(let ((beg (min pos outside)) (end (max pos outside)))
(unless (eq (syntax-class (syntax-after beg)) 8)
(setq mismatch
--
2.5.1
[-- Attachment #3: Type: text/plain, Size: 401 bytes --]
Interestingly, as I pasted the code into this `message-mode' buffer,
`show-paren-mode' doesn't fail any more, since ";;" don't register as
comments any more. Maybe `scan-sexps' could be modified to scan
differently (i.e. ignoring comments) if the starting position is in a
comment. This would be preferable to just ignoring the scan errors like
the attached patch does.
What do you think?
Oleh
reply other threads:[~2015-09-08 14:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vbblrodr.fsf@gmail.com \
--to=ohwoeowho@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.