emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add a custom list in org-mac-link.el
@ 2017-06-11  8:25 Takaaki Ishikawa
  2017-06-14 16:37 ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Takaaki Ishikawa @ 2017-06-11  8:25 UTC (permalink / raw)
  To: orgmode list


[-- Attachment #1.1: Type: text/plain, Size: 1658 bytes --]

Dear folks,

The attached patch includes a change for adding a custom variable to easily
extend link grabbing capabilities for masOS user. When someone wants to add
an additional menu to call an external application, it will be possible by
adding a setting to the proposed variable as follows:

#+BEGIN_SRC emacs-lisp
(add-to-list 'org-mac-link-descriptors
               `("P" "apers" org-mac-papers-insert-frontmost-paper-link
,org-mac-grab-Papers-app-p) t)
#+END_SRC

This example intends to handle Papers.app, not freeware[*1], in macOS. If
`org-mac-papers-insert-frontmost-paper-link' and `mac-grab-Papers-app-p'
are implemented by user correctly, an appropriate link will be inserted
into an org buffer. I don't want put such codes to `org-mac-link.el'
directly to avoid unnecessary increase of file size. This scenario can be
applied to other applications.

The inserted link can be opened by `C-c C-o' if the corresponding link type
is configured by `org-link-set-parameters' like the following.

#+BEGIN_SRC emacs-lisp
(org-link-set-parameters
       "papers3"
       :follow (lambda (path)
                 (let ((cmd (concat "open papers3:" path)))
                   (shell-command-to-string cmd)
                   (message "%s" cmd))))
#+END_SRC

===================================================
* contrib/lisp/org-mac-link.el: Add a custom list for link descriptors

`org-mac-link-descriptors' is added to extend link grabbing capabilities.

Modified from a patch proposal by Takaaki Ishikawa.
===================================================

Kind regards,
Takaaki

[*1] http://papersapp.com/mac/

--
Takaaki ISHIKAWA <takaxp@ieee.org>

[-- Attachment #1.2: Type: text/html, Size: 2457 bytes --]

[-- Attachment #2: org-mac-link.diff --]
[-- Type: text/plain, Size: 3005 bytes --]

diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index 8ba485d..fa424e0 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -217,6 +217,26 @@
   :group 'org-mac-link
   :type 'string)
 
+(defcustom org-mac-link-descriptors
+  `(("F" "inder" org-mac-finder-insert-selected ,org-mac-grab-Finder-app-p)
+    ("m" "ail" org-mac-message-insert-selected ,org-mac-grab-Mail-app-p)
+    ("d" "EVONthink Pro Office" org-mac-devonthink-item-insert-selected
+     ,org-mac-grab-devonthink-app-p)
+    ("o" "utlook" org-mac-outlook-message-insert-selected ,org-mac-grab-Outlook-app-p)
+    ("a" "ddressbook" org-mac-addressbook-insert-selected ,org-mac-grab-Addressbook-app-p)
+    ("s" "afari" org-mac-safari-insert-frontmost-url ,org-mac-grab-Safari-app-p)
+    ("f" "irefox" org-mac-firefox-insert-frontmost-url ,org-mac-grab-Firefox-app-p)
+    ("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p)
+    ("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p)
+    ("e" "evernote" org-mac-evernote-note-insert-selected ,org-mac-grab-Evernote-app-p)
+    ("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p)
+    ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
+    ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p))
+  "Descriptors to select an application."
+  :tag "A list of descriptors"
+  :group 'org-mac-link'
+  :type 'symbol)
+
 \f
 ;; In mac.c, removed in Emacs 23.
 (declare-function do-applescript "org-mac-message" (script))
@@ -238,21 +258,7 @@
   "Prompt for an application to grab a link from.
 When done, go grab the link, and insert it at point."
   (interactive)
-  (let* ((descriptors
-	  `(("F" "inder" org-mac-finder-insert-selected ,org-mac-grab-Finder-app-p)
-	    ("m" "ail" org-mac-message-insert-selected ,org-mac-grab-Mail-app-p)
-	    ("d" "EVONthink Pro Office" org-mac-devonthink-item-insert-selected
-	     ,org-mac-grab-devonthink-app-p)
-	    ("o" "utlook" org-mac-outlook-message-insert-selected ,org-mac-grab-Outlook-app-p)
-	    ("a" "ddressbook" org-mac-addressbook-insert-selected ,org-mac-grab-Addressbook-app-p)
-	    ("s" "afari" org-mac-safari-insert-frontmost-url ,org-mac-grab-Safari-app-p)
-	    ("f" "irefox" org-mac-firefox-insert-frontmost-url ,org-mac-grab-Firefox-app-p)
-	    ("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p)
-	    ("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p)
-            ("e" "evernote" org-mac-evernote-note-insert-selected ,org-mac-grab-Evernote-app-p)
-	    ("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p)
-	    ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
-	    ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p)))
+  (let* ((descriptors org-mac-link-descriptors)
          (menu-string (make-string 0 ?x))
          input)
 

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

* Re: [PATCH] Add a custom list in org-mac-link.el
  2017-06-11  8:25 [PATCH] Add a custom list in org-mac-link.el Takaaki Ishikawa
@ 2017-06-14 16:37 ` Nicolas Goaziou
  2017-06-15 13:56   ` Takaaki Ishikawa
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2017-06-14 16:37 UTC (permalink / raw)
  To: Takaaki Ishikawa; +Cc: orgmode list

Hello,

Takaaki Ishikawa <takaxp@ieee.org> writes:

> The attached patch includes a change for adding a custom variable to easily
> extend link grabbing capabilities for masOS user. When someone wants to add
> an additional menu to call an external application, it will be possible by
> adding a setting to the proposed variable as follows:
>
> #+BEGIN_SRC emacs-lisp
> (add-to-list 'org-mac-link-descriptors
>                `("P" "apers" org-mac-papers-insert-frontmost-paper-link
> ,org-mac-grab-Papers-app-p) t)
> #+END_SRC

Thank you.

Could you provide a patch, using format-patch, with an appropriate
commit message?

Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Add a custom list in org-mac-link.el
  2017-06-14 16:37 ` Nicolas Goaziou
@ 2017-06-15 13:56   ` Takaaki Ishikawa
  2017-06-15 16:32     ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Takaaki Ishikawa @ 2017-06-15 13:56 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: orgmode list


[-- Attachment #1.1: Type: text/plain, Size: 1056 bytes --]

Dear Nicolas and all,

I tried to generate a patch for this proposal. Please find an attached file.
If you have any comments or suggestions on the file, feel free to ask me.

Best,
Takaaki


Takaaki ISHIKAWA <takaxp@ieee.org>
  GITI, Waseda University
    :) http://about.me/takaxp

2017-06-15 1:37 GMT+09:00 Nicolas Goaziou <mail@nicolasgoaziou.fr>:

> Hello,
>
> Takaaki Ishikawa <takaxp@ieee.org> writes:
>
> > The attached patch includes a change for adding a custom variable to
> easily
> > extend link grabbing capabilities for masOS user. When someone wants to
> add
> > an additional menu to call an external application, it will be possible
> by
> > adding a setting to the proposed variable as follows:
> >
> > #+BEGIN_SRC emacs-lisp
> > (add-to-list 'org-mac-link-descriptors
> >                `("P" "apers" org-mac-papers-insert-frontmost-paper-link
> > ,org-mac-grab-Papers-app-p) t)
> > #+END_SRC
>
> Thank you.
>
> Could you provide a patch, using format-patch, with an appropriate
> commit message?
>
> Regards,
>
> --
> Nicolas Goaziou
>

[-- Attachment #1.2: Type: text/html, Size: 1923 bytes --]

[-- Attachment #2: 0001-org-mac-link-Add-a-custom-list-for-link-descriptors.patch --]
[-- Type: application/octet-stream, Size: 3759 bytes --]

From ec5827a48e4553c7816f93d205502ba778351e4d Mon Sep 17 00:00:00 2001
From: Takaaki ISHIKAWA <takaxp@ieee.org>
Date: Thu, 15 Jun 2017 22:42:27 +0900
Subject: [PATCH] org-mac-link: Add a custom list for link descriptors

* contrib/lisp/org-mac-link.el: Add a custom list for link descriptors

Adding a custom variable named `org-mac-link-descriptors' to easily extend link grabbing capabilities for masOS user. When someone wants to add an additional menu to call an external application, it will be possible by adding a new setting to the list.

Modified from a patch proposal by Takaaki Ishikawa.
---
 contrib/lisp/org-mac-link.el | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index 8ba485d..fa424e0 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -217,6 +217,26 @@
   :group 'org-mac-link
   :type 'string)
 
+(defcustom org-mac-link-descriptors
+  `(("F" "inder" org-mac-finder-insert-selected ,org-mac-grab-Finder-app-p)
+    ("m" "ail" org-mac-message-insert-selected ,org-mac-grab-Mail-app-p)
+    ("d" "EVONthink Pro Office" org-mac-devonthink-item-insert-selected
+     ,org-mac-grab-devonthink-app-p)
+    ("o" "utlook" org-mac-outlook-message-insert-selected ,org-mac-grab-Outlook-app-p)
+    ("a" "ddressbook" org-mac-addressbook-insert-selected ,org-mac-grab-Addressbook-app-p)
+    ("s" "afari" org-mac-safari-insert-frontmost-url ,org-mac-grab-Safari-app-p)
+    ("f" "irefox" org-mac-firefox-insert-frontmost-url ,org-mac-grab-Firefox-app-p)
+    ("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p)
+    ("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p)
+    ("e" "evernote" org-mac-evernote-note-insert-selected ,org-mac-grab-Evernote-app-p)
+    ("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p)
+    ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
+    ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p))
+  "Descriptors to select an application."
+  :tag "A list of descriptors"
+  :group 'org-mac-link'
+  :type 'symbol)
+
 \f
 ;; In mac.c, removed in Emacs 23.
 (declare-function do-applescript "org-mac-message" (script))
@@ -238,21 +258,7 @@
   "Prompt for an application to grab a link from.
 When done, go grab the link, and insert it at point."
   (interactive)
-  (let* ((descriptors
-	  `(("F" "inder" org-mac-finder-insert-selected ,org-mac-grab-Finder-app-p)
-	    ("m" "ail" org-mac-message-insert-selected ,org-mac-grab-Mail-app-p)
-	    ("d" "EVONthink Pro Office" org-mac-devonthink-item-insert-selected
-	     ,org-mac-grab-devonthink-app-p)
-	    ("o" "utlook" org-mac-outlook-message-insert-selected ,org-mac-grab-Outlook-app-p)
-	    ("a" "ddressbook" org-mac-addressbook-insert-selected ,org-mac-grab-Addressbook-app-p)
-	    ("s" "afari" org-mac-safari-insert-frontmost-url ,org-mac-grab-Safari-app-p)
-	    ("f" "irefox" org-mac-firefox-insert-frontmost-url ,org-mac-grab-Firefox-app-p)
-	    ("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p)
-	    ("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p)
-            ("e" "evernote" org-mac-evernote-note-insert-selected ,org-mac-grab-Evernote-app-p)
-	    ("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p)
-	    ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
-	    ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p)))
+  (let* ((descriptors org-mac-link-descriptors)
          (menu-string (make-string 0 ?x))
          input)
 
-- 
2.10.1 (Apple Git-78)


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

* Re: [PATCH] Add a custom list in org-mac-link.el
  2017-06-15 13:56   ` Takaaki Ishikawa
@ 2017-06-15 16:32     ` Nicolas Goaziou
  2017-06-15 18:38       ` Takaaki Ishikawa
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2017-06-15 16:32 UTC (permalink / raw)
  To: Takaaki Ishikawa; +Cc: orgmode list

Hello,

Takaaki Ishikawa <takaxp@ieee.org> writes:

> I tried to generate a patch for this proposal. Please find an attached
> file.

Thank you.

> +(defcustom org-mac-link-descriptors
> +  `(("F" "inder" org-mac-finder-insert-selected ,org-mac-grab-Finder-app-p)
> +    ("m" "ail" org-mac-message-insert-selected ,org-mac-grab-Mail-app-p)
> +    ("d" "EVONthink Pro Office" org-mac-devonthink-item-insert-selected
> +     ,org-mac-grab-devonthink-app-p)
> +    ("o" "utlook" org-mac-outlook-message-insert-selected ,org-mac-grab-Outlook-app-p)
> +    ("a" "ddressbook" org-mac-addressbook-insert-selected ,org-mac-grab-Addressbook-app-p)
> +    ("s" "afari" org-mac-safari-insert-frontmost-url ,org-mac-grab-Safari-app-p)
> +    ("f" "irefox" org-mac-firefox-insert-frontmost-url ,org-mac-grab-Firefox-app-p)
> +    ("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p)
> +    ("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p)
> +    ("e" "evernote" org-mac-evernote-note-insert-selected ,org-mac-grab-Evernote-app-p)
> +    ("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p)
> +    ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
> +    ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p))
> +  "Descriptors to select an application."

Could you expand the docstring a bit? What is a descriptor, what type of
data structure is it?

> +  :tag "A list of descriptors"
> +  :group 'org-mac-link'
> +  :type 'symbol)

The :type value is wrong. You need a composite type here.

>  \f
>  ;; In mac.c, removed in Emacs 23.
>  (declare-function do-applescript "org-mac-message" (script))
> @@ -238,21 +258,7 @@
>    "Prompt for an application to grab a link from.
>  When done, go grab the link, and insert it at point."
>    (interactive)
> -  (let* ((descriptors
> -	  `(("F" "inder" org-mac-finder-insert-selected ,org-mac-grab-Finder-app-p)
> -	    ("m" "ail" org-mac-message-insert-selected ,org-mac-grab-Mail-app-p)
> -	    ("d" "EVONthink Pro Office" org-mac-devonthink-item-insert-selected
> -	     ,org-mac-grab-devonthink-app-p)
> -	    ("o" "utlook" org-mac-outlook-message-insert-selected ,org-mac-grab-Outlook-app-p)
> -	    ("a" "ddressbook" org-mac-addressbook-insert-selected ,org-mac-grab-Addressbook-app-p)
> -	    ("s" "afari" org-mac-safari-insert-frontmost-url ,org-mac-grab-Safari-app-p)
> -	    ("f" "irefox" org-mac-firefox-insert-frontmost-url ,org-mac-grab-Firefox-app-p)
> -	    ("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p)
> -	    ("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p)
> -            ("e" "evernote" org-mac-evernote-note-insert-selected ,org-mac-grab-Evernote-app-p)
> -	    ("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p)
> -	    ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
> -	    ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p)))
> +  (let* ((descriptors org-mac-link-descriptors)
>           (menu-string (make-string 0 ?x))
>           input)

Is it useful to let the °descriptors' binding? We could simply replace
`descriptors' with `org-mac-link-descriptors' in the `let' body. WDYT?

Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Add a custom list in org-mac-link.el
  2017-06-15 16:32     ` Nicolas Goaziou
@ 2017-06-15 18:38       ` Takaaki Ishikawa
  2017-06-15 19:03         ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Takaaki Ishikawa @ 2017-06-15 18:38 UTC (permalink / raw)
  To: Nicolas Goaziou, orgmode list

[-- Attachment #1: Type: text/plain, Size: 2628 bytes --]

Dear Nicolas,

Thank you for your kind feedback. Please find my comments below.

> +(defcustom org-mac-link-descriptors
> > +  `(("F" "inder" org-mac-finder-insert-selected
> ,org-mac-grab-Finder-app-p)
> > +    ("m" "ail" org-mac-message-insert-selected
> ,org-mac-grab-Mail-app-p)
> > +    ("d" "EVONthink Pro Office" org-mac-devonthink-item-insert-selected
> > +     ,org-mac-grab-devonthink-app-p)
> > +    ("o" "utlook" org-mac-outlook-message-insert-selected
> ,org-mac-grab-Outlook-app-p)
> > +    ("a" "ddressbook" org-mac-addressbook-insert-selected
> ,org-mac-grab-Addressbook-app-p)
> > +    ("s" "afari" org-mac-safari-insert-frontmost-url
> ,org-mac-grab-Safari-app-p)
> > +    ("f" "irefox" org-mac-firefox-insert-frontmost-url
> ,org-mac-grab-Firefox-app-p)
> > +    ("v" "imperator" org-mac-vimperator-insert-frontmost-url
> ,org-mac-grab-Firefox+Vimperator-p)
> > +    ("c" "hrome" org-mac-chrome-insert-frontmost-url
> ,org-mac-grab-Chrome-app-p)
> > +    ("e" "evernote" org-mac-evernote-note-insert-selected
> ,org-mac-grab-Evernote-app-p)
> > +    ("t" "ogether" org-mac-together-insert-selected
> ,org-mac-grab-Together-app-p)
> > +    ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
> > +    ("A" "crobat" org-mac-acrobat-insert-page
> ,org-mac-grab-Acrobat-app-p))
> > +  "Descriptors to select an application."
>
> Could you expand the docstring a bit? What is a descriptor, what type of
> data structure is it?
>

Updated docstring is

  "Alist of descriptors. Each descriptor consists of four elements to build
the link grabber menu in the minibuffer. A single character shall be used
for the first element to select an application, and the pair with the second
element represents the name of the application. The third element is a
function to insert information grabbed from selected application. And the
last
element is a flag to indicate whether the descriptor appears in the link
grabber menu."

Do we need more detail?

> +  :tag "A list of descriptors"
> > +  :group 'org-mac-link'
> > +  :type 'symbol)
>
> The :type value is wrong. You need a composite type here.
>

What do you feel about the following composite type.

:type '(alist :value-type (string string function boolean)


Is it useful to let the °descriptors' binding? We could simply replace
> `descriptors' with `org-mac-link-descriptors' in the `let' body. WDYT?


Yes, agree with you. I'll replace two `descriptors' in the function with
`org-mac-link-descriptors' when I produce an updated patch after receiving
your comments.

Best,
Takaaki

[-- Attachment #2: Type: text/html, Size: 3924 bytes --]

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

* Re: [PATCH] Add a custom list in org-mac-link.el
  2017-06-15 18:38       ` Takaaki Ishikawa
@ 2017-06-15 19:03         ` Nicolas Goaziou
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2017-06-15 19:03 UTC (permalink / raw)
  To: Takaaki Ishikawa; +Cc: orgmode list

Takaaki Ishikawa <takaxp@ieee.org> writes:

> Thank you for your kind feedback. Please find my comments below.

Thank you for the quick answer.

> Updated docstring is
>
>   "Alist of descriptors. Each descriptor consists of four elements to build
> the link grabber menu in the minibuffer. A single character shall be used
> for the first element to select an application, and the pair with the second
> element represents the name of the application. The third element is a
> function to insert information grabbed from selected application. And the
> last
> element is a flag to indicate whether the descriptor appears in the link
> grabber menu."

Nice. Note that we can make it more explicit, e.g.,

  A descriptor follows the pattern:

    (KEY NAME FUN FLAG)

  where KEY is ...

The first line needs to end with the first sentence, i.e.,
"descriptors". Also, you need two spaces after each sentence.

>> +  :tag "A list of descriptors"
>> > +  :group 'org-mac-link'
>> > +  :type 'symbol)
>>
>> The :type value is wrong. You need a composite type here.
>>
>
> What do you feel about the following composite type.
>
> :type '(alist :value-type (string string function boolean)

OK. You could introduce :tag to make it easier,e.g.

  (string :tag "Key: ")


Regards,

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

end of thread, other threads:[~2017-06-15 19:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-11  8:25 [PATCH] Add a custom list in org-mac-link.el Takaaki Ishikawa
2017-06-14 16:37 ` Nicolas Goaziou
2017-06-15 13:56   ` Takaaki Ishikawa
2017-06-15 16:32     ` Nicolas Goaziou
2017-06-15 18:38       ` Takaaki Ishikawa
2017-06-15 19:03         ` Nicolas Goaziou

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