emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Link handling for qutebrowser org-mac-link.el
@ 2021-05-10 18:01 Aimé Bertrand
  2021-05-16 12:21 ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Aimé Bertrand @ 2021-05-10 18:01 UTC (permalink / raw)
  To: emacs-orgmode

Hi everyone,

hope to have done this right as a first time.
Work on a Mac with qutebrowser and thought the following patch 
would be helpful.

Salut
Aimé Bertrand



modified   lisp/org-mac-link.el
@@ -218,6 +218,12 @@
   :group 'org-mac-link
   :type 'string)

+(defcustom org-mac-grab-qutebrowser-app-p t
+  "Add menu option [q]utebrowser to grab links from 
qutebrowser.app."
+  :tag "Grab qutebrowser.app links"
+  :group 'org-mac-link
+  :type 'boolean)
+
 \f
 ;; In mac.c, removed in Emacs 23.
 (declare-function do-applescript "org-mac-message" (script))
@@ -254,7 +260,8 @@ When done, go grab the link, and insert it at 
point."
             ("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)))
+	    ("A" "crobat" org-mac-acrobat-insert-page 
,org-mac-grab-Acrobat-app-p)
+	    ("q" "utebrowser" org-mac-qutebrowser-insert-frontmost-url 
,org-mac-grab-qutebrowser-app-p)))
          (menu-string (make-string 0 ?x))
          input)

@@ -1013,6 +1020,52 @@ list of message:// links to flagged mail 
after heading."
 	(org-insert-heading nil t)
 	(insert org-heading "\n" (org-mac-message-get-links "f"))))))

+\f
+;; Handle links from qutebrowser.app
+
+(defun org-as-mac-qutebrowser-get-frontmost-url ()
+  (let ((result
+         (do-applescript
+          (concat
+           "set oldClipboard to the clipboard\n"
+           "set frontmostApplication to path to frontmost 
application\n"
+           "tell application \"qutebrowser\"\n"
+           "	activate\n"
+           "	delay 0.15\n"
+           "	tell application \"System Events\"\n"
+           "		keystroke \"y\"\n"
+           "		keystroke \"y\"\n"
+           "	end tell\n"
+           "	delay 0.15\n"
+           "	set theUrl to the clipboard\n"
+           "	set the clipboard to oldClipboard\n"
+           "	delay 0.15\n"
+           "	tell application \"System Events\"\n"
+           "		keystroke \"y\"\n"
+           "		keystroke \"T\"\n"
+           "	end tell\n"
+           "	delay 0.15\n"
+           "	set theTitle to the clipboard\n"
+           "	set the clipboard to oldClipboard\n"
+	       "    set theResult to (get theUrl) & \"::split::\" & 
(get theTitle)\n"
+           "end tell\n"
+           "activate application (frontmostApplication as 
text)\n"
+           "set links to {}\n"
+           "copy theResult to the end of links\n"
+           "return links as string\n"))))
+     (car (split-string result "[\r\n]+" t))))
+
+;;;###autoload
+(defun org-mac-qutebrowser-get-frontmost-url ()
+  (interactive)
+  (message "Applescript: Getting qutebrowser url...")
+  (org-mac-paste-applescript-links 
(org-as-mac-qutebrowser-get-frontmost-url)))
+
+;;;###autoload
+(defun org-mac-qutebrowser-insert-frontmost-url ()
+  (interactive)
+  (insert (org-mac-qutebrowser-get-frontmost-url)))
+
 \f
 (provide 'org-mac-link)


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

* Re: [PATCH] Link handling for qutebrowser org-mac-link.el
  2021-05-10 18:01 [PATCH] Link handling for qutebrowser org-mac-link.el Aimé Bertrand
@ 2021-05-16 12:21 ` Bastien
  2021-05-17 23:34   ` Aimé Bertrand Ntumwa-Nziza
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2021-05-16 12:21 UTC (permalink / raw)
  To: Aimé Bertrand; +Cc: emacs-orgmode

Hi Aimé,

> hope to have done this right as a first time.

Thanks for the effort - but the patch is not in a readable format for
me.  I suggest you clone org-mode.git* and run C-x v = in the modified
file to get a proper patch in the buffer, save this buffer as a patch
and attach it (vs. include it) to your email.

If you want your patch to be perfect, you can check this page too:
https://orgmode.org/worg/org-contribute.html#commit-messages

Thanks in advance,

-- 
 Bastien


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

* Re: [PATCH] Link handling for qutebrowser org-mac-link.el
  2021-05-16 12:21 ` Bastien
@ 2021-05-17 23:34   ` Aimé Bertrand Ntumwa-Nziza
  2021-05-18  6:33     ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Aimé Bertrand Ntumwa-Nziza @ 2021-05-17 23:34 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

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

Bonjour Bastien,

as per your wish and hint (thanx).
See attached.

Salut
Aimé


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-mac-link.el-Add-support-for-qutebrowser.patch --]
[-- Type: text/x-patch, Size: 3607 bytes --]

