From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: PATCH Make org-open-at-point only ask once Date: Mon, 29 Aug 2011 09:14:13 +0200 Message-ID: <87liuclmey.fsf@gmail.com> References: <20110828200542.GS5700@0x63.nu> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:54246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qxw3a-0005YC-Jt for emacs-orgmode@gnu.org; Mon, 29 Aug 2011 03:14:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qxw3Z-00014j-8s for emacs-orgmode@gnu.org; Mon, 29 Aug 2011 03:14:54 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:64794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qxw3Z-00014R-0J for emacs-orgmode@gnu.org; Mon, 29 Aug 2011 03:14:53 -0400 Received: by wyi11 with SMTP id 11so4257876wyi.0 for ; Mon, 29 Aug 2011 00:14:51 -0700 (PDT) In-Reply-To: <20110828200542.GS5700@0x63.nu> (Anders Waldenborg's message of "Sun, 28 Aug 2011 22:05:42 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Anders Waldenborg Cc: emacs-orgmode@gnu.org Hello, Anders Waldenborg writes: > If an org buffer is narrowed, and one tries to do org-open-at-point on > a link that points to outside of the restriction it asks: "No match - > create this as a new heading?". When answering no the buffer is > widened and the reseach is done, and if the link still can't be > resolved the question is asked again. > > For nonexistant links this happens even if the buffer isn't narrowed - > one needs to answer "n" twice. > > I also attached an alternate patch which (IMHO) simplifies the > implementation by hiding the hard work in a macro, and as a bonus it > only calls org-link-search once. But it is much more intrusive. Yes, imposing widening to the user is intrusive. Moreover, I think you cannot avoid to call org-link-search twice (once it has failed): the point is to do a local search and then a global one. Though, the macro idea is interesting, as I can see at least one other place where it might be useful. So, what about changing the macro to: 1. If current buffer is narrowed, execute body with the current restriction. If it fails (silently), re-execute body with a widened buffer. Restore default narrowing. 2. If the buffer has no narrowing in effect, just execute body. Also: 1. Doc-strings must refer to the arguments. 2. Don't forget to add: (def-edebug-spec macro-name (arguments)) just after it. 3. You need to add a proper ChangeLog message in your commit. Thank you for looking at this. Regards, -- Nicolas Goaziou