From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: How to stop from loading a script? Date: 21 Oct 2015 12:13:35 GMT Message-ID: References: <18d6c0ca-1d0f-4d17-8267-e3de2a4b7a45@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 X-Trace: ger.gmane.org 1445429730 24664 80.91.229.3 (21 Oct 2015 12:15:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Oct 2015 12:15:30 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 21 14:15:25 2015 Return-path: Envelope-to: geh-help-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 1ZosId-0005cH-K9 for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Oct 2015 14:15:23 +0200 Original-Received: from localhost ([::1]:51222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZosIc-0007tT-SP for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Oct 2015 08:15:22 -0400 X-Received: by 10.112.14.4 with SMTP id l4mr2099103lbc.20.1445429616599; Wed, 21 Oct 2015 05:13:36 -0700 (PDT) Original-Path: usenet.stanford.edu!o5no1271193lbc.0!news-out.google.com!wa5ni6062lbb.1!nntp.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 48 Original-X-Trace: individual.net 07tL7i8NZ17WUiMhkeCKQgWpIYIbub+b+X2SscMuZqUmamATAB Cancel-Lock: sha1:STVZ+zM4LXi6HiCTrOi1iFIDDa0= Mail-Copies-To: nobody X-Editor: Emacs of course! User-Agent: slrn/1.0.1 (Linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:215481 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:107764 Archived-At: Shiyao Ma wrote: > Hi, > > Say the caller will *always* load a script. > > But inside the script, I'd like to *directly* return to the caller if some conditions are met. > > A workaround is to wrap all the stuff in side a when/unless clause. > > e.g., > > > (unless (COND) > > do-my-stuff) > > > However, the do-my-stuff is too lengthy and I am in search of the following form: Why is it too lengthy? > (when (COND) > > EARLY_RETURN_TO_THE_LOADER) > > (do-my-stuff). > > So my question is, what should I fill in the EARLY_RETURN_TO_THE_LOADER slot? There is nothing that really fits the bill. You could exit the function with `error`, but that won't pass control back to the calling function unless the call was wrapped in a `condition-case` or `ignore-errors`. Alternatively, you could use `catch` and `throw`, but that also requires that the call to your function is wrapped in a special form. See the Elisp manual, section on nonlocal exits for both options. But in either case, you're making the code more complex for unnecessary reasons. Using `unless` the way you describe is not a workaround IMHO but the best way to do it. The fact that the body of `unless` is long is not an issue, the only "disadvantage" is that there are two additional spaces for indentation. -- Joost Kremers joostkremers@fastmail.fm Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9)