From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs 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 Message-ID: References: Reply-To: Andrea Corallo 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="27589"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 44660@debbugs.gnu.org To: Jim Myhrberg Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 15 21:43:10 2020 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 1keOrd-00073n-SX for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 15 Nov 2020 21:43:09 +0100 Original-Received: from localhost ([::1]:48116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keOrc-0003pU-VF for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 15 Nov 2020 15:43:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keOrW-0003pK-1X for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2020 15:43:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1keOrV-0006zu-Od for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2020 15:43:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1keOrV-00056V-Lq for bug-gnu-emacs@gnu.org; Sun, 15 Nov 2020 15:43:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrea Corallo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Nov 2020 20:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44660 X-GNU-PR-Package: emacs Original-Received: via spool by 44660-submit@debbugs.gnu.org id=B44660.160547297019597 (code B ref 44660); Sun, 15 Nov 2020 20:43:01 +0000 Original-Received: (at 44660) by debbugs.gnu.org; 15 Nov 2020 20:42:50 +0000 Original-Received: from localhost ([127.0.0.1]:54269 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1keOrK-000560-5b for submit@debbugs.gnu.org; Sun, 15 Nov 2020 15:42:50 -0500 Original-Received: from mx.sdf.org ([205.166.94.24]:61745) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1keOrE-00055o-B8 for 44660@debbugs.gnu.org; Sun, 15 Nov 2020 15:42:48 -0500 Original-Received: from mab (ma.sdf.org [205.166.94.33]) by mx.sdf.org (8.15.2/8.14.5) with ESMTP id 0AFKghsn029460; Sun, 15 Nov 2020 20:42:43 GMT In-Reply-To: (Jim Myhrberg's message of "Sun, 15 Nov 2020 18:14:48 +0000") 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:193382 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jim Myhrberg writes: > Hi, > > After the following pull request was merged: > https://github.com/Fuco1/smartparens/pull/958 > > I started getting this error: > > Error running timer =E2=80=98sp-show--pair-function=E2=80=99: (invali= d-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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=smartparens.patch 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 --=-=-=--