From: Dan Davison <davison@stats.ox.ac.uk>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: emacs org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: overzealous file link creation
Date: Wed, 12 Aug 2009 12:09:03 -0400 [thread overview]
Message-ID: <871vnhypy8.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: B9802B4B-62A6-47E3-AA3A-4362F7C1C39A@gmail.com
Carsten Dominik <carsten.dominik@gmail.com> writes:
> On Aug 11, 2009, at 10:29 PM, Dan Davison wrote:
>
<...>
>> Try putting the following fragment into python-mode, and getting rid
>> of
>> the asterisks. Then org-cycle issued with point at any of the
>> asterisked
>> locations eats the string 'file' and prompts for a link.
>>
>> --8<---------------cut here---------------start------------->8---
>> def f(filepath):
>> print(
>> *filepath*)*
>> *
>> *def g(arg):
>> return arg
>> --8<---------------cut here---------------end--------------->8---
>>
>> This is with latest git.
>
> Hi Dan,
>
> could you please check the following variables:
>
> org-tab-first-hook
,----
| org-tab-first-hook is a variable defined in `org.el'.
| Its value is
| (org-insert-link-maybe org-hide-block-toggle-maybe)
`----
OK, that was it, thanks. I had
(add-hook 'org-tab-first-hook 'org-insert-link-maybe)
I believe org-insert-link-maybe (code below) is something that Eric
threw together: am I right in thinking it has not been incorporated into
org core?
In any case, could someone help me with the regexp problem I encountered
when I tried to improve it? Here's the original version
--8<---------------cut here---------------start------------->8---
(defun org-insert-link-maybe ()
"insert a file link depending on the context"
(interactive)
(let ((case-fold-search t))
(if (save-excursion
(when (re-search-backward "[[:space:]]" nil t) (forward-char 1)
(looking-at "\\[?\\[?file:?")))
(progn (replace-match "") (org-insert-link '(4)) t)
nil)))
--8<---------------cut here---------------end--------------->8---
I want to (a) restrict it to looking at the current line and (b) not
allow it to match words like 'filepath'. This seems to be almost there
--8<---------------cut here---------------start------------->8---
(defun org-insert-link-maybe ()
"insert a file link depending on the context"
(interactive)
(let ((case-fold-search t))
(if (save-excursion
(backward-word)
(looking-at "\\[?\\[?file:?[ \t\n\f\v\r]"))
(progn (replace-match "") (org-insert-link '(4)) t)
nil)))
--8<---------------cut here---------------end--------------->8---
But this doesn't match 'file' followed by end-of-buffer. I want a
character class that matches any of
{space,tab,newline,end-of-buffer}. How do I do that? It seems that
although "\\'" matches end-of-buffer, it doesn't work in a character
class ("[\\']")?
Dan
>
> Probably one of these contains a function that will do file link
> completion.
>
> - Carsten
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2009-08-12 16:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-11 20:29 overzealous file link creation Dan Davison
2009-08-11 21:36 ` Nick Dokos
2009-08-12 7:52 ` Manish
2009-08-12 8:32 ` Carsten Dominik
2009-08-12 8:30 ` Carsten Dominik
2009-08-12 16:09 ` Dan Davison [this message]
2009-08-12 16:42 ` Carsten Dominik
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=871vnhypy8.fsf@stats.ox.ac.uk \
--to=davison@stats.ox.ac.uk \
--cc=carsten.dominik@gmail.com \
--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).