From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Brand Subject: Re: link interfering with brackets when abbreviated Date: Thu, 27 Feb 2014 21:01:34 +0100 Message-ID: References: <87ppm9sxoh.fsf@gmail.com> <87lhwxswby.fsf@gmail.com> <87ha7lsu5o.fsf@gmail.com> <8761o1n63t.fsf@bzg.ath.cx> <8738j5snms.fsf@gmail.com> <87vbw11o3q.fsf@bzg.ath.cx> <87ppm8rgrf.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJ79J-0003A5-Vl for emacs-orgmode@gnu.org; Thu, 27 Feb 2014 15:01:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJ79D-0007tq-Bl for emacs-orgmode@gnu.org; Thu, 27 Feb 2014 15:01:41 -0500 In-Reply-To: <87ppm8rgrf.fsf@gmail.com> 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: Nicolas Goaziou Cc: Bastien , Org Mode Hi Nicolas On Thu, Feb 27, 2014 at 11:28 AM, Nicolas Goaziou wrote: > The only really predictable behaviour is: "open the link under point". > Everything else is arguable. What for me is a conflict between ... 1) There are arguments to change - as you recently did in master - org-open-at-point to open only if there is a link _at point_. Just as its function name tells. 2) As a user I would like to have the possibility to open a link between point and end of line without having to navigate to the exact column. Also in modes other than Org. ... I solve for myself with the following function bound to "C-c o" (not "C-c C-o"). It moves to and opens the first link between point and end of line by simply trying point by point until it works the current org-open-at-point from master that opens only when point is on a link: #+BEGIN_SRC emacs-lisp (defun f-open-link-between-point-and-eol () "Move to and open first link between point and end of line. As long as not yet at end of line and as long as `org-open-at-point' or `browse-url-at-point' gives an error advance point by one character. For Org and other major modes." (interactive) (let ((p (point)) (err t)) (while (and (not (eolp)) (setq err (not (ignore-errors (or (cond ;; Org mode ((eq major-mode 'org-mode) (org-open-at-point)) ;; Maybe more major modes here ;; [...] ;; All other major modes (t (browse-url-at-point))) t))))) (forward-char)) (when err (goto-char p) (user-error "No link between point and end of line")))) #+END_SRC The above function does not only work for Org link and URL in Org mode but also for URL in any other major mode. The definition of what should be the alternative link when there is no link at the starting point is simply delegated to org-open-at-point and browse-url-at-point. This simplification makes it slow for links towards the end or not present in long lines. There is plenty of room for a better implementation than I did with this very simple first approach. In the case that, depending on user feedback, even "C-c C-o" itself should move to the first link between point and end of line - or whatever other link - also when there is no link at the starting point, I suggest to keep org-open-at-point to open only when point is on a link and to wrap this move into a new function, named e. g. org-open-between-point-and-eol to be bound to "C-c C-o". The simplified solution with f-open-link-between-point-and-eol already covers all my use cases of the old org-open-at-point. The predictability of what will be the alternative link remains arguable. I find its predictability at least better than with the old org-open-at-point. And last but not least also the original issue #+LINK: link-abbreviation http://www.orgmode.org/# 1) [ ] [[http://www.orgmode.org/#docs]] 2) [[link-abbreviation:docs]] 3) [ ] [[link-abbreviation:docs]] of this thread with point on the character "3" is of course solved for me. Michael