From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Aaron Hawley Newsgroups: gmane.emacs.bugs Subject: patch: thingatpt.el usage of char-before and char-after Date: Tue, 16 Oct 2007 10:59:36 -0400 Message-ID: <3a5d3564b02ca5af4d8a539f1fdd5623@groupware.garden.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1192546805 31736 80.91.229.12 (16 Oct 2007 15:00:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 16 Oct 2007 15:00:05 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 16 17:00:02 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Ihnti-0003WX-Sb for geb-bug-gnu-emacs@m.gmane.org; Tue, 16 Oct 2007 16:59:55 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ihntc-0002bf-13 for geb-bug-gnu-emacs@m.gmane.org; Tue, 16 Oct 2007 10:59:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ihnta-0002an-2E for bug-gnu-emacs@gnu.org; Tue, 16 Oct 2007 10:59:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IhntX-0002ab-Mv for bug-gnu-emacs@gnu.org; Tue, 16 Oct 2007 10:59:44 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IhntX-0002aY-GC for bug-gnu-emacs@gnu.org; Tue, 16 Oct 2007 10:59:43 -0400 Original-Received: from host13.natgard1.cust.sover.net ([207.136.219.173] helo=meristem.garden.org) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IhntW-0007Z8-S5 for bug-gnu-emacs@gnu.org; Tue, 16 Oct 2007 10:59:43 -0400 Original-Received: from localhost (unknown [192.168.219.10]) by meristem.garden.org (Postfix) with ESMTP id 89AE3576B8 for ; Tue, 16 Oct 2007 10:59:40 -0400 (EDT) X-Virus-Scanned: amavisd-new at garden.org Original-Received: from meristem.garden.org ([192.168.219.9]) by localhost (marigold.garden.org [192.168.219.10]) (amavisd-new, port 10024) with ESMTP id vRSa0SUwkj65 for ; Tue, 16 Oct 2007 10:59:36 -0400 (EDT) Original-Received: from carpel.garden.org (unknown [192.168.219.49]) by meristem.garden.org (Postfix) with ESMTP id D51D75763F for ; Tue, 16 Oct 2007 10:59:34 -0400 (EDT) Original-Received: from groupware.garden.org (localhost.localdomain [127.0.0.1]) by carpel.garden.org (Postfix) with ESMTP id 2BBA148044 for ; Tue, 16 Oct 2007 10:59:36 -0400 (EDT) Original-Received: from phpmailer ([192.168.219.106]) by groupware.garden.org with HTTP (PHPMailer); Tue, 16 Oct 2007 10:59:36 -0400 X-Priority: 3 X-Mailer: PHPMailer [version 1.71] X-Mailer: FeLaMiMail version 0.9.5 X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:16762 Archived-At: Since char-after and char-before use (point) as their default arguments, there's no sense specifying it. Also, I'm pretty confident that (char-after (1- (point))) is equivalent to (char-before). I noticed these in thingatpt.el. Below is a patch that makes these simplifications to the library's code. ChangeLog entry: 2007-10-16 Aaron Hawley * thingatpt.el (end-of-sexp, beginning-of-sexp) (forward-same-syntax): char-before and char-after use (point) as default argument. (forward-same-syntax): char-before is syntactic sugar for (char-after (1- (point))). --- orig/lisp/thingatpt.el +++ mod/lisp/thingatpt.el @@ -165,7 +165,7 @@ (nth 3 (parse-partial-sexp (point) orig))))) =20 (defun end-of-sexp () - (let ((char-syntax (char-syntax (char-after (point))))) + (let ((char-syntax (char-syntax (char-after)))) (if (or (eq char-syntax ?\)) (and (eq char-syntax ?\") (in-string-p))) (forward-char 1) @@ -174,7 +174,7 @@ (put 'sexp 'end-op 'end-of-sexp) =20 (defun beginning-of-sexp () - (let ((char-syntax (char-syntax (char-before (point))))) + (let ((char-syntax (char-syntax (char-before)))) (if (or (eq char-syntax ?\() (and (eq char-syntax ?\") (in-string-p))) (forward-char -1) @@ -374,10 +374,10 @@ (interactive "p") (while (< arg 0) (skip-syntax-backward - (char-to-string (char-syntax (char-after (1- (point)))))) + (char-to-string (char-syntax (char-before)))) (setq arg (1+ arg))) (while (> arg 0) - (skip-syntax-forward (char-to-string (char-syntax (char-after (point))))) + (skip-syntax-forward (char-to-string (char-syntax (char-after)))) (setq arg (1- arg)))) =20 ;; Aliases --=20 National Gardening Association 1100 Dorset Street, South Burlington, VT 05403=20 Email: support@garden.org - Web: www.garden.org/ --