* [PATCH] Add support for Brave to org-mac-link
@ 2018-11-24 13:26 Aaron Jensen
2018-11-25 9:08 ` Nicolas Goaziou
0 siblings, 1 reply; 3+ messages in thread
From: Aaron Jensen @ 2018-11-24 13:26 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 266 bytes --]
Hi all,
Brave is a chromium-based browser, so the existing Chrome code works
with slight modifications.
By the way, I’ve signed FSF papers though
https://orgmode.org/worg/org-contribute.html currently has me listed
in the wrong place.
Best,
Aaron
[-- Attachment #2: 0001-org-mac-link-Add-support-for-Brave.patch --]
[-- Type: application/octet-stream, Size: 3661 bytes --]
From 5a67274be3e50e9c60eac86ffdb8992734097277 Mon Sep 17 00:00:00 2001
From: Aaron Jensen <aaronjensen@gmail.com>
Date: Sat, 24 Nov 2018 05:10:19 -0800
Subject: [PATCH] org-mac-link: Add support for Brave
* contrib/lisp/org-mac-link.el (org-mac-grab-Brave-app-p)
(org-mac-grab-link, org-as-mac-brave-get-frontmost-url)
(org-mac-brave-get-frontmost-url)
(org-mac-brave-insert-frontmost-url): Add support for Brave
---
contrib/lisp/org-mac-link.el | 41 ++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index 3dfe43607..6bd6dc5c9 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -66,6 +66,7 @@
;; Vimperator/Firefox.app - Grab the url of the frontmost tab in the frontmost window
;; Safari.app - Grab the url of the frontmost tab in the frontmost window
;; Google Chrome.app - Grab the url of the frontmost tab in the frontmost window
+;; Brave.app - Grab the url of the frontmost tab in the frontmost window
;; Together.app - Grab links to the selected items in the library list
;; Skim.app - Grab a link to the selected page in the topmost pdf document
;; Microsoft Outlook.app - Grab a link to the selected message in the message list
@@ -164,6 +165,12 @@
:group 'org-mac-link
:type 'boolean)
+(defcustom org-mac-grab-Brave-app-p t
+ "Add menu option [b]rave to grab links from Brave.app."
+ :tag "Grab Brave.app links"
+ :group 'org-mac-link
+ :type 'boolean)
+
(defcustom org-mac-grab-Together-app-p nil
"Add menu option [t]ogether to grab links from Together.app."
:tag "Grab Together.app links"
@@ -249,6 +256,7 @@ When done, go grab the link, and insert it at point."
("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)
+ ("b" "rave" org-mac-brave-insert-frontmost-url ,org-mac-grab-Brave-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)
@@ -425,6 +433,39 @@ The links are of the form <link>::split::<name>."
(insert (org-mac-chrome-get-frontmost-url)))
\f
+;; Handle links from Brave.app
+;; Grab the frontmost url from Brave. Same limitations as
+;; Firefox/Chrome because Brave doesn't publish an Applescript
+;; dictionary
+
+(defun org-as-mac-brave-get-frontmost-url ()
+ (let ((result
+ (do-applescript
+ (concat
+ "set frontmostApplication to path to frontmost application\n"
+ "tell application \"Brave\"\n"
+ " set theUrl to get URL of active tab of first window\n"
+ " set theResult to (get theUrl) & \"::split::\" & (get name of window 1)\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"))))
+ (replace-regexp-in-string
+ "^\"\\|\"$" "" (car (split-string result "[\r\n]+" t)))))
+
+;;;###autoload
+(defun org-mac-brave-get-frontmost-url ()
+ (interactive)
+ (message "Applescript: Getting Brave url...")
+ (org-mac-paste-applescript-links (org-as-mac-brave-get-frontmost-url)))
+
+;;;###autoload
+(defun org-mac-brave-insert-frontmost-url ()
+ (interactive)
+ (insert (org-mac-brave-get-frontmost-url)))
+
+\f
;; Handle links from Safari.app
;; Grab the frontmost url from Safari.
--
2.19.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-25 17:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-24 13:26 [PATCH] Add support for Brave to org-mac-link Aaron Jensen
2018-11-25 9:08 ` Nicolas Goaziou
2018-11-25 17:20 ` Aaron Jensen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.