From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: globbing file links Date: Sun, 01 Jul 2018 07:19:59 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZdCw-0000pd-OX for emacs-orgmode@gnu.org; Sun, 01 Jul 2018 10:20:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZdCt-0002v7-9c for emacs-orgmode@gnu.org; Sun, 01 Jul 2018 10:20:06 -0400 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]:45085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZdCt-0002uj-3P for emacs-orgmode@gnu.org; Sun, 01 Jul 2018 10:20:03 -0400 Received: by mail-pf0-x22d.google.com with SMTP id y24-v6so2035317pfe.12 for ; Sun, 01 Jul 2018 07:20:02 -0700 (PDT) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Samuel Wales Cc: emacs-orgmode@gnu.org This could be useful. Here is something close. It does not use dired-virtual. I couldn't figure out how to generate the ls -lR like listing for each file, but if you know how to do that it should be straightforward to modify. #+BEGIN_SRC emacs-lisp (defun glob-follow (path) (interactive) (let ((files (directory-files-recursively "." path))) (if (= 1 (length files)) (find-file (car files)) (pop-to-buffer (get-buffer-create "*org-glob*")) (erase-buffer) (org-mode) (insert (cl-loop for file in files concat (format "[[./%s]]\n" (file-relative-name file "."))))))) (org-link-set-parameters "glob" :follow 'glob-follow) #+END_SRC Here is an example usage: [[glob:.org$]] Samuel Wales writes: > i frequently have broken file: links. this might reduce their occurrence. > > i'd like to be able to do this: > > file:.../**/myfile > > which would use bash's globbing mechanism or an elisp equivalent. > > also perhaps this: > > file:.../**/*myfile* > > if one file results, i would like it to open as normal. if more than > one file results, i would like all of them to open in a dired-virtual > buffer. i think dired-virtual is in core. > > the first case would prevent broken links by allowing myfile to be > moved as long as it is under .... > > the second case would allow you to select a bunch of files that have a > common substring. it would also prevent broken links by allowing > myfile to be renamed slightly [such as compressed or uncompressed]. > > i think broken links are likely a common problem for org users. maybe > this can help prevent it. > > does this sound like a good idea as an optional feature? > > if no, then what would be a good implementation of a glob: link? -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu