all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Jim Myhrberg <contact@jimeh.me>
Cc: 44660@debbugs.gnu.org
Subject: bug#44660: [feature/native-comp] defalias to macro in compiled elisp seems to not work in smartparens
Date: Sun, 15 Nov 2020 20:42:42 +0000	[thread overview]
Message-ID: <xjfima6gxml.fsf@sdf.org> (raw)
In-Reply-To: <CAGaZ61tei2FtDHpQ4aU3yjkSo0zq3tFD4e9Mc5NYei+qgyzBvQ@mail.gmail.com> (Jim Myhrberg's message of "Sun, 15 Nov 2020 18:14:48 +0000")

[-- Attachment #1: Type: text/plain, Size: 955 bytes --]

Jim Myhrberg <contact@jimeh.me> writes:

> Hi,
>
> After the following pull request was merged:
> https://github.com/Fuco1/smartparens/pull/958
>
> I started getting this error:
>
>     Error running timer ‘sp-show--pair-function’: (invalid-function
> sp--while-no-input)
>
> The offending code seems to be:
>
>     (defalias 'sp--while-no-input 'while-no-input)
>
> And then later the call to "sp--while-no-input" within the
> "sp-show--pair-function" function. If I manually eval the
> "sp-show--pair-function" so it's no longer a natively compiled
> function, things start working again.
>
> For now in my personal config (which is not native-compiled), I've
> resorted to this work-around which seems to work:
>
>     (defun sp--while-no-input (&rest body)
>       (eval (append '(while-no-input) body)))
>
> Thanks again :)

Hi Jim,

does the attached patch to smartparens.el fix the issue?

Ciao!

  Andrea


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: smartparens.patch --]
[-- Type: text/x-diff, Size: 3807 bytes --]

diff --git a/smartparens.el b/smartparens.el
index ea5221a..2822074 100644
--- a/smartparens.el
+++ b/smartparens.el
@@ -9408,44 +9408,45 @@ support custom pairs."
             (sp-show--pair-enc-function ok)))
       (execute-kbd-macro cmd))))
 
-(defalias 'sp--while-no-input 'while-no-input)
-(when (version< emacs-version "27")
-  ;; Ripped from Emacs 27.0 subr.el.
-  ;; See Github Issue#946 and Emacs bug#31692.
-  (defmacro sp--while-no-input (&rest body)
-    "Execute BODY only as long as there's no pending input.
+(eval-when-compile
+  (defalias 'sp--while-no-input 'while-no-input)
+  (when (version< emacs-version "27")
+    ;; Ripped from Emacs 27.0 subr.el.
+    ;; See Github Issue#946 and Emacs bug#31692.
+    (defmacro sp--while-no-input (&rest body)
+      "Execute BODY only as long as there's no pending input.
 If input arrives, that ends the execution of BODY,
 and `while-no-input' returns t.  Quitting makes it return nil.
 If BODY finishes, `while-no-input' returns whatever value BODY produced."
-    (declare (debug t) (indent 0))
-    (let ((catch-sym (make-symbol "input")))
-      `(with-local-quit
-         (catch ',catch-sym
-           (let ((throw-on-input ',catch-sym)
-                 val)
-             (setq val (or (input-pending-p)
-                           (progn ,@body)))
-             (cond
-              ;; When input arrives while throw-on-input is non-nil,
-              ;; kbd_buffer_store_buffered_event sets quit-flag to the
-              ;; value of throw-on-input.  If, when BODY finishes,
-              ;; quit-flag still has the same value as throw-on-input, it
-              ;; means BODY never tested quit-flag, and therefore ran to
-              ;; completion even though input did arrive before it
-              ;; finished.  In that case, we must manually simulate what
-              ;; 'throw' in process_quit_flag would do, and we must
-              ;; reset quit-flag, because leaving it set will cause us
-              ;; quit to top-level, which has undesirable consequences,
-              ;; such as discarding input etc.  We return t in that case
-              ;; because input did arrive during execution of BODY.
-              ((eq quit-flag throw-on-input)
-               (setq quit-flag nil)
-               t)
-              ;; This is for when the user actually QUITs during
-              ;; execution of BODY.
-              (quit-flag
-               nil)
-              (t val))))))))
+      (declare (debug t) (indent 0))
+      (let ((catch-sym (make-symbol "input")))
+	`(with-local-quit
+           (catch ',catch-sym
+             (let ((throw-on-input ',catch-sym)
+                   val)
+               (setq val (or (input-pending-p)
+                             (progn ,@body)))
+               (cond
+		;; When input arrives while throw-on-input is non-nil,
+		;; kbd_buffer_store_buffered_event sets quit-flag to the
+		;; value of throw-on-input.  If, when BODY finishes,
+		;; quit-flag still has the same value as throw-on-input, it
+		;; means BODY never tested quit-flag, and therefore ran to
+		;; completion even though input did arrive before it
+		;; finished.  In that case, we must manually simulate what
+		;; 'throw' in process_quit_flag would do, and we must
+		;; reset quit-flag, because leaving it set will cause us
+		;; quit to top-level, which has undesirable consequences,
+		;; such as discarding input etc.  We return t in that case
+		;; because input did arrive during execution of BODY.
+		((eq quit-flag throw-on-input)
+		 (setq quit-flag nil)
+		 t)
+		;; This is for when the user actually QUITs during
+		;; execution of BODY.
+		(quit-flag
+		 nil)
+		(t val)))))))))
 
 (defun sp-show--pair-function ()
   "Display the show pair overlays and print the line of the

  reply	other threads:[~2020-11-15 20:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-15 18:14 bug#44660: [feature/native-comp] defalias to macro in compiled elisp seems to not work in smartparens Jim Myhrberg
2020-11-15 20:42 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2020-11-15 22:32   ` Jim Myhrberg
2020-11-16 14:38     ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=xjfima6gxml.fsf@sdf.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=44660@debbugs.gnu.org \
    --cc=akrl@sdf.org \
    --cc=contact@jimeh.me \
    /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.