summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-11-25 10:08:03 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-11-25 10:08:03 +0100
commitfb5e3e8ab4e7a147f9175700f230acbbfdcba657 (patch)
tree5c7e0cb8d710ee23f21af25d503dd73d6790b323
parent86a6087f928292e973526ab72edbf32cd5e3fdac (diff)
parentf33fa994b987717db3276c661a45be38c204af4c (diff)
downloadorg-mode-fb5e3e8ab4e7a147f9175700f230acbbfdcba657.tar.gz
Merge branch 'master' into next
-rw-r--r--contrib/lisp/org-mac-link.el41
1 files changed, 41 insertions, 0 deletions
diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index 3dfe436..6bd6dc5 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)))
+;; 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)))
+
+
;; Handle links from Safari.app
;; Grab the frontmost url from Safari.