From: Visuwesh <visuweshm@gmail.com>
To: 55677@debbugs.gnu.org
Subject: bug#55677: [PATCH] pp--insert-lisp: Check if in beginning of buffer
Date: Fri, 27 May 2022 19:41:04 +0530 [thread overview]
Message-ID: <87fskvf4lj.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]
Tags: patch
Here's a reproduction for the bug,
(pp-emacs-lisp-code '((a)
(eeorg.matrix.msc1767.text . "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")))
This is the simplest structure I could come up with to reproduce the
problem. The specific length of the structure seems to be important.
pp--insert-lisp errors out because during the following lines,
;; If we're still too wide, then go up one step and try to
;; insert a newline there.
(when (> (current-column) (pp--max-width))
(condition-case ()
(backward-up-list 1)
(:success (when (looking-back " " 2)
(insert "\n")))
(error nil)))))))
the point is at the beginning of buffer and subsequently (looking-back " " 2)
errors out with a backtrace along the lines of
Debugger entered--Lisp error: (error "Invalid search bound (wrong side of point)")
re-search-backward("\\(?: \\)\\=" 2 t)
looking-back(" " 2)
eval((looking-back " " 2) t)
eval-expression((looking-back " " 2) nil nil 127)
funcall-interactively(eval-expression (looking-back " " 2) nil nil 127)
call-interactively(eval-expression nil nil)
command-execute(eval-expression)
The patch simply checks if point is at bob and skips the looking-back
call if so.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-pp-insert-lisp-Check-if-in-beginning-of-buffer.patch --]
[-- Type: text/patch, Size: 894 bytes --]
From 2b3ab4e5ee02c3e7128373c24f3fd13d36a7c08f Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
Date: Fri, 27 May 2022 19:36:23 +0530
Subject: [PATCH] pp--insert-lisp: Check if in beginning of buffer
* pp.el (pp--insert): Check if point is in beginning of buffer before
calling `looking-back'.
---
lisp/emacs-lisp/pp.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el
index 3c849c2d01..a3ff2ecbaa 100644
--- a/lisp/emacs-lisp/pp.el
+++ b/lisp/emacs-lisp/pp.el
@@ -382,7 +382,7 @@ pp--insert
(when (> (current-column) (pp--max-width))
(condition-case ()
(backward-up-list 1)
- (:success (when (looking-back " " 2)
+ (:success (when (and (not (bobp)) (looking-back " " 2))
(insert "\n")))
(error nil)))))))
--
2.33.1
next reply other threads:[~2022-05-27 14:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 14:11 Visuwesh [this message]
2022-05-28 10:54 ` bug#55677: [PATCH] pp--insert-lisp: Check if in beginning of buffer Lars Ingebrigtsen
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=87fskvf4lj.fsf@gmail.com \
--to=visuweshm@gmail.com \
--cc=55677@debbugs.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.