From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#55677: [PATCH] pp--insert-lisp: Check if in beginning of buffer Date: Fri, 27 May 2022 19:41:04 +0530 Message-ID: <87fskvf4lj.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27309"; mail-complaints-to="usenet@ciao.gmane.io" To: 55677@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 27 16:20:38 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nuapQ-0006xt-Mr for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 27 May 2022 16:20:36 +0200 Original-Received: from localhost ([::1]:37050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuapP-0002Zp-IR for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 27 May 2022 10:20:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuah8-0007pq-Bs for bug-gnu-emacs@gnu.org; Fri, 27 May 2022 10:12:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nuah8-0003Zw-1u for bug-gnu-emacs@gnu.org; Fri, 27 May 2022 10:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nuah7-0004GZ-Pq for bug-gnu-emacs@gnu.org; Fri, 27 May 2022 10:12:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 27 May 2022 14:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55677 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.165366069316324 (code B ref -1); Fri, 27 May 2022 14:12:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 May 2022 14:11:33 +0000 Original-Received: from localhost ([127.0.0.1]:35548 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuage-0004FE-LZ for submit@debbugs.gnu.org; Fri, 27 May 2022 10:11:32 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:56258) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuagb-0004F1-G8 for submit@debbugs.gnu.org; Fri, 27 May 2022 10:11:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuaga-0007El-LE for bug-gnu-emacs@gnu.org; Fri, 27 May 2022 10:11:28 -0400 Original-Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:35484) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nuagT-0003RP-LN for bug-gnu-emacs@gnu.org; Fri, 27 May 2022 10:11:26 -0400 Original-Received: by mail-pj1-x1042.google.com with SMTP id c10-20020a17090a4d0a00b001e283823a00so1060924pjg.0 for ; Fri, 27 May 2022 07:11:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version; bh=rbNuaiGaxM0DA1n5dQ2jNTbNJKIT0K6qHJpUM7moHhA=; b=mIMG7OWWrPk1qgSqyGwn5teD3MKVdu1q9i+JqAPOTxIX9ZzXm6phgSUy60MeLCN5QM Q8DVdFZbMr5LeL7w+xk6ISQzg0hVRV40f9MNb1ywjtyEMCBRSIJHe36tbBNtrINdq++J 8eDNj9MFqNqI8BIcTMKwDMBD9o0EyPh/XUwXYjmKZ/H8t4S3vfXOQyBB3nQ0KQq0ixki bu8UDMAnlogC/aHMdCchnByGXfsObcYYC6QUCVWTBz+2OQ/vuNKKcSSWef1hgzCYhWrT yRfNRCceABHh4Rwa9tWSxXnXOO07dfOZv6q1KvRdTKhqJWqzoMmFZ/XLHA2ho9KpLEpJ AjbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=rbNuaiGaxM0DA1n5dQ2jNTbNJKIT0K6qHJpUM7moHhA=; b=61Uy0m5Sq5dOqc+MjUtkAkxa7HrE5IJw10gO5+PX6mALS+4+7PrVFhYL9Orm/e8y8C 5p4POOyqN5pEa+XNOmFix10A/NXwumsJU4OR8s9sVze1yKbJQ4XmLiEfnPwakLuIiaRO HPEht6ZSYBcCyjljViZiVHSQ81lWpcBydxIMZ7YSTS5JNVj54MbWrkJIio0qb4iIEmWI F/ELWpuXMBeNbwCXqTVi8Wv+/7ASyR5emlOIBjtanUDLDVowNQBr0DmdtM5wLwPSyBgO Y0pnWVXdSftS1XZ0JG0XeIhKAmW4lHbAF7pyG8/VGzO4LQ4SgT6tn5bqdwl5a77pNLc8 D0oA== X-Gm-Message-State: AOAM5325nYytl3zj0pZh96sEN08Q0Kt9/9f7UjA5iPIuotf515siCX6X ZR0g1+/b7qFqrmYjFSWQHme5nnOY2QU= X-Google-Smtp-Source: ABdhPJwWPWNfDKVY+J10M/A7qasElgc6Ku+5gytyhUT7OGjnI97ma0sILFke5C4Nu11G8nbi30yg4A== X-Received: by 2002:a17:90b:3c50:b0:1df:7b1f:8b79 with SMTP id pm16-20020a17090b3c5000b001df7b1f8b79mr8737644pjb.71.1653660676302; Fri, 27 May 2022 07:11:16 -0700 (PDT) Original-Received: from localhost ([49.205.85.242]) by smtp.gmail.com with ESMTPSA id c10-20020a170902c2ca00b0015e8d4eb207sm3648257pla.81.2022.05.27.07.11.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 May 2022 07:11:15 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=visuweshm@gmail.com; helo=mail-pj1-x1042.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:233208 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-pp-insert-lisp-Check-if-in-beginning-of-buffer.patch >From 2b3ab4e5ee02c3e7128373c24f3fd13d36a7c08f Mon Sep 17 00:00:00 2001 From: Visuwesh 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 --=-=-=--