Commit c577d1f82f75
Changed files (5)
config/setup-org.el
@@ -193,24 +193,25 @@
:config
(setq org-link-abbrev-alist '(("att" . org-attach-expand-link))))
+;; my personal
+(use-package ol-github
+ :after (org))
+(use-package ol-gitlab
+ :after (org))
+
+;; built-in org-mode
(use-package ol-eshell
:after (org))
-
(use-package ol-git-link
:after (org))
-
(use-package ol-gnus
:after (org))
-
(use-package ol-irc
:after (org))
-
(use-package ol-info
:after (org))
-
(use-package ol-man
:after (org))
-
(use-package ol-notmuch
:after (org))
@@ -478,33 +479,6 @@ like this : [[pt:REGEXP:FOLDER]]"
(ripgrep-regexp exp (file-name-as-directory (expand-file-name folder)))))
)
- (org-link-set-parameters "gh"
- :follow #'vde/follow-gh-link
- :export #'vde/org-gh-export
- :face '(:foreground "DimGrey" :underline t))
- (defun vde/org-gh-export (link description format)
- "Export a github page link from Org files."
- (let ((path (vde/gh-get-url link))
- (desc (or description link)))
- (cond
- ((eq format 'html) (format "<a hrefl=\"_blank\" href=\"%s\">%s</a>" path desc))
- ((eq format 'latex) (format "\\href{%s}{%s}" path desc))
- ((eq format 'texinfo) (format "@uref{%s,%s}" path desc))
- ((eq format 'ascii) (format "%s (%s)" desc path))
- (t path))))
- (defun vde/follow-gh-link (issue)
- "Browse github issue/pr specified"
- (browse-url (vde/gh-get-url issue)))
-
- (defun vde/gh-get-url (path)
- "Translate org-mode link `gh:foo/bar#1' to github url."
- (setq expressions (split-string path "#"))
- (setq project (nth 0 expressions))
- (setq issue (nth 1 expressions))
- (if issue
- (format "https://github.com/%s/issues/%s" project issue)
- (format "https://github.com/%s" project)))
-
(org-link-set-parameters
"org"
:complete (lambda () (+org-link-read-file "org" org-directory))
lisp/ol-github.el
@@ -0,0 +1,67 @@
+;;; ol-github.el --- Links to GitHub -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2020 Vincent Demeester
+
+;; Author: Vincent Demeester <vincent@sbr.pm>
+;; Keywords: org link github
+;;
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 3.0, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Commentary:
+
+;; This file implements links to GitHub from within Org mode.
+;; gh:tektoncd/pipeline : project
+;; gh:tektoncd/pipeline#1 : issue or pr #1
+
+;;; Code:
+
+(require 'ol)
+
+;; Install the link type
+(org-link-set-parameters "gh"
+ :follow #'org-github-follow-link
+ :export #'org-github-export
+ :face '(:foreground "DimGrey" :underline t))
+
+
+(defun org-github-export (link description format)
+ "Export a github page link from Org files."
+ (let ((path (org-github-get-url link))
+ (desc (or description link)))
+ (cond
+ ((eq format 'html) (format "<a hrefl=\"_blank\" href=\"%s\">%s</a>" path desc))
+ ((eq format 'latex) (format "\\href{%s}{%s}" path desc))
+ ((eq format 'texinfo) (format "@uref{%s,%s}" path desc))
+ ((eq format 'ascii) (format "%s (%s)" desc path))
+ (t path))))
+
+(defun org-github-follow-link (issue)
+ "Browse github issue/pr specified."
+ (browse-url (org-github-get-url issue)))
+
+(defun org-github-get-url (path)
+ "Translate org-mode link `gh:foo/bar#1' to github url."
+ (setq expressions (split-string path "#"))
+ (setq project (nth 0 expressions))
+ (setq issue (nth 1 expressions))
+ (if issue
+ (format "https://github.com/%s/issues/%s" project issue)
+ (format "https://github.com/%s" project)))
+
+(provide 'ol-github)
+;;; ol-github.el ends here
lisp/ol-gitlab.el
@@ -0,0 +1,78 @@
+;;; ol-gitlab.el --- Links to Gitlab -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2020 Vincent Demeester
+
+;; Author: Vincent Demeester <vincent@sbr.pm>
+;; Keywords: org link gitlab
+;;
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 3.0, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Commentary:
+
+;; This file implements links to Gitlab from within Org mode.
+;; gl:vdemeester/emacs-config : project
+;; gl:vdemeester/emacs-config#1 : issue #1
+;; gl:vdemeester/emacs-config##1 : merge-request #1
+
+;;; Code:
+
+(require 'ol)
+
+;; Install the link type
+(org-link-set-parameters "gl"
+ :follow #'org-gitlab-follow-link
+ :export #'org-gitlab-export
+ :face '(:foreground "DimGrey" :underline t))
+
+
+(defun org-gitlab-export (link description format)
+ "Export a gitlab page link from Org files."
+ (let ((path (org-gitlab-get-url link))
+ (desc (or description link)))
+ (cond
+ ((eq format 'html) (format "<a hrefl=\"_blank\" href=\"%s\">%s</a>" path desc))
+ ((eq format 'latex) (format "\\href{%s}{%s}" path desc))
+ ((eq format 'texinfo) (format "@uref{%s,%s}" path desc))
+ ((eq format 'ascii) (format "%s (%s)" desc path))
+ (t path))))
+
+(defun org-gitlab-follow-link (issue)
+ "Browse gitlab issue/pr specified."
+ (browse-url (org-gitlab-get-url issue)))
+
+(defun org-gitlab-get-url (path)
+ "Translate org-mode link `gh:foo/bar#1' to gitlab url."
+ (setq expressions (split-string path "#"))
+ (setq project (nth 0 expressions))
+ (setq issue (nth 1 expressions))
+ (setq mr (nth 2 expressions))
+ (message (format "issue: %s" issue))
+ (message (format "mr: %s" mr))
+ (if (not (empty-string-p mr))
+ (format "https://gitlab.com/%s/-/merge_requests/%s" project mr)
+ (if (not (empty-string-p issue))
+ (format "https://gitlab.com/%s/-/issues/%s" project issue)
+ (format "https://gitlab.com/%s" project))))
+
+(defun empty-string-p (string)
+ "Return true if the STRING is empty or nil. Expects string type."
+ (or (null string)
+ (zerop (length (string-trim string)))))
+
+(provide 'ol-gitlab)
+;;; ol-gitlab.el ends here
emacs.org
@@ -1079,38 +1079,26 @@
(setq org-link-abbrev-alist '(("att" . org-attach-expand-link))))
#+end_src
-
#+begin_src emacs-lisp
+;; my personal
+(use-package ol-github
+ :after (org))
+(use-package ol-gitlab
+ :after (org))
+
+;; built-in org-mode
(use-package ol-eshell
:after (org))
-#+end_src
-
-#+begin_src emacs-lisp
(use-package ol-git-link
:after (org))
-#+end_src
-
-#+begin_src emacs-lisp
(use-package ol-gnus
:after (org))
-#+end_src
-
-#+begin_src emacs-lisp
(use-package ol-irc
:after (org))
-#+end_src
-
-#+begin_src emacs-lisp
(use-package ol-info
:after (org))
-#+end_src
-
-#+begin_src emacs-lisp
(use-package ol-man
:after (org))
-#+end_src
-
-#+begin_src emacs-lisp
(use-package ol-notmuch
:after (org))
#+end_src
@@ -3535,33 +3523,6 @@
(ripgrep-regexp exp (file-name-as-directory (expand-file-name folder)))))
)
- (org-link-set-parameters "gh"
- :follow #'vde/follow-gh-link
- :export #'vde/org-gh-export
- :face '(:foreground "DimGrey" :underline t))
- (defun vde/org-gh-export (link description format)
- "Export a github page link from Org files."
- (let ((path (vde/gh-get-url link))
- (desc (or description link)))
- (cond
- ((eq format 'html) (format "<a hrefl=\"_blank\" href=\"%s\">%s</a>" path desc))
- ((eq format 'latex) (format "\\href{%s}{%s}" path desc))
- ((eq format 'texinfo) (format "@uref{%s,%s}" path desc))
- ((eq format 'ascii) (format "%s (%s)" desc path))
- (t path))))
- (defun vde/follow-gh-link (issue)
- "Browse github issue/pr specified"
- (browse-url (vde/gh-get-url issue)))
-
- (defun vde/gh-get-url (path)
- "Translate org-mode link `gh:foo/bar#1' to github url."
- (setq expressions (split-string path "#"))
- (setq project (nth 0 expressions))
- (setq issue (nth 1 expressions))
- (if issue
- (format "https://github.com/%s/issues/%s" project issue)
- (format "https://github.com/%s" project)))
-
(org-link-set-parameters
"org"
:complete (lambda () (+org-link-read-file "org" org-directory))
@@ -4603,7 +4564,7 @@
:CUSTOM_ID: h:bd8804a0-df0e-4aca-b748-429ea9402cd6
:END:
-#+INCLUDE: "lisp/use-package-list.el" src lisp/use-package-list.el
+#+INCLUDE: "lisp/use-package-list.el" src emacs-lisp
** ~gotest-ui.el~
:PROPERTIES:
@@ -4612,7 +4573,24 @@
From [[https://github.com/antifuchs/gotest-ui-mode/][antifuchs/gotest-ui-mode]].
-#+INCLUDE: "lisp/gotest-ui.el" src lisp/gotest-ui.el
+#+INCLUDE: "lisp/gotest-ui.el" src emacs-lisp
+
+** Org mode links
+:PROPERTIES:
+:CUSTOM_ID: h:80cc4939-759a-456b-8dfd-220dd8b48727
+:END:
+
+I am defining additonal org-mode links for my day to day usage.
+
+- ~ol-github.el~: link to GitHub repositories, issues and pull-requests.
+
+ #+INCLUDE: "lisp/ol-github.el" src emacs-lisp
+
+- ~ol-gitlab.el~: link to GitLab repositories, issues and merge-requests.
+
+ #+INCLUDE: "lisp/ol-gitlab.el" src emacs-lisp
+
+More to comesโฆ
* Local Variables
:PROPERTIES:
publish.org
@@ -7,11 +7,16 @@
First let's import required libraries, which are =org= related.
#+begin_src emacs-lisp :tangle yes
- (require 'org)
- (require 'ox)
- (require 'ox-publish)
- (require 'ol-man)
- (require 'ol-git-link)
+;; Add my personal libraries ๐
+(add-to-list 'load-path (concat user-emacs-directory "lisp/"))
+
+(require 'org)
+(require 'ox)
+(require 'ox-publish)
+(require 'ol-man)
+(require 'ol-git-link)
+(require 'ol-github)
+(require 'ol-gitlab)
#+end_src
To get syntax coloring on other mode than ~emacs-lisp~, we need to load them too[fn:1].
@@ -145,33 +150,6 @@
(ripgrep-regexp exp (file-name-as-directory (expand-file-name folder)))))
)
- (org-link-set-parameters "gh"
- :follow #'vde/follow-gh-link
- :export #'vde/org-gh-export
- :face '(:foreground "DimGrey" :underline t))
- (defun vde/org-gh-export (link description format)
- "Export a github page link from Org files."
- (let ((path (vde/gh-get-url link))
- (desc (or description link)))
- (cond
- ((eq format 'html) (format "<a hrefl=\"_blank\" href=\"%s\">%s</a>" path desc))
- ((eq format 'latex) (format "\\href{%s}{%s}" path desc))
- ((eq format 'texinfo) (format "@uref{%s,%s}" path desc))
- ((eq format 'ascii) (format "%s (%s)" desc path))
- (t path))))
- (defun vde/follow-gh-link (issue)
- "Browse github issue/pr specified"
- (browse-url (vde/gh-get-url issue)))
-
- (defun vde/gh-get-url (path)
- "Translate org-mode link `gh:foo/bar#1' to github url."
- (setq expressions (split-string path "#"))
- (setq project (nth 0 expressions))
- (setq issue (nth 1 expressions))
- (if issue
- (format "https://github.com/%s/issues/%s" project issue)
- (format "https://github.com/%s" project)))
-
(org-link-set-parameters
"org"
:complete (lambda () (+org-link-read-file "org" org-directory))