emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Brand <michael.ch.brand@gmail.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: Bastien <bzg@gnu.org>, Org Mode <emacs-orgmode@gnu.org>
Subject: Re: link interfering with brackets when abbreviated
Date: Thu, 27 Feb 2014 21:01:34 +0100	[thread overview]
Message-ID: <CALn3zoj+au9zBUBCSZ_n9LLNvFX+ARD8a8e0ROWCSGPnbhPRww@mail.gmail.com> (raw)
In-Reply-To: <87ppm8rgrf.fsf@gmail.com>

Hi Nicolas

On Thu, Feb 27, 2014 at 11:28 AM, Nicolas Goaziou <n.goaziou@gmail.com> 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

  parent reply	other threads:[~2014-02-27 20:01 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-03 12:11 link interfering with brackets when abbreviated Michael Brand
2014-02-26 15:10 ` Michael Brand
2014-02-26 15:25   ` Nicolas Goaziou
2014-02-26 15:44     ` Michael Brand
2014-02-26 15:54       ` Nicolas Goaziou
2014-02-26 16:22         ` Michael Brand
2014-02-26 16:41           ` Nicolas Goaziou
2014-02-26 17:03             ` Michael Brand
2014-02-26 17:20               ` Bastien
2014-02-26 19:02                 ` Nicolas Goaziou
2014-02-26 22:54                   ` Bastien
2014-02-27 10:28                     ` Nicolas Goaziou
2014-02-27 11:04                       ` Bastien
2014-02-27 20:01                       ` Michael Brand [this message]
2014-02-27 22:08                         ` Bastien
2014-02-27 23:43                           ` Nicolas Goaziou
2014-03-01 18:44                             ` Yasushi SHOJI
2014-03-01 20:20                               ` Nicolas Goaziou
2014-03-01 20:54                                 ` Bastien
2014-03-01 20:57                                   ` Bastien
2014-03-01 21:35                                   ` Nicolas Goaziou
2014-03-01 21:50                                     ` Bastien
2014-03-01 22:14                                       ` Nicolas Goaziou
2014-03-02 13:35                                         ` Bastien
2014-03-03 14:12                                           ` Matt Lundin
2014-03-02  0:22                                 ` Yasushi SHOJI
2014-03-02  9:05                                   ` Nicolas Goaziou
2014-03-02 13:22                                     ` Bastien
2014-03-02 14:27                                       ` Nicolas Goaziou
2014-03-02 15:49                                         ` Bastien
2014-03-02 16:32                                           ` Thorsten Jolitz
2014-03-03  3:41                                           ` Josiah Schwab
2014-03-03  5:54                                           ` Michael Brand
2014-03-03  9:50                                             ` Context of interaction vs. literal syntactic interpretation (was: link interfering with brackets when abbreviated) Bastien
2014-03-03 16:09                                               ` Context of interaction vs. literal syntactic interpretation Matt Lundin
2014-03-03 18:00                                                 ` Nick Dokos
2014-03-03 18:13                                                 ` Jonathan Leech-Pepin
2014-03-14 13:46                                                 ` Sebastien Vauban
2014-03-21  8:44                                                 ` Bastien
2014-03-21 13:17                                                   ` Nicolas Goaziou
2014-03-23 22:51                                                     ` Bastien
2014-03-24 13:12                                                       ` Nicolas Goaziou
2014-03-01 18:44                             ` link interfering with brackets when abbreviated Yasushi SHOJI
2014-02-26 17:42   ` Bastien
2014-02-26 21:15     ` Nicolas Goaziou
2014-02-26 22:21       ` Bastien
  -- strict thread matches above, loose matches on Subject: below --
2014-03-02 21:16 Gustav Wikström
2014-03-03  1:30 ` Ista Zahn
2014-03-03 19:33   ` Samuel Wales
2014-03-03 19:46     ` Samuel Wales
2014-03-03 22:18       ` Sebastien Vauban
2014-03-03 22:33         ` Samuel Wales
     [not found]           ` <CAJcAo8vh0F0tqgX4=gUhJoWFcAsTiwfyi7Fp=spQeoaBog1OMQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-04 12:16             ` Sebastien Vauban
2014-03-04 20:06               ` Samuel Wales
2014-03-19 11:19     ` Bastien
2014-03-03 10:58 ` Christian Moe
2014-03-03 16:11 ` Sebastien Vauban
2014-03-03 23:16 ` Robert Horn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALn3zoj+au9zBUBCSZ_n9LLNvFX+ARD8a8e0ROWCSGPnbhPRww@mail.gmail.com \
    --to=michael.ch.brand@gmail.com \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).