From 5356ee77c368541113618a391b8480709c5eeb0b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aim=C3=A9=20Bertrand?= <aime.bertrand@macowners.club>
Date: Tue, 18 May 2021 01:23:51 +0200
Subject: [PATCH] org-mac-link.el: Add support for qutebrowser

* lisp/org-mac-link.el (org-mac-grab-qutebrowser-app-p): Variable for menu option
(org-mac-grab-link): Menu option for qutebrowser
(org-as-mac-qutebrowser-get-frontmost-url): Retrieve url and title
---
 lisp/org-mac-link.el | 55 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/lisp/org-mac-link.el b/lisp/org-mac-link.el
index f6d6da3..d887128 100644
--- a/lisp/org-mac-link.el
+++ b/lisp/org-mac-link.el
@@ -218,6 +218,12 @@
   :group 'org-mac-link
   :type 'string)
 
+(defcustom org-mac-grab-qutebrowser-app-p t
+  "Add menu option [q]utebrowser to grab links from qutebrowser.app."
+  :tag "Grab qutebrowser.app links"
+  :group 'org-mac-link
+  :type 'boolean)
+
 \f
 ;; In mac.c, removed in Emacs 23.
 (declare-function do-applescript "org-mac-message" (script))
@@ -254,7 +260,8 @@ When done, go grab the link, and insert it at point."
             ("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)))
+	    ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p)
+	    ("q" "utebrowser" org-mac-qutebrowser-insert-frontmost-url ,org-mac-grab-qutebrowser-app-p)))
          (menu-string (make-string 0 ?x))
          input)
 
@@ -1013,6 +1020,52 @@ list of message:// links to flagged mail after heading."
 	(org-insert-heading nil t)
 	(insert org-heading "\n" (org-mac-message-get-links "f"))))))
 
