From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas =?UTF-8?Q?R=C3=B6hler?= Newsgroups: gmane.emacs.bugs Subject: bug#13994: End of buffer error for forward-sexp Date: Mon, 29 Apr 2013 14:43:47 +0200 Message-ID: <517E6B03.9040109@easy-emacs.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1367239374 6956 80.91.229.3 (29 Apr 2013 12:42:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 29 Apr 2013 12:42:54 +0000 (UTC) To: 13994@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 29 14:42:59 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1UWnPy-0005VF-2B for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Apr 2013 14:42:54 +0200 Original-Received: from localhost ([::1]:43866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWnPx-0003ai-MW for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Apr 2013 08:42:53 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWnPr-0003a8-Me for bug-gnu-emacs@gnu.org; Mon, 29 Apr 2013 08:42:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWnPp-0007t9-CR for bug-gnu-emacs@gnu.org; Mon, 29 Apr 2013 08:42:47 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45739) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWnPp-0007t3-8q for bug-gnu-emacs@gnu.org; Mon, 29 Apr 2013 08:42:45 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UWnQ6-0001Mz-6O for bug-gnu-emacs@gnu.org; Mon, 29 Apr 2013 08:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas =?UTF-8?Q?R=C3=B6hler?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 Apr 2013 12:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13994 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13672393315062 (code B ref -1); Mon, 29 Apr 2013 12:43:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Apr 2013 12:42:11 +0000 Original-Received: from localhost ([127.0.0.1]:49847 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UWnPG-0001Ja-Lq for submit@debbugs.gnu.org; Mon, 29 Apr 2013 08:42:11 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55117) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UWnPC-0001JP-Ll for submit@debbugs.gnu.org; Mon, 29 Apr 2013 08:42:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWnOt-0007d7-J9 for submit@debbugs.gnu.org; Mon, 29 Apr 2013 08:41:49 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:53421) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWnOt-0007d3-Fz for submit@debbugs.gnu.org; Mon, 29 Apr 2013 08:41:47 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWnOo-0003X2-CN for bug-gnu-emacs@gnu.org; Mon, 29 Apr 2013 08:41:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWnOm-0007bV-Ep for bug-gnu-emacs@gnu.org; Mon, 29 Apr 2013 08:41:42 -0400 Original-Received: from moutng.kundenserver.de ([212.227.126.171]:63046) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWnOm-0007b6-5Y for bug-gnu-emacs@gnu.org; Mon, 29 Apr 2013 08:41:40 -0400 Original-Received: from [192.168.178.21] (brln-4dbc4f2b.pool.mediaWays.net [77.188.79.43]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0LpeYo-1V06HH2rBe-00fOuy; Mon, 29 Apr 2013 14:41:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 In-Reply-To: X-Provags-ID: V02:K0:HF6zLZIL9XrSjlJyhb3vX9SZqVqOI7eOPMWAreGmEho 30g+u3Cs7iTjTGhd+Zog/6owuDH8ZS5gmY6kPFPOH5TVcHThRh A+YrmX4LgC4qOHRKnRdm0tWiJz7em5/U7RegR3dDSDYTOHQSbc iVj0+/2dia9+ZFBWvyBEF2mxsgRY86k3hp4zoGuXS7O7QiUO2R LgjFMGijQnEBiSHjTWvRMTNT7dJe97AKeuUSbY4z99PCoTKtWW Fe3VXBDiYSLU3U81CwGshJWx43bOGaREFkWD5rVEkeynLSo2WX OBkrmm6QYIXaXt5hh4W0FWLZEasU4QcK1z8/qSjPRDdR104WzT 8njoXkkPxc+eTBvhnBGVLgURIPoms5wiQsu58tLsl X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:73819 Archived-At: Am 18.03.2013 22:54, schrieb Aaron S. Hawley: > I would like C-M-f (`forward-sexp') to signal an error when reaching > the beginning or end of a buffer. When running a keyboard macro that > contains this command, it should reach an error condition of "End of > buffer". If wish to run C-0 C-x e on a file full of S-expressions and > have the macro end when an error is reached. Currently, my macro puts > Emacs in an infinite loop. > > I've attached a patch that adds these error conditions. I also need > to correct my email address in the ChangeLog. > > What I wrote isn't every strict. I only catch the condition when the > function is started from beginning or end of buffer. If the user > gives an argument for more S-expressions than there are between the > beginning of the buffer there is no error triggered. This was a > compromise but also a simpler patch to contribute. I've added the > unit tests I wrote to implement. I hope they're helpful. > > I'm not sure why this was never the case in the first place, nor do I > know what the consequence of fixing it is. I'm not sure if the lack > of an error is necessary in the 112 libraries where this function is > used in Emacs (and probably many times more in libraries outside of > Emacs!). I'm hoping that after the release Emacs 24.3, now is a good > time to install this in trunk and find out. > > Thanks, > /a > > === modified file 'lisp/ChangeLog' > --- lisp/ChangeLog 2013-03-18 19:44:15 +0000 > +++ lisp/ChangeLog 2013-03-18 20:37:01 +0000 > @@ -1,3 +1,5 @@ > +2013-03-18 Aaron S. Hawley > + > + * emacs-lisp/lisp.el (forward-sexp): Signal an error when end of > + buffer or beginning of buffer reached. > + > @@ -1974,7 +1979,7 @@ > (js--multi-line-declaration-indentation): New function. > (js--proper-indentation): Use it. > > -2013-01-11 Aaron S. Hawley > +2013-01-11 Aaron S. Hawley > > * calc/calc.el (calc-highlight-selections-with-faces) > (calc-dispatch): > > === modified file 'lisp/emacs-lisp/lisp.el' > --- lisp/emacs-lisp/lisp.el 2013-01-01 09:11:05 +0000 > +++ lisp/emacs-lisp/lisp.el 2013-03-18 19:38:50 +0000 > @@ -58,6 +58,10 @@ > (or arg (setq arg 1)) > (if forward-sexp-function > (funcall forward-sexp-function arg) > + (when (and (> arg 0) (eobp)) > + (signal 'end-of-buffer nil)) > + (when (and (< arg 0) (bobp)) > + (signal 'beginning-of-buffer nil)) > (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) > (if (< arg 0) (backward-prefix-chars)))) > > > === added file 'test/automated/sexp-tests.el' > --- test/automated/sexp-tests.el 1970-01-01 00:00:00 +0000 > +++ test/automated/sexp-tests.el 2013-03-18 21:51:52 +0000 > @@ -0,0 +1,98 @@ > +;;; sexp-tests.el --- Test S-expression support in Emacs > + > +;; Copyright (C) 2013 Aaron S. Hawley > + > +;; Author: Aaron S. Hawley > +;; Keywords: internal > + > +;; This program is free software; you can redistribute it and/or modify > +;; it under the terms of the GNU General Public License as published by > +;; the Free Software Foundation, either version 3 of the License, or > +;; (at your option) any later version. > + > +;; This program is distributed in the hope that it will be useful, > +;; but WITHOUT ANY WARRANTY; without even the implied warranty of > +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +;; GNU General Public License for more details. > + > +;; You should have received a copy of the GNU General Public License > +;; along with this program. If not, see . > + > +;;; Commentary: > + > +;; Testing of `forward-sexp'. > + > +;;; Code: > + > +(require 'ert) > + > +(ert-deftest sexp-forward-1 () > + "Test basics of \\[forward-sexp]." > + (with-temp-buffer > + (insert "()") > + (goto-char (point-min)) > + (should (null > + (forward-sexp 1))))) > + > +(ert-deftest sexp-backward-1 () > + "Test basics of \\[backward-sexp]." > + (with-temp-buffer > + (insert "()") > + (should (null > + (forward-sexp -1))))) > + > +(ert-deftest sexp-forward-1-error-eobp () > + "Test error when \\[forward-sexp] at `eobp'." > + (with-temp-buffer > + (insert "()") > + (should-error > + (forward-sexp 1)))) > + > +(ert-deftest sexp-backward-1-error-eobp () > + "Test error when \\[backward-sexp] at `bobp'." > + (with-temp-buffer > + (insert "()") > + (goto-char (point-min)) > + (should-error > + (forward-sexp -1)))) > + > +(ert-deftest sexp-forward-2-eobp-no-error () > + "Test lack of error when \\[forward-sexp] beyond `eobp'." > + (with-temp-buffer > + (insert "()") > + (goto-char (point-min)) > + (should (null > + (forward-sexp 2))) > + (should (eobp)))) > + > +(ert-deftest sexp-backward-2-bobp-no-error () > + "Test lack of error when \\[backward-sexp] beyond `bobp'." > + (with-temp-buffer > + (insert "()") > + (should (null > + (forward-sexp -2))) > + (should (bobp)))) > + > +(ert-deftest sexp-forward-2-eobp-subsequent-error () > + "Test error when \\[forward-sexp] when started from `eobp'." > + (with-temp-buffer > + (insert "()") > + (goto-char (point-min)) > + (should (null > + (forward-sexp 2))) > + (should (eobp)) > + (should-error > + (forward-sexp 1)))) > + > +(ert-deftest sexp-backward-2-bobp-subsequent-error () > + "Test error when \\[backward-sexp] when started from `bobp'." > + (with-temp-buffer > + (insert "()") > + (should (null > + (forward-sexp -2))) > + (should (bobp)) > + (should-error > + (forward-sexp -1)))) > + > +(provide 'sexp-tests) > +;;; sexp-tests.el ends here > IIRC that was the default at XEmacs. Very annoying, as beginning or EOB are hitted quit often. Than the debugger starts. For now, what about writing (if (forward-sexp) DO-SOMEthing (message "%s" "nil")) Best regards, Andreas