* Proposed patch: ignore show-paren-mode fails in comments
@ 2015-09-08 14:12 Oleh Krehel
0 siblings, 0 replies; only message in thread
From: Oleh Krehel @ 2015-09-08 14:12 UTC (permalink / raw)
To: emacs-devel
[-- 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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-09-08 14:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-08 14:12 Proposed patch: ignore show-paren-mode fails in comments Oleh Krehel
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.