From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: [elpa] externals/auctex 7e762b9 09/10: Add support for prettify-symbols-mode Date: Mon, 31 Aug 2015 11:34:18 +0200 Message-ID: <87egijls2t.fsf@gnu.org> References: <20150828085448.24208.47194@vcs.savannah.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1441013690 5940 80.91.229.3 (31 Aug 2015 09:34:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 31 Aug 2015 09:34:50 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 31 11:34:42 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZWLU9-0004Iy-AL for ged-emacs-devel@m.gmane.org; Mon, 31 Aug 2015 11:34:41 +0200 Original-Received: from localhost ([::1]:35228 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWLU8-0001Vh-KS for ged-emacs-devel@m.gmane.org; Mon, 31 Aug 2015 05:34:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWLTr-0001VN-LD for emacs-devel@gnu.org; Mon, 31 Aug 2015 05:34:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWLTo-0000Pf-E2 for emacs-devel@gnu.org; Mon, 31 Aug 2015 05:34:23 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:56985) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWLTo-0000PL-8L for emacs-devel@gnu.org; Mon, 31 Aug 2015 05:34:20 -0400 Original-Received: from thinkpad-t440p (dhcp185.uni-koblenz.de [141.26.71.185]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id E7B5C1A8468; Mon, 31 Aug 2015 11:34:18 +0200 (CEST) Mail-Followup-To: Stefan Monnier , emacs-devel@gnu.org In-Reply-To: (Stefan Monnier's message of "Fri, 28 Aug 2015 12:45:38 -0400") User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 141.26.64.15 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:189343 Archived-At: Stefan Monnier writes: >> + (if (fboundp 'add-function) >> + (add-function :override (local 'prettify-symbols-compose-predicate) >> + #'tex--prettify-symbols-compose-p) >> + (set (make-local-variable 'prettify-symbols-compose-predicate) >> + #'tex--prettify-symbols-compose-p))) > > If you compile this code in Emacs-24.1 and then run it in Emacs-24.4 > it's signal an error, because add-function is a macro that will not have > been expanded. > > I recently solved the same problem in elpa/packages/dts-mode with > dts--using-macro. Is that what I should use? I guess you also know how to fix the FIXME about the indentation, right? --8<---------------cut here---------------start------------->8--- 1 file changed, 22 insertions(+), 3 deletions(-) tex.el | 25 ++++++++++++++++++++++--- modified tex.el @@ -578,6 +578,25 @@ the name of the file being processed, with an optional extension." ;;; Portability. +(defmacro TeX--if-macro-fboundp (name then &rest else) + "Execute THEN if macro NAME is bound and ELSE otherwise. +This essentially equivalent to + + (if (fboundp 'name) then else) + +but takes care of byte-compilation issues where the byte-code for +the above could signal an error if it has been compiled with +emacs 24.1 and then later run by emacs 24.5." + ;; FIXME: Is there an easy way to declare that this macro is to be indented + ;; exactly as `if'? + (declare (indent 1) (debug (symbolp form))) + (if (fboundp name) ;If macro exists at compile-time, just use it. + then + `(if (fboundp ',name) ;Else, check if it exists at run-time. + (eval ',then) ;If it does, then run the then code. + ,@(when else + `(eval (progn ',else)))))) ;Otherwise, run the else code. + (require 'easymenu) (eval-and-compile @@ -3442,9 +3461,9 @@ The algorithm is as follows: (when (and (boundp 'tex--prettify-symbols-alist) (boundp 'prettify-symbols-compose-predicate)) (set (make-local-variable 'prettify-symbols-alist) tex--prettify-symbols-alist) - (if (fboundp 'add-function) - (add-function :override (local 'prettify-symbols-compose-predicate) - #'tex--prettify-symbols-compose-p) + (TeX--if-macro-fboundp add-function + (add-function :override (local 'prettify-symbols-compose-predicate) + #'tex--prettify-symbols-compose-p) (set (make-local-variable 'prettify-symbols-compose-predicate) #'tex--prettify-symbols-compose-p))) --8<---------------cut here---------------end--------------->8--- Bye, Tassilo