Re: [final patch] Re: add new link type "contact:" for org-contacts.el

2021-04-24 Thread Timothy


I'm afraid it looks like I either made a typo while doing this, or
something odd happened. Regardless it didn't work correctly.

Take 2, sorry for the noise --- but at least the patch section on
updates.orgmode.org should be more useful now as it only shows pending
patches again.

Timothy  writes:

> This was not marked as applied on updates.orgmode.org.
> Doing so with the X-Woof-Patch header.
>
> Bastien  writes:
>
>> Of course, done (c822c80ef).
>>
>> Sorry I forgot about this patch, and thanks for your reply.



Re: [final patch] Re: add new link type "contact:" for org-contacts.el

2021-04-24 Thread Timothy


This was not marked as applied on updates.orgmode.org.
Doing so with the X-Woof-Patch header.

Bastien  writes:

> Of course, done (c822c80ef).
>
> Sorry I forgot about this patch, and thanks for your reply.



Re: [final patch] Re: add new link type "contact:" for org-contacts.el

2020-12-15 Thread Bastien
stardiviner  writes:

> If this is confirmed, I might don't need to add a new patch to add my
> name to maintainer. Can you add it directly? That will be more
> simple.

Of course, done (c822c80ef).

Sorry I forgot about this patch, and thanks for your reply.

-- 
 Bastien



Re: [final patch] Re: add new link type "contact:" for org-contacts.el

2020-12-15 Thread stardiviner
Thanks for reviewing.

Don't know why, it's been applied in the "master" branch already by you. (I
did git pull from upstream)
Here is the commit:
e9c3993ee * | org-contacts.el: Add new link type "contact:"

If this is confirmed, I might don't need to add a new patch to add my name
to maintainer. Can you add it directly? That will be more simple.

[stardiviner] GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/


On Tue, Dec 15, 2020 at 5:56 PM Bastien  wrote:

> stardiviner  writes:
>
> > My patch still in the previous "[UPDATED PATCH]" state. (I attached
> > in this email)
>
> Thanks.  It applies correctly on the maint branch but I'd rather apply
> it againt the master branch, where it fails to apply.
>
> Can you replay your changes on top of the main branch, and also add
> your name as the maintainer?
>
> Thanks a lot!
>
> --
>  Bastien
>


Re: [final patch] Re: add new link type "contact:" for org-contacts.el

2020-12-15 Thread Bastien
stardiviner  writes:

> My patch still in the previous "[UPDATED PATCH]" state. (I attached
> in this email)

Thanks.  It applies correctly on the maint branch but I'd rather apply
it againt the master branch, where it fails to apply.

Can you replay your changes on top of the main branch, and also add
your name as the maintainer?

Thanks a lot!

-- 
 Bastien



[final patch] Re: add new link type "contact:" for org-contacts.el

2020-12-15 Thread stardiviner
My patch still in the previous "[UPDATED PATCH]" state. (I attached in this
email)

I can take a try to be the maintainer for org-contacts.el
Seems it's not very frequently mentioned. So I don't spend too much time on
it.

[stardiviner] GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/


On Mon, Dec 14, 2020 at 2:06 PM Bastien  wrote:

> Hi stardiviner,
>
> what is the last state of your patch?  Feel free to resend it,
> I will apply it.
>
> Also, do you want to become the maintainer for org-contacts.el?
>
> Remember, elisp files in contrib/ will soon be extracted from
> the repository: https://orgmode.org/list/87wnzfy60h@bzg.fr
>
> Still, it's useful to already know who will be in charge.
>
> Thanks,
>
> --
>  Bastien
>
From 7446c0dda49554db0af18401984d20b9b460d408 Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Fri, 30 Oct 2020 15:11:53 +0800
Subject: [PATCH] org-contacts.el: Add new link type "contact:"

* contrib/lisp/org-contacts.el (org-contacts-link-store): Store a link
of org-contacts in Org file.

