From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Steve Youngs Newsgroups: gmane.emacs.xemacs.patches,gmane.emacs.devel Subject: [PATCH] New convenience macros Date: Sun, 19 Aug 2007 00:30:44 +1000 Organization: The SXEmacs Project Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1183068241==" X-Trace: sea.gmane.org 1187447480 25328 80.91.229.12 (18 Aug 2007 14:31:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 18 Aug 2007 14:31:20 +0000 (UTC) Keywords: body,emacs,xemacs,sxemacs,gnu,type,won,with-emacs-type Cc: Emacs devel To: XEmacs patches Original-X-From: xemacs-patches-bounces@xemacs.org Sat Aug 18 16:31:16 2007 Return-path: Envelope-to: gexp-xemacs-patches-2@gmane.org Original-Received: from 98.f7bed1.client.atlantech.net ([209.190.247.152] helo=calypso.tux.org) by lo.gmane.org with esmtp (Exim 4.50) id 1IMPKd-0002ij-JG for gexp-xemacs-patches-2@gmane.org; Sat, 18 Aug 2007 16:31:16 +0200 Original-Received: from calypso.tux.org (localhost [127.0.0.1]) by calypso.tux.org (Postfix) with ESMTP id 80D3E1180BA; Sat, 18 Aug 2007 10:31:14 -0400 (EDT) Original-Received: from gwyn.tux.org (gwyn.tux.org [207.172.156.132]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by calypso.tux.org (Postfix) with ESMTP id B055E1180B9 for ; Sat, 18 Aug 2007 10:31:12 -0400 (EDT) Original-Received: from gwyn.tux.org (ident-user@localhost.localdomain [127.0.0.1]) by gwyn.tux.org (8.12.11/8.12.11) with ESMTP id l7IEVCi9012069 for ; Sat, 18 Aug 2007 10:31:12 -0400 Original-Received: (from xemacweb@localhost) by gwyn.tux.org (8.12.11/8.12.11/Submit) id l7IEVCcQ012068 for xemacs-patches@calypso.tux.org; Sat, 18 Aug 2007 10:31:12 -0400 Original-Received: from gwyn.tux.org (ident-user@localhost.localdomain [127.0.0.1]) by gwyn.tux.org (8.12.11/8.12.11) with ESMTP id l7IEV8Cf012040 for ; Sat, 18 Aug 2007 10:31:08 -0400 Original-Received: (from mailnull@localhost) by gwyn.tux.org (8.12.11/8.12.11/Submit) id l7IEV8R2012039 for xemacweb@tux.org; Sat, 18 Aug 2007 10:31:08 -0400 Original-Received: from bastard.youngs.au.com (203-206-170-37.perm.iinet.net.au [203.206.170.37]) by gwyn.tux.org (8.12.11/8.12.11) with ESMTP id l7IEV6NC012023 for ; Sat, 18 Aug 2007 10:31:07 -0400 Original-Received: from bastard.youngs.au.com (localhost [127.0.0.1]) by bastard.youngs.au.com (8.14.1/8.14.1) with ESMTP id l7IEUiFi021191 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 19 Aug 2007 00:30:50 +1000 Original-Received: (from steve@localhost) by bastard.youngs.au.com (8.14.1/8.14.1/Submit) id l7IEUibH021190; Sun, 19 Aug 2007 00:30:44 +1000 X-Face: #O)>9erkUv7RJ~0G~5_6lEMz\HC2&~&kV2bsu4TWHI_v~<8Hj%KBBj1[*\uKF*dxbEzwAli ; tSuN`c)F,}p|7{6lA~e.P+7Qo\A%q"lJ7/UtUX@yEZ!X"Tph(3O8`nhPJF>hI4_GOvb%X{+e*Mi_| ^yTf#aTwGG,(3e41?C9B7Pak*'A$+$/hV Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAD1BMVEUqHB9XS0r9/M/BuaSL gHVNKMr/AAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAwAAAAMADO7oxXAAAB2klEQVQ4 y22Ti43DIAyGbV0G8B8Y4AodICUdIAT2n+lsII+eakVqxefHb7Ap/LM0fil8sVruoLtG/YRovsB6 /HmzMPCZKtaahYV8zekOVjJjD6wf4CliIAPIfr9AlB5QZfLZWY3YzzdqhIkmIPXiUaUuhAYwbQzf +0jJCniY/5RrJuxXg1m8BbDLHoy5AWv5mS1L0+p9PlKplU3BpDGqdQ+COEC0AGp9CIVICEPuazFf 4vaFjc/iVX1VFjQG+UXaxgCFmL0Ifn6JVa07HkpLcPXIvEfLVfcwOn8v6giwXYC26M+nLVZ7Y/fW 9zBd+wCxNLHUzUS7EQG6WXNIX0Cz+SsAietAPlLpNNBPoKi1t/NUBwfYrDqNC7xIdnqwG7CXuaFc KoqpeshoYVSC33vnD7vwLsbM24g08AsWEeZD2lbabFN4ss4NyA/Ark1+agCaLfcB5Skdi/MQla4q u7+UMbAK0K1ncscWWXE7xUh0zjiFl/XX55B4FIgGrOqR6kxkQIdGi9cWcWVSsJCAKdvqCc/H+iZT 1QfQlskm6uxjwXEbqOLHfpncTd+lXbxwzfcIYZ0YNibs57F5eolPrazEBFfbjTgUKzC9Cnytde0L OUY0ruVd1NariZDiHz+hamROjsvkAAAAGnpUWHRqcGVnOmNvbG9yc3BhY2UAAHjaMwIAADMAM4k4 IzUAAAAmelRYdGpwZWc6c2FtcGxpbmctZmFjdG9yAAB42jOqMNIxrDAEYQARgwLpPZcvTwAAAABJ RU5ErkJggg== Mail-Copies-To: never X-X-Day: Only 2430280 days till X-Day. Got Slack? X-URL: X-Reviewer-Action: X-Request-PGP: X-OpenPGP-Fingerprint: 1659 2093 19D5 C06E D320 3A20 1D27 DB4B A94B 3003 X-Now-Playing: Doctor Love --- [SplitEnz] X-Discordian-Date: Sweetmorn, the 12nd day of Bureaucracy, 3173. X-Attribution: SY X-Arch-Repo: steve@sxemacs.org--2007 http://arch.sxemacs.org/2007/ Mail-Followup-To: XEmacs patches , Emacs devel User-Agent: Gnus/5.110007 (No Gnus v0.7) SXEmacs/22.1.7 (De Lorean, linux) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.6 (gwyn.tux.org [0.0.0.0]); Sat, 18 Aug 2007 10:31:12 -0400 (EDT) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.6 (gwyn.tux.org [0.0.0.0]); Sat, 18 Aug 2007 10:31:08 -0400 (EDT) X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-1.6 (gwyn.tux.org [207.172.156.133]); Sat, 18 Aug 2007 10:31:08 -0400 (EDT) X-Virus-Scanned: ClamAV version 0.88.4, clamav-milter version 0.88.4 on gwyn.tux.org X-Virus-Scanned: ClamAV version 0.88.4, clamav-milter version 0.88.4 on gwyn.tux.org X-Virus-Scanned: ClamAV version 0.88.4, clamav-milter version 0.88.4 on gwyn.tux.org X-Virus-Status: Clean X-XEmacs-List: patches X-BeenThere: xemacs-patches@xemacs.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "XEmacs patch submissions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Mime-version: 1.0 Original-Sender: xemacs-patches-bounces@xemacs.org Errors-To: xemacs-patches-bounces@xemacs.org Xref: news.gmane.org gmane.emacs.xemacs.patches:8440 gmane.emacs.devel:76721 Archived-At: --===============1183068241== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --=-=-= Content-Transfer-Encoding: quoted-printable I added these to SXEmacs a little while ago. They are a couple of macros that can be used when you need to conditionalise on emacs flavour. And at the same time not generate byte-compiler warnings, regardless of the flavour of emacs you are using to compile the .el. It is my hope that both XEmacs and GNU/Emacs will include these macros so that elisp programmers can benefit from them no matter what their preferred emacsen is. ChangeLog entry for XEmacs (sorry, I have no clue where these macros should go in GNU/Emacs)... 2007-08-19 Steve Youngs * subr.el (do-in-sxemacs, do-in-xemacs, do-in-gnu-emacs) (with-emacs-type): Convenience macros to use when you need to conditionalise on emacs flavour. They have the added advantage of suppressing byte-compiler warnings. diff -r ad09012c3de7 lisp/subr.el =2D-- a/lisp/subr.el Wed Aug 15 23:23:30 2007 +0000 +++ b/lisp/subr.el Sun Aug 19 00:29:24 2007 +1000 @@ -188,6 +188,69 @@ ELT must be a string. Upper-case and lo (while (and list (not (eq t (compare-strings elt 0 nil (car list) 0 nil = t)))) (setq list (cdr list))) list) + +;; Convenience macros to let you conditionalise code for different +;; emacs variants without generating any byte-compiler warnings + +(eval-when-compile + (if (featurep 'xemacs) + (or (featurep 'sxemacs) + (defvar running-sxemacs)) + (defvar running-sxemacs) + (defvar running-xemacs))) + +(defmacro do-in-sxemacs (&rest body) + "Execute BODY if in SXEmacs." + (and running-sxemacs + (cons 'progn body))) + +(put 'do-in-sxemacs 'lisp-indent-hook 'defun) + +(defmacro do-in-xemacs (&rest body) + "Execute BODY if in XEmacs." + (and running-xemacs + (cons 'progn body))) + +(put 'do-in-xemacs 'lisp-indent-hook 'defun) + +(defmacro do-in-gnu-emacs (&rest body) + "Execute BODY if in GNU/Emacs." + (unless (or running-sxemacs + running-xemacs) + (cons 'progn body))) + +(put 'do-in-gnu-emacs 'lisp-indent-hook 'defun) + +(defmacro with-emacs-type (type &rest body) + "Execute BODY depending on emacs TYPE. + +Argument TYPE is a quoted symbol, being one of `sxemacs', `xemacs', or +`gnu'. For example... + + \(with-emacs-type 'sxemacs + ;; SXEmacs only code goes here. + ;; XEmacs and GNU/Emacs won't see it and won't complain about unbound + ;; funcs/vars. + \) + \(with-emacs-type 'xemacs + ;; XEmacs code goes here. + ;; GNU/Emacs won't see it and won't complain about unbound funcs/vars. + \) + \(with-emacs-type 'gnu + ;; GNU/Emacs code goes here. + ;; SXEmacs and XEmacs won't see it and won't complain about unbound + ;; funcs/vars. + \)" + (cond + ((equal type '(quote sxemacs)) + (do-in-sxemacs (cons 'progn body))) + ((equal type '(quote xemacs)) + (do-in-xemacs (cons 'progn body))) + ((equal type '(quote gnu)) + (do-in-gnu-emacs (cons 'progn body))) + (t (error 'invalid-argument type)))) + +(put 'with-emacs-type 'lisp-indent-hook 'defun) =20 ;;;; Keymap support. =2D-=20 |---------------------| | SXEmacs - The only _______ you'll ever need. | | Fill in the blank, yes, it's THAT good! | |---------------------------------------| --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.3 (GNU/Linux) Comment: The SXEmacs Project Comment: Eicq - The SXEmacs ICQ Client iEYEARECAAYFAkbHApQACgkQHSfbS6lLMANT/QCcDDtqEgrjr56j5WuypVqGBklz rUIAn0u9oZ1fbxHhRhSwmv5kjiGq7z4Y =O0fg -----END PGP SIGNATURE----- --=-=-=-- --===============1183068241== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ XEmacs-Patches mailing list XEmacs-Patches@xemacs.org http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches --===============1183068241==--