* Fast linking to files in private git repos through a hyperlink
@ 2012-04-19 11:24 Dov Grobgeld
2012-04-19 18:49 ` Karl Voit
2012-04-20 12:01 ` Bastien
0 siblings, 2 replies; 7+ messages in thread
From: Dov Grobgeld @ 2012-04-19 11:24 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 2007 bytes --]
I thought I would share the following hack that I did with git.
In my org-mode notebook I often find myself references files that reside in
various private git repos. So far I have referenced these either by just
writing their name or giving a full path. But giving the full path is
disruptive and if the repo moves it will no longer work. So I added a hack
to make the following hyperlink work git:myrepo::myfile . When opening it
the following happens:
- myrepo is looked up in the emacs hash my-git-repos and mapped to the path
of a git repo root.
- git-find-file-in-repo searches for the the file myfile in the the repo
repo
Here's the code for org-git-hyperlink.el:
(require 'org)
(org-add-link-type "git" 'org-git-hyperlink-open)
(defun org-git-hyperlink-open (path)
"Visit the file in learning-git"
(let* ((parts (split-string path "::"))
(repo-name (car parts))
(filename (cadr parts))
(repo (gethash repo-name my-git-repos))
)
(git-find-file-in-repo repo filename)))
(org-git-hyperlink-open "learning::PointPatternMatching.py")
;;; org-learning.el ends here
(provide 'org-git-hyperlink)
;;; org-git-hyperlink.el ends here
The code for git-find-file-in-repo is here:
https://github.com/hjz/emacs/blob/master/jz/git-find-file.el
with the following addition:
(defun git-find-file-in-repo (root file-name)
"Prompt with a completing list of all files in the project to find one."
(interactive)
(let* ((project-files (ffip-project-files root))
(files (delete-dups (mapcar 'car project-files)))
(file-paths (delq 'nil (mapcar '(lambda (file-cons)
(when (string= file-name (car
file-cons))
(cdr file-cons)))
project-files)))
(file-path (if (cdr file-paths)
(ffip-completing-read "Disambiguate: " file-paths)
(car file-paths))))
(find-file (concat root file-path))))
Regards,
Dov
[-- Attachment #2: Type: text/html, Size: 2602 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fast linking to files in private git repos through a hyperlink
2012-04-19 11:24 Fast linking to files in private git repos through a hyperlink Dov Grobgeld
@ 2012-04-19 18:49 ` Karl Voit
2012-04-20 12:01 ` Bastien
1 sibling, 0 replies; 7+ messages in thread
From: Karl Voit @ 2012-04-19 18:49 UTC (permalink / raw)
To: emacs-orgmode
* Dov Grobgeld <dov.grobgeld@gmail.com> wrote:
>
> I thought I would share the following hack that I did with git.
>
> In my org-mode notebook I often find myself references files that reside in
> various private git repos. So far I have referenced these either by just
> writing their name or giving a full path. But giving the full path is
> disruptive and if the repo moves it will no longer work. So I added a hack
> to make the following hyperlink work git:myrepo::myfile . When opening it
> the following happens:
>
> - myrepo is looked up in the emacs hash my-git-repos and mapped to the path
> of a git repo root.
> - git-find-file-in-repo searches for the the file myfile in the the repo
> repo
Cool hack! :-)
You might be interested in looking at the git-module of Memacs[1].
It puts your commits into your Agenda if you want. And for this
purpose it already holds a list of your local repositories. But this
list is generated using shell scripts - Sorry no ELISP here.
I do think both solutions could go well together ...
1. https://github.com/novoid/Memacs
--
Karl Voit
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fast linking to files in private git repos through a hyperlink
2012-04-19 11:24 Fast linking to files in private git repos through a hyperlink Dov Grobgeld
2012-04-19 18:49 ` Karl Voit
@ 2012-04-20 12:01 ` Bastien
2012-04-21 21:19 ` Dov Grobgeld
1 sibling, 1 reply; 7+ messages in thread
From: Bastien @ 2012-04-20 12:01 UTC (permalink / raw)
To: Dov Grobgeld; +Cc: emacs-orgmode
Hi Dov,
Dov Grobgeld <dov.grobgeld@gmail.com> writes:
> I thought I would share the following hack that I did with git.
>
> In my org-mode notebook I often find myself references files that
> reside in various private git repos. So far I have referenced these
> either by just writing their name or giving a full path. But giving
> the full path is disruptive and if the repo moves it will no longer
> work. So I added a hack to make the following hyperlink work
> git:myrepo::myfile . When opening it the following happens:
>
> - myrepo is looked up in the emacs hash my-git-repos and mapped to
> the path of a git repo root.
> - git-find-file-in-repo searches for the the file myfile in the the
> repo repo
>
> Here's the code for org-git-hyperlink.el:
Nice.
Can you try to merge these features with contrib/lisp/org-git-link.el
from the current repo?
Thanks!
--
Bastien
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fast linking to files in private git repos through a hyperlink
2012-04-20 12:01 ` Bastien
@ 2012-04-21 21:19 ` Dov Grobgeld
2012-04-26 14:00 ` Bastien
0 siblings, 1 reply; 7+ messages in thread
From: Dov Grobgeld @ 2012-04-21 21:19 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1449 bytes --]
Thanks for the link. I wasn't aware of that package. I see that I have a
conflict in syntax as I used double colon for indicating the git repo while
org-git-link.el used double colon for search pattern. Thus to join the
packages I need to change the syntax. Which of the following would make
more sense:
git:@repo:file-in-repo::pattern-in-file
git://repo/file-in-repo::pattern-in-file
or perhaps some other syntax? Suggestions?
Regards,
Dov
On Fri, Apr 20, 2012 at 15:01, Bastien <bzg@altern.org> wrote:
> Hi Dov,
>
> Dov Grobgeld <dov.grobgeld@gmail.com> writes:
>
> > I thought I would share the following hack that I did with git.
> >
> > In my org-mode notebook I often find myself references files that
> > reside in various private git repos. So far I have referenced these
> > either by just writing their name or giving a full path. But giving
> > the full path is disruptive and if the repo moves it will no longer
> > work. So I added a hack to make the following hyperlink work
> > git:myrepo::myfile . When opening it the following happens:
> >
> > - myrepo is looked up in the emacs hash my-git-repos and mapped to
> > the path of a git repo root.
> > - git-find-file-in-repo searches for the the file myfile in the the
> > repo repo
> >
> > Here's the code for org-git-hyperlink.el:
>
> Nice.
>
> Can you try to merge these features with contrib/lisp/org-git-link.el
> from the current repo?
>
> Thanks!
>
> --
> Bastien
>
[-- Attachment #2: Type: text/html, Size: 2086 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fast linking to files in private git repos through a hyperlink
2012-04-21 21:19 ` Dov Grobgeld
@ 2012-04-26 14:00 ` Bastien
2012-04-26 18:06 ` Dov Grobgeld
0 siblings, 1 reply; 7+ messages in thread
From: Bastien @ 2012-04-26 14:00 UTC (permalink / raw)
To: Dov Grobgeld; +Cc: emacs-orgmode
Hi Dov,
Dov Grobgeld <dov.grobgeld@gmail.com> writes:
> Thanks for the link. I wasn't aware of that package. I see that I
> have a conflict in syntax as I used double colon for indicating the
> git repo while org-git-link.el used double colon for search pattern.
The double colon is standard in Org for indicating the search pattern,
please use it this way too.
> Thus to join the packages I need to change the syntax. Which of the
> following would make more sense:
>
> git:@repo:file-in-repo::pattern-in-file
> git://repo/file-in-repo::pattern-in-file
>
> or perhaps some other syntax? Suggestions?
git:[user@?][repo-server]:[git-repo-itself]::[search-pattern]
When user is set, the repo-server URL won't have a protocol
(git will be used by default as a protocol.)
When user is not set, the repo-server may contain git:// or
http:// as the protocol.
But I didn't test your packing, so I'm maybe shooting in the
dark for this syntax suggestion.
HTH,
--
Bastien
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fast linking to files in private git repos through a hyperlink
2012-04-26 14:00 ` Bastien
@ 2012-04-26 18:06 ` Dov Grobgeld
2012-04-26 18:32 ` Samuel Wales
0 siblings, 1 reply; 7+ messages in thread
From: Dov Grobgeld @ 2012-04-26 18:06 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 2170 bytes --]
Thanks for your suggestion Bastien, but unfortunately it does not directly
map to the shortcut that I implemented in my package. In my *old* syntax:
git:repo::file.txt
file.txt is a search pattern for a *file* with in the symbolic repo "repo"
which maps to a real repo through the hash variable my-org-repos. The whole
idea was that I wanted to be able to use the symbolic name as a shortcut.
In addition file.txt is not the path of a file in the repo, but a search
pattern for a file in the repo. In case of duplicates the user is prompted
to interactively resolve the file. In addition I would also like to add a
search pattern for a string in the file.
My problem is how to merge this syntax with the org-git-link.el which uses
the syntax
git:/home/user/repo/data/results.png::nobelprize
where /home/.../results.png is the name of the path to a file and
nobelprize is the name of a tag.
Both my linking and the org-git-linking are two different equally valid use
cases. My problem is how to merge both these use cases under a single
syntax.
Regards,
Dov
On Thu, Apr 26, 2012 at 17:00, Bastien <bzg@gnu.org> wrote:
> Hi Dov,
>
> Dov Grobgeld <dov.grobgeld@gmail.com> writes:
>
> > Thanks for the link. I wasn't aware of that package. I see that I
> > have a conflict in syntax as I used double colon for indicating the
> > git repo while org-git-link.el used double colon for search pattern.
>
> The double colon is standard in Org for indicating the search pattern,
> please use it this way too.
>
> > Thus to join the packages I need to change the syntax. Which of the
> > following would make more sense:
> >
> > git:@repo:file-in-repo::pattern-in-file
> > git://repo/file-in-repo::pattern-in-file
> >
> > or perhaps some other syntax? Suggestions?
>
> git:[user@?][repo-server]:[git-repo-itself]::[search-pattern]
>
> When user is set, the repo-server URL won't have a protocol
> (git will be used by default as a protocol.)
>
> When user is not set, the repo-server may contain git:// or
> http:// as the protocol.
>
> But I didn't test your packing, so I'm maybe shooting in the
> dark for this syntax suggestion.
>
> HTH,
>
> --
> Bastien
>
[-- Attachment #2: Type: text/html, Size: 2980 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fast linking to files in private git repos through a hyperlink
2012-04-26 18:06 ` Dov Grobgeld
@ 2012-04-26 18:32 ` Samuel Wales
0 siblings, 0 replies; 7+ messages in thread
From: Samuel Wales @ 2012-04-26 18:32 UTC (permalink / raw)
To: Dov Grobgeld; +Cc: Bastien, emacs-orgmode
I imagine git allows a lot of opportunities for more features that we
would want in such a link. Perhaps a more general, flexible, lispy
keyword-style syntax would be useful here? Or handle with different
link types and shunt off to a git call?
--
The Kafka Pandemic: http://thekafkapandemic.blogspot.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-04-26 18:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-19 11:24 Fast linking to files in private git repos through a hyperlink Dov Grobgeld
2012-04-19 18:49 ` Karl Voit
2012-04-20 12:01 ` Bastien
2012-04-21 21:19 ` Dov Grobgeld
2012-04-26 14:00 ` Bastien
2012-04-26 18:06 ` Dov Grobgeld
2012-04-26 18:32 ` Samuel Wales
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).