On Aug 12, 2009, at 6:09 PM, Dan Davison wrote:
Carsten Dominik <carsten.domi...@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 ("[\\']")?
"\\(?:[ \t\n]\\|\\'\\)"
HTH
- 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