From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Stephen J. Turnbull" Newsgroups: gmane.emacs.devel Subject: Re: forward-paragraph return value Date: Tue, 24 Aug 2010 21:06:36 +0900 Message-ID: <87sk245i5v.fsf@uwakimon.sk.tsukuba.ac.jp> References: <4C72BD0A.8090104@online.de> <4C735C02.70804@online.de> <87y6bw5sb8.fsf@uwakimon.sk.tsukuba.ac.jp> <4C738D6D.5040805@online.de> 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: dough.gmane.org 1282651831 18693 80.91.229.12 (24 Aug 2010 12:10:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 24 Aug 2010 12:10:31 +0000 (UTC) Cc: Andreas Schwab , Emacs developers To: Andreas =?iso-8859-1?Q?R=F6hler?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 24 14:10:30 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OnsKb-0002jA-PZ for ged-emacs-devel@m.gmane.org; Tue, 24 Aug 2010 14:10:29 +0200 Original-Received: from localhost ([127.0.0.1]:53885 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnsKU-0006o6-Ks for ged-emacs-devel@m.gmane.org; Tue, 24 Aug 2010 08:10:14 -0400 Original-Received: from [140.186.70.92] (port=48948 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnsKP-0006o1-4w for emacs-devel@gnu.org; Tue, 24 Aug 2010 08:10:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnsKN-0006TM-DD for emacs-devel@gnu.org; Tue, 24 Aug 2010 08:10:08 -0400 Original-Received: from imss12.cc.tsukuba.ac.jp ([130.158.254.161]:37214) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnsKM-0006TA-QU for emacs-devel@gnu.org; Tue, 24 Aug 2010 08:10:07 -0400 Original-Received: from imss12.cc.tsukuba.ac.jp (imss12.cc.tsukuba.ac.jp [127.0.0.1]) by postfix.imss70 (Postfix) with ESMTP id D88D9F4003; Tue, 24 Aug 2010 21:10:04 +0900 (JST) Original-Received: from mgmt1.sk.tsukuba.ac.jp (unknown [130.158.97.223]) by imss12.cc.tsukuba.ac.jp (Postfix) with ESMTP id C9BF2F4002; Tue, 24 Aug 2010 21:10:04 +0900 (JST) Original-Received: from uwakimon.sk.tsukuba.ac.jp (uwakimon.sk.tsukuba.ac.jp [130.158.99.156]) by mgmt1.sk.tsukuba.ac.jp (Postfix) with ESMTP id C7F813FA024D; Tue, 24 Aug 2010 21:10:04 +0900 (JST) Original-Received: by uwakimon.sk.tsukuba.ac.jp (Postfix, from userid 1000) id E21921A47B8; Tue, 24 Aug 2010 21:06:36 +0900 (JST) In-Reply-To: <4C738D6D.5040805@online.de> X-Mailer: VM undefined under 21.5 (beta29) "garbanzo" ed3b274cc037 XEmacs Lucid (x86_64-unknown-linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:129126 Archived-At: Andreas R=F6hler writes: > Am 24.08.2010 10:27, schrieb Stephen J. Turnbull: > > Andreas R=F6hler writes: > > > > > Then people may write functions taking already the return > > > value. > > Sure. But will they? Show us examples of existing functions > > (preferably already in Emacs) that would benefit from this > > change. > >=20=20=20=20 >=20 > Didn't I point to? >=20 > If a look in forward-paragraph doesn't speak to you, Of course that doesn't speak to me; that's the function you propose to change. > maybe have a look into >=20 > bounds-of-thing-at-point . `forward-paragraph' is a command. `bounds-of-thing-at-point' is not. There's a big difference. > Forms like > (let > (beg > (progn > (funcall > (or (get thing 'beginning-op) > (lambda () (forward-thing thing -1)))) > (point)))) I doubt that form appears anywhere in Emacs. The style is nauseating, not to mention that `progn' is a very unusual choice for a variable you are let-binding. ;-) Please give *real* examples, or if you're going to simplify real code to make your point, say that's what you're doing. And do it correctly, even for a fragment like this. > Thats bug-sourcing BTW, as it returns point in any case, even if > move failed. Why not make implementation of return value from >=20 > search-forward >=20 > canonical instead, returning the position if succesful, nil > otherwise. Er, because otherwise `search-forward' does not return nil, but rather signals an error? You need to specify additional arguments to get it to return nil. There's a reason for this interface, related to the fact that `search-forward' is a command, as is `forward-paragraph'. > The gain will be for newly written code. For writers first, who > must not learn function by function the return value. A common convention might be a good idea. It's a better idea for non-commands than it is for commands, though. > In the example above we could write >=20 > (let > (beg > (funcall > (or (get thing 'beginning-op) > (lambda () (forward-thing thing -1)))))) >=20 > Its clean and much more reliable, as beg will be nil, if nothing > was found. Maybe. But in fact, this is a (broken) copy of (part of) the implementation of `bounds-of-thing-at-point'. At least in XEmacs, that function has *much* bigger problems than the return value of forward-thing. Also, since the return value of `forward-thing' is undocumented (and probably rather unreliable), you could change that, or define an internal function for the use of functions defun'ed in thingatpt.el. The issue with forward-paragraph is quite different, because it is documented and it is a command.