From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: overzealous file link creation Date: Wed, 12 Aug 2009 12:09:03 -0400 Message-ID: <871vnhypy8.fsf@stats.ox.ac.uk> References: <87ws5aozzv.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MbGO4-0003G5-Cw for emacs-orgmode@gnu.org; Wed, 12 Aug 2009 12:09:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MbGNz-0003EN-MV for emacs-orgmode@gnu.org; Wed, 12 Aug 2009 12:09:15 -0400 Received: from [199.232.76.173] (port=35392 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MbGNz-0003EH-9n for emacs-orgmode@gnu.org; Wed, 12 Aug 2009 12:09:11 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:33887) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MbGNx-0008U7-Py for emacs-orgmode@gnu.org; Wed, 12 Aug 2009 12:09:10 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: emacs org-mode mailing list Carsten Dominik 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