* contrib/lisp/org-contacts.el (org-contacts-link-open): Open contact:
link in Org file.

* contrib/lisp/org-contacts.el (org-contacts-link-complete): Insert a
contact: link with completion of contacts.

* contrib/lisp/org-contacts.el (org-contacts-link-face): Set different
face for contact: link.
---
 contrib/lisp/org-contacts.el | 75 
 1 file changed, 75 insertions(+)

diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index 4b3693a0e..d8d498425 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -1146,6 +1146,81 @@ (defun org-contacts-split-property (string  separators omit-nulls)
 (setq proplist (cons bufferstring proplist
 (cdr (reverse proplist
 
+;;; Add an Org link type `org-contact:' for easy jump to or searching org-contacts headline.
+;;; link spec: [[org-contact:query][desc]]
+(org-link-set-parameters "org-contact"
+			 :follow 'org-contacts-link-open
+			 :complete 'org-contacts-link-complete
+			 :store 'org-contacts-link-store
+			 :face 'org-contacts-link-face)
+
+(defun org-contacts-link-store ()
+  "Store the contact in `org-contacts-files' with a link."
+  (when (eq major-mode 'org-mode)
+;; (member (buffer-file-name) (mapcar 'expand-file-name org-contacts-files))
+(let ((headline-str (substring-no-properties (org-get-heading t t t t
+  (org-store-link-props
+   :type "org-contact"
+   :link headline-str
+   :description headline-str
+
+(defun org-contacts--all-contacts ()
+  "Return an alist (name . (file . position)) of all contacts in `org-contacts-files'."
+  (car (mapcar
+	(lambda (file)
+	  (unless (buffer-live-p (get-buffer (file-name-nondirectory file)))
+	(find-file file))
+	  (with-current-buffer (get-buffer (file-name-nondirectory file))
+	(org-map-entries
+	 (lambda ()
+	   (let ((name (substring-no-properties (org-get-heading t t t t)))
+		 (file (buffer-file-name))
+		 (position (point)))
+		 `(:name ,name :file ,file :position ,position))
+	org-contacts-files)))
+
+(defun org-contacts-link-open (path)
+  "Open contacts: link type with jumping or searching."
+  (let ((query path))
+(cond
+ ((string-match "/.*/" query)
+  (let* ((f (car org-contacts-files))
+	 (buf (get-buffer (file-name-nondirectory f
+	(unless (buffer-live-p buf) (find-file f))
+	(with-current-buffer buf
+	  (string-match "/\\(.*\\)/" query)
+	  (occur (match-string 1 query)
+ (t
+  (let* ((f (car org-contacts-files))
+	 (buf (get-buffer (file-name-nondirectory f
+	(unless (buffer-live-p buf) (find-file f))
+	(with-current-buffer buf
+	  (goto-char (marker-position (org-find-exact-headline-in-buffer query)
+  ;; FIXME
+  ;; (let* ((contact-entry (plist-get (org-contacts--all-contacts) query))
+  ;; 	 (contact-name (plist-get contact-entry :name))
+  ;; 	 (file (plist-get contact-entry :file))
+  ;; 	 (position (plist-get contact-entry :position))
+  ;; 	 (buf (get-buffer (file-name-nondirectory file
+  ;; 	(unless (buffer-live-p buf) (find-file file))
+  ;; 	(with-current-buffer buf (goto-char position)))
+  
+
+(defun org-contacts-link-complete ( arg)
+  "Create a org-contacts link using completion."
+  (let ((name (completing-read "org-contact Name: "
+			   (mapcar
+(lambda (plist) (plist-get plist :name))
+(org-contacts--all-contacts)
+(concat "org-contact:" name)))
+
+(defun org-contacts-link-face (path)
+  "Different face color for different org-contacts link query."
+  (cond
+   ((string-match "/.*/" path)
+'(:background "sky blue" :overline t :slant 'italic))
+   (t '(:background "green yellow" :underline t
+
 (provide 'org-contacts)