+\f
+;; Handle links from qutebrowser.app
+
+(defun org-as-mac-qutebrowser-get-frontmost-url ()
+  (let ((result
+         (do-applescript
+          (concat
+           "set oldClipboard to the clipboard\n"
+           "set frontmostApplication to path to frontmost application\n"
+           "tell application \"qutebrowser\"\n"
+           "	activate\n"
+           "	delay 0.15\n"
+           "	tell application \"System Events\"\n"
+           "		keystroke \"y\"\n"
+           "		keystroke \"y\"\n"
+           "	end tell\n"
+           "	delay 0.15\n"
+           "	set theUrl to the clipboard\n"
+           "	set the clipboard to oldClipboard\n"
+           "	delay 0.15\n"
+           "	tell application \"System Events\"\n"
+           "		keystroke \"y\"\n"
+           "		keystroke \"T\"\n"
+           "	end tell\n"
+           "	delay 0.15\n"
+           "	set theTitle to the clipboard\n"
+           "	set the clipboard to oldClipboard\n"
+	       "    set theResult to (get theUrl) & \"::split::\" & (get theTitle)\n"
+           "end tell\n"
+           "activate application (frontmostApplication as text)\n"
+           "set links to {}\n"
+           "copy theResult to the end of links\n"
+           "return links as string\n"))))
+     (car (split-string result "[\r\n]+" t))))
+
+;;;###autoload
+(defun org-mac-qutebrowser-get-frontmost-url ()
+  (interactive)
+  (message "Applescript: Getting qutebrowser url...")
+  (org-mac-paste-applescript-links (org-as-mac-qutebrowser-get-frontmost-url)))
+
+;;;###autoload
+(defun org-mac-qutebrowser-insert-frontmost-url ()
+  (interactive)
+  (insert (org-mac-qutebrowser-get-frontmost-url)))
+
 \f
 (provide 'org-mac-link)
 
-- 
2.30.1 (Apple Git-130)


[-- Attachment #3: Type: text/plain, Size: 554 bytes --]




Bastien @ 2021-05-16 14:21 :

> Hi Aimé,
>
>> hope to have done this right as a first time.
>
> Thanks for the effort - but the patch is not in a readable 
> format for
> me.  I suggest you clone org-mode.git* and run C-x v = in the 
> modified
> file to get a proper patch in the buffer, save this buffer as a 
> patch
> and attach it (vs. include it) to your email.
>
> If you want your patch to be perfect, you can check this page 
> too:
> https://orgmode.org/worg/org-contribute.html#commit-messages
>
> Thanks in advance,

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

* Re: [PATCH] Link handling for qutebrowser org-mac-link.el
  2021-05-17 23:34   ` Aimé Bertrand Ntumwa-Nziza
@ 2021-05-18  6:33     ` Bastien
  2021-05-18 13:24       ` Aimé Bertrand
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2021-05-18  6:33 UTC (permalink / raw)
  To: Aimé Bertrand Ntumwa-Nziza; +Cc: emacs-orgmode

Bonjour Aimé,

Aimé Bertrand Ntumwa-Nziza <aime.bertrand@macowners.club> writes:

> as per your wish and hint (thanx).

Thanks, applied to https://git.sr.ht/~bzg/org-contrib

Please see the README in https://git.sr.ht/~bzg/org-contrib

Do you want to take over maintainership of org-mac-link.el?

If so, please set up a dedicated repository for it and we will
advertize this new Homepage in org-mac-link.el, then remove it
from the next stable release of org-contrib.

Thanks,

-- 
 Bastien


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

* Re: [PATCH] Link handling for qutebrowser org-mac-link.el
  2021-05-18  6:33     ` Bastien
@ 2021-05-18 13:24       ` Aimé Bertrand
  2021-05-18 14:00         ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Aimé Bertrand @ 2021-05-18 13:24 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bastien,

I would love to, but don not now what that entails.
Willing to try, but don't wanna break stuff for the community.

- Do I have to stick to sourcehut or can I use gitlab as well?
- I would have to make sure the packages gets into elpa, melpa or 
  others?

Salut
Aimé Bertrand


> Do you want to take over maintainership of org-mac-link.el?
>
> If so, please set up a dedicated repository for it and we will
> advertize this new Homepage in org-mac-link.el, then remove it
> from the next stable release of org-contrib.


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

* Re: [PATCH] Link handling for qutebrowser org-mac-link.el
  2021-05-18 13:24       ` Aimé Bertrand
@ 2021-05-18 14:00         ` Bastien
  2021-05-18 15:37           ` Aimé Bertrand
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2021-05-18 14:00 UTC (permalink / raw)
  To: Aimé Bertrand; +Cc: emacs-orgmode

Hello Aimé,

Aimé Bertrand <aime.bertrand@macowners.club> writes:

> I would love to, but don not now what that entails.
> Willing to try, but don't wanna break stuff for the community.

Thanks for your consideration, appreciated.

> - Do I have to stick to sourcehut or can I use gitlab as well?

You can do whatever forge you'd like: I'd recommend sourcehut but
it can also also any other forge you want.

> - I would have to make sure the packages gets into elpa, melpa or
>   others?

If you want to, there is nothing mandatory about this.

Thanks!

-- 
 Bastien


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

* Re: [PATCH] Link handling for qutebrowser org-mac-link.el
  2021-05-18 14:00         ` Bastien
@ 2021-05-18 15:37           ` Aimé Bertrand
  2021-05-19  9:08             ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Aimé Bertrand @ 2021-05-18 15:37 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bastien,

you know what, I wanna do my part:

https://sr.ht/~aimebertrand/org-mac-link/

Salut
Aimé


Bastien @ 2021-05-18 16:00 :

> Hello Aimé,
>
> Aimé Bertrand <aime.bertrand@macowners.club> writes:
>
>> I would love to, but don not now what that entails.
>> Willing to try, but don't wanna break stuff for the community.
>
> Thanks for your consideration, appreciated.
>
>> - Do I have to stick to sourcehut or can I use gitlab as well?
>
> You can do whatever forge you'd like: I'd recommend sourcehut 
> but
> it can also also any other forge you want.
>
>> - I would have to make sure the packages gets into elpa, melpa 
>> or
>>   others?
>
> If you want to, there is nothing mandatory about this.
>
> Thanks!


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

* Re: [PATCH] Link handling for qutebrowser org-mac-link.el
  2021-05-18 15:37           ` Aimé Bertrand
@ 2021-05-19  9:08             ` Bastien
  0 siblings, 0 replies; 8+ messages in thread
From: Bastien @ 2021-05-19  9:08 UTC (permalink / raw)
  To: Aimé Bertrand; +Cc: emacs-orgmode

Aimé Bertrand <aime.bertrand@macowners.club> writes:

> you know what, I wanna do my part:
>
> https://sr.ht/~aimebertrand/org-mac-link/

Thanks!  I updated the org-contrib repository.

-- 
 Bastien


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

end of thread, other threads:[~2021-05-19  9:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 18:01 [PATCH] Link handling for qutebrowser org-mac-link.el Aimé Bertrand
2021-05-16 12:21 ` Bastien
2021-05-17 23:34   ` Aimé Bertrand Ntumwa-Nziza
2021-05-18  6:33     ` Bastien
2021-05-18 13:24       ` Aimé Bertrand
2021-05-18 14:00         ` Bastien
2021-05-18 15:37           ` Aimé Bertrand
2021-05-19  9:08             ` Bastien

Code repositories for project(s) associated with this 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 NNTP newsgroup(s).