emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Vincent Belaïche" <vincent.b.1@hotmail.fr>
To: Jean-Christophe Helary <brandelune@gmail.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>,
	EMACS devel list <emacs-devel@gnu.org>
Subject: RE: info URL « open at point » patch
Date: Sun, 24 Jun 2018 20:30:04 +0000	[thread overview]
Message-ID: <AM6PR10MB1957E857C42C80CBE2C8643E844B0@AM6PR10MB1957.EURPRD10.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <86C481C5-D11D-4598-92CB-9DA98ADA03CC@gmail.com>


I generated the regexp with (regexp-opt '("ftp" "http" "https"
"file")). I admit that the list of protocols is not clear from the
regexp, but it was already done this way before my change, and I tried
to minimize the change.
More concerning in my opinion is how the Info-get-token is written. As
some point of the code one can read the following statement:
      ;; First look for a match for START that goes across POS.
      (while (and (not (bobp)) (> (point) (- pos (length start)))
    (not (looking-at start)))
 (forward-char -1))


Here start is a regexp, so (length start) is just the length of the
string holding the regexp, not the max length over which the regexp
match can span. For instance assume that aaaaaaaaaa is a new new
protocol which you want Info-get-token to catch. This is 10 character
long, but the typical regexp to catch it would be « a\{10\} » which is
only 7 character long.
It would propably be cleaner to provide the value to be used instead of
(length start) as a separate optional argument that would be set to
(length start) if omitted.
Another way would be to have some standard function max-matchable-length
that given some regexp would compute the maximum length of its match (or
output some special value like t if the maximum length is infinite),
thus (length start) could be replaced by (max-matchable-length start)
--- maybe this is already somthing existing. In the same vein there
could be some standard function that given regexp re and some position
pos-in would function position pos-out such that the following
expression would be true:
(save-excursion
  (goto-char pos-out)
  (and (<= pos-out pos-in)
       (looking-at re)
       (>= (match-end 0) pos-in)))
I think that such standard function is already existing, but I can't
remember the package name which provides it…
  V.

      reply	other threads:[~2018-06-24 20:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-24  6:57 info URL « open at point » patch Vincent Belaïche
2018-06-24 14:31 ` Eli Zaretskii
2018-06-24 16:48   ` Vincent Belaïche
2018-06-24 16:49     ` Vincent Belaïche
2018-06-24 17:03     ` Eli Zaretskii
2018-06-24 18:21       ` Vincent Belaïche
2018-06-24 18:45         ` Eli Zaretskii
2018-06-24 20:34           ` Vincent Belaïche
2018-06-25  2:30             ` Eli Zaretskii
2018-06-26  5:19               ` Vincent Belaïche
2018-06-26  5:47                 ` Vincent Belaïche
2018-06-26 14:34                   ` Eli Zaretskii
2018-06-27 17:39                     ` Vincent Belaïche
2018-06-27 18:11                       ` Eli Zaretskii
2018-06-26 14:30                 ` Eli Zaretskii
2018-06-24 14:46 ` Jean-Christophe Helary
2018-06-24 20:30   ` Vincent Belaïche [this message]

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=AM6PR10MB1957E857C42C80CBE2C8643E844B0@AM6PR10MB1957.EURPRD10.PROD.OUTLOOK.COM \
    --to=vincent.b.1@hotmail.fr \
    --cc=brandelune@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    /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).