unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#55677: [PATCH] pp--insert-lisp: Check if in beginning of buffer
@ 2022-05-27 14:11 Visuwesh
  2022-05-28 10:54 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Visuwesh @ 2022-05-27 14:11 UTC (permalink / raw)
  To: 55677

[-- 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#55677: [PATCH] pp--insert-lisp: Check if in beginning of buffer
  2022-05-27 14:11 bug#55677: [PATCH] pp--insert-lisp: Check if in beginning of buffer Visuwesh
@ 2022-05-28 10:54 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-28 10:54 UTC (permalink / raw)
  To: Visuwesh; +Cc: 55677

Visuwesh <visuweshm@gmail.com> writes:

> The patch simply checks if point is at bob and skips the looking-back
> call if so.

Thanks; pushed to Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-28 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27 14:11 bug#55677: [PATCH] pp--insert-lisp: Check if in beginning of buffer Visuwesh
2022-05-28 10:54 ` Lars Ingebrigtsen

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).