From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lars Magne Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: Cleaning up further compat code Date: Sun, 03 Apr 2016 21:09:04 +0200 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1459710567 2423 80.91.229.3 (3 Apr 2016 19:09:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Apr 2016 19:09:27 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 03 21:09:17 2016 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 1amnOf-0002V0-37 for ged-emacs-devel@m.gmane.org; Sun, 03 Apr 2016 21:09:17 +0200 Original-Received: from localhost ([::1]:54873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amnOe-0001el-F7 for ged-emacs-devel@m.gmane.org; Sun, 03 Apr 2016 15:09:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amnOZ-0001eU-N4 for emacs-devel@gnu.org; Sun, 03 Apr 2016 15:09:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1amnOV-0002Jq-Mx for emacs-devel@gnu.org; Sun, 03 Apr 2016 15:09:11 -0400 Original-Received: from hermes.netfonds.no ([80.91.224.195]:47158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amnOV-0002Jg-GA for emacs-devel@gnu.org; Sun, 03 Apr 2016 15:09:07 -0400 Original-Received: from cm-84.215.1.64.getinternet.no ([84.215.1.64] helo=stories) by hermes.netfonds.no with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.84_2) (envelope-from ) id 1amnOS-0008QE-DC for emacs-devel@gnu.org; Sun, 03 Apr 2016 21:09:06 +0200 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEUpEA0RBQLy8u+ZgWlV Liz+//5yT0YxlBGVAAAB70lEQVQ4jcWTMa7bMAyGKVTwLAJC5sJpDvCshLMMEzxACu95FR/vf4RS cgK0KDq0Hcp4UPiZ/09ZFOy/Cfi/4D7Pl3meiwf5r7S+KhfY3yEkHBHwFQE/YA/EP2VrSA/oAEz7 /wR15E+Gyhw+4J7IEBAzHoImWVngBvtn0gqYIeSez9xOzLzeRsUDAjjrNmz2SSUmB+gghbQOqaxt KyIsB7CEjlCuSYyUotRwAAK3z5M1ETPTLFYGcC0HPdesNFPZ+s7vgXydcjYjZ1I2sgN0D4Pk7Th6 TF2r0Y/gZMamnt5UijwB1bzmDoyIm7VCA5AoZGA19yC7NmrtkOobgZq7tbgBe1fWQSPvyvdRRScv blK3Q8q9a4aUYoSptatE95ADSIoAmWsN3WY1P98O1DTEib0gBm/XTv0DHBU1RI0MGCOpraIb0z7M AeAR/Xggsmvx9QmI3Fo51oCTSGvMomUA427up4456rQRMz2l3rAirMk3gkCbCTav+IpWrhj7YEEV SN4WIwwpbf6iny2eytLUQCPCaYDt7Zipb8u5XMHWFSEPIO9j1KCcF/oSOaxYBxBbn1ObopS1ut86 wDPA3QF8jPrcOdjP5Yh5Pvtj437M86836v5Pl9Nv4YjLfnktXqDbnpfLPi/zsszn2197/Bn4Dh/x Dl3FnIoSAAAAAElFTkSuQmCC In-Reply-To: (Lars Magne Ingebrigtsen's message of "Sun, 03 Apr 2016 18:33:44 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 80.91.224.195 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:202648 Archived-At: I guess we should put off doing cleanups until Emacs 25.1 has been released, because merging between the branches get kinda hairy if you change the trunk a lot. But anyway, I thought I'd just post the two functions that I was using to do (if (featurep 'xemacs) (something) (something) (else)) cleanup, in case somebody wants to do some cleanup. The first deletes the "then" part, and the second deletes the "else" part (which is useful when it's (if (featurep 'emacs) ...) instead). Of course, you have to see whether the code makes sense afterwards. Which is might not if the code is (setq foo (if ...)), for instance. (defun lars-delete-then () "Delete the if statement and the then statement." (interactive) (if (looking-at " *(if") (delete-region (point) (match-end 0)) (search-backward "(if" (line-beginning-position)) (delete-region (point) (+ (point) 3))) (kill-sexp 2) (save-excursion (while (ignore-errors (forward-sexp 1) t)) ;; Delete the final ")". (delete-region (point) (1+ (point)))) (save-excursion (beginning-of-line) (when (looking-at "\\s-*$") (delete-region (point) (line-beginning-position 2)))) (save-excursion (search-backward "(") (indent-sexp))) (defun lars-delete-else () "Delete the if statement and the else statement." (interactive) (if (looking-at " *(if") (delete-region (point) (match-end 0)) (search-backward "(if" (line-beginning-position)) (delete-region (point) (+ (point) 3))) (kill-sexp 1) (let ((start (point))) (forward-sexp 1) (while (ignore-errors (kill-sexp 1) t)) ;; Delete the final ")". (delete-region (point) (1+ (point))) (goto-char start) (save-excursion (beginning-of-line) (when (looking-at "\\s-*$") (delete-region (point) (line-beginning-position 2)))) (save-excursion (search-backward "(") (indent-sexp)))) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no