emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Aimé Bertrand" <aime.bertrand@macowners.club>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Link handling for qutebrowser org-mac-link.el
Date: Mon, 10 May 2021 20:01:55 +0200	[thread overview]
Message-ID: <ba4bt9pmxyv564.fsf@macowners.club> (raw)

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)


             reply	other threads:[~2021-05-10 18:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10 18:01 Aimé Bertrand [this message]
2021-05-16 12:21 ` [PATCH] Link handling for qutebrowser org-mac-link.el 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba4bt9pmxyv564.fsf@macowners.club \
    --to=aime.bertrand@macowners.club \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).