emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* globbing file links
@ 2018-06-27  1:50 Samuel Wales
  2018-07-01 14:19 ` John Kitchin
  0 siblings, 1 reply; 2+ messages in thread
From: Samuel Wales @ 2018-06-27  1:50 UTC (permalink / raw)
  To: emacs-orgmode

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?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: globbing file links
  2018-06-27  1:50 globbing file links Samuel Wales
@ 2018-07-01 14:19 ` John Kitchin
  0 siblings, 0 replies; 2+ messages in thread
From: John Kitchin @ 2018-07-01 14:19 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

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 <samologist@gmail.com> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-01 14:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-27  1:50 globbing file links Samuel Wales
2018-07-01 14:19 ` John Kitchin

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).